Atrinik Server  4.0
Macros | Functions | Variables
object_methods.c File Reference
#include <global.h>
#include <plugin.h>
#include <arch.h>
#include <player.h>
#include <object.h>
#include <object_methods.h>
#include <object_type_list.h>

Go to the source code of this file.

Functions

static void object_methods_init_one (object_methods_t *methods)
 
void object_methods_init (void)
 
object_methods_tobject_methods_get (int type)
 
void object_cb_init (object *op)
 
void object_cb_deinit (object *op)
 
int object_apply (object *op, object *applier, int aflags)
 
void object_process (object *op)
 
char * object_describe (object *op, object *observer, char *buf, size_t size)
 
int object_move_on (object *op, object *victim, object *originator, int state)
 
int object_trigger (object *op, object *cause, int state)
 
int object_trigger_button (object *op, object *cause, int state)
 
void object_cb_insert_map (object *op)
 
void object_cb_remove_map (object *op)
 
void object_cb_remove_inv (object *op)
 
objectobject_projectile_fire (object *op, object *shooter, int dir)
 
objectobject_projectile_move (object *op)
 
int object_projectile_hit (object *op, object *victim)
 
objectobject_projectile_stop (object *op, int reason)
 
int object_ranged_fire (object *op, object *shooter, int dir, double *delay)
 
void object_auto_apply (object *op)
 
int object_process_treasure (object *op, object **ret, int difficulty, treasure_affinity_t *affinity, int flags)
 

Variables

static object_methods_t object_type_methods [OBJECT_TYPE_MAX]
 
static object_methods_t object_methods_base
 
static int object_move_on_recursion_depth = 0
 

Detailed Description

Object methods system.

Definition in file object_methods.c.

Function Documentation

int object_apply ( object op,
object applier,
int  aflags 
)

Applies an object.

Parameters
opThe object to apply.
applierThe object that executes the apply action.
aflagsSpecial (always apply/unapply) flags.

Definition at line 154 of file object_methods.c.

void object_auto_apply ( object op)

Processes an object with FLAG_AUTO_APPLY.

Parameters
opThe object to process.

Definition at line 470 of file object_methods.c.

void object_cb_deinit ( object op)

De-initializes an object.

Parameters
opThe object to de-initialize.

Definition at line 137 of file object_methods.c.

void object_cb_init ( object op)

Initializes an object.

Parameters
opThe object to initialize.

Definition at line 120 of file object_methods.c.

void object_cb_insert_map ( object op)

Called when an object is inserted on a map.

Parameters
opThe object being inserted.

Definition at line 306 of file object_methods.c.

void object_cb_remove_inv ( object op)

Called when an object is removed from inventory.

Parameters
opThe object being removed.

Definition at line 338 of file object_methods.c.

void object_cb_remove_map ( object op)

Called when an object is removed from map.

Parameters
opThe object being removed.

Definition at line 322 of file object_methods.c.

char* object_describe ( object op,
object observer,
char *  buf,
size_t  size 
)

Returns the description of an object, as seen by the given observer.

Parameters
opThe object to describe.
observerThe object to which the description is made.
bufBuffer that will contain the description.
sizeSize of 'buf'.

Definition at line 204 of file object_methods.c.

object_methods_t* object_methods_get ( int  type)

Acquire object methods for the specified object type.

Parameters
typeThe object type.
Returns
The object methods for the specified type, never NULL.

Definition at line 109 of file object_methods.c.

void object_methods_init ( void  )

Initializes the object methods system.

Definition at line 72 of file object_methods.c.

static void object_methods_init_one ( object_methods_t methods)
static

Initialize one object methods structure.

Parameters
methodsWhat to initialize.

Definition at line 63 of file object_methods.c.

int object_move_on ( object op,
object victim,
object originator,
int  state 
)

Triggered when an object moves moves off a square and when object moves onto a square.

