Mobs should not drop XP when dying by fire from sunlight

This commit is contained in:
ancientmarinerdev 2023-02-05 05:34:32 +00:00 committed by Michieal
parent 01a4eea631
commit da3a576637
2 changed files with 19 additions and 2 deletions

View File

@ -365,6 +365,9 @@ function mob_class:on_step(dtime)
if self:check_despawn(pos, dtime) then return true end
if self:outside_limits() then return end
-- Start: Death/damage processing
-- All damage needs to be undertaken at the start.
-- We need to exit processing if the mob dies.
if self:check_death_and_slow_mob() then
--minetest.log("action", "Mob is dying: ".. tostring(self.name))
-- Do we abandon out of here now?
@ -377,9 +380,16 @@ function mob_class:on_step(dtime)
mcl_burning.tick(self.object, dtime, self)
-- mcl_burning.tick may remove object immediately
if not self.object:get_pos() then return end
if self:check_for_death("fire", {type = "fire"}) then
return true
end
end
if self:env_damage (dtime, pos) then return end
if self.state == "die" then return end
-- End: Death/damage processing
self:check_water_flow()
self:env_danger_movement_checks (dtime)
@ -425,7 +435,6 @@ function mob_class:on_step(dtime)
self:mob_sound("random", true)
end
if self:env_damage (dtime, pos) then return end
if self:do_states(dtime) then return end
if not self.object:get_luaentity() then

View File

@ -462,6 +462,14 @@ function mob_class:check_for_death(cause, cmi_cause)
self:mob_sound("death")
local function death_handle(self)
if cmi_cause and cmi_cause["type"] then
--minetest.log("cmi_cause: " .. tostring(cmi_cause["type"]))
end
--minetest.log("cause: " .. tostring(cause))
-- TODO other env damage shouldn't drop xp
-- "rain", "water", "drowning", "suffocation"
-- dropped cooked item if mob died in fire or lava
if cause == "lava" or cause == "fire" then
self:item_drop(true, 0)
@ -800,7 +808,7 @@ function mob_class:do_env_damage()
self.suffocation_timer = 0
end
return self:check_for_death("", {type = "unknown"})
return self:check_for_death("unknown", {type = "unknown"})
end
function mob_class:env_damage (dtime, pos)