ID:165804
 
how do you make it so that you recharge your HP overtime while you are waiting, and make it so it doesn't go past the maximum number of HP?
mob/proc
damageMe(var/damage)
src.health -= damage
src.rechargeMe(5,1)
src << "recharging..."

rechargeMe(var/rechargeRate,var/delay)
while(src.health < src.maxHealth)
spawn(delay)
src.health += rechargeRate
src.health = src.maxHealth // incase the recharge rate doesnt divide equally into maxHealth. Just makes sure health doesnt go over maxHealth.
src << "health recharged!"


Untested but dont just paste it in or else it obviously wont work, learn from it.

- Conj'
In response to The Conjuror
Problems noticed:

- What if someone got damaged very quickly after, two+ of th same proc will be working, maybe add a variable or somehting to see if it's in use or something?

- Where's the death() proc? ;/

- I think you want sleep() rather than spawn() under the while()

- The min() and max() procs were meant for these type of system (max() for damage intake so it doesn't go below 0 and min() so that the healed amt doesn't go over the max)

- GhostAnime
In response to GhostAnime
I see what you mean with the sleep bit, but other than that the rest is left out on purpose, the point is he figures out the basics of it so he can tweak his own version later. I see your point with calling the proc multiple times making it recharge faster, I didnt think about that but that again is something he should find and then learn from to fix later on.