From 0a380265c888c64386406187b34914438cdff161 Mon Sep 17 00:00:00 2001 From: jordan4ibanez Date: Sun, 25 Apr 2021 00:16:54 -0400 Subject: [PATCH] Fix dead-alive mobs and add in hurt/die sound --- .../mcl_mobs/api/mob_functions/ai.lua | 46 +++++++++++-------- .../mcl_mobs/api/mob_functions/set_up.lua | 3 +- 2 files changed, 30 insertions(+), 19 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua b/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua index 5d619a7d3..a4b0df808 100644 --- a/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua @@ -829,9 +829,36 @@ mobs.mob_step = function(self, dtime) end end + --do death logic (animation, poof, explosion, etc) + if self.health <= 0 then + + --play death sound once + if not self.played_death_sound then + self.dead = true + mobs.play_sound(self,"death") + self.played_death_sound = true + end + + mobs.death_logic(self, dtime) + + --this is here because the mob must continue to move + --while stunned before coming to a complete halt even during + --the death tilt + if self.pause_timer > 0 then + self.pause_timer = self.pause_timer - dtime + --perfectly reset pause_timer + if self.pause_timer < 0 then + self.pause_timer = 0 + end + end + + return + end + --color modifier which coincides with the pause_timer if self.old_health and self.health < self.old_health then self.object:set_texture_mod("^[colorize:red:120") + mobs.play_sound(self,"damage") end self.old_health = self.health @@ -888,24 +915,7 @@ mobs.mob_step = function(self, dtime) - --do death logic (animation, poof, explosion, etc) - if self.health <= 0 then - - mobs.death_logic(self, dtime) - - --this is here because the mob must continue to move - --while stunned before coming to a complete halt even during - --the death tilt - if self.pause_timer > 0 then - self.pause_timer = self.pause_timer - dtime - --perfectly reset pause_timer - if self.pause_timer < 0 then - self.pause_timer = 0 - end - end - - return - end + --baby grows up if self.baby then diff --git a/mods/ENTITIES/mcl_mobs/api/mob_functions/set_up.lua b/mods/ENTITIES/mcl_mobs/api/mob_functions/set_up.lua index 41f3932f7..b4de9a1c2 100644 --- a/mods/ENTITIES/mcl_mobs/api/mob_functions/set_up.lua +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/set_up.lua @@ -137,9 +137,10 @@ mobs.mob_activate = function(self, staticdata, def, dtime) } end - if self.health == 0 then + if not self.dead and self.health == 0 then self.health = math_random (self.hp_min, self.hp_max) end + if self.breath == nil then self.breath = self.breath_max end