Crossfire Server, Trunk  1.75.0
events.h File Reference
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define BITMASK_EVENT(evt)   (1ULL << evt)
 Convert an event to its bit. More...
 
#define BITMASK_VALID   (1ULL << 63)
 Bit indicating if the event bitmask is valid or not. More...
 
#define EVENT_APPLY   1
 Object applied-unapplied. More...
 
#define EVENT_ATTACKED   2
 Object attacked, with weapon or spell. More...
 
#define EVENT_ATTACKS   33
 Weapon or arrow hitting something. More...
 
#define EVENT_BORN   14
 A new character has been created. More...
 
#define EVENT_BOUGHT   34
 Object is being bought by player. More...
 
#define EVENT_CLOCK   15
 Global time event. More...
 
#define EVENT_CLOSE   11
 Container closed. More...
 
#define EVENT_CRASH   16
 Triggered when the server crashes. More...
 
#define EVENT_DEATH   3
 Player or monster dead. More...
 
#define EVENT_DESTROY   13
 Object destroyed (includes map reset/swapout)
More...
 
#define EVENT_DROP   4
 Object dropped on the floor. More...
 
#define EVENT_GBOUGHT   36
 Player bought object in shop, but global. More...
 
#define EVENT_GKILL   18
 Triggered when anything got killed by anyone. More...
 
#define EVENT_GSOLD   37
 Player sold object in shop, but global. More...
 
#define EVENT_KICK   28
 A player was Kicked by a DM
More...
 
#define EVENT_LOGIN   19
 Player login. More...
 
#define EVENT_LOGOUT   20
 Player logout. More...
 
#define EVENT_MAPENTER   21
 A player entered a map. More...
 
#define EVENT_MAPLEAVE   22
 A player left a map. More...
 
#define EVENT_MAPLOAD   30
 A map is loaded (pristine state)
More...
 
#define EVENT_MAPREADY   35
 A map is ready, either first load or after reload. More...
 
#define EVENT_MAPRESET   23
 A map is resetting. More...
 
#define EVENT_MAPUNLOAD   29
 A map is freed (includes swapping out)
More...
 
#define EVENT_MUZZLE   27
 A player was Muzzled (no_shout set). More...
 
#define EVENT_NONE   0
 No event. More...
 
#define EVENT_PICKUP   5
 Object picked up. More...
 
#define EVENT_PLAYER_DEATH   17
 Global Death event
More...
 
#define EVENT_REMOVE   24
 A Player character has been removed. More...
 
#define EVENT_SAY   6
 Someone speaks. More...
 
#define EVENT_SELLING   32
 Object is being sold by another one. More...
 
#define EVENT_SHOUT   25
 A player 'shout' something. More...
 
#define EVENT_STOP   7
 Thrown object stopped. More...
 
#define EVENT_TELL   26
 A player 'tell' something. More...
 
#define EVENT_THROW   9
 Object is thrown. More...
 
#define EVENT_TIME   8
 Triggered each time the object can react/move. More...
 
#define EVENT_TIMER   12
 Timer connected triggered it. More...
 
#define EVENT_TRIGGER   10
 Button pushed, lever pulled, etc. More...
 
#define EVENT_USER   31
 User-defined event. More...
 
#define NR_EVENTS   38
 Number of events, maximum code + 1. More...
 

Typedefs

typedef unsigned long event_registration
 Registration identifier type. More...
 
typedef int(* f_plug_event) (int *type,...)
 Function to call to handle global or object-related events. More...
 

Functions

void events_execute_global_event (int eventcode,...)
 Execute a global event. More...
 
int events_execute_object_event (object *op, int eventcode, object *activator, object *third, const char *message, int fix)
 Execute an event on the specified object. More...
 
int events_execute_object_say (object *npc, talk_info *talk)
 Execute an EVENT_SAY on the specified object. More...
 
int events_execute_object_user (object *op, object *activator, object *third, const char *message, int fix)
 Execute an EVENT_USER on the specified object. More...
 
event_registration events_register_global_handler (int eventcode, f_plug_event hook)
 Register a global event handler. More...
 
void events_register_object_handler (const char *id, f_plug_event handler)
 Register an object event handler. More...
 
void events_unregister_global_handler (int eventcode, event_registration id)
 Remove a global event handler. More...
 
void events_unregister_object_handler (const char *id)
 Remove an object event handler. More...
 

Macro Definition Documentation

◆ BITMASK_EVENT

#define BITMASK_EVENT (   evt)    (1ULL << evt)