Parameters
opThe object that wants to catch this event.
victimThe object moving.
originatorThe object that is the cause of the move.
state1 if the object is moving onto a square, 0 if moving off a square.

Definition at line 225 of file object_methods.c.

void object_process ( object op)

Processes an object, giving it the opportunity to move or react.

Parameters
opThe object to process.

Definition at line 174 of file object_methods.c.

int object_process_treasure ( object op,
object **  ret,
int  difficulty,
treasure_affinity_t *  affinity,
int  flags 
)

Process generated treasure.

Parameters
opObject to process.
[out]retIf the function returns OBJECT_METHOD_OK, this variable will contain the processed treasure object, which may be different from 'op' (which may be destroyed). Indeterminate on any other return value.
difficultyDifficulty level.
affinityTreasure affinity.
flagsA combination of GT_xxx flags.
Returns
One of Object method return values.
Warning
If OBJECT_METHOD_ERROR is returned from this function, it is possible that the original object has been destroyed and thus any further processing should stop.

Definition at line 500 of file object_methods.c.

object* object_projectile_fire ( object op,
object shooter,
int  dir 
)

Function to handle firing a projectile, eg, an arrow being fired from a bow, or a potion being thrown.

Parameters
opWhat is being fired.
shooterWho is doing the firing.
dirDirection to fire into.
Returns
The fired object on success, NULL on failure.

Definition at line 354 of file object_methods.c.

int object_projectile_hit ( object op,
object victim 
)

Called when a fired object finds an alive object on the square it just moved to.

Parameters
opThe fired object.
victimThe found alive object. Note that this just means that the object is on the LAYER_LIVING layer, which may or may not imply that the object is actually alive.
Return values
OBJECT_METHOD_OKSuccessfully processed and should stop the fired arch.
OBJECT_METHOD_UNHANDLEDDid not handle the event, should continue trying to look for another alive object.
OBJECT_METHOD_ERROR'op' was destroyed.

Definition at line 389 of file object_methods.c.

object* object_projectile_move ( object op)

Function to handle a fired object moving, eg, arrow moving to the next square along its path.

Parameters
opThe fired object.
Returns
The fired object, NULL if it was destroyed for some reason.

Definition at line 372 of file object_methods.c.

object* object_projectile_stop ( object op,
int  reason 
)

Called to stop a fired object.

Parameters
opThe fired object.
reasonReason for stopping, one of Projectile stop reasons.
Returns
The fired object if it still exists, NULL otherwise.

Definition at line 407 of file object_methods.c.

int object_ranged_fire ( object op,
object shooter,
int  dir,
double *  delay 
)

Used to fire a ranged weapon, eg, a bow firing arrows, throwing weapons/potions, firing wands/rods, etc.

Parameters
opThe weapon being fired (bow, wand, throwing object).
shooterWho is doing the firing.
dirDirection to fire into.
[out]delayIf non-NULL, will contain delay caused by this action.
Returns
One of Object method return values.

Definition at line 428 of file object_methods.c.

int object_trigger ( object op,
object cause,
int  state 
)

An object is triggered by another one.

Parameters
opThe object being triggered.
causeThe object that is the cause of the trigger.
stateTrigger state.

Definition at line 270 of file object_methods.c.

int object_trigger_button ( object op,
object cause,
int  state 
)

An object is triggered by a button.

Parameters
opThe object being triggered.
causeThe object that is the cause of the trigger; the button.
stateTrigger state.

Definition at line 288 of file object_methods.c.

Variable Documentation

object_methods_t object_methods_base
static

The base object type methods; all object types inherit from this.

Definition at line 45 of file object_methods.c.

int object_move_on_recursion_depth = 0
static

Recursion counter for object_move_on().

Definition at line 50 of file object_methods.c.

object_methods_t object_type_methods[OBJECT_TYPE_MAX]
static

Registered method handlers.

Definition at line 40 of file object_methods.c.