]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/mutators/events.qh
2d32dc966a32f375c726888f7f4bcda3d0c69228
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / mutators / events.qh
1 #pragma once
2
3 #include <common/mutators/base.qh>
4
5 // register all possible hooks here
6
7 /** called when a player becomes observer, after shared setup */
8 #define EV_MakePlayerObserver(i, o) \
9     /** player */ i(entity, MUTATOR_ARGV_0_entity) \
10     /**/
11 MUTATOR_HOOKABLE(MakePlayerObserver, EV_MakePlayerObserver)
12
13 /** */
14 #define EV_PutClientInServer(i, o) \
15         /** client wanting to spawn */ i(entity, MUTATOR_ARGV_0_entity) \
16     /**/
17 MUTATOR_HOOKABLE(PutClientInServer, EV_PutClientInServer);
18
19 /**
20  * return true to prevent a spectator/observer to spawn as player
21  */
22  #define EV_ForbidSpawn(i, o) \
23     /** player */ i(entity, MUTATOR_ARGV_0_entity) \
24     /**/
25 MUTATOR_HOOKABLE(ForbidSpawn, EV_ForbidSpawn);
26
27 /** called when a player spawns as player, after shared setup, before his weapon is chosen (so items may be changed in here) */
28 #define EV_PlayerSpawn(i, o) \
29         /** player spawning */ i(entity, MUTATOR_ARGV_0_entity) \
30     /** spot that was used, or NULL */ i(entity, MUTATOR_ARGV_1_entity) \
31     /**/
32 MUTATOR_HOOKABLE(PlayerSpawn, EV_PlayerSpawn);
33
34 /** called after a player's weapon is chosen so it can be overriden here */
35 #define EV_PlayerWeaponSelect(i, o) \
36         /** player spawning */ i(entity, MUTATOR_ARGV_0_entity) \
37     /**/
38 MUTATOR_HOOKABLE(PlayerWeaponSelect, EV_PlayerWeaponSelect);
39
40 /** called in reset_map */
41 #define EV_reset_map_global(i, o) \
42     /**/
43 MUTATOR_HOOKABLE(reset_map_global, EV_reset_map_global);
44
45 /** called in reset_map */
46 #define EV_reset_map_players(i, o) \
47     /**/
48 MUTATOR_HOOKABLE(reset_map_players, EV_reset_map_players);
49
50 /** returns 1 if clearing player score shall not be allowed */
51 #define EV_ForbidPlayerScore_Clear(i, o) \
52     /**/
53 MUTATOR_HOOKABLE(ForbidPlayerScore_Clear, EV_ForbidPlayerScore_Clear);
54
55 /** called when a player disconnects */
56 #define EV_ClientDisconnect(i, o) \
57     /** player */ i(entity, MUTATOR_ARGV_0_entity) \
58     /**/
59 MUTATOR_HOOKABLE(ClientDisconnect, EV_ClientDisconnect);
60
61 /** called when a player dies to e.g. remove stuff he was carrying. */
62 #define EV_PlayerDies(i, o) \
63         /** inflictor           */ i(entity, MUTATOR_ARGV_0_entity) \
64     /** attacker        */ i(entity, MUTATOR_ARGV_1_entity) \
65     /** target                  */ i(entity, MUTATOR_ARGV_2_entity) \
66     /** deathtype       */ i(float,  MUTATOR_ARGV_3_float) \
67     /** damage          */ i(float,  MUTATOR_ARGV_4_float) \
68     /** damage                  */ o(float,  MUTATOR_ARGV_4_float) \
69     /**/
70 MUTATOR_HOOKABLE(PlayerDies, EV_PlayerDies);
71
72 /** allows overriding the frag centerprint messages */
73 #define EV_FragCenterMessage(i, o) \
74     /** attacker       */ i(entity, MUTATOR_ARGV_0_entity) \
75     /** target         */ i(entity, MUTATOR_ARGV_1_entity) \
76     /** deathtype      */ i(float, MUTATOR_ARGV_2_float) \
77     /** attacker kcount*/ i(int,  MUTATOR_ARGV_3_int) \
78     /** targ killcount */ i(int,  MUTATOR_ARGV_4_int) \
79     /**/
80 MUTATOR_HOOKABLE(FragCenterMessage, EV_FragCenterMessage);
81
82 /** called when a player dies to e.g. remove stuff he was carrying */
83 #define EV_PlayHitsound(i, o) \
84     /** victim */ i(entity, MUTATOR_ARGV_0_entity) \
85     /** attacker */ i(entity, MUTATOR_ARGV_1_entity) \
86     /**/
87 MUTATOR_HOOKABLE(PlayHitsound, EV_PlayHitsound);
88
89 /** called when a weapon sound is about to be played, allows custom paths etc. */
90 #define EV_WeaponSound(i, o) \
91     /** sound       */ i(string, MUTATOR_ARGV_0_string) \
92     /** output      */ i(string, MUTATOR_ARGV_1_string) \
93     /**/               o(string, MUTATOR_ARGV_1_string) \
94     /**/
95 MUTATOR_HOOKABLE(WeaponSound, EV_WeaponSound);
96
97 /** called when an item model is about to be set, allows custom paths etc. */
98 #define EV_ItemModel(i, o) \
99     /** model       */ i(string, MUTATOR_ARGV_0_string) \
100     /** output      */ i(string, MUTATOR_ARGV_1_string) \
101     /**/               o(string, MUTATOR_ARGV_1_string) \
102     /**/
103 MUTATOR_HOOKABLE(ItemModel, EV_ItemModel);
104
105 /** called when an item sound is about to be played, allows custom paths etc. */
106 #define EV_ItemSound(i, o) \
107     /** sound       */ i(string, MUTATOR_ARGV_0_string) \
108     /** output      */ i(string, MUTATOR_ARGV_1_string) \
109     /**/               o(string, MUTATOR_ARGV_1_string) \
110     /**/
111 MUTATOR_HOOKABLE(ItemSound, EV_ItemSound);
112
113 /** called when someone was fragged by "self", and is expected to change frag_score to adjust scoring for the kill */
114 #define EV_GiveFragsForKill(i, o) \
115     /** attacker   */ i(entity, MUTATOR_ARGV_0_entity) \
116     /** target     */ i(entity, MUTATOR_ARGV_1_entity) \
117     /** frag score */ i(float, MUTATOR_ARGV_2_float) \
118     /**            */ o(float, MUTATOR_ARGV_2_float) \
119     /**/
120 MUTATOR_HOOKABLE(GiveFragsForKill, EV_GiveFragsForKill);
121
122 /** called when the match ends */
123 MUTATOR_HOOKABLE(MatchEnd, EV_NO_ARGS);
124
125 /** allows adjusting allowed teams */
126 #define EV_CheckAllowedTeams(i, o) \
127     /** mask of teams      */ i(float, MUTATOR_ARGV_0_float) \
128     /**/                      o(float, MUTATOR_ARGV_0_float) \
129     /** team entity name   */ i(string, MUTATOR_ARGV_1_string) \
130     /**/                      o(string, MUTATOR_ARGV_1_string) \
131     /**/
132 MUTATOR_HOOKABLE(CheckAllowedTeams, EV_CheckAllowedTeams);
133
134 /** copies variables for spectating "spectatee" to "this" */
135 #define EV_SpectateCopy(i, o) \
136     /** spectatee   */ i(entity, MUTATOR_ARGV_0_entity) \
137     /** client      */ i(entity, MUTATOR_ARGV_1_entity) \
138     /**/
139 MUTATOR_HOOKABLE(SpectateCopy, EV_SpectateCopy);
140
141 /** called when formatting a chat message to replace fancy functions */
142 #define EV_FormatMessage(i, o) \
143     /** player        */ i(entity, MUTATOR_ARGV_0_entity) \
144     /** escape        */ i(string, MUTATOR_ARGV_1_string) \
145     /** replacement   */ i(string, MUTATOR_ARGV_2_string) \
146     /**/                 o(string, MUTATOR_ARGV_2_string) \
147     /** message       */ i(string, MUTATOR_ARGV_3_string) \
148     /**/
149 MUTATOR_HOOKABLE(FormatMessage, EV_FormatMessage);
150
151 /** called before any formatting is applied, handy for tweaking the message before scripts get ahold of it */
152 #define EV_PreFormatMessage(i, o) \
153     /** player        */ i(entity, MUTATOR_ARGV_0_entity) \
154     /** message       */ i(string, MUTATOR_ARGV_1_string) \
155     /**/                 o(string, MUTATOR_ARGV_1_string) \
156     /**/
157 MUTATOR_HOOKABLE(PreFormatMessage, EV_PreFormatMessage);
158
159 /** returns true if throwing the current weapon shall not be allowed */
160 #define EV_ForbidThrowCurrentWeapon(i, o) \
161     /** player        */ i(entity, MUTATOR_ARGV_0_entity) \
162     /** weapon entity */ i(entity, MUTATOR_ARGV_1_entity) \
163     /**/
164 MUTATOR_HOOKABLE(ForbidThrowCurrentWeapon, EV_ForbidThrowCurrentWeapon);
165
166 /** returns true if dropping the current weapon shall not be allowed at any time including death */
167 #define EV_ForbidDropCurrentWeapon(i, o) \
168     /** player */        i(entity, MUTATOR_ARGV_0_entity) \
169     /** weapon id */     i(int, MUTATOR_ARGV_1_int) \
170     /**/
171 MUTATOR_HOOKABLE(ForbidDropCurrentWeapon, EV_ForbidDropCurrentWeapon);
172
173 /**  */
174 MUTATOR_HOOKABLE(SetDefaultAlpha, EV_NO_ARGS);
175
176 /** allows changing attack rate */
177 #define EV_WeaponRateFactor(i, o) \
178     /** weapon rate */  i(float, MUTATOR_ARGV_0_float) \
179     /**/                o(float, MUTATOR_ARGV_0_float) \
180     /** player */       i(entity, MUTATOR_ARGV_1_entity) \
181     /**/
182 MUTATOR_HOOKABLE(WeaponRateFactor, EV_WeaponRateFactor);
183
184 /** allows changing weapon speed (projectiles mostly) */
185 #define EV_WeaponSpeedFactor(i, o) \
186     /** weapon speed */ i(float, MUTATOR_ARGV_0_float) \
187     /**/                o(float, MUTATOR_ARGV_0_float) \
188     /** player */       i(entity, MUTATOR_ARGV_1_entity) \
189     /**/
190 MUTATOR_HOOKABLE(WeaponSpeedFactor, EV_WeaponSpeedFactor);
191
192 /** adjusts {warmup_}start_{items,weapons,ammo_{cells,plasma,rockets,nails,shells,fuel}} */
193 MUTATOR_HOOKABLE(SetStartItems, EV_NO_ARGS);
194
195 /** called every frame. customizes the waypoint for spectators */
196 #define EV_CustomizeWaypoint(i, o) \
197     /** waypoint                        */ i(entity, MUTATOR_ARGV_0_entity) \
198     /** player; other.enemy = spectator */ i(entity, MUTATOR_ARGV_1_entity) \
199     /**/
200 MUTATOR_HOOKABLE(CustomizeWaypoint, EV_CustomizeWaypoint);
201
202 /**
203  * checks if the current item may be spawned (.items and .weapons may be read and written to, as well as the ammo_ fields)
204  * return error to request removal
205  */
206 #define EV_FilterItem(i, o) \
207     /** item        */ i(entity, MUTATOR_ARGV_0_entity) \
208     /**/
209 MUTATOR_HOOKABLE(FilterItem, EV_FilterItem);
210
211 /** return error to request removal */
212 #define EV_TurretSpawn(i, o) \
213     /** turret        */ i(entity, MUTATOR_ARGV_0_entity) \
214     /**/
215 MUTATOR_HOOKABLE(TurretSpawn, EV_TurretSpawn);
216
217 /** return error to not attack */
218 #define EV_TurretFire(i, o) \
219     /** turret        */ i(entity, MUTATOR_ARGV_0_entity) \
220     /**/
221 MUTATOR_HOOKABLE(TurretFire, EV_TurretFire);
222
223 /** return error to not attack */
224 #define EV_Turret_CheckFire(i, o) \
225     /** turret                      */ i(entity, MUTATOR_ARGV_0_entity) \
226     /** to fire or not to fire      */ o(bool, MUTATOR_ARGV_1_bool) \
227     /**/
228 MUTATOR_HOOKABLE(Turret_CheckFire, EV_Turret_CheckFire);
229
230 /** return error to prevent entity spawn, or modify the entity */
231 #define EV_OnEntityPreSpawn(i, o) \
232    /** entity  */ i(entity, MUTATOR_ARGV_0_entity) \
233     /**/
234 MUTATOR_HOOKABLE(OnEntityPreSpawn, EV_OnEntityPreSpawn);
235
236 /** runs in the event loop for players; is called for ALL player entities, also bots, also the dead, or spectators */
237 #define EV_PlayerPreThink(i, o) \
238     /** player */ i(entity, MUTATOR_ARGV_0_entity) \
239     /**/
240 MUTATOR_HOOKABLE(PlayerPreThink, EV_PlayerPreThink);
241
242 /** TODO change this into a general PlayerPostThink hook? */
243 #define EV_GetPressedKeys(i, o) \
244     /** player */ i(entity, MUTATOR_ARGV_0_entity) \
245     /**/
246 MUTATOR_HOOKABLE(GetPressedKeys, EV_GetPressedKeys);
247
248 /** is meant to call GetCvars_handle*(get_cvars_s, get_cvars_f, cvarfield, "cvarname") for cvars this mutator needs from the client */
249 #define EV_GetCvars(i, o) \
250     /**/ i(float, get_cvars_f) \
251     /**/ i(string, get_cvars_s) \
252     /**/
253 float get_cvars_f;
254 string get_cvars_s;
255 MUTATOR_HOOKABLE(GetCvars, EV_NO_ARGS); // NOTE: Can't use EV_GetCvars because of `SZ_GetSpace: overflow`
256
257 /** can edit any "just fired" projectile */
258 #define EV_EditProjectile(i, o) \
259     /** projectile owner */ i(entity, MUTATOR_ARGV_0_entity) \
260     /** projectile */ i(entity, MUTATOR_ARGV_1_entity) \
261     /**/
262 MUTATOR_HOOKABLE(EditProjectile, EV_EditProjectile);
263
264 /** called when a monster spawns */
265 #define EV_MonsterSpawn(i, o) \
266     /** monster */ i(entity, MUTATOR_ARGV_0_entity) \
267     /**/
268 MUTATOR_HOOKABLE(MonsterSpawn, EV_MonsterSpawn);
269
270 /** called when a monster dies */
271 #define EV_MonsterDies(i, o) \
272     /** target       */ i(entity, MUTATOR_ARGV_0_entity) \
273     /** attacker     */ i(entity, MUTATOR_ARGV_1_entity) \
274     /** deathtype    */ i(float, MUTATOR_ARGV_2_float) \
275     /**/
276 MUTATOR_HOOKABLE(MonsterDies, EV_MonsterDies);
277
278 /** called when a monster dies */
279 #define EV_MonsterRemove(i, o) \
280     /** monster */ i(entity, MUTATOR_ARGV_0_entity) \
281     /**/
282 MUTATOR_HOOKABLE(MonsterRemove, EV_MonsterRemove);
283
284 /** called when a monster wants to respawn */
285 #define EV_MonsterRespawn(i, o) \
286     /** monster */ i(entity, MUTATOR_ARGV_0_entity) \
287     /**/
288 MUTATOR_HOOKABLE(MonsterRespawn, EV_MonsterRespawn);
289
290 /** called when a monster is dropping loot */
291 #define EV_MonsterDropItem(i, o) \
292     /* monster */                          i(entity, MUTATOR_ARGV_0_entity) \
293     /* item (can be removed or changed) */ i(entity, MUTATOR_ARGV_1_entity) \
294     /**/                                   o(entity, MUTATOR_ARGV_1_entity) \
295     /* attacker */                         i(entity, MUTATOR_ARGV_2_entity) \
296     /**/
297 .void(entity this) monster_loot;
298 MUTATOR_HOOKABLE(MonsterDropItem, EV_MonsterDropItem);
299
300 /**
301  * called when a monster moves
302  * returning true makes the monster stop
303  */
304 #define EV_MonsterMove(i, o) \
305     /** monster */       i(entity, MUTATOR_ARGV_0_entity) \
306     /** run speed */     i(float, MUTATOR_ARGV_1_float) \
307     /**/                 o(float, MUTATOR_ARGV_1_float) \
308     /** walk speed */    i(float, MUTATOR_ARGV_2_float) \
309     /**/                 o(float, MUTATOR_ARGV_2_float) \
310     /** move target */   i(entity, MUTATOR_ARGV_3_entity) \
311     /**/                 o(entity, MUTATOR_ARGV_3_entity) \
312     /**/
313 MUTATOR_HOOKABLE(MonsterMove, EV_MonsterMove);
314
315 /** called when a monster looks for another target */
316 MUTATOR_HOOKABLE(MonsterFindTarget, EV_NO_ARGS);
317
318 /**
319  * called when validating a monster's target
320  */
321 #define EV_MonsterValidTarget(i, o) \
322     /** monster */       i(entity, MUTATOR_ARGV_0_entity) \
323     /** target */        i(entity, MUTATOR_ARGV_1_entity) \
324     /**/
325 MUTATOR_HOOKABLE(MonsterValidTarget, EV_MonsterValidTarget);
326
327 /** called to change a random monster to a miniboss */
328 #define EV_MonsterCheckBossFlag(i, o) \
329     /** monster */ i(entity, MUTATOR_ARGV_0_entity) \
330     /**/
331 MUTATOR_HOOKABLE(MonsterCheckBossFlag, EV_MonsterCheckBossFlag);
332
333 /**
334  * called when a player tries to spawn a monster
335  * return 1 to prevent spawning
336  * NOTE: requires reason if disallowed
337  */
338  #define EV_AllowMobSpawning(i, o) \
339     /** caller */ i(entity, MUTATOR_ARGV_0_entity) \
340     /** reason */ o(string, MUTATOR_ARGV_1_string) \
341     /**/
342 MUTATOR_HOOKABLE(AllowMobSpawning, EV_AllowMobSpawning);
343
344 /** called when a player gets damaged to e.g. remove stuff he was carrying. */
345 #define EV_PlayerDamage_SplitHealthArmor(i, o) \
346         /** inflictor           */ i(entity, MUTATOR_ARGV_0_entity) \
347     /** attacker        */ i(entity, MUTATOR_ARGV_1_entity) \
348     /** target                  */ i(entity, MUTATOR_ARGV_2_entity) \
349     /** force (no out)  */ i(vector, MUTATOR_ARGV_3_vector) \
350     /** damage take     */ i(float,  MUTATOR_ARGV_4_float) \
351     /** damage take     */ o(float,  MUTATOR_ARGV_4_float) \
352     /** damage save     */ i(float,  MUTATOR_ARGV_5_float) \
353     /** damage save     */ o(float,  MUTATOR_ARGV_5_float) \
354     /** deathtype               */ i(float,  MUTATOR_ARGV_6_float) \
355     /** damage              */ i(float,  MUTATOR_ARGV_7_float) \
356     /**/
357 MUTATOR_HOOKABLE(PlayerDamage_SplitHealthArmor, EV_PlayerDamage_SplitHealthArmor);
358
359 /**
360  * called to adjust damage and force values which are applied to the player, used for e.g. strength damage/force multiplier
361  * i'm not sure if I should change this around slightly (Naming of the entities, and also how they're done in g_damage).
362  */
363 #define EV_Damage_Calculate(i, o) \
364     /** inflictor               */ i(entity, MUTATOR_ARGV_0_entity) \
365     /** attacker        */ i(entity, MUTATOR_ARGV_1_entity) \
366     /** target                  */ i(entity, MUTATOR_ARGV_2_entity) \
367     /** deathtype       */ i(float,  MUTATOR_ARGV_3_float) \
368     /** damage          */ i(float,  MUTATOR_ARGV_4_float) \
369     /** damage                  */ o(float,  MUTATOR_ARGV_4_float) \
370     /** mirrordamage    */ i(float,  MUTATOR_ARGV_5_float) \
371     /** mirrordamage    */ o(float,  MUTATOR_ARGV_5_float) \
372     /** force           */ i(vector, MUTATOR_ARGV_6_vector) \
373     /** force                   */ o(vector, MUTATOR_ARGV_6_vector) \
374     /**/
375 MUTATOR_HOOKABLE(Damage_Calculate, EV_Damage_Calculate);
376
377 /**
378  * Called when a player is damaged
379  */
380 #define EV_PlayerDamaged(i, o) \
381     /** attacker  */ i(entity, MUTATOR_ARGV_0_entity) \
382     /** target    */ i(entity, MUTATOR_ARGV_1_entity) \
383     /** health    */ i(float,    MUTATOR_ARGV_2_float) \
384     /** armor     */ i(float,    MUTATOR_ARGV_3_float) \
385     /** location  */ i(vector, MUTATOR_ARGV_4_vector) \
386     /** deathtype */ i(int,    MUTATOR_ARGV_5_int) \
387     /** potential_damage     */ i(float,    MUTATOR_ARGV_6_float) \
388     /**/
389 MUTATOR_HOOKABLE(PlayerDamaged, EV_PlayerDamaged);
390
391 /**
392  * Called by W_DecreaseAmmo
393  */
394 #define EV_W_DecreaseAmmo(i, o) \
395     /** actor */            i(entity, MUTATOR_ARGV_0_entity) \
396     /** weapon entity */    i(entity, MUTATOR_ARGV_1_entity) \
397     /**/
398 MUTATOR_HOOKABLE(W_DecreaseAmmo, EV_W_DecreaseAmmo);
399
400 /**
401  * Called by W_Reload
402  */
403 #define EV_W_Reload(i, o) \
404     /** actor */ i(entity, MUTATOR_ARGV_0_entity) \
405     /**/
406 MUTATOR_HOOKABLE(W_Reload, EV_W_Reload);
407
408 /** called at the end of player_powerups() in client.qc, used for manipulating the values which are set by powerup items. */
409 #define EV_PlayerPowerups(i, o) \
410     /** player */    i(entity, MUTATOR_ARGV_0_entity) \
411     /** old items */ i(int, MUTATOR_ARGV_1_int) \
412     /**/
413 MUTATOR_HOOKABLE(PlayerPowerups, EV_PlayerPowerups);
414
415 /**
416  * called every player think frame
417  * return 1 to disable regen
418  */
419  #define EV_PlayerRegen(i, o) \
420     /** player */               i(entity, MUTATOR_ARGV_0_entity) \
421     /** max_mod */              i(float, MUTATOR_ARGV_1_float) \
422     /**/                        o(float, MUTATOR_ARGV_1_float) \
423     /** regen_mod */            i(float, MUTATOR_ARGV_2_float) \
424     /**/                        o(float, MUTATOR_ARGV_2_float) \
425     /** rot_mod */              i(float, MUTATOR_ARGV_3_float) \
426     /**/                        o(float, MUTATOR_ARGV_3_float) \
427     /** limit_mod */            i(float, MUTATOR_ARGV_4_float) \
428     /**/                        o(float, MUTATOR_ARGV_4_float) \
429     /** health_regen */         i(float, MUTATOR_ARGV_5_float) \
430     /**/                        o(float, MUTATOR_ARGV_5_float) \
431     /** health_regenlinear */   i(float, MUTATOR_ARGV_6_float) \
432     /**/                        o(float, MUTATOR_ARGV_6_float) \
433     /** health_rot */           i(float, MUTATOR_ARGV_7_float) \
434     /**/                        o(float, MUTATOR_ARGV_7_float) \
435     /** health_rotlinear */     i(float, MUTATOR_ARGV_8_float) \
436     /**/                        o(float, MUTATOR_ARGV_8_float) \
437     /** health_stable */        i(float, MUTATOR_ARGV_9_float) \
438     /**/                        o(float, MUTATOR_ARGV_9_float) \
439     /** health_rotstable */     i(float, MUTATOR_ARGV_10_float) \
440     /**/                        o(float, MUTATOR_ARGV_10_float) \
441     /**/
442 MUTATOR_HOOKABLE(PlayerRegen, EV_PlayerRegen);
443
444 /**
445  * called when the use key is pressed
446  * if MUTATOR_RETURNVALUE is 1, don't do anything
447  * return 1 if the use key actually did something
448  */
449  #define EV_PlayerUseKey(i, o) \
450     /** player */ i(entity, MUTATOR_ARGV_0_entity) \
451     /**/
452 MUTATOR_HOOKABLE(PlayerUseKey, EV_PlayerUseKey);
453
454 /**
455  * called when a client command is parsed
456  * NOTE: hooks MUST start with if (MUTATOR_RETURNVALUE) return false;
457  * NOTE: return true if you handled the command, return false to continue handling
458  * NOTE: THESE HOOKS MUST NEVER EVER CALL tokenize()
459  * // example:
460  * MUTATOR_HOOKFUNCTION(foo_SV_ParseClientCommand)
461  * {
462  *     if (MUTATOR_RETURNVALUE) // command was already handled?
463  *         return false;
464  *     if (cmd_name == "echocvar" && cmd_argc >= 2)
465  *     {
466  *         print(cvar_string(argv(1)), "\n");
467  *         return true;
468  *     }
469  *     if (cmd_name == "echostring" && cmd_argc >= 2)
470  *     {
471  *         print(substring(cmd_string, argv_start_index(1), argv_end_index(-1) - argv_start_index(1)), "\n");
472  *         return true;
473  *     }
474  *     return false;
475  * }
476  */
477 #define EV_SV_ParseClientCommand(i, o) \
478         /** client sending the command */       i(entity, MUTATOR_ARGV_0_entity) \
479     /** command name */                     i(string, MUTATOR_ARGV_1_string) \
480         /** argc (also, argv() can be used) */  i(int, MUTATOR_ARGV_2_int) \
481         /** whole command, use only if you really have to */ i(string, MUTATOR_ARGV_3_string) \
482     /**/
483 MUTATOR_HOOKABLE(SV_ParseClientCommand, EV_SV_ParseClientCommand);
484
485 /** please read EV_SV_ParseClientCommand description before using */
486 #define EV_SV_ParseServerCommand(i, o) \
487    /** command name */ i(string, MUTATOR_ARGV_0_string) \
488         /** argc (also, argv() can be used) */ i(int, MUTATOR_ARGV_1_int) \
489         /** whole command, use only if you really have to */ i(string, MUTATOR_ARGV_2_string) \
490     /**/
491 MUTATOR_HOOKABLE(SV_ParseServerCommand, EV_SV_ParseServerCommand);
492
493 /**
494  * called when a spawnpoint is being evaluated
495  * return 1 to make the spawnpoint unusable
496  */
497 #define EV_Spawn_Score(i, o) \
498     /** player wanting to spawn */ i(entity, MUTATOR_ARGV_0_entity) \
499     /** spot to be evaluated */ i(entity, MUTATOR_ARGV_1_entity) \
500     /** spot score, _x is priority, _y is "distance" */ i(vector, MUTATOR_ARGV_2_vector) \
501     /**/ o(vector, MUTATOR_ARGV_2_vector) \
502     /**/
503 MUTATOR_HOOKABLE(Spawn_Score, EV_Spawn_Score);
504
505 /** runs globally each server frame */
506 MUTATOR_HOOKABLE(SV_StartFrame, EV_NO_ARGS);
507
508 #define EV_SetModname(i, o) \
509     /** name of the mutator/mod if it warrants showing as such in the server browser */ \
510     /**/ i(string, MUTATOR_ARGV_0_string) \
511     /**/ o(string, MUTATOR_ARGV_0_string) \
512     /**/
513 MUTATOR_HOOKABLE(SetModname, EV_SetModname);
514
515 /**
516  * called for each item being spawned on a map, including dropped weapons
517  * return 1 to remove an item
518  */
519 #define EV_Item_Spawn(i, o) \
520     /** item */ i(entity, MUTATOR_ARGV_0_entity) \
521     /**/
522 MUTATOR_HOOKABLE(Item_Spawn, EV_Item_Spawn);
523
524 #define EV_SetWeaponreplace(i, o) \
525     /** map entity */  i(entity, MUTATOR_ARGV_0_entity) \
526     /** weapon info */ i(entity, MUTATOR_ARGV_1_entity) \
527     /** replacement */ i(string, MUTATOR_ARGV_2_string) \
528     /**/               o(string, MUTATOR_ARGV_2_string) \
529     /**/
530 MUTATOR_HOOKABLE(SetWeaponreplace, EV_SetWeaponreplace);
531
532 /** called when an item is about to respawn */
533 #define EV_Item_RespawnCountdown(i, o) \
534     /** item name */   i(string, MUTATOR_ARGV_0_string) \
535     /**/               o(string, MUTATOR_ARGV_0_string) \
536     /** item colour */ i(vector, MUTATOR_ARGV_1_vector) \
537     /**/               o(vector, MUTATOR_ARGV_1_vector) \
538     /**/
539 MUTATOR_HOOKABLE(Item_RespawnCountdown, EV_Item_RespawnCountdown);
540
541 /** called when a bot checks a target to attack */
542 #define EV_BotShouldAttack(i, o) \
543     /** bot */    i(entity, MUTATOR_ARGV_0_entity) \
544     /** target */ i(entity, MUTATOR_ARGV_1_entity) \
545     /**/
546 MUTATOR_HOOKABLE(BotShouldAttack, EV_BotShouldAttack);
547
548 /**
549  * called whenever a player goes through a portal gun teleport
550  * allows you to strip a player of an item if they go through the teleporter to help prevent cheating
551  */
552 #define EV_PortalTeleport(i, o) \
553     /** player */ i(entity, MUTATOR_ARGV_0_entity) \
554     /**/
555 MUTATOR_HOOKABLE(PortalTeleport, EV_PortalTeleport);
556
557 /**
558  * called whenever a player uses impulse 33 (help me) in impulse.qc
559  * normally help me ping uses .waypointsprite_attachedforcarrier,
560  * but if your mutator uses something different then you can handle it
561  * in a special manner using this hook
562  */
563 #define EV_HelpMePing(i, o) \
564     /** the player who pressed impulse 33 */ i(entity, MUTATOR_ARGV_0_entity) \
565     /**/
566 MUTATOR_HOOKABLE(HelpMePing, EV_HelpMePing);
567
568 /**
569  * called when a vehicle initializes
570  * return true to remove the vehicle
571  */
572 #define EV_VehicleInit(i, o) \
573     /** vehicle */ i(entity, MUTATOR_ARGV_0_entity) \
574     /**/
575 MUTATOR_HOOKABLE(VehicleInit, EV_VehicleInit);
576
577 /**
578  * called when a player enters a vehicle
579  * allows mutators to set special settings in this event
580  */
581 #define EV_VehicleEnter(i, o) \
582     /** player */ i(entity, MUTATOR_ARGV_0_entity) \
583     /** vehicle */ i(entity, MUTATOR_ARGV_1_entity) \
584     /**/
585 MUTATOR_HOOKABLE(VehicleEnter, EV_VehicleEnter);
586
587 /**
588  * called when a player touches a vehicle
589  * return true to stop player from entering the vehicle
590  */
591 #define EV_VehicleTouch(i, o) \
592     /** vehicle */ i(entity, MUTATOR_ARGV_0_entity) \
593     /** player */ i(entity, MUTATOR_ARGV_1_entity) \
594     /**/
595 MUTATOR_HOOKABLE(VehicleTouch, EV_VehicleTouch);
596
597 /**
598  * called when a player exits a vehicle
599  * allows mutators to set special settings in this event
600  */
601 #define EV_VehicleExit(i, o) \
602     /** player */ i(entity, MUTATOR_ARGV_0_entity) \
603     /** vehicle */ i(entity, MUTATOR_ARGV_1_entity) \
604     /**/
605 MUTATOR_HOOKABLE(VehicleExit, EV_VehicleExit);
606
607 /** called when a speedrun is aborted and the player is teleported back to start position */
608 #define EV_AbortSpeedrun(i, o) \
609     /** player */ i(entity, MUTATOR_ARGV_0_entity) \
610     /**/
611 MUTATOR_HOOKABLE(AbortSpeedrun, EV_AbortSpeedrun);
612
613 /** called at when a item is touched. Called early, can edit item properties. */
614 #define EV_ItemTouch(i, o) \
615     /** item */    i(entity, MUTATOR_ARGV_0_entity) \
616     /** toucher */ i(entity, MUTATOR_ARGV_1_entity) \
617     /**/           o(entity, MUTATOR_ARGV_1_entity) \
618     /**/
619 MUTATOR_HOOKABLE(ItemTouch, EV_ItemTouch);
620
621 enum {
622         MUT_ITEMTOUCH_CONTINUE, // return this flag to make the function continue as normal
623         MUT_ITEMTOUCH_RETURN, // return this flag to make the function return (handled entirely by mutator)
624         MUT_ITEMTOUCH_PICKUP // return this flag to have the item "picked up" and taken even after mutator handled it
625 };
626
627 /** called at when a player connect */
628 #define EV_ClientConnect(i, o) \
629     /** player */ i(entity, MUTATOR_ARGV_0_entity) \
630     /**/
631 MUTATOR_HOOKABLE(ClientConnect, EV_ClientConnect);
632
633 #define EV_HavocBot_ChooseRole(i, o) \
634     /** bot */ i(entity, MUTATOR_ARGV_0_entity) \
635     /**/
636 MUTATOR_HOOKABLE(HavocBot_ChooseRole, EV_HavocBot_ChooseRole);
637
638 /** called when a target is checked for accuracy */
639 #define EV_AccuracyTargetValid(i, o) \
640     /** attacker */ i(entity, MUTATOR_ARGV_0_entity) \
641     /** target */ i(entity, MUTATOR_ARGV_1_entity) \
642     /**/
643 MUTATOR_HOOKABLE(AccuracyTargetValid, EV_AccuracyTargetValid);
644 enum {
645         MUT_ACCADD_VALID, // return this flag to make the function continue if target is a client
646         MUT_ACCADD_INVALID, // return this flag to make the function always continue
647         MUT_ACCADD_INDIFFERENT // return this flag to make the function always return
648 };
649
650 /** Called when clearing the global parameters for a model */
651 MUTATOR_HOOKABLE(ClearModelParams, EV_NO_ARGS);
652
653 /** Called when getting the global parameters for a model */
654 #define EV_GetModelParams(i, o) \
655     /** input */   i(string, MUTATOR_ARGV_0_string) \
656     /** command */ i(string, MUTATOR_ARGV_1_string) \
657     /**/
658 MUTATOR_HOOKABLE(GetModelParams, EV_GetModelParams);
659
660 /** called when a bullet has hit a target */
661 #define EV_FireBullet_Hit(i, o) \
662     /** player */       i(entity, MUTATOR_ARGV_0_entity) \
663     /** targ */         i(entity, MUTATOR_ARGV_1_entity) \
664     /** start pos */    i(vector, MUTATOR_ARGV_2_vector) \
665     /** end pos */      i(vector, MUTATOR_ARGV_3_vector) \
666     /** damage */       i(float, MUTATOR_ARGV_4_float) \
667     /**/                o(float, MUTATOR_ARGV_4_float) \
668     /** wep entity */   i(entity, MUTATOR_ARGV_5_entity) \
669     /**/
670 MUTATOR_HOOKABLE(FireBullet_Hit, EV_FireBullet_Hit);
671
672 #define EV_FixPlayermodel(i, o) \
673     /** model */    i(string, MUTATOR_ARGV_0_string) \
674     /**/            o(string, MUTATOR_ARGV_0_string) \
675     /** skin */     i(int, MUTATOR_ARGV_1_int) \
676     /**/            o(int, MUTATOR_ARGV_1_int) \
677     /** player */   i(entity, MUTATOR_ARGV_2_entity) \
678     /**/
679 MUTATOR_HOOKABLE(FixPlayermodel, EV_FixPlayermodel);
680
681 /** Return error to play frag remaining announcements */
682 MUTATOR_HOOKABLE(Scores_CountFragsRemaining, EV_NO_ARGS);
683
684 #define EV_GrappleHookThink(i, o) \
685     /** hook */                i(entity, MUTATOR_ARGV_0_entity) \
686     /** tarzan */              i(int, MUTATOR_ARGV_1_int) \
687     /**/                       o(int, MUTATOR_ARGV_1_int) \
688     /** pulling entity */      i(entity, MUTATOR_ARGV_2_entity) \
689     /**/                       o(entity, MUTATOR_ARGV_2_entity) \
690     /** velocity multiplier */ i(float, MUTATOR_ARGV_3_float) \
691     /**/                       o(float, MUTATOR_ARGV_3_float) \
692     /**/
693 MUTATOR_HOOKABLE(GrappleHookThink, EV_GrappleHookThink);
694
695 #define EV_BuffModel_Customize(i, o) \
696     /** buff */    i(entity, MUTATOR_ARGV_0_entity) \
697     /** player */  i(entity, MUTATOR_ARGV_1_entity) \
698     /**/
699 MUTATOR_HOOKABLE(BuffModel_Customize, EV_BuffModel_Customize);
700
701 /** called at when a buff is touched. Called early, can edit buff properties. */
702 #define EV_BuffTouch(i, o) \
703     /** buff */    i(entity, MUTATOR_ARGV_0_entity) \
704     /** player */  i(entity, MUTATOR_ARGV_1_entity) \
705     /**/           o(entity, MUTATOR_ARGV_1_entity) \
706     /**/
707 MUTATOR_HOOKABLE(BuffTouch, EV_BuffTouch);
708
709 MUTATOR_HOOKABLE(SetNewParms, EV_NO_ARGS);
710
711 MUTATOR_HOOKABLE(SetChangeParms, EV_NO_ARGS);
712
713 MUTATOR_HOOKABLE(DecodeLevelParms, EV_NO_ARGS);
714
715 #define EV_GetRecords(i, o) \
716     /** page */           i(int, MUTATOR_ARGV_0_int) \
717     /** record list */    i(string, MUTATOR_ARGV_1_string) \
718     /**/                  o(string, MUTATOR_ARGV_1_string) \
719     /**/
720 MUTATOR_HOOKABLE(GetRecords, EV_GetRecords);
721
722 #define EV_Race_FinalCheckpoint(i, o) \
723     /** player */ i(entity, MUTATOR_ARGV_0_entity) \
724     /**/
725 MUTATOR_HOOKABLE(Race_FinalCheckpoint, EV_Race_FinalCheckpoint);
726
727 /** called when player triggered kill (or is changing teams), return error to not do anything */
728 #define EV_ClientKill(i, o) \
729     /** player */        i(entity, MUTATOR_ARGV_0_entity) \
730     /** kill delay */    i(float, MUTATOR_ARGV_1_float) \
731     /**/                 o(float, MUTATOR_ARGV_1_float) \
732     /**/
733 MUTATOR_HOOKABLE(ClientKill, EV_ClientKill);
734
735 #define EV_FixClientCvars(i, o) \
736     /** player */        i(entity, MUTATOR_ARGV_0_entity) \
737     /**/
738 MUTATOR_HOOKABLE(FixClientCvars, EV_FixClientCvars);
739
740 #define EV_SpectateSet(i, o) \
741     /** client */    i(entity, MUTATOR_ARGV_0_entity) \
742     /** target */    i(entity, MUTATOR_ARGV_1_entity) \
743     /**/             o(entity, MUTATOR_ARGV_1_entity) \
744     /**/
745 MUTATOR_HOOKABLE(SpectateSet, EV_SpectateSet);
746
747 #define EV_SpectateNext(i, o) \
748     /** client */    i(entity, MUTATOR_ARGV_0_entity) \
749     /** target */    i(entity, MUTATOR_ARGV_1_entity) \
750     /**/             o(entity, MUTATOR_ARGV_1_entity) \
751     /**/
752 MUTATOR_HOOKABLE(SpectateNext, EV_SpectateNext);
753
754 #define EV_SpectatePrev(i, o) \
755     /** client */    i(entity, MUTATOR_ARGV_0_entity) \
756     /** target */    i(entity, MUTATOR_ARGV_1_entity) \
757     /**/             o(entity, MUTATOR_ARGV_1_entity) \
758         /** first */     i(entity, MUTATOR_ARGV_2_entity) \
759     /**/
760 MUTATOR_HOOKABLE(SpectatePrev, EV_SpectatePrev);
761
762 enum {
763     MUT_SPECPREV_CONTINUE, // return this flag to make the function continue as normal
764     MUT_SPECPREV_RETURN, // return this flag to make the function return (handled entirely by mutator)
765     MUT_SPECPREV_FOUND // return this flag to make the function continue without default functions (handled mostly by mutator)
766 };
767
768 /** called when player triggered kill (or is changing teams), return error to not do anything */
769 #define EV_Bot_FixCount(i, o) \
770         /** active real players */  i(int, MUTATOR_ARGV_0_int) \
771         /**/                                            o(int, MUTATOR_ARGV_0_int) \
772     /** real players */                 i(int, MUTATOR_ARGV_1_int) \
773     /**/                                        o(int, MUTATOR_ARGV_1_int) \
774     /**/
775 MUTATOR_HOOKABLE(Bot_FixCount, EV_Bot_FixCount);
776
777 #define EV_ClientCommand_Spectate(i, o) \
778     /** player */ i(entity, MUTATOR_ARGV_0_entity) \
779     /**/
780 MUTATOR_HOOKABLE(ClientCommand_Spectate, EV_ClientCommand_Spectate);
781
782 enum {
783     MUT_SPECCMD_CONTINUE, // return this flag to make the function continue as normal
784     MUT_SPECCMD_RETURN, // return this flag to make the function return (don't spectate)
785     MUT_SPECCMD_FORCE // return this flag to force the player to spectate, even if they're not a player
786 };
787
788 #define EV_CheckRules_World(i, o) \
789     /** status */    i(float, MUTATOR_ARGV_0_float) \
790     /**/             o(float, MUTATOR_ARGV_0_float) \
791     /* time limit */ i(float, MUTATOR_ARGV_1_float) \
792     /* frag limit */ i(float, MUTATOR_ARGV_2_float) \
793     /**/
794 MUTATOR_HOOKABLE(CheckRules_World, EV_CheckRules_World);
795
796 #define EV_WantWeapon(i, o) \
797     /** weapon info entity */    i(entity, MUTATOR_ARGV_0_entity) \
798     /** do want? */              i(float, MUTATOR_ARGV_1_float) \
799     /**/                         o(float, MUTATOR_ARGV_1_float) \
800     /** want all guns */         i(bool, MUTATOR_ARGV_2_bool) \
801     /**/                         o(bool, MUTATOR_ARGV_2_bool) \
802     /** want mutator blocked */  i(bool, MUTATOR_ARGV_3_bool) \
803     /**/                         o(bool, MUTATOR_ARGV_3_bool) \
804     /**/
805 MUTATOR_HOOKABLE(WantWeapon, EV_WantWeapon);
806
807 #define EV_AddPlayerScore(i, o) \
808     /** score field */  i(PlayerScoreField, MUTATOR_ARGV_0_entity) \
809     /** score */        i(float, MUTATOR_ARGV_1_float) \
810     /**/                o(float, MUTATOR_ARGV_1_float) \
811     /** player */       i(entity, MUTATOR_ARGV_2_entity) \
812     /**/
813 MUTATOR_HOOKABLE(AddPlayerScore, EV_AddPlayerScore);
814
815 #define EV_GetPlayerStatus(i, o) \
816     /** player */    i(entity, MUTATOR_ARGV_0_entity) \
817     /**/
818 MUTATOR_HOOKABLE(GetPlayerStatus, EV_GetPlayerStatus);
819
820 #define EV_SetWeaponArena(i, o) \
821     /** arena */     i(string, MUTATOR_ARGV_0_string) \
822     /**/             o(string, MUTATOR_ARGV_0_string) \
823     /**/
824 MUTATOR_HOOKABLE(SetWeaponArena, EV_SetWeaponArena);
825
826 #define EV_DropSpecialItems(i, o) \
827     /** target */ i(entity, MUTATOR_ARGV_0_entity) \
828     /**/
829 MUTATOR_HOOKABLE(DropSpecialItems, EV_DropSpecialItems);
830
831 /**
832  * called when an admin tries to kill all monsters
833  * return 1 to prevent spawning
834  */
835 #define EV_AllowMobButcher(i, o) \
836     /** reason */ o(string, MUTATOR_ARGV_0_string) \
837     /**/
838 MUTATOR_HOOKABLE(AllowMobButcher, EV_AllowMobButcher);
839
840 MUTATOR_HOOKABLE(ReadLevelCvars, EV_NO_ARGS);
841
842 #define EV_SendWaypoint(i, o) \
843         /** waypoint */     i(entity, MUTATOR_ARGV_0_entity) \
844         /** to */               i(entity, MUTATOR_ARGV_1_entity) \
845         /** send flags */   i(int, MUTATOR_ARGV_2_int) \
846         /**/                            o(int, MUTATOR_ARGV_2_int) \
847         /** wp flag */      i(int, MUTATOR_ARGV_3_int) \
848         /**/                            o(int, MUTATOR_ARGV_3_int) \
849     /**/
850 MUTATOR_HOOKABLE(SendWaypoint, EV_SendWaypoint);
851
852 #define EV_TurretValidateTarget(i, o) \
853     /** turret */          i(entity, MUTATOR_ARGV_0_entity) \
854     /** target */          i(entity, MUTATOR_ARGV_1_entity) \
855     /** validate flags */  i(int, MUTATOR_ARGV_2_int) \
856     /** target score */    o(float, MUTATOR_ARGV_3_float) \
857     /**/
858 MUTATOR_HOOKABLE(TurretValidateTarget, EV_TurretValidateTarget);
859
860 #define EV_TurretThink(i, o) \
861     /** turret */ i(entity, MUTATOR_ARGV_0_entity) \
862     /**/
863 MUTATOR_HOOKABLE(TurretThink, EV_TurretThink);
864
865 MUTATOR_HOOKABLE(Ent_Init, EV_NO_ARGS);
866
867 /** */
868 #define EV_PrepareExplosionByDamage(i, o) \
869     /** projectile */ i(entity, MUTATOR_ARGV_0_entity) \
870     /** attacker */   i(entity, MUTATOR_ARGV_1_entity) \
871     /**/
872 MUTATOR_HOOKABLE(PrepareExplosionByDamage, EV_PrepareExplosionByDamage);
873
874 /** called when a monster model is about to be set, allows custom paths etc. */
875 #define EV_MonsterModel(i, o) \
876         /** model */  i(string, MUTATOR_ARGV_0_string) \
877         /** output */ i(string, MUTATOR_ARGV_1_string) \
878         /**/              o(string, MUTATOR_ARGV_1_string) \
879     /**/
880 MUTATOR_HOOKABLE(MonsterModel, EV_MonsterModel);
881
882 /**/
883 #define EV_Player_ChangeTeam(i, o) \
884     /** player */         i(entity, MUTATOR_ARGV_0_entity) \
885         /** current team */   i(float, MUTATOR_ARGV_1_float) \
886         /** new team */       i(float, MUTATOR_ARGV_2_float) \
887     /**/
888 MUTATOR_HOOKABLE(Player_ChangeTeam, EV_Player_ChangeTeam);
889
890 /**/
891 #define EV_URI_GetCallback(i, o) \
892         /** id */       i(float, MUTATOR_ARGV_0_float) \
893         /** status */   i(float, MUTATOR_ARGV_1_float) \
894         /** data */     i(string, MUTATOR_ARGV_2_string) \
895     /**/
896 MUTATOR_HOOKABLE(URI_GetCallback, EV_URI_GetCallback);
897
898 /**
899  * return true to prevent weapon use for a player
900  */
901  #define EV_ForbidWeaponUse(i, o) \
902     /** player */ i(entity, MUTATOR_ARGV_0_entity) \
903     /**/
904 MUTATOR_HOOKABLE(ForbidWeaponUse, EV_ForbidWeaponUse);
905
906 /** called when creating a clone of the player (usually for corpses that stay after the player has re-spawned) */
907 #define EV_CopyBody(i, o) \
908     /** player */               i(entity, MUTATOR_ARGV_0_entity) \
909     /** newly created clone */  i(entity, MUTATOR_ARGV_1_entity) \
910     /** keepvelocity? */        i(bool, MUTATOR_ARGV_2_bool) \
911     /**/
912 MUTATOR_HOOKABLE(CopyBody, EV_CopyBody);
913
914 /** called when sending a chat message, ret argument can be changed to prevent the message */
915 #define EV_ChatMessage(i, o) \
916     /** sender */ i(entity, MUTATOR_ARGV_0_entity) \
917     /** ret */ i(int, MUTATOR_ARGV_1_int) \
918     /**/ o(int, MUTATOR_ARGV_1_int) \
919     /**/
920 MUTATOR_HOOKABLE(ChatMessage, EV_ChatMessage);
921
922 /** return true to prevent sending a chat (private, team or regular) message from reaching a certain player */
923 #define EV_ChatMessageTo(i, o) \
924     /** destination player */ i(entity, MUTATOR_ARGV_0_entity) \
925     /** sender */ i(entity, MUTATOR_ARGV_1_entity) \
926     /**/
927 MUTATOR_HOOKABLE(ChatMessageTo, EV_ChatMessageTo);
928
929 /** return true to just restart the match, for modes that don't support readyrestart */
930 MUTATOR_HOOKABLE(ReadyRestart_Deny, EV_NO_ARGS);