ID:179281
 
i have a push ups verb:
mob/verb/PushUps()
if(usr.pushups==0)
set category = "Training"
usr.icon_state = "pushup"
usr.pushups+=1
Do//i put this here so i could make it repeat attackup only way i could think of
Attackup()
sleep(30)
goto Do

else if(usr.pushups==1)
usr.icon_state = "Normal"
usr.pushups = 0


mob/proc/Attackup()
usr.Attack += 0.5

but after they player chooses to stop doing pushups they Attack power still goe's up how do i stop it??

-NilFisk
I don't see anything about setting usr.pushups to 0 with a proc or anything. Right now, how exactly does the usr stop doing the pushups?
In response to Mertek
the usr icon state stops but i dunno how to make them stop getting stronger
Do//i put this here so i could make it repeat attackup only way i could think of
Attackup()
sleep(30)
goto Do
this would be a continuous loop, that would loop over and over and over and over, no matter how many times you clickit. If you click it once, it just keeps going and going.

If you wanna stop a loop you would include something like the DM equivalent of this:
if(i<30)
i++
goto Do
else
stoping stuff(usr.icon_state="normal")

NilFisk wrote:
mob/verb/PushUps()
if(usr.pushups==0)
set category = "Training"
usr.icon_state = "pushup"
usr.pushups+=1
Do//i put this here so i could make it repeat attackup only way i could think of
Attackup()
sleep(30)
goto Do

else if(usr.pushups==1)
usr.icon_state = "Normal"
usr.pushups = 0

You know, I'm a big defender of goto but this is one place you shouldn't be using it. A do... while loop is what you would want, if this code were correct. However, it's not correct.

First thing to change: You need to move set category = "Training" to the top of the verb, not after the if().

Second thing: AttackUp() is being called constantly whether the player keeps doing pushups or not. You have an infinite loop with no if() or while() statement to break out of it, like this one:
while(usr.pushups)
sleep(30)
Attackup()

You need to have the sleep before the attack increase or else an abusive player will keep macroing the pushup verb on and off to maximum advantage.

Actually, I would suggest you take a completely different approach to all of this. You're going to want training to stop when Move() is called, or else there's a real flaw for people to abuse in the game. Odds are you have several training methods, so why not make that into a string?
mob/verb/PushUps()
set category = "Training"
if(usr.training!="pushup")
usr.training="pushup"
usr.icon_state=usr.training // makes cut&paste easier
while(training=="pushup")
sleep(30)
if(training=="pushup") Attackup()
else
usr.training=null
usr.icon_state="" // usually the normal state is ""

mob/Move()
if(training)
training=null
icon_state=""
return 0 // don't move yet, just stand up
return ..()

Now, using sleep() for the training, I suspect this is still abusable. Say a player starts and stops pushups 5 times, then starts pushups again, all before the first 3-second delay winds down. That's 6 loops sleeping now, each waiting to call Attackup() as long as the player is still doing push-ups. When the first loop wakes up, it calls Attackup(); the next loop will wake up not long afterward and do the same, and so on. And every loop will keep going. A player who gets the timing right could get lots of loops going, maybe 20 or more, and their attack power would just shoot through the roof without their doing a thing.

To avoid this kind of thing you'd need something more sophisticated, like this:
mob
var/training=null
var/list/traininglist=null

proc/train(t,time=0)
training=t
icon_state=(t!=null)?(t):""
if(!traininglist) traininglist=list(t)
else traininglist+=t
spawn(time) FinishTraining()

proc/FinishTraining()
var/t=traininglist[1]
traininglist.Cut(1,2) // cut the first item
if(!t || traininglist.len) return
switch(t)
if("pushups") Attackup()
if("pinball") Agilityup()

Now, instead of calling sleep(30) and Attackup(), you'd call usr.train("pushups",30) to start, and to stop you'd call usr.train(null). You don't even have to set the icon_state, because it does it for you.

The way this system works is that if you stop training and start something else, it gets added to the end of the list. The FinishTraining() proc only gives you the bonus for training if it's the only thing left in the list--that is, if you haven't stopped training or moved on to something different.

Lummox JR