i have it so when you are training you lose energy but when you stop training you keep loseing energy. I also want it so the usr movement stops but that doesn't work.
turf
trainingpost
icon = 'training.dmi'
density = 1
verb
train()
set src in oview(1)
if(usr.training==1)
usr << "\red You already are training"
else
if(usr.energy<=0)
usr << "\blue You are to tired"
else
usr.Lock()
usr.icon_state = "attack"
src.icon_state = "attack"
usr.drain()
stop_training()
set src in oview(1)
if(usr.training==0)
usr << "\red You aren't training"
else
usr.Move()
usr.icon_state = ""
src.icon_state = ""
mob/var/lock = 0
mob/proc/Lock(mob/M)
M.lock = 1
mob/Move()
if(src.lock)
return
else
return ..()
mob
proc
drain()
usr.energy-=3
sleep(15)
drain()
ID:261534
Jun 13 2002, 8:00 am
|
|
Also, you should avoid using sleep() -- spawn(15) drain() is easier on the processor.
I'll rewrite your drain() proc, since it's not too large:
mob
proc
drain()
if(!src.training) //We're no longer training,
return // so let's quit out of this loop
else //We're still training
src.energy-=3
spawn(15) drain()