ID:176297
 
anyone know how to make a code to regenerate health
Chrisshehu wrote:
anyone know how to make a code to regenerate health

Of course it depends on how your health system works, but I can give you the general principle. A simple way is to spawn() a health generation process whenever you want. It can be very simple, like this:
mob
proc
genHealth(amount)
src.health += min(amount, src.maxhealth)
if(src.health < src.maxhealth)
spawn(50) genHealth(amount) // Every 5 seconds, restore some health.

I used the min() function so you don't have to worry about passing the mobs maxhealth variable.


/Gazoot
In response to Gazoot
Erm, don't you mean<code> src.health = min(src.health+amount,src.maxhealth) </code>?
In response to Garthor
Garthor wrote:
Erm, don't you mean<code> src.health = min(src.health+amount,src.maxhealth) <code>? Of course I did. Thanks. /Gaz
In response to Gazoot
Oops, I left out the / in </code>. Silly me.
In response to Garthor
Garthor wrote:
Oops, I left out the / in </code>. Silly me.

We all make mistakes. :)