forked from mtcontrib/mobs_redo
add mobs:safe_boom and some nil checks
This commit is contained in:
parent
0f480942b5
commit
5751d98ab0
27
api.lua
27
api.lua
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
mobs = {}
|
mobs = {}
|
||||||
mobs.mod = "redo"
|
mobs.mod = "redo"
|
||||||
mobs.version = "20180104"
|
mobs.version = "20180112"
|
||||||
|
|
||||||
|
|
||||||
-- Intllib
|
-- Intllib
|
||||||
@ -3119,6 +3119,20 @@ function mobs:explosion(pos, radius)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- no damage to nodes explosion
|
||||||
|
function mobs:safe_boom(self, pos, radius)
|
||||||
|
|
||||||
|
minetest.sound_play(self.sounds and self.sounds.explode or "tnt_explode", {
|
||||||
|
pos = pos,
|
||||||
|
gain = 1.0,
|
||||||
|
max_hear_distance = self.sounds and self.sounds.distance or 32
|
||||||
|
})
|
||||||
|
|
||||||
|
entity_physics(pos, radius)
|
||||||
|
effect(pos, 32, "tnt_smoke.png", radius * 3, radius * 5, radius, 1, 0)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
-- make explosion with protection and tnt mod check
|
-- make explosion with protection and tnt mod check
|
||||||
function mobs:boom(self, pos, radius)
|
function mobs:boom(self, pos, radius)
|
||||||
|
|
||||||
@ -3128,18 +3142,11 @@ function mobs:boom(self, pos, radius)
|
|||||||
tnt.boom(pos, {
|
tnt.boom(pos, {
|
||||||
radius = radius,
|
radius = radius,
|
||||||
damage_radius = radius,
|
damage_radius = radius,
|
||||||
sound = self.sounds.explode,
|
sound = self.sounds and self.sounds.explode,
|
||||||
explode_center = true,
|
explode_center = true,
|
||||||
})
|
})
|
||||||
else
|
else
|
||||||
minetest.sound_play(self.sounds.explode, {
|
mobs:safe_boom(self, pos, radius)
|
||||||
pos = pos,
|
|
||||||
gain = 1.0,
|
|
||||||
max_hear_distance = self.sounds.distance or 32
|
|
||||||
})
|
|
||||||
|
|
||||||
entity_physics(pos, radius)
|
|
||||||
effect(pos, 32, "tnt_smoke.png", radius * 3, radius * 5, radius, 1, 0)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user