ID:160437
 
i tryed the follow:

    rest()
set name="rest"
Enter(0)
//flick() will come here
while(src.HP<src.max_HP)
if(src.HP<=(src.HP-6))
sleep(30) //i try to do a deley of 3 sec between each time
src.HP+=6

else
src.HP=src.max_HP // my HP its /6 always...
//flick() wil come here again
return

</DM

i want the mob will stack when he(or she) rest.
problem: i dont know if its stack on not cuse my delay cod its wrong..the life up instently.

i notice that sleep its not the command for delay the cod, so what is the command to do it?

thx, Orhalimi
Good job, Billy!
You've managed to provide us with no information to aid us in aiding you.

mob/verb/Rest()
view() << "[src] rests!"
Well, your math isn't adding up. (Haha, get it?)

Look at the if() line.
If your CURRENT health is less than your CURRENT Health subtracted by 6, then it'll add 6. If not, then it'll make it maximum.

An example, if you have 6 apples and you'll add 6 apples only if you have 0 apples. However, you have 6 apples so you won't ever add 6 apples.
Get it?

I think you meant to put src.max_HP-6

Also, that return will break the while() procedure. Might want to put it indented after the code after the else.
maybe something like this
    rest()
set name="rest"
Enter(0)
while(src.HP<src.max_HP)
if(src.HP<=(src.HP-6))
restloop
//add a proc call here that will check and see if the user's HP is around "src.max_HP" and if it's ">= src.max_HP" then it will do the "src.HP=src.max_HP"
sleep(30)
src.HP+=6
goto restloop

else
src.HP=src.max_HP
return

I'm not 100% if that would work, but the "goto" option is very handy when it comes to loops ^.^
In response to ElderKain
Don't post replies to code if you program like that.
In response to Thief Jack
thx, its work to me now

mob/verb
kill()
Kill()
rest()
set name="rest"

Enter(src)
//flick() will come here
view() << "you begin to rest"
while(src.HP < src.max_HP)
if(src.HP<=(src.max_HP-6))
sleep(20) //i try to do a deley of 3 sec between each time
src.HP+=src.defence

else
src.HP=src.max_HP
usr << "you finish resting"
return


but, the usr dont stack untile the rest finish. i ant he wont be able to move untile he will get full life...

i think its becuse the sleep, meby i need deley command and not sleep?
In response to Orhalimi
I think what you want is make it so the person cant move while resting your, also the Enter(src) what is that for. But if you want to be able to stop movement try something like this

mob/verb
kill()
Kill()
rest()
set name="rest"
view() << "you begin to rest"
usr.resting=1//define a mob variable for resting and then modify the move proc like below
while(src.HP < src.max_HP)
if(src.HP<=(src.max_HP-6))
sleep(20) //i try to do a deley of 3 sec between each time
src.HP+=src.defence

else
src.HP=src.max_HP
usr.resting=0
usr << "you finish resting"
return


mob
Move()
if(src.resting)
return
else
..()//calls the original move proc so they can move the rest of the time
In response to NightJumper88
Note the Move() override should ultimately be like this instead:
client/Move() //override player-initiated movements only
if(src.mob.cantmove) //whatever var you're using
return 0 //stop the proc and report failure
//else, do the default behavior and return whatever it returns
return ..()
In response to ElderKain
Nononononono.

No loops with goto.

Look up while() and for()
In response to Andre-g1
Andre-g1 wrote:
Nononononono.

No loops with goto.

Look up while() and for()

well the usage of goto can be used for loops, most people perfer to use while() & for() but goto can be used also, it's just the code gets a bit more cluttered that way.

if goto works then it's alright, it's all a matter of opinion.
In response to ElderKain
That's like saying, if crossing the road while on green light for the cars works because they stop, then it's alright.