Data Realms Fan Forums
http://forums.datarealms.com/

How to make HP regeneration
http://forums.datarealms.com/viewtopic.php?f=1&t=45552
Page 1 of 1

Author:  HeadcrabPL [ Mon Feb 03, 2014 6:11 pm ]
Post subject:  How to make HP regeneration


How to make health regenerate every X seconds?

Author:  clunatic [ Mon Feb 03, 2014 6:32 pm ]
Post subject:  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

Author:  zalo [ Mon Feb 17, 2014 9:32 am ]
Post subject:  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.

Author:  clunatic [ Mon Feb 17, 2014 6:01 pm ]
Post subject:  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.

Page 1 of 1 All times are UTC [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/