Atrinik Server  4.0
Data Structures | Macros | Typedefs | Functions
monster_data.h File Reference

Go to the source code of this file.

Data Structures

struct  monster_data_dialog
 
struct  monster_data
 

Macros

#define MONSTER_DATA_INTERFACE_CLEANUP   10
 
#define MONSTER_DATA_INTERFACE_TIMEOUT   60 * 15
 
#define MONSTER_DATA_INTERFACE_DISTANCE   2
 
#define MONSTER_DATA(_obj)   ((monster_data_t *) (_obj)->custom_attrset)
 

Typedefs

typedef struct monster_data_dialog monster_data_dialog_t
 
typedef struct monster_data monster_data_t
 

Functions

void monster_data_init (object *op)
 
void monster_data_deinit (object *op)
 
void monster_data_enemy_update (object *op, object *enemy)
 
bool monster_data_enemy_get_coords (object *op, mapstruct **map, uint16_t *x, uint16_t *y)
 
void monster_data_dialogs_add (object *op, object *activator, uint32_t secs)
 
void monster_data_dialogs_remove (object *op, object *activator)
 
bool monster_data_dialogs_check (object *op, object *activator)
 
size_t monster_data_dialogs_num (object *op)
 
void monster_data_dialogs_cleanup (object *op)
 
void monster_data_dialogs_purge (object *op)
 

Detailed Description

Header file related to monster data.

Author
Alex Tokar

Definition in file monster_data.h.

Macro Definition Documentation

#define MONSTER_DATA (   _obj)    ((monster_data_t *) (_obj)->custom_attrset)

Acquire monster data structure from an object structure.

Definition at line 98 of file monster_data.h.

#define MONSTER_DATA_INTERFACE_CLEANUP   10

How often to clean up stale dialog entries in the monster's database, in seconds (every X seconds).

Definition at line 39 of file monster_data.h.

#define MONSTER_DATA_INTERFACE_DISTANCE   2

Maximum distance the activator can be (from the monster) before their dialog is considered stale.

Todo:
This should really be a define somewhere else; we need a constant here only because socket_command_talk() does not define one and simply uses SIZEOFFREE.

Definition at line 53 of file monster_data.h.

#define MONSTER_DATA_INTERFACE_TIMEOUT   60 * 15

Base number of seconds before a dialog is considered as stale. This is mostly a protection against malicious clients.

Definition at line 44 of file monster_data.h.

Typedef Documentation

Structure that holds information about dialogs the monster has open.

typedef struct monster_data monster_data_t

Structure that holds monster data, ie, the monster's brain.

Function Documentation

void monster_data_deinit ( object op)

Deinitialize monster data for the specified object.

Parameters
opMonster.

Definition at line 62 of file monster_data.c.

void monster_data_dialogs_add ( object op,
object activator,
uint32_t  secs 
)

Add a dialog to the monster's database of open dialogs.

Parameters
opMonster.
activatorWho opened the dialog with the monster.
secsSeconds the dialog should remain open for. MONSTER_DATA_INTERFACE_TIMEOUT is added to this value automatically.

Definition at line 214 of file monster_data.c.

bool monster_data_dialogs_check ( object op,
object activator 
)

Determine whether the monster has a dialog open with the specified activator.

Parameters
opMonster.
activatorInterface activator to attempt to find.
Returns
True if there is a dialog open with the specified object, false otherwise.

Definition at line 290 of file monster_data.c.

void monster_data_dialogs_cleanup ( object op)

Cleanup stale and invalid dialogs for the specified monster. Only executes if MONSTER_DATA_INTERFACE_CLEANUP number of seconds have passed.

Parameters
opMonster.

Definition at line 349 of file monster_data.c.

size_t monster_data_dialogs_num ( object op)

Determine the number of dialogs that the specified monster has open.

Parameters
opMonster.
Returns
Number of open dialogs.

Definition at line 321 of file monster_data.c.

void monster_data_dialogs_purge ( object op)

Purge all the dialogs the monster has open.

Parameters
opMonster.

Definition at line 389 of file monster_data.c.

void monster_data_dialogs_remove ( object op,
object activator 
)

Search through the monster's database of dialogs and remove the dialog that was opened by the activator.

It's NOT an error if there is no dialog for the specified object.

Parameters
opMonster.
activatorInterface activator to try and remove.

Definition at line 254 of file monster_data.c.

bool monster_data_enemy_get_coords ( object op,
mapstruct **  map,
uint16_t *  x,
uint16_t *  y 
)

Acquire last coordinates the monster's enemy was spotted at.

Warning
If this function returns false, the out parameters will NOT be modified!
Parameters
opMonster.
[out]mapEnemy's map.
[out]xEnemy's X.
[out]yEnemy's Y.
Returns
True if the coordinates were acquired, false otherwise.

Definition at line 120 of file monster_data.c.

void monster_data_enemy_update ( object op,
object enemy 
)

Update the monster's remembered enemy coordinates.

Parameters
opMonster.
enemyEnemy. Can be NULL, in which case the coordinates will be cleared.

Definition at line 89 of file monster_data.c.

void monster_data_init ( object op)

Initialize monster data for the specified object.

Parameters
opMonster.

Definition at line 48 of file monster_data.c.