Crossfire Server, Branch 1.12  R12190
Functions
move.c File Reference

Those functions handle object moving and pushing. More...

#include <global.h>
#include <sproto.h>
Include dependency graph for move.c:

Go to the source code of this file.

Functions

int move_ob (object *op, int dir, object *originator)
 Op is trying to move in direction dir.
int move_object (object *op, int dir)
 Try to move op in the direction "dir".
int move_to (object *op, int x, int y)
 Move an object one square toward a specified destination on the same map.
int push_ob (object *who, int dir, object *pusher)
 Something is pushing some other object.
void recursive_roll (object *op, int dir, object *pusher)
 An object is pushed by another which is trying to take its place.
static int roll_ob (object *op, int dir, object *pusher)
 An object is being pushed, and may push other objects.
int teleport (object *teleporter, uint8 tele_type, object *user)
 Teleport an item around a nearby random teleporter of specified type.
int transfer_ob (object *op, int x, int y, int randomly, object *originator)
 Move an object (even linked objects) to another spot on the same map.
static int try_fit (object *op, mapstruct *m, int x, int y)
 Checks if an objects fits on a specified spot.

Detailed Description

Those functions handle object moving and pushing.

Definition in file move.c.


Function Documentation

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

Op is trying to move in direction dir.

Parameters:
opwhat is moving.
dirwhat direction op wants to move.
originatortypically the same as op, but can be different if originator is causing op to move (originator is pushing op).
Return values:
0op is not able to move to the desired space.
1op was moved.

Definition at line 72 of file move.c.

References blocked_link(), check_doors(), check_earthwalls(), pl::do_los, esrv_map_scroll(), FLAG_REMOVED, FLAG_WIZPASS, freearr_x, freearr_y, get_map_flags(), get_map_from_coord(), insert_ob_in_map(), llevDebug, llevError, LOG(), move_ob(), P_OUT_OF_MAP, PLAYER, QUERY_FLAG, remove_ob(), and TRANSPORT.

Referenced by cfapi_object_move(), flee_player(), move_golem(), move_ob(), move_object(), move_player_attack(), move_to(), pet_move(), and recursive_roll().

Here is the call graph for this function:

Here is the caller graph for this function:

int move_object ( object *  op,
int  dir 
)

Try to move op in the direction "dir".

Parameters:
opwhat to move.
dirmoving direction.
Return values:
0something blocks the passage.
1op was moved..

Definition at line 53 of file move.c.

References move_ob().

Referenced by check_spell_knockback(), circ1_move(), circ2_move(), move_monster(), move_player_mover(), move_randomly(), pace2_moveh(), pace2_movev(), pace_moveh(), pace_movev(), push_ob(), and rand_move().

Here is the call graph for this function:

Here is the caller graph for this function:

int move_to ( object *  op,
int  x,
int  y 
)

Move an object one square toward a specified destination on the same map.

The move takes into account blocked squares for op, and things like that. No check is done to know if the object has enough speed to move.

Parameters:
opobject to move
x
ydestination coordinates
Returns:
0 if op is on the specified spot, 1 if it moved towards the goal, 2 if it didn't find any path to the goal.

Definition at line 626 of file move.c.

References compute_path(), GET_MAP_FLAGS, GET_MAP_OB, move_ob(), and P_OUT_OF_MAP.

Referenced by cfapi_object_transfer().

Here is the call graph for this function:

Here is the caller graph for this function:

int push_ob ( object *  who,
int  dir,
object *  pusher 
)

Something is pushing some other object.

Parameters:
whoobject being pushed.
dirpushing direction.
pusherwhat is pushing who.
Return values:
1if pushing invokes a attack
0no attack during pushing.
Todo:
fix return value which is weird for last case.

Definition at line 492 of file move.c.

References CLEAR_FLAG, draw_ext_info_format(), esrv_map_scroll(), FLAG_FRIENDLY, FLAG_NEUTRAL, FLAG_SLEEP, FLAG_STAND_STILL, FLAG_UNAGGRESSIVE, FLAG_WIZ, freearr_x, freearr_y, get_owner(), insert_ob_in_map(), move_object(), MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_FAILURE, MSG_TYPE_VICTIM, MSG_TYPE_VICTIM_WAS_PUSHED, NDI_UNIQUE, PLAYER, PREFER_HIGH, QUERY_FLAG, random_roll(), and remove_ob().

