Atrinik Server  4.0
Functions
monster_data.c File Reference
#include <global.h>
#include <monster_data.h>
#include <toolkit/packet.h>
#include <monster_guard.h>
#include <player.h>
#include <object.h>

Go to the source code of this file.

Functions

static void monster_data_dialogs_free (monster_data_dialog_t *dialog)
 
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)
 
static void monster_data_dialogs_close (monster_data_dialog_t *dialog)
 
static bool monster_data_dialogs_verify (monster_data_t *monster_data, monster_data_dialog_t *dialog)
 
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

Handles code for monsters related to monster data.

Author
Alex Tokar

Definition in file monster_data.c.

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.

static void monster_data_dialogs_close ( monster_data_dialog_t dialog)
static

Closes the specified dialog (for players).

Parameters
dialogDialog.

Definition at line 158 of file monster_data.c.

static void monster_data_dialogs_free ( monster_data_dialog_t dialog)
static

Frees the data associated with the specified monster_data_dialog_t.

Parameters
dialogThe dialog.

Definition at line 147 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.

static bool monster_data_dialogs_verify ( monster_data_t monster_data,
monster_data_dialog_t dialog 
)
static

Verify that the specified dialog is still valid (the activator wasn't destroyed, the dialog hasn't expired, etc).

Parameters
monster_dataMonster's data.
dialogInterface to verify.
Returns
True if the dialog is still OK, false otherwise.

Definition at line 180 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.