Search the Community
Showing results for tags 'Kill'.
-
Hello there, I have been messing around with Leadwerks and have made new npc's and created new scrips for those npcs and it all works well they move, attack me, and such however I can't seem to kill them. When I try to shoot them, it just goes right through them and I cant seem to figure it out. Second issue, when they come after me they are always looking away, I have the Character angle at 180 but when I turn it to 0, once they get near me they kind of just bounce away not sure why. Any help is much appreciated and thank you.
-
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