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