From 5a059379b289456d457cf3b5644e8d434cce2c41 Mon Sep 17 00:00:00 2001 From: ancientmarinerdev Date: Sat, 13 May 2023 18:10:20 +0100 Subject: [PATCH] Group damage logic. Remove physics falling logic out of suspend with duplicate falling call --- mods/ENTITIES/mcl_mobs/api.lua | 19 ++++--------------- mods/ENTITIES/mcl_mobs/physics.lua | 15 ++++++++++----- 2 files changed, 14 insertions(+), 20 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/api.lua b/mods/ENTITIES/mcl_mobs/api.lua index d4913305d..a9a1a0dad 100644 --- a/mods/ENTITIES/mcl_mobs/api.lua +++ b/mods/ENTITIES/mcl_mobs/api.lua @@ -387,25 +387,14 @@ local function on_step_work (self, dtime) end if self:falling(pos) then return end - - local player_in_active_range = self:player_in_active_range() - - self:check_suspend(player_in_active_range) - - if not self.fire_resistant then - mcl_burning.tick(self.object, dtime, self) - if not self.object:get_pos() then return end -- mcl_burning.tick may remove object immediately - - if self:check_for_death("fire", {type = "fire"}) then - return true - end - end - - if self:env_damage (dtime, pos) then return end + if self:step_damage (dtime, pos) then return end if self.state == "die" then return end -- End: Death/damage processing + local player_in_active_range = self:player_in_active_range() + self:check_suspend(player_in_active_range) + self:check_water_flow() if not self._jumping_cliff then diff --git a/mods/ENTITIES/mcl_mobs/physics.lua b/mods/ENTITIES/mcl_mobs/physics.lua index 55199d9f3..090b921c7 100644 --- a/mods/ENTITIES/mcl_mobs/physics.lua +++ b/mods/ENTITIES/mcl_mobs/physics.lua @@ -820,11 +820,19 @@ function mob_class:do_env_damage() return self:check_for_death("unknown", {type = "unknown"}) end -function mob_class:env_damage (dtime, pos) +function mob_class:step_damage (dtime, pos) + if not self.fire_resistant then + mcl_burning.tick(self.object, dtime, self) + if not self.object:get_pos() then return end -- mcl_burning.tick may remove object immediately + + if self:check_for_death("fire", {type = "fire"}) then + return true + end + end + -- environmental damage timer (every 1 second) self.env_damage_timer = self.env_damage_timer + dtime - if self.env_damage_timer > 1 then self.env_damage_timer = 0 @@ -1019,9 +1027,6 @@ function mob_class:check_suspend(player_in_active_range) self.object:set_acceleration(vector.zero()) self.object:set_velocity(vector.zero()) end - if acc.y == 0 and node_under == "air" then - self:falling(pos) - end end return true end