Debian Codegraph @

doc/Developers/plugins

raw
1 An enhanced version of this documentation is in the plugins.ps file (PostScript format).
2
3 The latest version can be found at http://wiki.metalforge.net/doku.php/server_plugin
4
5
6 Plugin support
7 ==============
8
9 Crossfire can be extended through plugins. It's basically a library file, that gets loaded
10 at server initialization.
11 A plugin can be hooked to different events, either related to an object or global ones.
12 (see list later on).
13
14 You should always include two header files in your plugin projects:
15
16 - plugin.h, which contains the declaration of most plugin-related constants and
17 the required Crossfire includes;
18 - plugin_common.h (from the plugins/plugin_common directory), which includes the
19 necessary support for Crossfire function wrappers.
20
21 All your projects should also include plugin_common.c in their build processes;
22 that source file contains a lot of Crossfire function wrappers you can call.
23 Do *not* call the callbacks sent by the Crossfire server directly - use what's
24 provided by plugin_common.c.
25
26 Important: a plugin should *never* directly call malloc, free, or any function
27 manipulating memory if the memory needs to be given to server. This breaks Windows
28 compatibility. Hooks are provided in case of need.
29
30
31 The technical documentation is in Developers/plugins.ps, and Developers/cfpython.ps
32 for Python plugin.
33
34 List of supported events.
35 =========================
36
37 Local events
38 ------------
39 Those can be attached to a specific object in the game.
40
41 APPLY
42 Tag: event_apply
43 This event is generated whenever the object is applied or unapplied.
44
45 ATTACK
46 Tag: event_attack
47 This event is used in two cases:
48 - bound to a weapon, it is triggered each time the weapon is used to slay
49 something; this can typically be used to generate special effects when
50 you hit a monster;
51 - bound to a monster, it is triggered when the monster is attacked.
52
53 CLOSE
54 Tag: event_close
55 Generated when a container is closed.
56
57 DEATH
58 Tag: event_death
59 Generated when the object dies.
60
61 DROP
62 Tag: event_drop
63 Generated when the object is dropped, either on the floor or in a container.
64
65 PICKUP
66 Tag: event_pickup
67 Generated when the object is picked up.
68
69 SAY
70 Tag: event_say
71 Generated when someone says something around the object.
72
73 STOP
74 Tag: event_stop
75 Generated for a thrown object, when the object is stopped for some reason.
76
77 TIME
78 Tag: event_time
79 Generated each time the object gets an opportunity to move.
80
81 THROW
82 Tag: event_throw
83 Generated when the object is thrown.
84
85 TRIGGER
86 Tag: event_trigger
87 Used for various objects, like traps, teleporters or triggers. Generated when
88 those objects are used (for example, when a player passes through a teleporter).
89
90 TIMER
91 Tag: event_timer
92 Generated when the timer connected triggered.
93
94 Global events
95 -------------
96 Those concern the game as a whole or can't be bound to a specific object.
97 Those events may be "registered" by a plugin (it means that the plugin requests
98 to get a message each time one of those events happens).
99
100 BORN
101 Generated when a new character is created.
102
103 CLOCK
104 Generated at each game loop.
105 Warning: When no player is logged, the loop "stops", meaning that clock events
106 are not generated anymore!
107
108 CRASH
109 Generated when a server crash does occur. It is not a recursive event, so if a
110 crash occur from *inside* the crash event handling, it is not called a second
111 time, preventing infinite loops to occur.
112 Note: This event is not implemented for now.
113
114 GDEATH
115 Generated whenever someone dies.
116
117 GKILL
118 Generated whenever something/someone is killed.
119
120 LOGIN
121 Generated whenever a player logs into the game.
122
123 LOGOUT
124 Generated whenever a player logs out the game.
125
126 MAPENTER
127 Generated whenever someone enters a map.
128
129 MAPLEAVE
130 Generated whenever someone leaves a map.
131
132 MAPRESET
133 Generated each time a map is reset.
134
135 REMOVE
136 Generated when a player character is removed from the game ("quit" command).
137
138 SHOUT
139 Generated whenever someone shouts something.
140
141 TELL
142 Generated whenever someone tells something.
143
144 MUZZLE
145 Generated when a player was muzzled by a DM.
146
147 KICK
148 Generated when a player was kicked by a DM.