ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/pod/events.pod
Revision: 1.12
Committed: Mon Dec 25 11:25:49 2006 UTC (17 years, 5 months ago) by root
Branch: MAIN
Changes since 1.11: +32 -46 lines
Log Message:
- small, but subtle, rewrite of object management
- perl will now keep attachable objects alive
- objects are now refcounted
- refcouts need to be tested explicitly (refcnt_chk)
- explicit destroy is required current
- explicit destroy asks "nicely" for the object to self destruct, if possible
- refcounts will be used during mortal killing
- minor bugfixes, optimisations etc.
- some former hacks removed.

File Contents

# User Rev Content
1 elmex 1.2 =head1 CROSSFIRE+ PLUG-IN EVENTS
2 pippijn 1.1
3     This document briefly describes each plug-in event. It is also used to
4     generate the event-list itself, so is always complete. Be careful wehn
5     changing it, though.
6    
7     =head2 NOTATION
8    
9     the event description below uses a variant of the forth stack notation -
10     an opening parenthesis followed by the type of each parameter, optionally
11     followed by two dashes and the returning parameters. If the latter is
12     missing, the event will be invoked but cannot change wether the event gets
13     processed.
14    
15     If it is specified (even if no return values are supported), a plug-in
16     can override (e.g. using C<cf::override> in Perl) event processing,
17     basically short-circuiting it. For example, if you override from within a
18     player BIRTH event, nothing much will happen with respect to the built-in
19     processing, but if you override from within a player TELL event, the tell
20     will be ignored (presumably your plug-in took care of it).
21    
22    
23 root 1.12 =head2 ATTACHABLE EVENTS
24 pippijn 1.1
25 root 1.12 No time to document this, screw me.
26 pippijn 1.1
27     =head3 instantiate (object init-args...)
28    
29 root 1.12 An object was instantiated.
30    
31     For objects, this event occurs when a map is loaded for the first time
32     when it was instantiated from an archetype, or when the object was created
33 pippijn 1.1 dynamically. The arguments are as specified in the C<attach> attribute of
34     the object or archetype.
35    
36     This is useful to initialise any per-object state you might need.
37    
38     =head3 reattach (object)
39    
40     Invoked whenever attachments/plug-ins need to get reattached to the
41     object. This usually happens when it was loaded from disk, or when the
42     server was reloaded. This event will only be generated if the object has
43     attachments.
44    
45     =head3 clone (object destination)
46    
47 root 1.12 An object with _attached plugin_ is cloned, that is, a copy was made. The
48     copy automatically has all attachments the original object had. The perl
49     variables get copied in a shallow way (references are shared between
50     instances). If this is not the behaviour you need, you have to adjust the
51     B<destination> object as you see fit.
52    
53     =head3 destroy (object -- )
54    
55     Invoked when the crossfire object gets destroyed, and only when the object
56     has a handler for this event. This event can occur many times, as its
57     called when the in-memory object is destroyed, not when the object itself
58     dies.
59    
60    
61     =head2 OBJECT EVENTS
62    
63     Object events always relate to a specific object, which is always the
64     first argument. Not all events get generated for every object, some are
65     specific to an object type.
66 pippijn 1.1
67 root 1.6 =head3 add_bonus (item creator difficulty max_magic flags)
68    
69     A basic item has been created (e.g. for shops, monsters drops etc.)
70     that needs bonus values applied. The B<creator> object is a template
71     object that can be used to inherit stuff (and can be NULL). Flags is a
72     combination of GT_ENVIRONMENT (???) or GT_STARTEQUIP (set FLAG_STARTEQUIP
73     on item or set its value to 0) or GT_MINIMAL (???)
74    
75     When overriden, built-in bonus generation is skipped, otherwise
76     treasure generation continues as it would without this hook.
77    
78     In general, if flags != 0 or creator != 0 you should just return and leave
79     item generation to the standard code.
80    
81 root 1.12 =head3 remove (object -- )
82    
83     Invoked before the object is removed from its environment.
84    
85     =head3 insert (object -- )
86 pippijn 1.1
87 root 1.12 Called after the object was inserted into a container or map.
88 pippijn 1.1
89 root 1.12 =head3 tick (object -- )
90 pippijn 1.1
91     Invoked whenever the object "ticks", i.e. has positive B<speed_left>. Only
92     during ticks should an objetc process any movement or other events.
93    
94     =head3 kill (object hitter -- )
95    
96     Invoked whenever an object is dead and about to get removed. Overriding
97     processing will skip removal, but to do this successfully you have to
98     objetc from dieing, otherwise the event gets invoked again and again.
99    
100     =head3 apply (object who -- applytype)
101    
102     Invoked whenever the object is being applied in some way. The applytype is one of:
103    
104     =over 4
105    
106     =item B<0> player or monster can't apply objects of that type
107    
108     =item B<1> has been applied, or there was an error applying the object
109    
110     =item B<2> objects of that type can't be applied if not in inventory
111    
112     =back
113    
114     =head3 throw (object thrower)
115    
116     Invoked when an B<object> is thrown by B<thrower>.
117    
118     =head3 stop (object -- )
119    
120     Invoked when a thrown B<object> (arrow, other stuff) hits something and is
121     thus being "stopped".
122    
123     =head3 can_apply (who object -- reason)
124    
125     =head3 can_be_applied (object who -- reason)
126    
127     Check wether the B<object> can be applied/readied/etc. by the
128     object B<who> and return reason otherwise. Reason is a bitset composed of
129     C<CAN_APPLY_*>-flags.
130    
131     =head3 be_ready (object who -- success)
132    
133     =head3 ready (who object -- success)
134    
135     Invoked whenever an B<object> is being applied by object B<who>. See
136     I<can_apply> for an alternative if you just want to check wether something
137     can apply an object.
138    
139     =head3 be_unready (object who -- deleted)
140    
141     =head3 unready (who object -- deleted)
142    
143     Unwield/unapply/unready the given spell/weapon/skill/etc. B<object>,
144     currently applied by B<who>. If your override, make sure you give 'who'
145     (if it is a player) an indication of whats wrong. Must return true if the
146     object was freed.
147    
148     =head3 use_skill (skill who part direction strignarg -- )
149    
150     Invoked whenever a skill is used by somebody or something.
151    
152     =head3 cast_spell (spell casting_object owner direction stringarg -- )
153    
154     Invoked whenever a given spell is cast by B<casting_object> (used by
155     B<owner>).
156    
157     =head3 drop (object who -- )
158    
159     Invoked whenever an item gets dropped by somebody, e.g. as a result of a
160     drop command.
161    
162     =head3 drop_on (floor object who -- )
163    
164     Invoked whenever some B<object> is being dropped on the B<floor> object.
165    
166     =head3 say (object player message)
167    
168     Invoked whenever the I<object> can hear a B<message> being said by
169     B<player> in its vicinity.
170    
171     =head3 monster_move (monster enemy -- )
172    
173     Invoked whenever the B<monster> tries to move, just after B<enemy> and
174     other parameters have been determined, but before movement is actually
175     executed.
176    
177     =head3 attack (object hitter -- damage)
178    
179     Object gets attacked by somebody - when overriden, should return the
180     damage that has been dealt.
181    
182     =head3 skill_attack (attacker victim message skill -- success)
183    
184     Invoked whenever an B<attacker> attacks B<victim> using a B<skill> (skill
185     cna be C<undef>). B<message> is the message that describes the attack when
186     damage is done.
187    
188     =head3 weapon_attack (weapon hitter victim)
189    
190     Invoked whenever an object is used as a B<weapon> by B<hitter> to attack
191     B<victim>.
192    
193     =head3 inscribe_note (book pl message skill -- )
194    
195     Used whenever a book gets inscribed with a message.
196    
197     =head3 trigger (object who -- )
198    
199     Invoked whenever a lever-like B<object> has been activated/triggered in some
200     (manual) way.
201    
202     =head3 move_trigger (object victim originator -- )
203    
204     Invoked whenever a trap-like B<object> has been activated, usually by
205     moving onto it. This includes not just traps, but also buttons, holes,
206     signs and similar stuff.
207    
208     =head3 close (container who -- )
209    
210     Invoked whenever a container gets closed (this event is not yet reliable!).
211    
212    
213     =head2 GLOBAL EVENTS
214    
215     Global events have no relation to specific objects.
216    
217 root 1.3 =head3 cleanup ()
218    
219     Called when the server is cleaning up, just before it calls exit.
220    
221 pippijn 1.1 =head3 clock ( )
222    
223     Is invoked on every server tick, usually every 0.12 seconds.
224    
225 root 1.3
226 pippijn 1.1 =head2 PLAYER EVENTS
227    
228     Player events always have a player object as first argument.
229    
230     =head3 birth (player)
231    
232     Invoked as very first thing after creating a player.
233    
234     =head3 quit (player)
235    
236     Invoked wheneever a player quits, before actually removing him/her.
237    
238     =head3 kick (player params -- )
239    
240     Invoked when the given plaer is being kicked, before the kick is executed.
241    
242     =head3 load (player)
243    
244     Invoked whenever a player has been loaded from disk, but before
245     actual login.
246    
247     =head3 save (player)
248    
249     Invoked just before a player gets saved.
250    
251     =head3 login (player)
252    
253     Invoked whenever a player logs in.
254    
255     =head3 logout (player)
256    
257     Invoked whenever a player logs out, gets disconnected etc.
258    
259     =head3 death (player)
260    
261     Invoked whenever a player dies, before the death actually gets processed.
262    
263 root 1.4 =head3 map_change (player newmap x y -- )
264 pippijn 1.1
265 root 1.4 Invoked before a player moves from one map to another, can override the movement.
266 pippijn 1.1
267 root 1.7 =head3 command (player command args -- time)
268    
269     Execute a user command send by the client. Programmable plug-ins usually
270     handle this event internally.
271    
272 pippijn 1.1 =head3 extcmd (player string)
273    
274 root 1.7 Invoked whenever a client issues the C<extcmd> protocol command.
275     Programmable plug-ins usually handle this event internally.
276 pippijn 1.1
277     =head3 move (player direction -- )
278    
279     =head3 pray_altar (player altar skill -- )
280    
281     Invoked whenever the B<player> prays over an B<altar>, using the given B<skill>.
282    
283     =head3 tell (player name message -- )
284    
285     Invoked whenever the player uses the B<tell> or B<reply> command, before
286     it gets processed.
287    
288     =head3 say (player message --)
289    
290     =head3 chat (player message --)
291    
292     =head3 shout (player message --)
293    
294     Invoked whenever the player uses the B<say>, B<chat> or B<shout> command,
295     before it gets processed.
296    
297    
298     =head2 MAP EVENTS
299    
300     These events are generally dependent on a map and thus all have a map
301     as first argument.
302    
303     =head3 instantiate (map)
304    
305     Original B<map> has been loaded (e.g. on first use, or after a map
306     reset).
307    
308     =head3 swapin (map)
309    
310     Invoked when a previously swapped-out temporary B<map> has been loaded again.
311    
312     =head3 swapout (map)
313    
314     Invoked after a B<map> has been swapped out to disk.
315    
316     =head3 reset (map)
317    
318     Invoked when a B<map> gets reset.
319    
320     =head3 clean (map)
321    
322     Invoked when a temporary B<map> gets deleted on-disk.
323    
324 root 1.4 =head3 enter (map player x y -- )
325 pippijn 1.1
326 root 1.4 Invoked whenever a player tries to enter the B<map>, while he/she is still
327 root 1.5 on the old map. Overriding means the player won't be able to enter, and,
328     if newmap/x/y are given, will be redirected to that map instead.
329 pippijn 1.1
330 root 1.4 =head3 leave (map player -- )
331 pippijn 1.1
332 root 1.4 Invoked whenever a player tries to leave the B<map>. Overriding means the
333     player won't be able to leave.
334 pippijn 1.1
335 root 1.9 =head3 trigger (map connection state -- )
336 pippijn 1.1
337     Invoked whenever something activates a B<connection> on the B<map>. If B<state>
338     is true the connection was 'state' and if false it is 'released'.
339 root 1.5
340 root 1.8
341     =head2 CLIENT EVENTS
342    
343     These events are very similar to player events, but they are might be
344     handled asynchronously as soon as the command reaches the server, even when
345     the player hasn't logged in yet (meaning there is no player yet).
346    
347 root 1.9 =head3 connect (client -- )
348    
349     Called as soon as a new connection to the server is established. Should
350     not be overriden.
351    
352     =head3 addme (client -- )
353    
354     The client sent an addme, thus ending the initial handshaking. If overriden, the server
355     will not send any response.
356    
357 root 1.10 =head3 reply (client replystring -- )
358    
359     Called when the client submits a reply in the ST_CUSTOM state. Usually
360     handled internally by language plugins.
361    
362 root 1.9 =head3 exticmd (client string -- )
363 root 1.8
364     Like C<extcmd>, but can be called before a player has logged in.
365    
366     Programmable plug-ins usually handle this event internally.
367