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 64 of file events.h.

◆ BITMASK_VALID

#define BITMASK_VALID   (1ULL << 63)

Bit indicating if the event bitmask is valid or not.

Definition at line 66 of file events.h.

◆ EVENT_APPLY

#define EVENT_APPLY   1

Object applied-unapplied.


Definition at line 20 of file events.h.

◆ EVENT_ATTACKED

#define EVENT_ATTACKED   2

Object attacked, with weapon or spell.


Definition at line 21 of file events.h.

◆ EVENT_ATTACKS

#define EVENT_ATTACKS   33

Weapon or arrow hitting something.


Definition at line 22 of file events.h.

◆ EVENT_BORN

#define EVENT_BORN   14

A new character has been created.


Definition at line 39 of file events.h.

◆ EVENT_BOUGHT

#define EVENT_BOUGHT   34

Object is being bought by player.


Definition at line 23 of file events.h.

◆ EVENT_CLOCK

#define EVENT_CLOCK   15

Global time event.


Definition at line 40 of file events.h.

◆ EVENT_CLOSE

#define EVENT_CLOSE   11

Container closed.


Definition at line 24 of file events.h.

◆ EVENT_CRASH

#define EVENT_CRASH   16

Triggered when the server crashes.

Not recursive

Definition at line 41 of file events.h.

◆ EVENT_DEATH

#define EVENT_DEATH   3

Player or monster dead.


Definition at line 25 of file events.h.

◆ EVENT_DESTROY

#define EVENT_DESTROY   13

Object destroyed (includes map reset/swapout)

Definition at line 26 of file events.h.

◆ EVENT_DROP

#define EVENT_DROP   4

Object dropped on the floor.


Definition at line 27 of file events.h.

◆ EVENT_GBOUGHT

#define EVENT_GBOUGHT   36

Player bought object in shop, but global.


Definition at line 57 of file events.h.

◆ EVENT_GKILL

#define EVENT_GKILL   18

Triggered when anything got killed by anyone.


Definition at line 42 of file events.h.

◆ EVENT_GSOLD

#define EVENT_GSOLD   37

Player sold object in shop, but global.


Definition at line 58 of file events.h.

◆ EVENT_KICK

#define EVENT_KICK   28

A player was Kicked by a DM

Definition at line 43 of file events.h.

◆ EVENT_LOGIN

#define EVENT_LOGIN   19

Player login.


Definition at line 44 of file events.h.

◆ EVENT_LOGOUT

#define EVENT_LOGOUT   20

Player logout.


Definition at line 45 of file events.h.

◆ EVENT_MAPENTER

#define EVENT_MAPENTER   21

A player entered a map.


Definition at line 46 of file events.h.

◆ EVENT_MAPLEAVE

#define EVENT_MAPLEAVE   22

A player left a map.


Definition at line 47 of file events.h.

◆ EVENT_MAPLOAD

#define EVENT_MAPLOAD   30

A map is loaded (pristine state)

Definition at line 48 of file events.h.

◆ EVENT_MAPREADY

#define EVENT_MAPREADY   35

A map is ready, either first load or after reload.

Definition at line 49 of file events.h.

◆ EVENT_MAPRESET

#define EVENT_MAPRESET   23

A map is resetting.


Definition at line 50 of file events.h.

◆ EVENT_MAPUNLOAD

#define EVENT_MAPUNLOAD   29

A map is freed (includes swapping out)

Definition at line 51 of file events.h.

◆ EVENT_MUZZLE

#define EVENT_MUZZLE   27

A player was Muzzled (no_shout set).


Definition at line 52 of file events.h.

◆ EVENT_NONE

#define EVENT_NONE   0

No event.

This exists only to reserve the "0".

Definition at line 19 of file events.h.

◆ EVENT_PICKUP

#define EVENT_PICKUP   5

Object picked up.


Definition at line 28 of file events.h.

◆ EVENT_PLAYER_DEATH

#define EVENT_PLAYER_DEATH   17

Global Death event

Definition at line 53 of file events.h.

◆ EVENT_REMOVE

#define EVENT_REMOVE   24

A Player character has been removed.


Definition at line 54 of file events.h.

◆ EVENT_SAY

#define EVENT_SAY   6

Someone speaks.


Definition at line 29 of file events.h.

◆ EVENT_SELLING

#define EVENT_SELLING   32

Object is being sold by another one.


Definition at line 30 of file events.h.

◆ EVENT_SHOUT

#define EVENT_SHOUT   25

A player 'shout' something.


Definition at line 55 of file events.h.

◆ EVENT_STOP

#define EVENT_STOP   7

Thrown object stopped.


Definition at line 31 of file events.h.

◆ EVENT_TELL

#define EVENT_TELL   26

A player 'tell' something.


Definition at line 56 of file events.h.

◆ EVENT_THROW

#define EVENT_THROW   9

Object is thrown.


Definition at line 33 of file events.h.

◆ EVENT_TIME

#define EVENT_TIME   8

Triggered each time the object can react/move.

Definition at line 32 of file events.h.

◆ EVENT_TIMER

#define EVENT_TIMER   12

Timer connected triggered it.


Definition at line 35 of file events.h.

◆ EVENT_TRIGGER

#define EVENT_TRIGGER   10

Button pushed, lever pulled, etc.


Definition at line 34 of file events.h.

◆ EVENT_USER

#define EVENT_USER   31

User-defined event.


Definition at line 36 of file events.h.

◆ NR_EVENTS

#define NR_EVENTS   38

Number of events, maximum code + 1.

Definition at line 61 of file events.h.

Typedef Documentation

◆ event_registration

typedef unsigned long event_registration

Registration identifier type.

Definition at line 71 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 69 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 308 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 312 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 316 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 298 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 303 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: