View unanswered posts | View active topics It is currently Thu Dec 26, 2024 3:18 pm



Reply to topic  [ 4 posts ] 
 How to make HP regeneration 
Author Message
User avatar

Joined: Mon May 23, 2011 3:41 pm
Posts: 269
Reply with quote
Post How to make HP regeneration

How to make health regenerate every X seconds?


Mon Feb 03, 2014 6:11 pm
Profile

Joined: Fri Nov 23, 2012 5:42 am
Posts: 143
Reply with quote
Post Re: How to make HP regeneration
You need to use lua.

Here's some code, save it to a lua file and set an actor's scriptpath to point towards it. The actor will heal 1 hp every 0.5 seconds.

Code:
dofile("Base.rte/Constants.lua")
require("Actors/AI/NativeHumanAI")

function Create(self)
   self.AI = NativeHumanAI:Create(self)
    self.HealTimer = Timer()
    self.HealTime = 500     --Healing time: change this to make the healing go faster/slower. currently set to 500 miliseconds
end

function UpdateAI(self)
   self.AI:Update(self)
end

function Update(self)
   if self.Health < 100 then
      if self.HealTimer:IsPastSimMS(self.HealTime) then
         self.Health = self.Health + 1      --Healing amount: change this to make the healing go faster/slower. Currently set to 1 hp
         self.HealTimer:Reset();
      end         
   end
end


Mon Feb 03, 2014 6:32 pm
Profile

Joined: Sat Feb 03, 2007 7:11 pm
Posts: 1496
Reply with quote
Post Re: How to make HP regeneration
Or attach an emitter to the actor and have it deal negative damage.

TLB had some health packs a while back that utilized this method.


Mon Feb 17, 2014 9:32 am
Profile WWW

Joined: Fri Nov 23, 2012 5:42 am
Posts: 143
Reply with quote
Post Re: How to make HP regeneration
I tried that method myself, a long time ago, but if I recall correctly the problem was that the AEmitters don't stop when the actor's hp is 100, so you still need to use some lua to stop that. So I prefer the all lua method to the mixed lua and ini method, it just seems simpler to me.


Mon Feb 17, 2014 6:01 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 4 posts ] 

Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.061s | 14 Queries | GZIP : Off ]