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