Make mobs and bed use mcl_explosions

This commit is contained in:
Wuzzy 2020-05-02 18:50:25 +02:00
parent 6a576c50a0
commit 56d484f69b
5 changed files with 21 additions and 41 deletions

@ -93,7 +93,7 @@ local node_snow = "mcl_core:snow"
mobs.fallback_node = minetest.registered_aliases["mapgen_dirt"] or "mcl_core:dirt"
local mod_weather = minetest.get_modpath("mcl_weather") ~= nil
local mod_tnt = minetest.get_modpath("mcl_tnt") ~= nil
local mod_explosions = minetest.get_modpath("mcl_explosions") ~= nil
local mod_mobspawners = minetest.get_modpath("mcl_mobspawners") ~= nil
local mod_hunger = minetest.get_modpath("mcl_hunger") ~= nil
local mod_worlds = minetest.get_modpath("mcl_worlds") ~= nil
@ -2218,26 +2218,10 @@ local do_states = function(self, dtime)
local pos = self.object:get_pos()
-- dont damage anything if area protected or next to water
if minetest.find_node_near(pos, 1, {"group:water"})
or minetest.is_protected(pos, "") then
node_break_radius = 1
end
self.object:remove()
if mobs_griefing and mod_tnt and tnt and tnt.boom
and not minetest.is_protected(pos, "") then
tnt.boom(pos, {
radius = node_break_radius,
damage_radius = entity_damage_radius,
sound = self.sounds.explode,
is_tnt = false,
})
if mod_explosions then
if mobs_griefing and not minetest.is_protected(pos, "") then
mcl_explosions.explode(self.object:get_pos(), self.explosion_strength, { drop_chance = 1.0 }, self.object)
else
minetest.sound_play(self.sounds.explode, {
pos = pos,
gain = 1.0,
@ -2247,6 +2231,8 @@ local do_states = function(self, dtime)
entity_physics(pos, entity_damage_radius)
effect(pos, 32, "tnt_smoke.png", nil, nil, node_break_radius, 1, 0)
end
end
self.object:remove()
return true
end
@ -3365,8 +3351,8 @@ minetest.register_entity(name, {
runaway_timer = 0,
pathfinding = def.pathfinding,
immune_to = def.immune_to or {},
explosion_radius = def.explosion_radius,
explosion_damage_radius = def.explosion_damage_radius,
explosion_radius = def.explosion_radius, -- LEGACY
explosion_damage_radius = def.explosion_damage_radius, -- LEGACY
explosion_timer = def.explosion_timer or 3,
allow_fuse_reset = def.allow_fuse_reset ~= false,
stop_to_explode = def.stop_to_explode ~= false,
@ -3393,6 +3379,7 @@ minetest.register_entity(name, {
texture_mods = {},
shoot_arrow = def.shoot_arrow,
sounds_child = def.sounds_child,
explosion_strength = def.explosion_strength,
-- End of MCL2 extensions
on_spawn = def.on_spawn,
@ -3838,7 +3825,6 @@ 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,
@ -3853,17 +3839,12 @@ end
-- make explosion with protection and tnt mod check
function mobs:boom(self, pos, radius)
if mobs_griefing
and mod_tnt and tnt and tnt.boom
and not minetest.is_protected(pos, "") then
tnt.boom(pos, {
radius = radius,
damage_radius = radius,
sound = self.sounds and self.sounds.explode,
explode_center = true,
is_tnt = false,
})
if mod_explosions then
if mobs_griefing and not minetest.is_protected(pos, "") then
mcl_explosions.explode(pos, self.explosion_strength, { drop_chance = 1.0 }, self.object)
else
mobs:safe_boom(self, pos, radius)
end
else
mobs:safe_boom(self, pos, radius)
end

@ -1,2 +1,2 @@
name = mcl_mobs
optional_depends = mcl_weather, mcl_tnt, mcl_hunger, mcl_worlds, invisibility, lucky_block, cmi, doc_identifier, mcl_armor
optional_depends = mcl_weather, mcl_explosions, mcl_hunger, mcl_worlds, invisibility, lucky_block, cmi, doc_identifier, mcl_armor

@ -36,9 +36,8 @@ mobs:register_mob("mobs_mc:creeper", {
runaway_from = { "mobs_mc:ocelot", "mobs_mc:cat" },
attack_type = "explode",
explosion_radius = 3,
explosion_strength = 3,
reach = 4,
explosion_damage_radius = 7,
explosion_timer = 1.5,
allow_fuse_reset = true,
stop_to_explode = true,

@ -49,8 +49,7 @@ mobs:register_mob("mobs_mc:wither", {
lava_damage = 0,
fire_damage = 0,
attack_type = "dogshoot",
explosion_radius = 3,
explosion_fire = false,
explosion_strength = 8,
dogshoot_stop = true,
arrow = "mobs_mc:wither_skull",
reach = 5,

@ -5,6 +5,7 @@ local pi = math.pi
local player_in_bed = 0
local is_sp = minetest.is_singleplayer()
local weather_mod = minetest.get_modpath("mcl_weather") ~= nil
local explosions_mod = minetest.get_modpath("mcl_explosions") ~= nil
-- Helper functions
@ -307,8 +308,8 @@ function mcl_beds.on_rightclick(pos, player, is_top)
if dim == "nether" or dim == "end" then
-- Bed goes BOOM in the Nether or End.
minetest.remove_node(pos)
if minetest.get_modpath("mcl_tnt") then
tnt.boom(pos, {radius = 4, damage_radius = 4, is_tnt = false})
if explosions_mod then
mcl_explosions.explode(pos, 5, {drop_chance = 1.0, fire = true})
end
return
end