I was updating a pain trigger and noticed that in the fpsplayer.lua file that the functions:
Script:Hurt(damage,distributorOfPain)
and
Script:TakeDamage(damage)
Script:Hurt will lower your health and when dead initiate the death sequence by calling Script:Kill(), BUT it will NOT set the players self.alive to false, call Script:OnHit() or Script:OnDead()
Script:TakeDamage will lower your health, set your self.alive to false, call the self:OnHit() and self:OnDead() outputs but will not start the death sequence by calling Script:Kill()
Fixed functions:
function Script:Hurt(damage,distributorOfPain)
if self.health>0 then
self.sound.damage[math.random(#self.sound.damage)]:Play()
self.health = self.health - damage
self.hurtoffset = Vec3(math.random(-1,1),math.random(-1,1),0):Normalize()*30
local blood = {}
local n=1
blood.texture=self.image.blood[math.random(1,4)]
blood.intensity=1
table.insert(self.bloodoverlay,blood)
if self.bloodindex>4 then self.bloodindex=1 end
self:OnHit()
if self.health<=0 then
self.alive = false
self:Kill()
self:OnDead()
end
end
end
function Script:TakeDamage(damage)
-- Decrease health
self.health = self.health - damage;
-- Call OnHit output
self:OnHit()
-- If health lower or equal to zero, the player is dead
if self.health <= 0 then
self.alive = false
-- Call the OnDead output
self:OnDead()
self:Kill()
end
end