Fix mobs playing damage sound when they healed
This commit is contained in:
parent
5d6d1cf790
commit
a3d798ca13
|
@ -421,18 +421,22 @@ local check_for_death = function(self, cause, cmi_cause)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local damaged = self.health < self.old_health
|
||||||
self.old_health = self.health
|
self.old_health = self.health
|
||||||
|
|
||||||
-- still got some health? play hurt sound
|
-- still got some health?
|
||||||
if self.health > 0 then
|
if self.health > 0 then
|
||||||
|
|
||||||
mob_sound(self, self.sounds.damage)
|
|
||||||
|
|
||||||
-- make sure health isn't higher than max
|
-- make sure health isn't higher than max
|
||||||
if self.health > self.hp_max then
|
if self.health > self.hp_max then
|
||||||
self.health = self.hp_max
|
self.health = self.hp_max
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- play damage sound if health was reduced
|
||||||
|
if damaged then
|
||||||
|
mob_sound(self, self.sounds.damage)
|
||||||
|
end
|
||||||
|
|
||||||
-- backup nametag so we can show health stats
|
-- backup nametag so we can show health stats
|
||||||
if not self.nametag2 then
|
if not self.nametag2 then
|
||||||
self.nametag2 = self.nametag or ""
|
self.nametag2 = self.nametag or ""
|
||||||
|
|
Loading…
Reference in New Issue