Convert an event to its bit.

Definition at line 77 of file events.h.

◆ BITMASK_VALID

#define BITMASK_VALID   (1ULL << 63)

Bit indicating if the event bitmask is valid or not.

Definition at line 79 of file events.h.

◆ NR_EVENTS

#define NR_EVENTS   38

Number of events, maximum code + 1.

Definition at line 74 of file events.h.

Typedef Documentation

◆ event_registration

typedef unsigned long event_registration

Registration identifier type.

Definition at line 84 of file events.h.

◆ f_plug_event

typedef int(* f_plug_event) (int *type,...)

Function to call to handle global or object-related events.

Definition at line 82 of file events.h.

Function Documentation

◆ events_execute_global_event()

◆ events_execute_object_event()

int events_execute_object_event ( object op,
int  eventcode,
object activator,
object third,
const char *  message,
int  fix 
)

Execute an event on the specified object.

Parameters
opobject to execute the event on.
eventcodeevent code to execute.
activatorobject which caused the event to be triggered.
thirdadditional object.
messagewhat the object said to trigger.
fixwhether to fix op or not.
Returns
value to return to the caller.

Definition at line 309 of file events.cpp.

References do_execute_event(), and message.

Referenced by apply_container(), attack_ob_simple(), cftimer_process_event(), common_pre_ob_move_on(), do_throw(), drop_object(), events_execute_object_user(), hit_player(), hit_with_arrow(), kill_object(), kill_player(), move_teleporter(), ob_apply(), object_free(), pick_lock(), pick_up_object(), player_changer_type_process(), pray_at_altar(), process_object(), sell_item(), shop_pay_unpaid_callback(), stop_projectile(), trigger_connected(), write_note(), and write_scroll().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ events_execute_object_say()

int events_execute_object_say ( object npc,
talk_info talk 
)

Execute an EVENT_SAY on the specified object.

Parameters
npcobject to execute the event on.
talkdialog information, which may be altered to add replies or questions.
Returns
value to return to the caller.

Definition at line 313 of file events.cpp.

References do_execute_event(), EVENT_SAY, SCRIPT_FIX_ALL, talk_info::text, and talk_info::who.

Referenced by monster_talk_to_npc().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ events_execute_object_user()

int events_execute_object_user ( object op,
object activator,
object third,
const char *  message,
int  fix 
)

Execute an EVENT_USER on the specified object.

Parameters
opobject to execute the event on.
activatorobject which caused the event to be triggered.
thirdadditional object.
messagewhat the object said to trigger.
fixwhether to fix op or not.
Returns
value to return to the caller.

Definition at line 317 of file events.cpp.

References EVENT_USER, events_execute_object_event(), and message.

Referenced by cfapi_object_user_event().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ events_register_global_handler()

event_registration events_register_global_handler ( int  eventcode,
f_plug_event  hook 
)

Register a global event handler.

Parameters
eventcodeevent code to register the handler for.
hookfunction to call for the event.
Returns
registration identifier, used with events_unregister_global_handler().

Definition at line 19 of file events.cpp.

References eg, global_handlers, and next_event_registration.

Referenced by cfapi_system_register_global_event(), cfcitybell_init(), citylife_init(), and random_house_generator_init().

+ Here is the caller graph for this function:

◆ events_register_object_handler()

void events_register_object_handler ( const char *  id,
f_plug_event  handler 
)

Register an object event handler.

Parameters
idhandler identifier, must be unique and match the "title" field of the event connector.
handlerfunction to call for the event.

Definition at line 299 of file events.cpp.

References llevDebug, LOG(), and object_handlers.

Referenced by citylife_init(), and plugins_init_plugin().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ events_unregister_global_handler()

void events_unregister_global_handler ( int  eventcode,
event_registration  id 
)

Remove a global event handler.

Parameters
eventcodeevent code to unregister the handler of.
idregistration identifier as returned by events_register_global_handler().

Definition at line 26 of file events.cpp.

References global_handlers.

Referenced by cfapi_system_unregister_global_event(), cfcitybell_close(), citylife_close(), plugins_remove_plugin(), and random_house_generator_close().

+ Here is the caller graph for this function:

◆ events_unregister_object_handler()

void events_unregister_object_handler ( const char *  id)

Remove an object event handler.

Parameters
idhandler identifier.

Definition at line 304 of file events.cpp.

References llevDebug, LOG(), and object_handlers.

Referenced by citylife_close(), and plugins_remove_plugin().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: