Support mob explosions again

This commit is contained in:
Wuzzy 2017-07-25 04:44:46 +02:00
parent b25254e516
commit 388b324fb1
3 changed files with 46 additions and 34 deletions

View File

@ -1694,7 +1694,7 @@ local do_states = function(self, dtime)
self.object:remove() self.object:remove()
if minetest.get_modpath("tnt") and tnt and tnt.boom if minetest.get_modpath("mcl_tnt") and tnt and tnt.boom
and not minetest.is_protected(pos, "") then and not minetest.is_protected(pos, "") then
tnt.boom(pos, { tnt.boom(pos, {

View File

@ -1,4 +1,5 @@
mcl_core mcl_core
mcl_tnt?
invisibility? invisibility?
intllib? intllib?
lucky_block? lucky_block?

View File

@ -158,22 +158,35 @@ function TNT:on_step(dtime)
self.blinkstatus = not self.blinkstatus self.blinkstatus = not self.blinkstatus
end end
if self.timer > 4 then if self.timer > 4 then
local pos = self.object:getpos() tnt.boom(self.object:getpos(), TNT_RANGE)
self.object:remove()
end
end
tnt.boom = function(pos, info)
local range = info.radius
local damage_range = info.damage_radius
pos.x = math.floor(pos.x+0.5) pos.x = math.floor(pos.x+0.5)
pos.y = math.floor(pos.y+0.5) pos.y = math.floor(pos.y+0.5)
pos.z = math.floor(pos.z+0.5) pos.z = math.floor(pos.z+0.5)
do_tnt_physics(pos, TNT_RANGE) do_tnt_physics(pos, range)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
minetest.sound_play("tnt_explode", {pos = pos,gain = 1.0,max_hear_distance = 16,}) local sound
if not info.sound then
sound = "tnt_explode"
else
sound = info.sound
end
minetest.sound_play(sound, {pos = pos,gain = 1.0,max_hear_distance = 16,})
if minetest.get_node(pos).name == "mcl_core:water_source" or minetest.get_node(pos).name == "mcl_core:water_flowing" or minetest.get_node(pos).name == "mcl_core:bedrock" or minetest.get_node(pos).name == "protector:display" or minetest.is_protected(pos, "tnt") then if minetest.get_node(pos).name == "mcl_core:water_source" or minetest.get_node(pos).name == "mcl_core:water_flowing" or minetest.get_node(pos).name == "mcl_core:bedrock" or minetest.get_node(pos).name == "protector:display" or minetest.is_protected(pos, "tnt") then
-- Cancel the Explosion -- Cancel the Explosion
self.object:remove()
return return
end end
for x=-TNT_RANGE,TNT_RANGE do for x=-range,range do
for y=-TNT_RANGE,TNT_RANGE do for y=-range,range do
for z=-TNT_RANGE,TNT_RANGE do for z=-range,range do
if x*x+y*y+z*z <= TNT_RANGE * TNT_RANGE + TNT_RANGE then if x*x+y*y+z*z <= range * range + range then
local np={x=pos.x+x,y=pos.y+y,z=pos.z+z} local np={x=pos.x+x,y=pos.y+y,z=pos.z+z}
local n = minetest.get_node(np) local n = minetest.get_node(np)
local def = minetest.registered_nodes[n.name] local def = minetest.registered_nodes[n.name]
@ -197,9 +210,7 @@ function TNT:on_step(dtime)
end end
end end
end end
self.object:remove() add_effects(pos, range, {})
add_effects(pos, TNT_RANGE, {})
end
end end
end end