ID:178461
 
//part of an attack verb
Deathcheck
if(M.vitality <= 0)
if(!M.client)
del(M)
else
world << "[M] has died!"
M.vitality = M.max_vitality
else
if(M.ishealing == 0)
goto recover
else
return
recover
M.recover()//116th line


Then it gives me errors becuase the sleep() part is delaying the WHOLE proc. Like when attacking something, after its dead, I keep on getting a null vitality bug. How can I make the sleep() proc not delay the WHOLE proc?


This is the error:

runtime error: Cannot execute null.recover().
proc name: Attack (/proc/Attack)
source file: Battle.dm,116
usr: Sariat (/mob/kid)
src: null
call stack:
Attack(null)
Sariat (/mob/kid): punch()

Thanks for reading!
-ST
I don't see a sleep() part. Did you post the right part of the code?
In response to Skysaw
I erased it on accident! Here is the recover code

mob/proc/recover()
if(usr.ishealing == 0)
usr.ishealing = 1
while(usr.vitality <= usr.max_vitality)
usr.vitality+=rand(1,3)
sleep(rand(130-usr.recovery))
usr.vitality = usr.max_vitality
usr.ishealing = 0
else
..()


Sorry about that
In response to Sariat
Sariat wrote:
I erased it on accident! Here is the recover code

> mob/proc/recover()
> if(usr.ishealing == 0)
> usr.ishealing = 1
> while(usr.vitality <= usr.max_vitality)
> usr.vitality+=rand(1,3)
> sleep(rand(130-usr.recovery))
> usr.vitality = usr.max_vitality
> usr.ishealing = 0
> else
> ..()
>

Sorry about that

The only problem with this piece is using usr when it makes no sense to do so.

The first piece is giving you an error because "recover" is just a label for a place in the code. After your first checks, the code passes down through recover anyway, and in one case, M has already been deleted.

Yet another argument for getting rid of goto statements :-)
In response to Skysaw
Deathcheck
if(M.vitality <= 0)
if(!M.client)
del(M)
else
world << "[M] has died!"
M.vitality = M.max_vitality
<font color="yellow">return</font>
else
if(M.ishealing == 0)
goto recover
else
return
In response to Skysaw
Gah! It worked, thanks!