]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/mutators/events.qh
Stop server from requesting cvar values to the client on connection as it's no longer...
[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 // to use a hook, first register your mutator using REGISTER_MUTATOR
8 // then create your function using MUTATOR_HOOKFUNCTION
9
10 /** called when a player becomes observer, after shared setup */
11 #define EV_MakePlayerObserver(i, o) \
12     /** player */ i(entity, MUTATOR_ARGV_0_entity) \
13     /**/
14 MUTATOR_HOOKABLE(MakePlayerObserver, EV_MakePlayerObserver)
15
16 /** */
17 #define EV_PutClientInServer(i, o) \
18         /** client wanting to spawn */ i(entity, MUTATOR_ARGV_0_entity) \
19     /**/
20 MUTATOR_HOOKABLE(PutClientInServer, EV_PutClientInServer);
21
22 /**
23  * return true to prevent a spectator/observer to spawn as player
24  */
25  #define EV_ForbidSpawn(i, o) \
26     /** player */ i(entity, MUTATOR_ARGV_0_entity) \
27     /**/
28 MUTATOR_HOOKABLE(ForbidSpawn, EV_ForbidSpawn);
29
30 /** returns true if client should be put as player on connection */
31 #define EV_AutoJoinOnConnection(i, o) \
32     /** player */ i(entity, MUTATOR_ARGV_0_entity) \
33     /**/
34 MUTATOR_HOOKABLE(AutoJoinOnConnection, EV_AutoJoinOnConnection);
35
36 /** called when player spawns to determine whether to give them random start weapons. Return true to forbid giving them. */
37 #define EV_ForbidRandomStartWeapons(i, o) \
38         /** player */ i(entity, MUTATOR_ARGV_0_entity) \
39     /**/
40 MUTATOR_HOOKABLE(ForbidRandomStartWeapons, EV_ForbidRandomStartWeapons);
41
42 /** called when a player spawns as player, after shared setup, before his weapon is chosen (so items may be changed in here) */
43 #define EV_PlayerSpawn(i, o) \
44         /** player spawning */ i(entity, MUTATOR_ARGV_0_entity) \
45     /** spot that was used, or NULL */ i(entity, MUTATOR_ARGV_1_entity) \
46     /**/
47 MUTATOR_HOOKABLE(PlayerSpawn, EV_PlayerSpawn);
48
49 /** called after a player's weapon is chosen so it can be overriden here */
50 #define EV_PlayerWeaponSelect(i, o) \
51         /** player spawning */ i(entity, MUTATOR_ARGV_0_entity) \
52     /**/
53 MUTATOR_HOOKABLE(PlayerWeaponSelect, EV_PlayerWeaponSelect);
54
55 /** called in reset_map */
56 #define EV_reset_map_global(i, o) \
57     /**/
58 MUTATOR_HOOKABLE(reset_map_global, EV_reset_map_global);
59
60 /** called in reset_map */
61 #define EV_reset_map_players(i, o) \
62     /**/
63 MUTATOR_HOOKABLE(reset_map_players, EV_reset_map_players);
64
65 /** returns 1 if clearing player score shall not be allowed */
66 #define EV_ForbidPlayerScore_Clear(i, o) \
67     /**/
68 MUTATOR_HOOKABLE(ForbidPlayerScore_Clear, EV_ForbidPlayerScore_Clear);
69
70 /** called when a player disconnects */
71 #define EV_ClientDisconnect(i, o) \
72     /** player */ i(entity, MUTATOR_ARGV_0_entity) \
73     /**/
74 MUTATOR_HOOKABLE(ClientDisconnect, EV_ClientDisconnect);
75
76 /** called when a player dies to e.g. remove stuff he was carrying. */
77 #define EV_PlayerDies(i, o) \
78         /** inflictor           */ i(entity, MUTATOR_ARGV_0_entity) \
79     /** attacker        */ i(entity, MUTATOR_ARGV_1_entity) \
80     /** target                  */ i(entity, MUTATOR_ARGV_2_entity) \
81     /** deathtype       */ i(float,  MUTATOR_ARGV_3_float) \
82     /** damage         */ i(float,  MUTATOR_ARGV_4_float) \
83     /** damage                  */ o(float,  MUTATOR_ARGV_4_float) \
84     /**/
85 MUTATOR_HOOKABLE(PlayerDies, EV_PlayerDies);
86
87 /** called after a player died. */
88 #define EV_PlayerDied(i, o) \
89     /** player                  */ i(entity, MUTATOR_ARGV_0_entity) \
90     /**/
91 MUTATOR_HOOKABLE(PlayerDied, EV_PlayerDied);
92
93 /** allows overriding the frag centerprint messages */
94 #define EV_FragCenterMessage(i, o) \
95     /** attacker       */ i(entity, MUTATOR_ARGV_0_entity) \
96     /** target         */ i(entity, MUTATOR_ARGV_1_entity) \
97     /** deathtype      */ i(float, MUTATOR_ARGV_2_float) \
98     /** attacker kcount*/ i(int,  MUTATOR_ARGV_3_int) \
99     /** targ killcount */ i(int,  MUTATOR_ARGV_4_int) \
100     /**/
101 MUTATOR_HOOKABLE(FragCenterMessage, EV_FragCenterMessage);
102
103 /** called when a player dies to e.g. remove stuff he was carrying */
104 #define EV_PlayHitsound(i, o) \
105     /** victim */ i(entity, MUTATOR_ARGV_0_entity) \
106     /** attacker */ i(entity, MUTATOR_ARGV_1_entity) \
107     /**/
108 MUTATOR_HOOKABLE(PlayHitsound, EV_PlayHitsound);
109
110 /** called when an item model is about to be set, allows custom paths etc. */
111 #define EV_ItemModel(i, o) \
112     /** model       */ i(string, MUTATOR_ARGV_0_string) \
113     /** output      */ i(string, MUTATOR_ARGV_1_string) \
114     /**/               o(string, MUTATOR_ARGV_1_string) \
115     /**/
116 MUTATOR_HOOKABLE(ItemModel, EV_ItemModel);
117
118 /** called when an item sound is about to be played, allows custom paths etc. */
119 #define EV_ItemSound(i, o) \
120     /** sound       */ i(string, MUTATOR_ARGV_0_string) \
121     /** output      */ i(string, MUTATOR_ARGV_1_string) \
122     /**/               o(string, MUTATOR_ARGV_1_string) \
123     /**/
124 MUTATOR_HOOKABLE(ItemSound, EV_ItemSound);
125
126 /** called when someone was fragged by "self", and is expected to change frag_score to adjust scoring for the kill */
127 #define EV_GiveFragsForKill(i, o) \
128     /** attacker   */ i(entity, MUTATOR_ARGV_0_entity) \
129     /** target     */ i(entity, MUTATOR_ARGV_1_entity) \
130     /** frag score */ i(float, MUTATOR_ARGV_2_float) \
131     /**            */ o(float, MUTATOR_ARGV_2_float) \
132     /** deathtype  */ i(float, MUTATOR_ARGV_3_float) \
133     /** wep entity */ i(entity, MUTATOR_ARGV_4_entity) \
134     /**/
135 MUTATOR_HOOKABLE(GiveFragsForKill, EV_GiveFragsForKill);
136
137 /** called when the match ends */
138 MUTATOR_HOOKABLE(MatchEnd, EV_NO_ARGS);
139
140 /** Allows adjusting allowed teams. Return true to use the bitmask value and set
141  * non-empty string to use team entity name. Both behaviors can be active at the
142  * same time and will stack allowed teams.
143  */
144 #define EV_TeamBalance_CheckAllowedTeams(i, o) \
145     /** mask of teams      */ i(float, MUTATOR_ARGV_0_float) \
146     /**/                      o(float, MUTATOR_ARGV_0_float) \
147     /** team entity name   */ i(string, MUTATOR_ARGV_1_string) \
148     /**/                      o(string, MUTATOR_ARGV_1_string) \
149     /** player checked     */ i(entity, MUTATOR_ARGV_2_entity) \
150     /**/
151 MUTATOR_HOOKABLE(TeamBalance_CheckAllowedTeams,
152         EV_TeamBalance_CheckAllowedTeams);
153
154 /** return true to manually override team counts */
155 MUTATOR_HOOKABLE(TeamBalance_GetTeamCounts, EV_NO_ARGS);
156
157 /** allows overriding of team counts */
158 #define EV_TeamBalance_GetTeamCount(i, o) \
159     /** team index to count             */ i(float, MUTATOR_ARGV_0_float) \
160     /** player to ignore                */ i(entity, MUTATOR_ARGV_1_entity) \
161     /** number of players in a team     */ o(float, MUTATOR_ARGV_2_float) \
162     /** number of bots in a team        */ o(float, MUTATOR_ARGV_3_float) \
163     /**/
164 MUTATOR_HOOKABLE(TeamBalance_GetTeamCount, EV_TeamBalance_GetTeamCount);
165
166 /** allows overriding the teams that will make the game most balanced if the
167  *  player joins any of them.
168  */
169 #define EV_TeamBalance_FindBestTeams(i, o) \
170     /** player checked   */ i(entity, MUTATOR_ARGV_0_entity) \
171     /** bitmask of teams */ o(float, MUTATOR_ARGV_1_float) \
172     /**/
173 MUTATOR_HOOKABLE(TeamBalance_FindBestTeams, EV_TeamBalance_FindBestTeams);
174
175 /** Called during autobalance. Return true to override the player that will be
176 switched. */
177 #define EV_TeamBalance_GetPlayerForTeamSwitch(i, o) \
178     /** source team index      */ i(int, MUTATOR_ARGV_0_int) \
179     /** destination team index */ i(int, MUTATOR_ARGV_1_int) \
180     /** is looking for bot     */ i(bool, MUTATOR_ARGV_2_bool) \
181     /** player to switch       */ o(entity, MUTATOR_ARGV_3_entity) \
182     /**/
183 MUTATOR_HOOKABLE(TeamBalance_GetPlayerForTeamSwitch,
184         EV_TeamBalance_GetPlayerForTeamSwitch);
185
186 /** copies variables for spectating "spectatee" to "this" */
187 #define EV_SpectateCopy(i, o) \
188     /** spectatee   */ i(entity, MUTATOR_ARGV_0_entity) \
189     /** client      */ i(entity, MUTATOR_ARGV_1_entity) \
190     /**/
191 MUTATOR_HOOKABLE(SpectateCopy, EV_SpectateCopy);
192
193 /** called when formatting a chat message to replace fancy functions */
194 #define EV_FormatMessage(i, o) \
195     /** player        */ i(entity, MUTATOR_ARGV_0_entity) \
196     /** escape        */ i(string, MUTATOR_ARGV_1_string) \
197     /** replacement   */ i(string, MUTATOR_ARGV_2_string) \
198     /**/                 o(string, MUTATOR_ARGV_2_string) \
199     /** message       */ i(string, MUTATOR_ARGV_3_string) \
200     /**/
201 MUTATOR_HOOKABLE(FormatMessage, EV_FormatMessage);
202
203 /** called before any formatting is applied, handy for tweaking the message before scripts get ahold of it */
204 #define EV_PreFormatMessage(i, o) \
205     /** player        */ i(entity, MUTATOR_ARGV_0_entity) \
206     /** message       */ i(string, MUTATOR_ARGV_1_string) \
207     /**/                 o(string, MUTATOR_ARGV_1_string) \
208     /**/
209 MUTATOR_HOOKABLE(PreFormatMessage, EV_PreFormatMessage);
210
211 /** returns true if throwing the current weapon shall not be allowed */
212 #define EV_ForbidThrowCurrentWeapon(i, o) \
213     /** player        */ i(entity, MUTATOR_ARGV_0_entity) \
214     /** weapon entity */ i(entity, MUTATOR_ARGV_1_entity) \
215     /**/
216 MUTATOR_HOOKABLE(ForbidThrowCurrentWeapon, EV_ForbidThrowCurrentWeapon);
217
218 /** returns true if dropping the current weapon shall not be allowed at any time including death */
219 #define EV_ForbidDropCurrentWeapon(i, o) \
220     /** player */        i(entity, MUTATOR_ARGV_0_entity) \
221     /** weapon id */     i(int, MUTATOR_ARGV_1_int) \
222     /**/
223 MUTATOR_HOOKABLE(ForbidDropCurrentWeapon, EV_ForbidDropCurrentWeapon);
224
225 /**  */
226 MUTATOR_HOOKABLE(SetDefaultAlpha, EV_NO_ARGS);
227
228 /** allows changing attack rate */
229 #define EV_WeaponRateFactor(i, o) \
230     /** weapon rate */  i(float, MUTATOR_ARGV_0_float) \
231     /**/                o(float, MUTATOR_ARGV_0_float) \
232     /** player */       i(entity, MUTATOR_ARGV_1_entity) \
233     /**/
234 MUTATOR_HOOKABLE(WeaponRateFactor, EV_WeaponRateFactor);
235
236 /** allows changing weapon speed (projectiles mostly) */
237 #define EV_WeaponSpeedFactor(i, o) \
238     /** weapon speed */ i(float, MUTATOR_ARGV_0_float) \
239     /**/                o(float, MUTATOR_ARGV_0_float) \
240     /** player */       i(entity, MUTATOR_ARGV_1_entity) \
241     /**/
242 MUTATOR_HOOKABLE(WeaponSpeedFactor, EV_WeaponSpeedFactor);
243
244 /** adjusts {warmup_}start_{items,weapons,ammo_{cells,plasma,rockets,nails,shells,fuel}} */
245 MUTATOR_HOOKABLE(SetStartItems, EV_NO_ARGS);
246
247 /** called every frame. customizes the waypoint for spectators */
248 #define EV_CustomizeWaypoint(i, o) \
249     /** waypoint                        */ i(entity, MUTATOR_ARGV_0_entity) \
250     /** player; other.enemy = spectator */ i(entity, MUTATOR_ARGV_1_entity) \
251     /**/
252 MUTATOR_HOOKABLE(CustomizeWaypoint, EV_CustomizeWaypoint);
253
254 /** Check if items having the given definition are allowed to spawn.
255  *  Return true to disallow spawning.
256  */
257 #define EV_FilterItemDefinition(i, o) \
258     /** item        */ i(entity, MUTATOR_ARGV_0_entity) \
259     /**/
260 MUTATOR_HOOKABLE(FilterItemDefinition, EV_FilterItemDefinition);
261
262 /**
263  * checks if the current item may be spawned (.items may be read and written to, as well as the ammo_ fields)
264  * return error to request removal
265  */
266 #define EV_FilterItem(i, o) \
267     /** item        */ i(entity, MUTATOR_ARGV_0_entity) \
268     /**/
269 MUTATOR_HOOKABLE(FilterItem, EV_FilterItem);
270
271 /** return error to request removal */
272 #define EV_TurretSpawn(i, o) \
273     /** turret        */ i(entity, MUTATOR_ARGV_0_entity) \
274     /**/
275 MUTATOR_HOOKABLE(TurretSpawn, EV_TurretSpawn);
276
277 /** return error to not attack */
278 #define EV_TurretFire(i, o) \
279     /** turret        */ i(entity, MUTATOR_ARGV_0_entity) \
280     /**/
281 MUTATOR_HOOKABLE(TurretFire, EV_TurretFire);
282
283 /** return error to not attack */
284 #define EV_Turret_CheckFire(i, o) \
285     /** turret                      */ i(entity, MUTATOR_ARGV_0_entity) \
286     /** to fire or not to fire      */ o(bool, MUTATOR_ARGV_1_bool) \
287     /**/
288 MUTATOR_HOOKABLE(Turret_CheckFire, EV_Turret_CheckFire);
289
290 /** return error to prevent entity spawn, or modify the entity */
291 #define EV_OnEntityPreSpawn(i, o) \
292    /** entity  */ i(entity, MUTATOR_ARGV_0_entity) \
293     /**/
294 MUTATOR_HOOKABLE(OnEntityPreSpawn, EV_OnEntityPreSpawn);
295
296 /** runs in the event loop for players; is called for ALL player entities, also bots, also the dead, or spectators */
297 #define EV_PlayerPreThink(i, o) \
298     /** player */ i(entity, MUTATOR_ARGV_0_entity) \
299     /**/
300 MUTATOR_HOOKABLE(PlayerPreThink, EV_PlayerPreThink);
301
302 /** TODO change this into a general PlayerPostThink hook? */
303 #define EV_GetPressedKeys(i, o) \
304     /** player */ i(entity, MUTATOR_ARGV_0_entity) \
305     /**/
306 MUTATOR_HOOKABLE(GetPressedKeys, EV_GetPressedKeys);
307
308 /** is meant to call GetCvars_handle*(get_cvars_s, get_cvars_f, cvarfield, "cvarname") for cvars this mutator needs from the client */
309 // NOTE: requesting cvar values (get_cvars_f 0) is deprecated
310 #define EV_GetCvars(i, o) \
311     /**/ i(float, get_cvars_f) \
312     /**/ i(string, get_cvars_s) \
313     /**/
314 float get_cvars_f;
315 string get_cvars_s;
316 MUTATOR_HOOKABLE(GetCvars, EV_NO_ARGS); // NOTE: Can't use EV_GetCvars because of `SZ_GetSpace: overflow`
317
318 /** can edit any "just fired" projectile */
319 #define EV_EditProjectile(i, o) \
320     /** projectile owner */ i(entity, MUTATOR_ARGV_0_entity) \
321     /** projectile */ i(entity, MUTATOR_ARGV_1_entity) \
322     /**/
323 MUTATOR_HOOKABLE(EditProjectile, EV_EditProjectile);
324
325 /** called when a monster spawns */
326 #define EV_MonsterSpawn(i, o) \
327     /** monster */ i(entity, MUTATOR_ARGV_0_entity) \
328     /**/
329 MUTATOR_HOOKABLE(MonsterSpawn, EV_MonsterSpawn);
330
331 /** called when a monster dies */
332 #define EV_MonsterDies(i, o) \
333     /** target       */ i(entity, MUTATOR_ARGV_0_entity) \
334     /** attacker     */ i(entity, MUTATOR_ARGV_1_entity) \
335     /** deathtype    */ i(float, MUTATOR_ARGV_2_float) \
336     /**/
337 MUTATOR_HOOKABLE(MonsterDies, EV_MonsterDies);
338
339 /** called when a monster dies */
340 #define EV_MonsterRemove(i, o) \
341     /** monster */ i(entity, MUTATOR_ARGV_0_entity) \
342     /**/
343 MUTATOR_HOOKABLE(MonsterRemove, EV_MonsterRemove);
344
345 /** called when a monster wants to respawn */
346 #define EV_MonsterRespawn(i, o) \
347     /** monster */ i(entity, MUTATOR_ARGV_0_entity) \
348     /**/
349 MUTATOR_HOOKABLE(MonsterRespawn, EV_MonsterRespawn);
350
351 /** called when a monster is dropping loot */
352 #define EV_MonsterDropItem(i, o) \
353     /* monster */                          i(entity, MUTATOR_ARGV_0_entity) \
354     /* item (can be removed or changed) */ i(entity, MUTATOR_ARGV_1_entity) \
355     /**/                                   o(entity, MUTATOR_ARGV_1_entity) \
356     /* attacker */                         i(entity, MUTATOR_ARGV_2_entity) \
357     /**/
358 .entity monster_loot;
359 MUTATOR_HOOKABLE(MonsterDropItem, EV_MonsterDropItem);
360
361 /**
362  * called when a monster moves
363  * returning true makes the monster stop
364  */
365 #define EV_MonsterMove(i, o) \
366     /** monster */       i(entity, MUTATOR_ARGV_0_entity) \
367     /** run speed */     i(float, MUTATOR_ARGV_1_float) \
368     /**/                 o(float, MUTATOR_ARGV_1_float) \
369     /** walk speed */    i(float, MUTATOR_ARGV_2_float) \
370     /**/                 o(float, MUTATOR_ARGV_2_float) \
371     /** move target */   i(entity, MUTATOR_ARGV_3_entity) \
372     /**/                 o(entity, MUTATOR_ARGV_3_entity) \
373     /**/
374 MUTATOR_HOOKABLE(MonsterMove, EV_MonsterMove);
375
376 /** called when a monster looks for another target */
377 MUTATOR_HOOKABLE(MonsterFindTarget, EV_NO_ARGS);
378
379 /**
380  * called when validating a monster's target
381  */
382 #define EV_MonsterValidTarget(i, o) \
383     /** monster */       i(entity, MUTATOR_ARGV_0_entity) \
384     /** target */        i(entity, MUTATOR_ARGV_1_entity) \
385     /**/
386 MUTATOR_HOOKABLE(MonsterValidTarget, EV_MonsterValidTarget);
387
388 /** called to change a random monster to a miniboss */
389 #define EV_MonsterCheckBossFlag(i, o) \
390     /** monster */ i(entity, MUTATOR_ARGV_0_entity) \
391     /**/
392 MUTATOR_HOOKABLE(MonsterCheckBossFlag, EV_MonsterCheckBossFlag);
393
394 /**
395  * called when a player tries to spawn a monster
396  * return 1 to prevent spawning
397  * NOTE: requires reason if disallowed
398  */
399  #define EV_AllowMobSpawning(i, o) \
400     /** caller */ i(entity, MUTATOR_ARGV_0_entity) \
401     /** reason */ o(string, MUTATOR_ARGV_1_string) \
402     /**/
403 MUTATOR_HOOKABLE(AllowMobSpawning, EV_AllowMobSpawning);
404
405 /** called when a player gets damaged to e.g. remove stuff he was carrying. */
406 #define EV_PlayerDamage_SplitHealthArmor(i, o) \
407         /** inflictor           */ i(entity, MUTATOR_ARGV_0_entity) \
408     /** attacker        */ i(entity, MUTATOR_ARGV_1_entity) \
409     /** target                  */ i(entity, MUTATOR_ARGV_2_entity) \
410     /** force (no out)  */ i(vector, MUTATOR_ARGV_3_vector) \
411     /** damage take     */ i(float,  MUTATOR_ARGV_4_float) \
412     /** damage take     */ o(float,  MUTATOR_ARGV_4_float) \
413     /** damage save     */ i(float,  MUTATOR_ARGV_5_float) \
414     /** damage save     */ o(float,  MUTATOR_ARGV_5_float) \
415     /** deathtype               */ i(float,  MUTATOR_ARGV_6_float) \
416     /** damage              */ i(float,  MUTATOR_ARGV_7_float) \
417     /**/
418 MUTATOR_HOOKABLE(PlayerDamage_SplitHealthArmor, EV_PlayerDamage_SplitHealthArmor);
419
420 /**
421  * called to adjust damage and force values which are applied to the player, used for e.g. strength damage/force multiplier
422  * i'm not sure if I should change this around slightly (Naming of the entities, and also how they're done in g_damage).
423  */
424 #define EV_Damage_Calculate(i, o) \
425     /** inflictor               */ i(entity, MUTATOR_ARGV_0_entity) \
426     /** attacker        */ i(entity, MUTATOR_ARGV_1_entity) \
427     /** target                  */ i(entity, MUTATOR_ARGV_2_entity) \
428     /** deathtype       */ i(float,  MUTATOR_ARGV_3_float) \
429     /** damage          */ i(float,  MUTATOR_ARGV_4_float) \
430     /** damage                  */ o(float,  MUTATOR_ARGV_4_float) \
431     /** mirrordamage    */ i(float,  MUTATOR_ARGV_5_float) \
432     /** mirrordamage    */ o(float,  MUTATOR_ARGV_5_float) \
433     /** force           */ i(vector, MUTATOR_ARGV_6_vector) \
434     /** force           */ o(vector, MUTATOR_ARGV_6_vector) \
435     /** weapon entity   */ i(entity, MUTATOR_ARGV_7_entity) \
436     /**/
437 MUTATOR_HOOKABLE(Damage_Calculate, EV_Damage_Calculate);
438
439 /**
440  * Called when a player is damaged
441  */
442 #define EV_PlayerDamaged(i, o) \
443     /** attacker  */ i(entity, MUTATOR_ARGV_0_entity) \
444     /** target    */ i(entity, MUTATOR_ARGV_1_entity) \
445     /** health    */ i(float,    MUTATOR_ARGV_2_float) \
446     /** armor     */ i(float,    MUTATOR_ARGV_3_float) \
447     /** location  */ i(vector, MUTATOR_ARGV_4_vector) \
448     /** deathtype */ i(int,    MUTATOR_ARGV_5_int) \
449     /** potential_damage     */ i(float,    MUTATOR_ARGV_6_float) \
450     /**/
451 MUTATOR_HOOKABLE(PlayerDamaged, EV_PlayerDamaged);
452
453 /**
454  * Called by W_DecreaseAmmo
455  */
456 #define EV_W_DecreaseAmmo(i, o) \
457     /** actor */            i(entity, MUTATOR_ARGV_0_entity) \
458     /** weapon entity */    i(entity, MUTATOR_ARGV_1_entity) \
459     /** ammo to take */     i(float, MUTATOR_ARGV_2_float) \
460     /**/                    o(float, MUTATOR_ARGV_2_float) \
461     /**/
462 MUTATOR_HOOKABLE(W_DecreaseAmmo, EV_W_DecreaseAmmo);
463
464 /**
465  * Called by W_Reload
466  */
467 #define EV_W_Reload(i, o) \
468     /** actor */ i(entity, MUTATOR_ARGV_0_entity) \
469     /**/
470 MUTATOR_HOOKABLE(W_Reload, EV_W_Reload);
471
472 /** called at the end of player_powerups() in client.qc, used for manipulating the values which are set by powerup items. */
473 #define EV_PlayerPowerups(i, o) \
474     /** player */    i(entity, MUTATOR_ARGV_0_entity) \
475     /** old items */ i(int, MUTATOR_ARGV_1_int) \
476     /**/
477 MUTATOR_HOOKABLE(PlayerPowerups, EV_PlayerPowerups);
478
479 /**
480  * called every player think frame
481  * return 1 to disable regen
482  */
483  #define EV_PlayerRegen(i, o) \
484     /** player */               i(entity, MUTATOR_ARGV_0_entity) \
485     /** max_mod */              i(float, MUTATOR_ARGV_1_float) \
486     /**/                        o(float, MUTATOR_ARGV_1_float) \
487     /** regen_mod */            i(float, MUTATOR_ARGV_2_float) \
488     /**/                        o(float, MUTATOR_ARGV_2_float) \
489     /** rot_mod */              i(float, MUTATOR_ARGV_3_float) \
490     /**/                        o(float, MUTATOR_ARGV_3_float) \
491     /** limit_mod */            i(float, MUTATOR_ARGV_4_float) \
492     /**/                        o(float, MUTATOR_ARGV_4_float) \
493     /** health_regen */         i(float, MUTATOR_ARGV_5_float) \
494     /**/                        o(float, MUTATOR_ARGV_5_float) \
495     /** health_regenlinear */   i(float, MUTATOR_ARGV_6_float) \
496     /**/                        o(float, MUTATOR_ARGV_6_float) \
497     /** health_rot */           i(float, MUTATOR_ARGV_7_float) \
498     /**/                        o(float, MUTATOR_ARGV_7_float) \
499     /** health_rotlinear */     i(float, MUTATOR_ARGV_8_float) \
500     /**/                        o(float, MUTATOR_ARGV_8_float) \
501     /** health_stable */        i(float, MUTATOR_ARGV_9_float) \
502     /**/                        o(float, MUTATOR_ARGV_9_float) \
503     /** health_rotstable */     i(float, MUTATOR_ARGV_10_float) \
504     /**/                        o(float, MUTATOR_ARGV_10_float) \
505     /**/
506 MUTATOR_HOOKABLE(PlayerRegen, EV_PlayerRegen);
507
508 /**
509  * called when the use key is pressed
510  * if MUTATOR_RETURNVALUE is 1, don't do anything
511  * return 1 if the use key actually did something
512  */
513  #define EV_PlayerUseKey(i, o) \
514     /** player */ i(entity, MUTATOR_ARGV_0_entity) \
515     /**/
516 MUTATOR_HOOKABLE(PlayerUseKey, EV_PlayerUseKey);
517
518 /**
519  * called when a client command is parsed
520  * NOTE: hooks MUST start with if (MUTATOR_RETURNVALUE) return false;
521  * NOTE: return true if you handled the command, return false to continue handling
522  * NOTE: THESE HOOKS MUST NEVER EVER CALL tokenize()
523  * // example:
524  * MUTATOR_HOOKFUNCTION(foo_SV_ParseClientCommand)
525  * {
526  *     if (MUTATOR_RETURNVALUE) // command was already handled?
527  *         return false;
528  *     if (cmd_name == "echocvar" && cmd_argc >= 2)
529  *     {
530  *         print(cvar_string(argv(1)), "\n");
531  *         return true;
532  *     }
533  *     if (cmd_name == "echostring" && cmd_argc >= 2)
534  *     {
535  *         print(substring(cmd_string, argv_start_index(1), argv_end_index(-1) - argv_start_index(1)), "\n");
536  *         return true;
537  *     }
538  *     return false;
539  * }
540  */
541 #define EV_SV_ParseClientCommand(i, o) \
542         /** client sending the command */       i(entity, MUTATOR_ARGV_0_entity) \
543     /** command name */                     i(string, MUTATOR_ARGV_1_string) \
544         /** argc (also, argv() can be used) */  i(int, MUTATOR_ARGV_2_int) \
545         /** whole command, use only if you really have to */ i(string, MUTATOR_ARGV_3_string) \
546     /**/
547 MUTATOR_HOOKABLE(SV_ParseClientCommand, EV_SV_ParseClientCommand);
548
549 /** please read EV_SV_ParseClientCommand description before using */
550 #define EV_SV_ParseServerCommand(i, o) \
551    /** command name */ i(string, MUTATOR_ARGV_0_string) \
552         /** argc (also, argv() can be used) */ i(int, MUTATOR_ARGV_1_int) \
553         /** whole command, use only if you really have to */ i(string, MUTATOR_ARGV_2_string) \
554     /**/
555 MUTATOR_HOOKABLE(SV_ParseServerCommand, EV_SV_ParseServerCommand);
556
557 /**
558  * called when a spawnpoint is being evaluated
559  * return 1 to make the spawnpoint unusable
560  */
561 #define EV_Spawn_Score(i, o) \
562     /** player wanting to spawn */ i(entity, MUTATOR_ARGV_0_entity) \
563     /** spot to be evaluated */ i(entity, MUTATOR_ARGV_1_entity) \
564     /** spot score, _x is priority, _y is "distance" */ i(vector, MUTATOR_ARGV_2_vector) \
565     /**/ o(vector, MUTATOR_ARGV_2_vector) \
566     /**/
567 MUTATOR_HOOKABLE(Spawn_Score, EV_Spawn_Score);
568
569 /** runs globally each server frame */
570 MUTATOR_HOOKABLE(SV_StartFrame, EV_NO_ARGS);
571
572 #define EV_SetModname(i, o) \
573     /** name of the mutator/mod if it warrants showing as such in the server browser */ \
574     /**/ i(string, MUTATOR_ARGV_0_string) \
575     /**/ o(string, MUTATOR_ARGV_0_string) \
576     /**/
577 MUTATOR_HOOKABLE(SetModname, EV_SetModname);
578
579 /**
580  * called for each item being spawned on a map, including dropped weapons
581  * return 1 to remove an item
582  */
583 #define EV_Item_Spawn(i, o) \
584     /** item */ i(entity, MUTATOR_ARGV_0_entity) \
585     /**/
586 MUTATOR_HOOKABLE(Item_Spawn, EV_Item_Spawn);
587
588 #define EV_SetWeaponreplace(i, o) \
589     /** map entity */  i(entity, MUTATOR_ARGV_0_entity) \
590     /** weapon info */ i(entity, MUTATOR_ARGV_1_entity) \
591     /** replacement */ i(string, MUTATOR_ARGV_2_string) \
592     /**/               o(string, MUTATOR_ARGV_2_string) \
593     /**/
594 MUTATOR_HOOKABLE(SetWeaponreplace, EV_SetWeaponreplace);
595
596 /** called when an item is about to respawn */
597 #define EV_Item_RespawnCountdown(i, o) \
598     /** item */   i(entity, MUTATOR_ARGV_0_entity) \
599     /**/
600 MUTATOR_HOOKABLE(Item_RespawnCountdown, EV_Item_RespawnCountdown);
601
602 /** called when a bot checks a target to attack */
603 #define EV_BotShouldAttack(i, o) \
604     /** bot */    i(entity, MUTATOR_ARGV_0_entity) \
605     /** target */ i(entity, MUTATOR_ARGV_1_entity) \
606     /**/
607 MUTATOR_HOOKABLE(BotShouldAttack, EV_BotShouldAttack);
608
609 /**
610  * called whenever a player goes through a portal gun teleport
611  * allows you to strip a player of an item if they go through the teleporter to help prevent cheating
612  */
613 #define EV_PortalTeleport(i, o) \
614     /** player */ i(entity, MUTATOR_ARGV_0_entity) \
615     /**/
616 MUTATOR_HOOKABLE(PortalTeleport, EV_PortalTeleport);
617
618 /**
619  * called whenever a player uses impulse 33 (help me) in impulse.qc
620  * normally help me ping uses .waypointsprite_attachedforcarrier,
621  * but if your mutator uses something different then you can handle it
622  * in a special manner using this hook
623  */
624 #define EV_HelpMePing(i, o) \
625     /** the player who pressed impulse 33 */ i(entity, MUTATOR_ARGV_0_entity) \
626     /**/
627 MUTATOR_HOOKABLE(HelpMePing, EV_HelpMePing);
628
629 /**
630  * called when a vehicle initializes
631  * return true to remove the vehicle
632  */
633 #define EV_VehicleInit(i, o) \
634     /** vehicle */ i(entity, MUTATOR_ARGV_0_entity) \
635     /**/
636 MUTATOR_HOOKABLE(VehicleInit, EV_VehicleInit);
637
638 /**
639  * called when a player enters a vehicle
640  * allows mutators to set special settings in this event
641  */
642 #define EV_VehicleEnter(i, o) \
643     /** player */ i(entity, MUTATOR_ARGV_0_entity) \
644     /** vehicle */ i(entity, MUTATOR_ARGV_1_entity) \
645     /**/
646 MUTATOR_HOOKABLE(VehicleEnter, EV_VehicleEnter);
647
648 /**
649  * called when a player touches a vehicle
650  * return true to stop player from entering the vehicle
651  */
652 #define EV_VehicleTouch(i, o) \
653     /** vehicle */ i(entity, MUTATOR_ARGV_0_entity) \
654     /** player */ i(entity, MUTATOR_ARGV_1_entity) \
655     /**/
656 MUTATOR_HOOKABLE(VehicleTouch, EV_VehicleTouch);
657
658 /**
659  * called when a player exits a vehicle
660  * allows mutators to set special settings in this event
661  */
662 #define EV_VehicleExit(i, o) \
663     /** player */ i(entity, MUTATOR_ARGV_0_entity) \
664     /** vehicle */ i(entity, MUTATOR_ARGV_1_entity) \
665     /**/
666 MUTATOR_HOOKABLE(VehicleExit, EV_VehicleExit);
667
668 /** called when a speedrun is aborted and the player is teleported back to start position */
669 #define EV_AbortSpeedrun(i, o) \
670     /** player */ i(entity, MUTATOR_ARGV_0_entity) \
671     /**/
672 MUTATOR_HOOKABLE(AbortSpeedrun, EV_AbortSpeedrun);
673
674 /** called at when a item is touched. Called early, can edit item properties. */
675 #define EV_ItemTouch(i, o) \
676     /** item */    i(entity, MUTATOR_ARGV_0_entity) \
677     /** toucher */ i(entity, MUTATOR_ARGV_1_entity) \
678     /**/           o(entity, MUTATOR_ARGV_1_entity) \
679     /**/
680 MUTATOR_HOOKABLE(ItemTouch, EV_ItemTouch);
681
682 enum {
683         MUT_ITEMTOUCH_CONTINUE, // return this flag to make the function continue as normal
684         MUT_ITEMTOUCH_RETURN, // return this flag to make the function return (handled entirely by mutator)
685         MUT_ITEMTOUCH_PICKUP // return this flag to have the item "picked up" and taken even after mutator handled it
686 };
687
688 /** called after the item has been touched. */
689 #define EV_ItemTouched(i, o) \
690     /** item */    i(entity, MUTATOR_ARGV_0_entity) \
691     /** toucher */ i(entity, MUTATOR_ARGV_1_entity) \
692     /**/
693 MUTATOR_HOOKABLE(ItemTouched, EV_ItemTouched);
694
695 /** Called when the amount of entity resources changes. Can be used to override
696 resource limit. */
697 #define EV_GetResourceLimit(i, o) \
698         /** checked entity */ i(entity, MUTATOR_ARGV_0_entity) \
699         /** resource type */  i(int, MUTATOR_ARGV_1_int) \
700         /** limit */          i(float, MUTATOR_ARGV_2_float) \
701         /**/                  o(float, MUTATOR_ARGV_2_float) \
702         /**/
703 MUTATOR_HOOKABLE(GetResourceLimit, EV_GetResourceLimit);
704
705 /** Called when the amount of resource of an entity changes. See RES_*
706 constants for resource types. Return true to forbid the change. */
707 #define EV_SetResource(i, o) \
708         /** checked entity */ i(entity, MUTATOR_ARGV_0_entity) \
709         /** resource type */  i(int, MUTATOR_ARGV_1_int) \
710         /**/                  o(int, MUTATOR_ARGV_1_int) \
711         /** amount */         i(float, MUTATOR_ARGV_2_float) \
712         /**/                  o(float, MUTATOR_ARGV_2_float) \
713         /**/
714 MUTATOR_HOOKABLE(SetResource, EV_SetResource);
715
716 /** Called after the amount of resource of an entity has changed. See RES_*
717 constants for resource types. Amount wasted is the amount of resource that is
718 above resource limit so it was not given. */
719 #define EV_ResourceAmountChanged(i, o) \
720         /** checked entity */ i(entity, MUTATOR_ARGV_0_entity) \
721         /** resource type */  i(int, MUTATOR_ARGV_1_int) \
722         /** amount */         i(float, MUTATOR_ARGV_2_float) \
723         /**/
724 MUTATOR_HOOKABLE(ResourceAmountChanged, EV_ResourceAmountChanged);
725
726 /** Called when there was an attempt to set entity resources higher than their
727 limit. See RES_* constants for resource types. Amount wasted is the amount
728 of resource that is above resource limit so it was not given. */
729 #define EV_ResourceWasted(i, o) \
730         /** checked entity */ i(entity, MUTATOR_ARGV_0_entity) \
731         /** resource type */  i(int, MUTATOR_ARGV_1_int) \
732         /** amount wasted */  i(float, MUTATOR_ARGV_2_float) \
733         /**/
734 MUTATOR_HOOKABLE(ResourceWasted, EV_ResourceWasted);
735
736 /** Called when entity is being given some resource. See RES_* constants
737 for resource types. Return true to forbid giving.
738 NOTE: This hook is also called by GiveResourceWithLimit */
739 #define EV_GiveResource(i, o) \
740         /** receiver */      i(entity, MUTATOR_ARGV_0_entity) \
741         /** resource type */ i(int, MUTATOR_ARGV_1_int) \
742         /**/                 o(int, MUTATOR_ARGV_1_int) \
743         /** amount */        i(float, MUTATOR_ARGV_2_float) \
744         /**/                 o(float, MUTATOR_ARGV_2_float) \
745         /**/
746 MUTATOR_HOOKABLE(GiveResource, EV_GiveResource);
747
748 /** Called when entity is being given some resource with specified limit. See
749 RES_* constants for resource types. Return true to forbid giving. */
750 #define EV_GiveResourceWithLimit(i, o) \
751         /** receiver */      i(entity, MUTATOR_ARGV_0_entity) \
752         /** resource type */ i(int, MUTATOR_ARGV_1_int) \
753         /**/                 o(int, MUTATOR_ARGV_1_int) \
754         /** amount */        i(float, MUTATOR_ARGV_2_float) \
755         /**/                 o(float, MUTATOR_ARGV_2_float) \
756         /** limit */         i(float, MUTATOR_ARGV_3_float) \
757         /**/                 o(float, MUTATOR_ARGV_3_float) \
758         /**/
759 MUTATOR_HOOKABLE(GiveResourceWithLimit, EV_GiveResourceWithLimit);
760
761 /** Called when some resource is being taken from an entity. See RES_* constants
762 for resource types. Return true to forbid giving.
763 NOTE: This hook is also called by TakeResourceWithLimit */
764 #define EV_TakeResource(i, o) \
765     /** receiver */      i(entity, MUTATOR_ARGV_0_entity) \
766     /** resource type */ i(int, MUTATOR_ARGV_1_int) \
767     /**/                 o(int, MUTATOR_ARGV_1_int) \
768     /** amount */        i(float, MUTATOR_ARGV_2_float) \
769     /**/                 o(float, MUTATOR_ARGV_2_float) \
770     /**/
771 MUTATOR_HOOKABLE(TakeResource, EV_TakeResource);
772
773 /** Called when some resource is being taken from an entity, with a limit. See
774 RES_* constants for resource types. Return true to forbid giving. */
775 #define EV_TakeResourceWithLimit(i, o) \
776     /** receiver */      i(entity, MUTATOR_ARGV_0_entity) \
777     /** resource type */ i(int, MUTATOR_ARGV_1_int) \
778     /**/                 o(int, MUTATOR_ARGV_1_int) \
779     /** amount */        i(float, MUTATOR_ARGV_2_float) \
780     /**/                 o(float, MUTATOR_ARGV_2_float) \
781     /** limit */         i(float, MUTATOR_ARGV_3_float) \
782     /**/                 o(float, MUTATOR_ARGV_3_float) \
783     /**/
784 MUTATOR_HOOKABLE(TakeResourceWithLimit, EV_TakeResourceWithLimit);
785
786 /** called at when a player connect */
787 #define EV_ClientConnect(i, o) \
788     /** player */ i(entity, MUTATOR_ARGV_0_entity) \
789     /**/
790 MUTATOR_HOOKABLE(ClientConnect, EV_ClientConnect);
791
792 #define EV_HavocBot_ChooseRole(i, o) \
793     /** bot */ i(entity, MUTATOR_ARGV_0_entity) \
794     /**/
795 MUTATOR_HOOKABLE(HavocBot_ChooseRole, EV_HavocBot_ChooseRole);
796
797 /** called when a target is checked for accuracy */
798 #define EV_AccuracyTargetValid(i, o) \
799     /** attacker */ i(entity, MUTATOR_ARGV_0_entity) \
800     /** target */ i(entity, MUTATOR_ARGV_1_entity) \
801     /**/
802 MUTATOR_HOOKABLE(AccuracyTargetValid, EV_AccuracyTargetValid);
803 enum {
804         MUT_ACCADD_VALID, // return this flag to make the function continue if target is a client
805         MUT_ACCADD_INVALID, // return this flag to make the function always continue
806         MUT_ACCADD_INDIFFERENT // return this flag to make the function always return
807 };
808
809 /** Called when clearing the global parameters for a model */
810 MUTATOR_HOOKABLE(ClearModelParams, EV_NO_ARGS);
811
812 /** Called when getting the global parameters for a model */
813 #define EV_GetModelParams(i, o) \
814     /** input */   i(string, MUTATOR_ARGV_0_string) \
815     /** command */ i(string, MUTATOR_ARGV_1_string) \
816     /**/
817 MUTATOR_HOOKABLE(GetModelParams, EV_GetModelParams);
818
819 /** called when a bullet has hit a target */
820 #define EV_FireBullet_Hit(i, o) \
821     /** player */       i(entity, MUTATOR_ARGV_0_entity) \
822     /** targ */         i(entity, MUTATOR_ARGV_1_entity) \
823     /** start pos */    i(vector, MUTATOR_ARGV_2_vector) \
824     /** end pos */      i(vector, MUTATOR_ARGV_3_vector) \
825     /** damage */       i(float, MUTATOR_ARGV_4_float) \
826     /**/                o(float, MUTATOR_ARGV_4_float) \
827     /** wep entity */   i(entity, MUTATOR_ARGV_5_entity) \
828     /**/
829 MUTATOR_HOOKABLE(FireBullet_Hit, EV_FireBullet_Hit);
830
831 #define EV_FixPlayermodel(i, o) \
832     /** model */    i(string, MUTATOR_ARGV_0_string) \
833     /**/            o(string, MUTATOR_ARGV_0_string) \
834     /** skin */     i(int, MUTATOR_ARGV_1_int) \
835     /**/            o(int, MUTATOR_ARGV_1_int) \
836     /** player */   i(entity, MUTATOR_ARGV_2_entity) \
837     /**/
838 MUTATOR_HOOKABLE(FixPlayermodel, EV_FixPlayermodel);
839
840 /** Return error to play frag remaining announcements */
841 MUTATOR_HOOKABLE(Scores_CountFragsRemaining, EV_NO_ARGS);
842
843 #define EV_GrappleHookThink(i, o) \
844     /** hook */                i(entity, MUTATOR_ARGV_0_entity) \
845     /** tarzan */              i(int, MUTATOR_ARGV_1_int) \
846     /**/                       o(int, MUTATOR_ARGV_1_int) \
847     /** pulling entity */      i(entity, MUTATOR_ARGV_2_entity) \
848     /**/                       o(entity, MUTATOR_ARGV_2_entity) \
849     /** velocity multiplier */ i(float, MUTATOR_ARGV_3_float) \
850     /**/                       o(float, MUTATOR_ARGV_3_float) \
851     /**/
852 MUTATOR_HOOKABLE(GrappleHookThink, EV_GrappleHookThink);
853
854 #define EV_BuffModel_Customize(i, o) \
855     /** buff */    i(entity, MUTATOR_ARGV_0_entity) \
856     /** player */  i(entity, MUTATOR_ARGV_1_entity) \
857     /**/
858 MUTATOR_HOOKABLE(BuffModel_Customize, EV_BuffModel_Customize);
859
860 /** called at when a buff is touched. Called early, can edit buff properties. */
861 #define EV_BuffTouch(i, o) \
862     /** buff */    i(entity, MUTATOR_ARGV_0_entity) \
863     /** player */  i(entity, MUTATOR_ARGV_1_entity) \
864     /**/           o(entity, MUTATOR_ARGV_1_entity) \
865     /**/
866 MUTATOR_HOOKABLE(BuffTouch, EV_BuffTouch);
867
868 MUTATOR_HOOKABLE(SetNewParms, EV_NO_ARGS);
869
870 MUTATOR_HOOKABLE(SetChangeParms, EV_NO_ARGS);
871
872 MUTATOR_HOOKABLE(DecodeLevelParms, EV_NO_ARGS);
873
874 #define EV_GetRecords(i, o) \
875     /** page */           i(int, MUTATOR_ARGV_0_int) \
876     /** record list */    i(string, MUTATOR_ARGV_1_string) \
877     /**/                  o(string, MUTATOR_ARGV_1_string) \
878     /**/
879 MUTATOR_HOOKABLE(GetRecords, EV_GetRecords);
880
881 #define EV_Race_FinalCheckpoint(i, o) \
882     /** player */ i(entity, MUTATOR_ARGV_0_entity) \
883     /**/
884 MUTATOR_HOOKABLE(Race_FinalCheckpoint, EV_Race_FinalCheckpoint);
885
886 /** called when player triggered kill (or is changing teams), return error to not do anything */
887 #define EV_ClientKill(i, o) \
888     /** player */        i(entity, MUTATOR_ARGV_0_entity) \
889     /** kill delay */    i(float, MUTATOR_ARGV_1_float) \
890     /**/                 o(float, MUTATOR_ARGV_1_float) \
891     /**/
892 MUTATOR_HOOKABLE(ClientKill, EV_ClientKill);
893
894 /** called when player is about to be killed during kill command or changing teams */
895 #define EV_ClientKill_Now(i, o) \
896     /** player */        i(entity, MUTATOR_ARGV_0_entity) \
897     /**/
898 MUTATOR_HOOKABLE(ClientKill_Now, EV_ClientKill_Now);
899
900 #define EV_FixClientCvars(i, o) \
901     /** player */        i(entity, MUTATOR_ARGV_0_entity) \
902     /**/
903 MUTATOR_HOOKABLE(FixClientCvars, EV_FixClientCvars);
904
905 #define EV_SpectateSet(i, o) \
906     /** client */    i(entity, MUTATOR_ARGV_0_entity) \
907     /** target */    i(entity, MUTATOR_ARGV_1_entity) \
908     /**/             o(entity, MUTATOR_ARGV_1_entity) \
909     /**/
910 MUTATOR_HOOKABLE(SpectateSet, EV_SpectateSet);
911
912 #define EV_SpectateNext(i, o) \
913     /** client */    i(entity, MUTATOR_ARGV_0_entity) \
914     /** target */    i(entity, MUTATOR_ARGV_1_entity) \
915     /**/             o(entity, MUTATOR_ARGV_1_entity) \
916     /**/
917 MUTATOR_HOOKABLE(SpectateNext, EV_SpectateNext);
918
919 #define EV_SpectatePrev(i, o) \
920     /** client */    i(entity, MUTATOR_ARGV_0_entity) \
921     /** target */    i(entity, MUTATOR_ARGV_1_entity) \
922     /**/             o(entity, MUTATOR_ARGV_1_entity) \
923         /** first */     i(entity, MUTATOR_ARGV_2_entity) \
924     /**/
925 MUTATOR_HOOKABLE(SpectatePrev, EV_SpectatePrev);
926
927 enum {
928     MUT_SPECPREV_CONTINUE, // return this flag to make the function continue as normal
929     MUT_SPECPREV_RETURN, // return this flag to make the function return (handled entirely by mutator)
930     MUT_SPECPREV_FOUND // return this flag to make the function continue without default functions (handled mostly by mutator)
931 };
932
933 /** called when player triggered kill (or is changing teams), return error to not do anything */
934 #define EV_Bot_FixCount(i, o) \
935         /** active real players */  i(int, MUTATOR_ARGV_0_int) \
936         /**/                                            o(int, MUTATOR_ARGV_0_int) \
937     /** real players */                 i(int, MUTATOR_ARGV_1_int) \
938     /**/                                        o(int, MUTATOR_ARGV_1_int) \
939     /**/
940 MUTATOR_HOOKABLE(Bot_FixCount, EV_Bot_FixCount);
941
942 #define EV_ClientCommand_Spectate(i, o) \
943     /** player */ i(entity, MUTATOR_ARGV_0_entity) \
944     /**/
945 MUTATOR_HOOKABLE(ClientCommand_Spectate, EV_ClientCommand_Spectate);
946
947 enum {
948     MUT_SPECCMD_CONTINUE, // return this flag to make the function continue as normal
949     MUT_SPECCMD_RETURN, // return this flag to make the function return (don't spectate)
950     MUT_SPECCMD_FORCE // return this flag to force the player to spectate, even if they're not a player
951 };
952
953 #define EV_CheckRules_World(i, o) \
954     /** status */    i(float, MUTATOR_ARGV_0_float) \
955     /**/             o(float, MUTATOR_ARGV_0_float) \
956     /* time limit */ i(float, MUTATOR_ARGV_1_float) \
957     /* frag limit */ i(float, MUTATOR_ARGV_2_float) \
958     /**/
959 MUTATOR_HOOKABLE(CheckRules_World, EV_CheckRules_World);
960
961 #define EV_WantWeapon(i, o) \
962     /** weapon info entity */    i(entity, MUTATOR_ARGV_0_entity) \
963     /** do want? */              i(float, MUTATOR_ARGV_1_float) \
964     /**/                         o(float, MUTATOR_ARGV_1_float) \
965     /** want all guns */         i(bool, MUTATOR_ARGV_2_bool) \
966     /**/                         o(bool, MUTATOR_ARGV_2_bool) \
967     /** want mutator blocked */  i(bool, MUTATOR_ARGV_3_bool) \
968     /**/                         o(bool, MUTATOR_ARGV_3_bool) \
969     /**/
970 MUTATOR_HOOKABLE(WantWeapon, EV_WantWeapon);
971
972 #define EV_AddPlayerScore(i, o) \
973     /** score field */  i(entity, MUTATOR_ARGV_0_entity) \
974     /** score */        i(float, MUTATOR_ARGV_1_float) \
975     /**/                o(float, MUTATOR_ARGV_1_float) \
976     /** player */       i(entity, MUTATOR_ARGV_2_entity) \
977     /**/
978 MUTATOR_HOOKABLE(AddPlayerScore, EV_AddPlayerScore);
979
980 #define EV_AddedPlayerScore(i, o) \
981     /** score field */  i(entity, MUTATOR_ARGV_0_entity) \
982     /** score */        i(float, MUTATOR_ARGV_1_float) \
983     /** player */       i(entity, MUTATOR_ARGV_2_entity) \
984     /**/
985 MUTATOR_HOOKABLE(AddedPlayerScore, EV_AddPlayerScore);
986
987 #define EV_GetPlayerStatus(i, o) \
988     /** player */    i(entity, MUTATOR_ARGV_0_entity) \
989     /**/
990 MUTATOR_HOOKABLE(GetPlayerStatus, EV_GetPlayerStatus);
991
992 #define EV_SetWeaponArena(i, o) \
993     /** arena */     i(string, MUTATOR_ARGV_0_string) \
994     /**/             o(string, MUTATOR_ARGV_0_string) \
995     /**/
996 MUTATOR_HOOKABLE(SetWeaponArena, EV_SetWeaponArena);
997
998 #define EV_DropSpecialItems(i, o) \
999     /** target */ i(entity, MUTATOR_ARGV_0_entity) \
1000     /**/
1001 MUTATOR_HOOKABLE(DropSpecialItems, EV_DropSpecialItems);
1002
1003 /**
1004  * called when an admin tries to kill all monsters
1005  * return 1 to prevent spawning
1006  */
1007 #define EV_AllowMobButcher(i, o) \
1008     /** reason */ o(string, MUTATOR_ARGV_0_string) \
1009     /**/
1010 MUTATOR_HOOKABLE(AllowMobButcher, EV_AllowMobButcher);
1011
1012 MUTATOR_HOOKABLE(ReadLevelCvars, EV_NO_ARGS);
1013
1014 #define EV_SendWaypoint(i, o) \
1015         /** waypoint */     i(entity, MUTATOR_ARGV_0_entity) \
1016         /** to */               i(entity, MUTATOR_ARGV_1_entity) \
1017         /** send flags */   i(int, MUTATOR_ARGV_2_int) \
1018         /**/                            o(int, MUTATOR_ARGV_2_int) \
1019         /** wp flag */      i(int, MUTATOR_ARGV_3_int) \
1020         /**/                            o(int, MUTATOR_ARGV_3_int) \
1021     /**/
1022 MUTATOR_HOOKABLE(SendWaypoint, EV_SendWaypoint);
1023
1024 #define EV_TurretValidateTarget(i, o) \
1025     /** turret */          i(entity, MUTATOR_ARGV_0_entity) \
1026     /** target */          i(entity, MUTATOR_ARGV_1_entity) \
1027     /** validate flags */  i(int, MUTATOR_ARGV_2_int) \
1028     /** target score */    o(float, MUTATOR_ARGV_3_float) \
1029     /**/
1030 MUTATOR_HOOKABLE(TurretValidateTarget, EV_TurretValidateTarget);
1031
1032 #define EV_TurretThink(i, o) \
1033     /** turret */ i(entity, MUTATOR_ARGV_0_entity) \
1034     /**/
1035 MUTATOR_HOOKABLE(TurretThink, EV_TurretThink);
1036
1037 MUTATOR_HOOKABLE(Ent_Init, EV_NO_ARGS);
1038
1039 /** */
1040 #define EV_PrepareExplosionByDamage(i, o) \
1041     /** projectile */ i(entity, MUTATOR_ARGV_0_entity) \
1042     /** attacker */   i(entity, MUTATOR_ARGV_1_entity) \
1043     /**/
1044 MUTATOR_HOOKABLE(PrepareExplosionByDamage, EV_PrepareExplosionByDamage);
1045
1046 /** called when a monster model is about to be set, allows custom paths etc. */
1047 #define EV_MonsterModel(i, o) \
1048         /** model */  i(string, MUTATOR_ARGV_0_string) \
1049         /** output */ i(string, MUTATOR_ARGV_1_string) \
1050         /**/              o(string, MUTATOR_ARGV_1_string) \
1051     /**/
1052 MUTATOR_HOOKABLE(MonsterModel, EV_MonsterModel);
1053
1054 /**
1055  * Called before player changes their team. Return true to block team change.
1056  */
1057 #define EV_Player_ChangeTeam(i, o) \
1058     /** player */             i(entity, MUTATOR_ARGV_0_entity) \
1059     /** current team index */ i(float, MUTATOR_ARGV_1_float) \
1060     /** new team index */     i(float, MUTATOR_ARGV_2_float) \
1061     /**/
1062 MUTATOR_HOOKABLE(Player_ChangeTeam, EV_Player_ChangeTeam);
1063
1064 /**
1065  * Called after player has changed their team.
1066  */
1067 #define EV_Player_ChangedTeam(i, o) \
1068     /** player */             i(entity, MUTATOR_ARGV_0_entity) \
1069     /** old team index */     i(float, MUTATOR_ARGV_1_float) \
1070     /** current team index */ i(float, MUTATOR_ARGV_2_float) \
1071     /**/
1072 MUTATOR_HOOKABLE(Player_ChangedTeam, EV_Player_ChangedTeam);
1073
1074 /**
1075  * Called when player is about to be killed when changing teams. Return true to block killing.
1076  */
1077 #define EV_Player_ChangeTeamKill(i, o) \
1078     /** player */    i(entity, MUTATOR_ARGV_0_entity) \
1079     /**/
1080 MUTATOR_HOOKABLE(Player_ChangeTeamKill, EV_Player_ChangeTeamKill);
1081
1082 /**/
1083 #define EV_URI_GetCallback(i, o) \
1084         /** id */       i(float, MUTATOR_ARGV_0_float) \
1085         /** status */   i(float, MUTATOR_ARGV_1_float) \
1086         /** data */     i(string, MUTATOR_ARGV_2_string) \
1087         /**/
1088 MUTATOR_HOOKABLE(URI_GetCallback, EV_URI_GetCallback);
1089
1090 /**
1091  * return true to lock weapon (can't be used nor changed) for a player
1092  */
1093 #define EV_LockWeapon(i, o) \
1094         /** player */ i(entity, MUTATOR_ARGV_0_entity) \
1095         /**/
1096 MUTATOR_HOOKABLE(LockWeapon, EV_LockWeapon);
1097
1098 /**
1099  * return true to prevent weapon use for a player
1100  */
1101 #define EV_ForbidWeaponUse(i, o) \
1102         /** player */ i(entity, MUTATOR_ARGV_0_entity) \
1103         /**/
1104 MUTATOR_HOOKABLE(ForbidWeaponUse, EV_ForbidWeaponUse);
1105
1106 /** called when creating a clone of the player (usually for corpses that stay after the player has re-spawned) */
1107 #define EV_CopyBody(i, o) \
1108     /** player */               i(entity, MUTATOR_ARGV_0_entity) \
1109     /** newly created clone */  i(entity, MUTATOR_ARGV_1_entity) \
1110     /** keepvelocity? */        i(bool, MUTATOR_ARGV_2_bool) \
1111     /**/
1112 MUTATOR_HOOKABLE(CopyBody, EV_CopyBody);
1113
1114 /** called when sending a chat message, ret argument can be changed to prevent the message */
1115 #define EV_ChatMessage(i, o) \
1116     /** sender */ i(entity, MUTATOR_ARGV_0_entity) \
1117     /** ret */ i(int, MUTATOR_ARGV_1_int) \
1118     /**/ o(int, MUTATOR_ARGV_1_int) \
1119     /**/
1120 MUTATOR_HOOKABLE(ChatMessage, EV_ChatMessage);
1121
1122 /** return true to prevent sending a chat (private, team or regular) message from reaching a certain player */
1123 #define EV_ChatMessageTo(i, o) \
1124     /** destination player */ i(entity, MUTATOR_ARGV_0_entity) \
1125     /** sender */ i(entity, MUTATOR_ARGV_1_entity) \
1126     /**/
1127 MUTATOR_HOOKABLE(ChatMessageTo, EV_ChatMessageTo);
1128
1129 /** return true to just restart the match, for modes that don't support readyrestart */
1130 MUTATOR_HOOKABLE(ReadyRestart_Deny, EV_NO_ARGS);
1131
1132 /** called when a fusion reactor is validating its target */
1133 #define EV_FusionReactor_ValidTarget(i, o) \
1134     /** turret */    i(entity, MUTATOR_ARGV_0_entity) \
1135     /** target */    i(entity, MUTATOR_ARGV_1_entity) \
1136     /**/
1137 MUTATOR_HOOKABLE(FusionReactor_ValidTarget, EV_FusionReactor_ValidTarget);
1138
1139 enum {
1140     MUT_FUSREAC_TARG_CONTINUE, // return this flag to make the function continue as normal
1141     MUT_FUSREAC_TARG_VALID, // return this flag to make the function return true (valid target)
1142     MUT_FUSREAC_TARG_INVALID // return this flag to make the function return false (invalid target)
1143 };
1144
1145 /** return true to hide the 'teamnumbers are imbalanced' message */
1146 #define EV_HideTeamNagger(i, o) \
1147     /** player */ i(entity, MUTATOR_ARGV_0_entity) \
1148     /**/
1149 MUTATOR_HOOKABLE(HideTeamNagger, EV_HideTeamNagger);
1150
1151 /** return true to show a waypoint while the item is spawning */
1152 #define EV_Item_ScheduleRespawn(i, o) \
1153     /** item */             i(entity, MUTATOR_ARGV_0_entity) \
1154     /** respawn time */     i(float, MUTATOR_ARGV_1_float) \
1155     /**/
1156 MUTATOR_HOOKABLE(Item_ScheduleRespawn, EV_Item_ScheduleRespawn);
1157
1158 /** called before physics stats are set on a player, allows limited early customization */
1159 #define EV_PlayerPhysics_UpdateStats(i, o) \
1160     /** player */             i(entity, MUTATOR_ARGV_0_entity) \
1161     /**/
1162 MUTATOR_HOOKABLE(PlayerPhysics_UpdateStats, EV_PlayerPhysics_UpdateStats);
1163
1164 /** called after physics stats are set on a player, allows post-initialization modifications */
1165 #define EV_PlayerPhysics_PostUpdateStats(i, o) \
1166     /** player */             i(entity, MUTATOR_ARGV_0_entity) \
1167     /** maxspeed_mod */       i(float, MUTATOR_ARGV_1_float) \
1168     /**/
1169 MUTATOR_HOOKABLE(PlayerPhysics_PostUpdateStats, EV_PlayerPhysics_PostUpdateStats);
1170
1171 /** return true to use your own aim target (or none at all) */
1172 #define EV_HavocBot_Aim(i, o) \
1173     /** bot */ i(entity, MUTATOR_ARGV_0_entity) \
1174     /**/
1175 MUTATOR_HOOKABLE(HavocBot_Aim, EV_HavocBot_Aim);
1176
1177 /** return true to skip respawn time calculations */
1178 #define EV_CalculateRespawnTime(i, o) \
1179     /** player */ i(entity, MUTATOR_ARGV_0_entity) \
1180     /**/
1181 MUTATOR_HOOKABLE(CalculateRespawnTime, EV_CalculateRespawnTime);
1182
1183 /** called when parsing a vote command. */
1184 #define EV_VoteCommand_Parse(i, o) \
1185     /** caller */                           i(entity, MUTATOR_ARGV_0_entity) \
1186     /** first command */                    i(string, MUTATOR_ARGV_1_string) \
1187     /** vote command */                     i(string, MUTATOR_ARGV_2_string) \
1188     /** start position of vote command */   i(float, MUTATOR_ARGV_3_float) \
1189     /** argument count */                   i(float, MUTATOR_ARGV_4_float) \
1190     /**/
1191 MUTATOR_HOOKABLE(VoteCommand_Parse, EV_VoteCommand_Parse);
1192
1193 enum {
1194     MUT_VOTEPARSE_CONTINUE, // return this flag to make the function continue as normal
1195     MUT_VOTEPARSE_SUCCESS, // return 1 (vote parsed)
1196     MUT_VOTEPARSE_INVALID, // return -1 (vote parsed but counted as invalid, no action or vote)
1197     MUT_VOTEPARSE_UNACCEPTABLE // return 0 (vote parameter counted as unacceptable, warns caller)
1198 };
1199
1200 /**
1201  * Called when freezing an entity (monster or player), return true to force showing a waypoint
1202  */
1203 #define EV_Freeze(i, o) \
1204     /** targ */             i(entity, MUTATOR_ARGV_0_entity) \
1205     /** revive speed */     i(float, MUTATOR_ARGV_1_float) \
1206     /** frozen type */      i(int, MUTATOR_ARGV_2_int) \
1207     /**/
1208 MUTATOR_HOOKABLE(Freeze, EV_Freeze);
1209
1210 /**
1211  * Called when an entity (monster or player) is defrosted
1212  */
1213 #define EV_Unfreeze(i, o) \
1214     /** targ */             i(entity, MUTATOR_ARGV_0_entity) \
1215     /**/
1216 MUTATOR_HOOKABLE(Unfreeze, EV_Unfreeze);
1217
1218 /**
1219  * Called when a player is trying to join, argument is the number of players allowed to join the match
1220  */
1221 #define EV_GetPlayerLimit(i, o) \
1222     /** g_maxplayers */             i(int, MUTATOR_ARGV_0_int) \
1223     /**/                            o(int, MUTATOR_ARGV_0_int) \
1224     /**/
1225 MUTATOR_HOOKABLE(GetPlayerLimit, EV_GetPlayerLimit);
1226
1227 /** include special item codes for a death to the game log */
1228 #define EV_LogDeath_AppendItemCodes(i, o) \
1229     /** player */         i(entity, MUTATOR_ARGV_0_entity) \
1230     /** item codes */     i(string, MUTATOR_ARGV_1_string) \
1231     /**/                  o(string, MUTATOR_ARGV_1_string) \
1232     /**/
1233 MUTATOR_HOOKABLE(LogDeath_AppendItemCodes, EV_LogDeath_AppendItemCodes);