1
0
Fork 0

Fix dead-alive mobs and add in hurt/die sound

This commit is contained in:
jordan4ibanez 2021-04-25 00:16:54 -04:00
parent 8d3eff0c16
commit 0a380265c8
2 changed files with 30 additions and 19 deletions

View File

@ -829,9 +829,36 @@ mobs.mob_step = function(self, dtime)
end end
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 --color modifier which coincides with the pause_timer
if self.old_health and self.health < self.old_health then if self.old_health and self.health < self.old_health then
self.object:set_texture_mod("^[colorize:red:120") self.object:set_texture_mod("^[colorize:red:120")
mobs.play_sound(self,"damage")
end end
self.old_health = self.health 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 --baby grows up
if self.baby then if self.baby then

View File

@ -137,9 +137,10 @@ mobs.mob_activate = function(self, staticdata, def, dtime)
} }
end 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) self.health = math_random (self.hp_min, self.hp_max)
end end
if self.breath == nil then if self.breath == nil then
self.breath = self.breath_max self.breath = self.breath_max
end end