ID:150296
 
How would I make it so that a client's Move() is temporarily disabled? I want it so that when a certian object bumps into you, you cant move for a while.
obj/blah
Bump(O)
if(ismob(O))
//tried to do some stuff here, but to no luck
Sariat wrote:
How would I make it so that a client's Move() is temporarily disabled? I want it so that when a certian object bumps into you, you cant move for a while.
> obj/blah
> Bump(O)
> if(ismob(O))
> //tried to do some stuff here, but to no luck
>
>


How about make a proc like mob/LockMovement(). Have a mob var called movetime or something and initialize it to 0. Inside mob/LockMovement(), set src.movetime equal to world.time + however many ticks you want to lock the movement. This means that movetime is the earliest time at which the mob is allowed to move again. Finally, in mob/Move(), check to see if world.time > src.movetime. If it is, then call ..() otherwise do nothing. Then just call O.LockMovement() from the Bump proc above. If you want to get really fancy and have different delays for bumping into different things, you could add an argument to LockMovement for the delay rather than hardcoding it into LockMovement.
In response to Air Mapster
Air Mapster wrote:
Sariat wrote:
How would I make it so that a client's Move() is temporarily disabled? I want it so that when a certian object bumps into you, you cant move for a while.
> > obj/blah
> > Bump(O)
> > if(ismob(O))
> > //tried to do some stuff here, but to no luck
> >
> >

How about make a proc like mob/LockMovement(). Have a mob var called movetime or something and initialize it to 0. Inside mob/LockMovement(), set src.movetime equal to world.time + however many ticks you want to lock the movement. This means that movetime is the earliest time at which the mob is allowed to move again. Finally, in mob/Move(), check to see if world.time > src.movetime. If it is, then call ..() otherwise do nothing. Then just call O.LockMovement() from the Bump proc above. If you want to get really fancy and have different delays for bumping into different things, you could add an argument to LockMovement for the delay rather than hardcoding it into LockMovement.

Yeah, but how do I set the O's Move() so that he cannot move at all in the firstplace? The rest would be easy,breezy.
In response to Sariat
Sariat wrote:
Air Mapster wrote:
How about make a proc like mob/LockMovement(). Have a mob var called movetime or something and initialize it to 0. Inside mob/LockMovement(), set src.movetime equal to world.time + however many ticks you want to lock the movement. This means that movetime is the earliest time at which the mob is allowed to move again. Finally, <font color=red>in mob/Move(), check to see if world.time > src.movetime. If it is, then call ..() otherwise do nothing</font>. Then just call O.LockMovement() from the Bump proc above. If you want to get really fancy and have different delays for bumping into different things, you could add an argument to LockMovement for the delay rather than hardcoding it into LockMovement.

Yeah, but how do I set the O's Move() so that he cannot move at all in the firstplace? The rest would be easy,breezy.

Just like I said above:
mob/Move()
if (world.time > src.movetime)
. = ..()

If movetime is in the future, ..() isn't called, so nothing happens.