ID:1433547
 
(See the best response by Kaiochao.)
Code:
client
//Handlers for when a player is stunned or something.
North()
if(mob.block_movement)
return 0
..()
South()
if(mob.block_movement)
return 0
..()
East()
if(mob.block_movement)
return 0
..()
West()
if(mob.block_movement)
return 0
..()


Problem description:
I've been trying to figure out how to override movement so that when called from somewhere else. With the code above, movement is successfully "blocked". But what other ways can you move a player on the map?

(I tried Move(), but it kept throwing me errors or I just don't know how to use it properly)

To provide an example of what I am trying to accomplish, let's say an enemy grabs you and moves you around. While the enemy is moving, you are also moving with the enemy. You can't control your character until the enemy lets you go.
Best response
Overriding client/Move() would definitely be shorter/cleaner than overriding each directional verb individually. By default, the arrow keys are macroed to those verbs, which call client/Move(), which then calls mob/Move().

Here's how your code would probably be done in client/Move():
client
// Whenever the player tries to move
Move()
// Check if the mob's movement isn't blocked
if(!mob.block_movement)
// Do the default action and return the result
return ..()

*It's important to preserve the return value of built-in procs that return a value by default (check the DM Reference for what built-in return values for any proc would be, if any).

The player's mob can be moved using any movement proc, such as walk(), step(), or Move(). In your example, you should do this when the controlling mob moves.

Moving the mob manually doesn't go through client/Move() because the player isn't directly causing the movement.
In response to Kaiochao
Kaiochao wrote:
Overriding client/Move() would definitely be shorter/cleaner than overriding each directional verb individually. By default, the arrow keys are macroed to those verbs, which call client/Move(), which then calls mob/Move().

Here's how your code would probably be done in client/Move():
> client
> // Whenever the player tries to move
> Move()
> // Check if the mob's movement isn't blocked
> if(!mob.block_movement)
> // Do the default action and return the result
> return ..()
>

*It's important to preserve the return value of built-in procs that return a value by default (check the DM Reference for what built-in return values for any proc would be, if any).

The player's mob can be moved using any movement proc, such as walk(), step(), or Move(). In your example, you should do this when the controlling mob moves.

Moving the mob manually doesn't go through client/Move() because the player isn't directly causing the movement.

Aha! Thanks a bunch! I used other other procs to move the mob and it works flawlessly.