var/Regenloop=0
mob
proc
Regen()
set background=1
sleep(30)
for(var/mob/M in TotalPlayers) //All players currently online
if(Regenloop==1)
goto skip
if(M.hit) //If M was hit(In combat)
Regenloop=1
sleep(200)
Regenloop=0
goto skip
else
Regenloop=1
M.health+=M.maxhealth/100*M.basehealthregen
if(M.health>M.maxhealth)
M.health=M.maxhealth
M.UpdateHMB() //This updates the Healthbar
M.MenuUpdate() //This updates the statpanel
Regenloop=0
skip
Regen()
Problem description:
I've been trying out different things for some passive health Regeneration. Basically my question is, if there is a better way of doing this?
Secondly you're using goto in a very inappropriate way.
As a mob proc, you don't really need the for(), since it's not in the global scope. You don't need 'goto' to make the proc loop, you can use while() for that.
Now Regen() will call every 3 ticks for every mob that logs in.
If you wanted something that only ran the loop while they were damaged you could make the condition of the while() based on their health, which would terminate the loop when that condition was met, then you could call the Regen() proc when they took damage (and the loop wasn't already running).