Referenced by move_player_attack().

Here is the call graph for this function:

Here is the caller graph for this function:

void recursive_roll ( object *  op,
int  dir,
object *  pusher 
)

An object is pushed by another which is trying to take its place.

Parameters:
opwhat is being pushed.
dirpushing direction.
pusherwhat is pushing op.

Definition at line 340 of file move.c.

References draw_ext_info_format(), MAX_BUF, move_ob(), MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_FAILURE, MSG_TYPE_COMMAND_SUCCESS, NDI_BLACK, NDI_UNIQUE, query_name(), and roll_ob().

Referenced by move_player_attack().

Here is the call graph for this function:

Here is the caller graph for this function:

static int roll_ob ( object *  op,
int  dir,
object *  pusher 
) [static]

An object is being pushed, and may push other objects.

This is not perfect yet. it does not roll objects behind multipart objects properly. Support for rolling multipart objects is questionable.

Parameters:
opwhat is being pushed.
dirpushing direction.
pusherwhat is pushing op.
Return values:
0op couldn't move.
1op, and potentially other objects, moved.

Definition at line 432 of file move.c.

References FLAG_CAN_ROLL, flags, freearr_x, freearr_y, get_map_flags(), GET_MAP_MOVE_BLOCK, GET_MAP_OB, insert_ob_in_map(), OB_MOVE_BLOCK, P_IS_ALIVE, P_OUT_OF_MAP, PREFER_LOW, QUERY_FLAG, random_roll(), remove_ob(), and try_fit().

Referenced by recursive_roll().

Here is the call graph for this function:

Here is the caller graph for this function:

int teleport ( object *  teleporter,
uint8  tele_type,
object *  user 
)

Teleport an item around a nearby random teleporter of specified type.

It is basically used so that shop_mats and normal teleporters can be used close to each other and not have the player put to the one of another type.

Parameters:
teleporterwhat is teleporting user.
tele_typewhat object type user can be put on. this is either set to SHOP_MAT or TELEPORTER.
userwhat object to teleport.
Return values:
1user was destroyed.
0user is still valid, but may have moved or not.
Todo:
fix weird return values.

Definition at line 244 of file move.c.

References find_free_spot(), freearr_x, freearr_y, get_map_flags(), GET_MAP_MOVE_BLOCK, GET_MAP_OB, insert_ob_in_map(), llevError, LOG(), map_newmap_cmd(), OB_TYPE_MOVE_BLOCK, OUT_OF_REAL_MAP, P_OUT_OF_MAP, PLAYER, remove_ob(), and SHOP_MAT.

Referenced by initteleport(), move_teleporter(), runteleport(), and shop_mat_type_move_on().

Here is the call graph for this function:

Here is the caller graph for this function:

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

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.
x
ynew coordinates.
randomlyif true, use find_free_spot() to find the destination, otherwise use find_first_free_spot().
originatorwhat is causing op to move.
Return values:
1op was destroyed.
0op was moved.

Definition at line 197 of file move.c.

References find_first_free_spot(), find_free_spot(), freearr_x, freearr_y, insert_ob_in_map(), map_newmap_cmd(), PLAYER, remove_ob(), and SIZEOFFREE.

Referenced by cfapi_object_transfer(), hole_type_move_on(), kill_player(), move_teleporter(), shop_mat_type_move_on(), and trapdoor_type_move_on().

Here is the call graph for this function:

Here is the caller graph for this function:

static int try_fit ( object *  op,
mapstruct m,
int  x,
int  y 
) [static]

Checks if an objects fits on a specified spot.

This is a new version of blocked, this one handles objects that can be passed through by monsters with the CAN_PASS_THRU defined.

Very new version handles also multipart objects This is currently only used for the boulder roll code.

Parameters:
opwhat object to fit.
m
x
ywhere to put op.
Return values:
1object does not fit.
0object fits.

Definition at line 380 of file move.c.

References DOOR, FLAG_ALIVE, get_map_flags(), GET_MAP_OB, OB_MOVE_BLOCK, P_OUT_OF_MAP, and QUERY_FLAG.

Referenced by roll_ob().

Here is the call graph for this function:

Here is the caller graph for this function: