mirror of
https://git.minetest.land/Mineclonia/Mineclonia.git
synced 2024-11-10 11:45:06 +00:00
Add griefing option to mcl_explosions.explode
When set to false explosions will only affect entities and not destroy nodes.
This commit is contained in:
parent
e3d2284485
commit
34274486c7
1 changed files with 31 additions and 26 deletions
|
@ -141,6 +141,7 @@ end
|
|||
-- Values in info:
|
||||
-- drop_chance - The chance that destroyed nodes will drop their items
|
||||
-- fire - If true, 1/3 nodes become fire
|
||||
-- griefing - If true, the explosion will destroy nodes (default: true)
|
||||
--
|
||||
-- Note that this function has been optimized, it contains code which has been
|
||||
-- inlined to avoid function calls and unnecessary table creation. This was
|
||||
|
@ -171,6 +172,7 @@ local function trace_explode(pos, strength, raydirs, radius, info, puncher)
|
|||
local fire = info.fire
|
||||
|
||||
-- Trace rays for environment destruction
|
||||
if info.griefing then
|
||||
for i = 1, #raydirs do
|
||||
local rpos_x = pos.x
|
||||
local rpos_y = pos.y
|
||||
|
@ -206,6 +208,7 @@ local function trace_explode(pos, strength, raydirs, radius, info, puncher)
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Entities in radius of explosion
|
||||
local punch_radius = 2 * strength
|
||||
|
@ -399,6 +402,7 @@ end
|
|||
-- sound - If true, the explosion will play a sound (default: true)
|
||||
-- particles - If true, the explosion will create particles (default: true)
|
||||
-- fire - If true, 1/3 nodes become fire (default: false)
|
||||
-- griefing - If true, the explosion will destroy nodes (default: true)
|
||||
function mcl_explosions.explode(pos, strength, info, puncher)
|
||||
if info == nil then
|
||||
info = {}
|
||||
|
@ -417,6 +421,7 @@ function mcl_explosions.explode(pos, strength, info, puncher)
|
|||
if info.particles == nil then info.particles = true end
|
||||
if info.sound == nil then info.sound = true end
|
||||
if info.fire == nil then info.fire = false end
|
||||
if info.griefing == nil then info.griefing = true end
|
||||
|
||||
-- For backwards compatability
|
||||
if info.no_particle then info.particles = false end
|
||||
|
|
Loading…
Reference in a new issue