add damage_radius and texture to mobs:boom()

This commit is contained in:
tenplus1 2022-09-22 08:04:58 +01:00
parent 2935d1ee5d
commit b4a8ce71c6
2 changed files with 14 additions and 31 deletions

41
api.lua
View File

@ -28,7 +28,7 @@ local use_cmi = minetest.global_exists("cmi")
mobs = { mobs = {
mod = "redo", mod = "redo",
version = "20220918", version = "20220922",
intllib = S, intllib = S,
invis = minetest.global_exists("invisibility") and invisibility or {} invis = minetest.global_exists("invisibility") and invisibility or {}
} }
@ -2535,27 +2535,7 @@ function mob_class:do_states(dtime)
remove_mob(self, true) remove_mob(self, true)
if minetest.get_modpath("tnt") and tnt and tnt.boom mobs:boom(self, pos, entity_damage_radius, node_break_radius)
and not minetest.is_protected(pos, "") then
tnt.boom(pos, {
radius = node_break_radius,
damage_radius = entity_damage_radius,
sound = self.sounds.explode
})
else
minetest.sound_play(self.sounds.explode, {
pos = pos,
gain = 1.0,
max_hear_distance = self.sounds.distance or 32
})
entity_physics(pos, entity_damage_radius)
effect(pos, 32, "tnt_smoke.png", nil, nil,
node_break_radius, 1, 0)
end
return true return true
end end
@ -4292,14 +4272,14 @@ function mobs:register_arrow(name, def)
end end
-- compatibility function -- compatibility function (deprecated)
function mobs:explosion(pos, radius) function mobs:explosion(pos, radius)
mobs:boom({sounds = {explode = "tnt_explode"}}, pos, radius) mobs:boom({sounds = {explode = "tnt_explode"}}, pos, radius, radius, "tnt_smoke.png")
end end
-- no damage to nodes explosion -- no damage to nodes explosion
function mobs:safe_boom(self, pos, radius) function mobs:safe_boom(self, pos, radius, texture)
minetest.sound_play(self.sounds and self.sounds.explode or "tnt_explode", { minetest.sound_play(self.sounds and self.sounds.explode or "tnt_explode", {
pos = pos, pos = pos,
@ -4309,12 +4289,12 @@ function mobs:safe_boom(self, pos, radius)
entity_physics(pos, radius) entity_physics(pos, radius)
effect(pos, 32, "tnt_smoke.png", radius * 3, radius * 5, radius, 1, 0) effect(pos, 32, texture, radius * 3, radius * 5, radius, 1, 0)
end 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, damage_radius, texture)
if mobs_griefing if mobs_griefing
and minetest.get_modpath("tnt") and tnt and tnt.boom and minetest.get_modpath("tnt") and tnt and tnt.boom
@ -4322,12 +4302,13 @@ function mobs:boom(self, pos, radius)
tnt.boom(pos, { tnt.boom(pos, {
radius = radius, radius = radius,
damage_radius = radius, damage_radius = damage_radius,
sound = self.sounds and self.sounds.explode, sound = self.sounds and self.sounds.explode,
explode_center = true explode_center = true,
tiles = {(texture or "tnt_smoke.png")}
}) })
else else
mobs:safe_boom(self, pos, radius) mobs:safe_boom(self, pos, radius, texture)
end end
end end

View File

@ -526,10 +526,12 @@ Explosion Function
mobs:explosion(pos, radius) -- DEPRECATED!!! use mobs:boom() instead mobs:explosion(pos, radius) -- DEPRECATED!!! use mobs:boom() instead
mobs:boom(self, pos, radius) mobs:boom(self, pos, radius, damage_radius, texture)
'self' mob entity 'self' mob entity
'pos' centre position of explosion 'pos' centre position of explosion
'radius' radius of explosion (typically set to 3) 'radius' radius of explosion (typically set to 3)
'damage_radius' radius of damage around explosion
'texture' particle texture during explosion, defaults to "tnt_smoke.png"
This function generates an explosion which removes nodes in a specific radius This function generates an explosion which removes nodes in a specific radius
and damages any entity caught inside the blast radius. Protection will limit and damages any entity caught inside the blast radius. Protection will limit