Atrinik Server  4.0
Functions
move.c File Reference
#include <global.h>
#include <arch.h>
#include <player.h>
#include <object.h>
#include <door.h>

Go to the source code of this file.

Functions

int get_random_dir (void)
 
int get_randomized_dir (int dir)
 
int object_move_to (object *op, int dir, object *originator, mapstruct *m, int x, int y)
 
int move_ob (object *op, int dir, object *originator)
 
int transfer_ob (object *op, int x, int y, int randomly, object *originator, object *trap)
 
int push_ob (object *op, int dir, object *pusher)
 

Detailed Description

Handles object moving and pushing.

Definition in file move.c.

Function Documentation

int get_random_dir ( void  )

Returns a random direction (1..8).

Returns
The random direction.

Definition at line 41 of file move.c.

int get_randomized_dir ( int  dir)

Returns a random direction (1..8) similar to a given direction.

Parameters
dirThe exact direction.
Returns
The randomized direction.

Definition at line 53 of file move.c.

int move_ob ( object op,
int  dir,
object originator 
)

Try to move object in specified direction.

Parameters
opWhat to move.
dirDirection to move the object to.
originatorTypically the same as op, but can be different if originator is causing op to move (originator is pushing op).
Returns
0 if the object is not able to move to the desired space, -1 if the object was not able to move there yet but some sort of action was performed that might allow us to move there (door opening for example), direction number that the object ended up moving in otherwise.

Definition at line 155 of file move.c.

int object_move_to ( object op,
int  dir,
object originator,
mapstruct m,
int  x,
int  y 
)

Move the object to the specified coordinates.

Will update the object's sub-layer if necessary.

Parameters
opObject.
dirDirection the object is moving into.
originatorWhat caused the object to move.
mMap.
xX coordinate.
yY coordinate.
Returns
1 on success, 0 on failure.

Definition at line 77 of file move.c.

int push_ob ( object op,
int  dir,
object pusher 
)

An object is being pushed.

Parameters
opWhat is being pushed.
dirPushing direction.
pusherWhat is pushing op.
Returns
0 if the object couldn't be pushed, 1 otherwise.

Definition at line 284 of file move.c.

int transfer_ob ( object op,
int  x,
int  y,
int  randomly,
object originator,
object trap 
)

Move an object (even linked objects) to another spot on the same map.

Does nothing if there is no free spot.

Parameters
opWhat to move.
xNew X coordinate.
yNew Y coordinate.
randomlyIf 1, use map_free_spot() to find the destination, otherwise use map_free_spot_first().
originatorWhat is causing op to move.
trapTrap.
Returns
1 if the object was destroyed, 0 otherwise.

Definition at line 237 of file move.c.