forked from VoxeLibre/VoxeLibre
Merge pull request 'Fix dead-alive mobs and add in hurt/die sound' (#1645) from jordan4ibanez/MineClone2:mineclone5 into mineclone5
Reviewed-on: MineClone2/MineClone2#1645
This commit is contained in:
commit
857434a4ff
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue