]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/mutators/events.qh
Merge branch 'terencehill/lms_spectatable' into 'master'
[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 his 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 he was 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 he was 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 /** is meant to call GetCvars_handle*(get_cvars_s, get_cvars_f, cvarfield, "cvarname") for cvars this mutator needs from the client */
321 // NOTE: requesting cvar values (get_cvars_f 0) is deprecated
322 #define EV_GetCvars(i, o) \
323     /**/ i(float, get_cvars_f) \
324     /**/ i(string, get_cvars_s) \
325     /**/
326 float get_cvars_f;
327 string get_cvars_s;
328 MUTATOR_HOOKABLE(GetCvars, EV_NO_ARGS); // NOTE: Can't use EV_GetCvars because of `SZ_GetSpace: overflow`
329
330 /** can edit any "just fired" projectile */
331 #define EV_EditProjectile(i, o) \
332     /** projectile owner */ i(entity, MUTATOR_ARGV_0_entity) \
333     /** projectile */ i(entity, MUTATOR_ARGV_1_entity) \
334     /**/
335 MUTATOR_HOOKABLE(EditProjectile, EV_EditProjectile);
336
337 /** called when a monster spawns */
338 #define EV_MonsterSpawn(i, o) \
339     /** monster */ i(entity, MUTATOR_ARGV_0_entity) \
340     /**/
341 MUTATOR_HOOKABLE(MonsterSpawn, EV_MonsterSpawn);
342
343 /** called when a monster dies */
344 #define EV_MonsterDies(i, o) \
345     /** target       */ i(entity, MUTATOR_ARGV_0_entity) \
346     /** attacker     */ i(entity, MUTATOR_ARGV_1_entity) \
347     /** deathtype    */ i(float, MUTATOR_ARGV_2_float) \
348     /**/
349 MUTATOR_HOOKABLE(MonsterDies, EV_MonsterDies);
350
351 /** called when a monster dies */
352 #define EV_MonsterRemove(i, o) \
353     /** monster */ i(entity, MUTATOR_ARGV_0_entity) \
354     /**/
355 MUTATOR_HOOKABLE(MonsterRemove, EV_MonsterRemove);
356
357 /** called when a monster wants to respawn */
358 #define EV_MonsterRespawn(i, o) \
359     /** monster */ i(entity, MUTATOR_ARGV_0_entity) \
360     /**/
361 MUTATOR_HOOKABLE(MonsterRespawn, EV_MonsterRespawn);
362
363 /** called when a monster is dropping loot */
364 #define EV_MonsterDropItem(i, o) \
365     /* monster */                          i(entity, MUTATOR_ARGV_0_entity) \
366     /* item (can be removed or changed) */ i(entity, MUTATOR_ARGV_1_entity) \
367     /**/                                   o(entity, MUTATOR_ARGV_1_entity) \
368     /* attacker */                         i(entity, MUTATOR_ARGV_2_entity) \
369     /**/
370 .entity monster_loot;
371 MUTATOR_HOOKABLE(MonsterDropItem, EV_MonsterDropItem);
372
373 /**
374  * called when a monster moves
375  * returning true makes the monster stop
376  */
377 #define EV_MonsterMove(i, o) \
378     /** monster */       i(entity, MUTATOR_ARGV_0_entity) \
379     /** run speed */     i(float, MUTATOR_ARGV_1_float) \
380     /**/                 o(float, MUTATOR_ARGV_1_float) \
381     /** walk speed */    i(float, MUTATOR_ARGV_2_float) \
382     /**/                 o(float, MUTATOR_ARGV_2_float) \
383     /** move target */   i(entity, MUTATOR_ARGV_3_entity) \
384     /**/                 o(entity, MUTATOR_ARGV_3_entity) \
385     /**/
386 MUTATOR_HOOKABLE(MonsterMove, EV_MonsterMove);
387
388 /** called when a monster looks for another target */
389 MUTATOR_HOOKABLE(MonsterFindTarget, EV_NO_ARGS);
390
391 /**
392  * called when validating a monster's target
393  */
394 #define EV_MonsterValidTarget(i, o) \
395     /** monster */       i(entity, MUTATOR_ARGV_0_entity) \
396     /** target */        i(entity, MUTATOR_ARGV_1_entity) \
397     /**/
398 MUTATOR_HOOKABLE(MonsterValidTarget, EV_MonsterValidTarget);
399
400 /** called to change a random monster to a miniboss */
401 #define EV_MonsterCheckBossFlag(i, o) \
402     /** monster */ i(entity, MUTATOR_ARGV_0_entity) \
403     /**/
404 MUTATOR_HOOKABLE(MonsterCheckBossFlag, EV_MonsterCheckBossFlag);
405
406 /**
407  * called when a player tries to spawn a monster
408  * return 1 to prevent spawning
409  * NOTE: requires reason if disallowed
410  */
411  #define EV_AllowMobSpawning(i, o) \
412     /** caller */ i(entity, MUTATOR_ARGV_0_entity) \
413     /** reason */ o(string, MUTATOR_ARGV_1_string) \
414     /**/
415 MUTATOR_HOOKABLE(AllowMobSpawning, EV_AllowMobSpawning);
416
417 /** called when a player gets damaged to e.g. remove stuff he was carrying. */
418 #define EV_PlayerDamage_SplitHealthArmor(i, o) \
419         /** inflictor           */ i(entity, MUTATOR_ARGV_0_entity) \
420     /** attacker        */ i(entity, MUTATOR_ARGV_1_entity) \
421     /** target                  */ i(entity, MUTATOR_ARGV_2_entity) \
422     /** force (no out)  */ i(vector, MUTATOR_ARGV_3_vector) \
423     /** damage take     */ i(float,  MUTATOR_ARGV_4_float) \
424     /** damage take     */ o(float,  MUTATOR_ARGV_4_float) \
425     /** damage save     */ i(float,  MUTATOR_ARGV_5_float) \
426     /** damage save     */ o(float,  MUTATOR_ARGV_5_float) \
427     /** deathtype               */ i(float,  MUTATOR_ARGV_6_float) \
428     /** damage              */ i(float,  MUTATOR_ARGV_7_float) \
429     /**/
430 MUTATOR_HOOKABLE(PlayerDamage_SplitHealthArmor, EV_PlayerDamage_SplitHealthArmor);
431
432 /**
433  * called to adjust damage and force values which are applied to the player, used for e.g. strength damage/force multiplier
434  * i'm not sure if I should change this around slightly (Naming of the entities, and also how they're done in g_damage).
435  */
436 #define EV_Damage_Calculate(i, o) \
437     /** inflictor               */ i(entity, MUTATOR_ARGV_0_entity) \
438     /** attacker        */ i(entity, MUTATOR_ARGV_1_entity) \
439     /** target                  */ i(entity, MUTATOR_ARGV_2_entity) \
440     /** deathtype       */ i(float,  MUTATOR_ARGV_3_float) \
441     /** damage          */ i(float,  MUTATOR_ARGV_4_float) \
442     /** damage                  */ o(float,  MUTATOR_ARGV_4_float) \
443     /** mirrordamage    */ i(float,  MUTATOR_ARGV_5_float) \
444     /** mirrordamage    */ o(float,  MUTATOR_ARGV_5_float) \
445     /** force           */ i(vector, MUTATOR_ARGV_6_vector) \
446     /** force           */ o(vector, MUTATOR_ARGV_6_vector) \
447     /** weapon entity   */ i(entity, MUTATOR_ARGV_7_entity) \
448     /**/
449 MUTATOR_HOOKABLE(Damage_Calculate, EV_Damage_Calculate);
450
451 /**
452  * Called when a player is damaged
453  * Returns true if damage shouldn't be logged
454  */
455 #define EV_PlayerDamaged(i, o) \
456     /** attacker  */ i(entity, MUTATOR_ARGV_0_entity) \
457     /** target    */ i(entity, MUTATOR_ARGV_1_entity) \
458     /** health    */ i(float,    MUTATOR_ARGV_2_float) \
459     /** armor     */ i(float,    MUTATOR_ARGV_3_float) \
460     /** location  */ i(vector, MUTATOR_ARGV_4_vector) \
461     /** deathtype */ i(int,    MUTATOR_ARGV_5_int) \
462     /** potential_damage     */ i(float,    MUTATOR_ARGV_6_float) \
463     /**/
464 MUTATOR_HOOKABLE(PlayerDamaged, EV_PlayerDamaged);
465
466 /**
467  * Called by W_DecreaseAmmo
468  */
469 #define EV_W_DecreaseAmmo(i, o) \
470     /** actor */            i(entity, MUTATOR_ARGV_0_entity) \
471     /** weapon entity */    i(entity, MUTATOR_ARGV_1_entity) \
472     /** ammo to take */     i(float, MUTATOR_ARGV_2_float) \
473     /**/                    o(float, MUTATOR_ARGV_2_float) \
474     /**/
475 MUTATOR_HOOKABLE(W_DecreaseAmmo, EV_W_DecreaseAmmo);
476
477 /**
478  * Called by W_Reload
479  */
480 #define EV_W_Reload(i, o) \
481     /** actor */ i(entity, MUTATOR_ARGV_0_entity) \
482     /**/
483 MUTATOR_HOOKABLE(W_Reload, EV_W_Reload);
484
485 /** called at the end of player_powerups() in client.qc, used for manipulating the values which are set by powerup items. */
486 #define EV_PlayerPowerups(i, o) \
487     /** player */    i(entity, MUTATOR_ARGV_0_entity) \
488     /** old items */ i(int, MUTATOR_ARGV_1_int) \
489     /**/
490 MUTATOR_HOOKABLE(PlayerPowerups, EV_PlayerPowerups);
491
492 /**
493  * called every player think frame
494  * return 1 to disable regen
495  */
496  #define EV_PlayerRegen(i, o) \
497     /** player */               i(entity, MUTATOR_ARGV_0_entity) \
498     /** max_mod */              i(float, MUTATOR_ARGV_1_float) \
499     /**/                        o(float, MUTATOR_ARGV_1_float) \
500     /** regen_mod */            i(float, MUTATOR_ARGV_2_float) \
501     /**/                        o(float, MUTATOR_ARGV_2_float) \
502     /** rot_mod */              i(float, MUTATOR_ARGV_3_float) \
503     /**/                        o(float, MUTATOR_ARGV_3_float) \
504     /** limit_mod */            i(float, MUTATOR_ARGV_4_float) \
505     /**/                        o(float, MUTATOR_ARGV_4_float) \
506     /** health_regen */         i(float, MUTATOR_ARGV_5_float) \
507     /**/                        o(float, MUTATOR_ARGV_5_float) \
508     /** health_regenlinear */   i(float, MUTATOR_ARGV_6_float) \
509     /**/                        o(float, MUTATOR_ARGV_6_float) \
510     /** health_rot */           i(float, MUTATOR_ARGV_7_float) \
511     /**/                        o(float, MUTATOR_ARGV_7_float) \
512     /** health_rotlinear */     i(float, MUTATOR_ARGV_8_float) \
513     /**/                        o(float, MUTATOR_ARGV_8_float) \
514     /** health_stable */        i(float, MUTATOR_ARGV_9_float) \
515     /**/                        o(float, MUTATOR_ARGV_9_float) \
516     /** health_rotstable */     i(float, MUTATOR_ARGV_10_float) \
517     /**/                        o(float, MUTATOR_ARGV_10_float) \
518     /**/
519 MUTATOR_HOOKABLE(PlayerRegen, EV_PlayerRegen);
520
521 /**
522  * called when the use key is pressed
523  * if MUTATOR_RETURNVALUE is 1, don't do anything
524  * return 1 if the use key actually did something
525  */
526  #define EV_PlayerUseKey(i, o) \
527     /** player */ i(entity, MUTATOR_ARGV_0_entity) \
528     /**/
529 MUTATOR_HOOKABLE(PlayerUseKey, EV_PlayerUseKey);
530
531 /**
532  * called when a client command is parsed
533  * NOTE: hooks MUST start with if (MUTATOR_RETURNVALUE) return false;
534  * NOTE: return true if you handled the command, return false to continue handling
535  * NOTE: THESE HOOKS MUST NEVER EVER CALL tokenize()
536  * // example:
537  * MUTATOR_HOOKFUNCTION(foo_SV_ParseClientCommand)
538  * {
539  *     if (MUTATOR_RETURNVALUE) // command was already handled?
540  *         return false;
541  *     if (cmd_name == "echocvar" && cmd_argc >= 2)
542  *     {
543  *         print(cvar_string(argv(1)), "\n");
544  *         return true;
545  *     }
546  *     if (cmd_name == "echostring" && cmd_argc >= 2)
547  *     {
548  *         print(substring(cmd_string, argv_start_index(1), argv_end_index(-1) - argv_start_index(1)), "\n");
549  *         return true;
550  *     }
551  *     return false;
552  * }
553  */
554 #define EV_SV_ParseClientCommand(i, o) \
555         /** client sending the command */       i(entity, MUTATOR_ARGV_0_entity) \
556     /** command name */                     i(string, MUTATOR_ARGV_1_string) \
557         /** argc (also, argv() can be used) */  i(int, MUTATOR_ARGV_2_int) \
558         /** whole command, use only if you really have to */ i(string, MUTATOR_ARGV_3_string) \
559     /**/
560 MUTATOR_HOOKABLE(SV_ParseClientCommand, EV_SV_ParseClientCommand);
561
562 /** please read EV_SV_ParseClientCommand description before using */
563 #define EV_SV_ParseServerCommand(i, o) \
564    /** command name */ i(string, MUTATOR_ARGV_0_string) \
565         /** argc (also, argv() can be used) */ i(int, MUTATOR_ARGV_1_int) \
566         /** whole command, use only if you really have to */ i(string, MUTATOR_ARGV_2_string) \
567     /**/
568 MUTATOR_HOOKABLE(SV_ParseServerCommand, EV_SV_ParseServerCommand);
569
570 /**
571  * called when a spawnpoint is being evaluated
572  * return 1 to make the spawnpoint unusable
573  */
574 #define EV_Spawn_Score(i, o) \
575     /** player wanting to spawn */ i(entity, MUTATOR_ARGV_0_entity) \
576     /** spot to be evaluated */ i(entity, MUTATOR_ARGV_1_entity) \
577     /** spot score, _x is priority, _y is "distance" */ i(vector, MUTATOR_ARGV_2_vector) \
578     /**/ o(vector, MUTATOR_ARGV_2_vector) \
579     /**/
580 MUTATOR_HOOKABLE(Spawn_Score, EV_Spawn_Score);
581
582 /** runs globally each server frame */
583 MUTATOR_HOOKABLE(SV_StartFrame, EV_NO_ARGS);
584
585 #define EV_SetModname(i, o) \
586     /** name of the mutator/mod if it warrants showing as such in the server browser */ \
587     /**/ i(string, MUTATOR_ARGV_0_string) \
588     /**/ o(string, MUTATOR_ARGV_0_string) \
589     /**/
590 MUTATOR_HOOKABLE(SetModname, EV_SetModname);
591
592 /**
593  * called for each item being spawned on a map, including dropped weapons
594  * return 1 to remove an item
595  */
596 #define EV_Item_Spawn(i, o) \
597     /** item */ i(entity, MUTATOR_ARGV_0_entity) \
598     /**/
599 MUTATOR_HOOKABLE(Item_Spawn, EV_Item_Spawn);
600
601 #define EV_SetWeaponreplace(i, o) \
602     /** map entity */  i(entity, MUTATOR_ARGV_0_entity) \
603     /** weapon info */ i(entity, MUTATOR_ARGV_1_entity) \
604     /** replacement */ i(string, MUTATOR_ARGV_2_string) \
605     /**/               o(string, MUTATOR_ARGV_2_string) \
606     /**/
607 MUTATOR_HOOKABLE(SetWeaponreplace, EV_SetWeaponreplace);
608
609 /** called when an item is about to respawn */
610 #define EV_Item_RespawnCountdown(i, o) \
611     /** item */   i(entity, MUTATOR_ARGV_0_entity) \
612     /**/
613 MUTATOR_HOOKABLE(Item_RespawnCountdown, EV_Item_RespawnCountdown);
614
615 /** called when a bot checks a target to attack */
616 #define EV_BotShouldAttack(i, o) \
617     /** bot */    i(entity, MUTATOR_ARGV_0_entity) \
618     /** target */ i(entity, MUTATOR_ARGV_1_entity) \
619     /**/
620 MUTATOR_HOOKABLE(BotShouldAttack, EV_BotShouldAttack);
621
622 /**
623  * called whenever a player goes through a portal gun teleport
624  * allows you to strip a player of an item if they go through the teleporter to help prevent cheating
625  */
626 #define EV_PortalTeleport(i, o) \
627     /** player */ i(entity, MUTATOR_ARGV_0_entity) \
628     /**/
629 MUTATOR_HOOKABLE(PortalTeleport, EV_PortalTeleport);
630
631 /**
632  * called whenever a player uses impulse 33 (help me) in impulse.qc
633  * normally help me ping uses .waypointsprite_attachedforcarrier,
634  * but if your mutator uses something different then you can handle it
635  * in a special manner using this hook
636  */
637 #define EV_HelpMePing(i, o) \
638     /** the player who pressed impulse 33 */ i(entity, MUTATOR_ARGV_0_entity) \
639     /**/
640 MUTATOR_HOOKABLE(HelpMePing, EV_HelpMePing);
641
642 /**
643  * called when a vehicle initializes
644  * return true to remove the vehicle
645  */
646 #define EV_VehicleInit(i, o) \
647     /** vehicle */ i(entity, MUTATOR_ARGV_0_entity) \
648     /**/
649 MUTATOR_HOOKABLE(VehicleInit, EV_VehicleInit);
650
651 /**
652  * called when a player enters a vehicle
653  * allows mutators to set special settings in this event
654  */
655 #define EV_VehicleEnter(i, o) \
656     /** player */ i(entity, MUTATOR_ARGV_0_entity) \
657     /** vehicle */ i(entity, MUTATOR_ARGV_1_entity) \
658     /**/
659 MUTATOR_HOOKABLE(VehicleEnter, EV_VehicleEnter);
660
661 /**
662  * called when a player touches a vehicle
663  * return true to stop player from entering the vehicle
664  */
665 #define EV_VehicleTouch(i, o) \
666     /** vehicle */ i(entity, MUTATOR_ARGV_0_entity) \
667     /** player */ i(entity, MUTATOR_ARGV_1_entity) \
668     /**/
669 MUTATOR_HOOKABLE(VehicleTouch, EV_VehicleTouch);
670
671 /**
672  * called when a player exits a vehicle
673  * allows mutators to set special settings in this event
674  */
675 #define EV_VehicleExit(i, o) \
676     /** player */ i(entity, MUTATOR_ARGV_0_entity) \
677     /** vehicle */ i(entity, MUTATOR_ARGV_1_entity) \
678     /**/
679 MUTATOR_HOOKABLE(VehicleExit, EV_VehicleExit);
680
681 /** called when a speedrun is aborted and the player is teleported back to start position */
682 #define EV_AbortSpeedrun(i, o) \
683     /** player */ i(entity, MUTATOR_ARGV_0_entity) \
684     /**/
685 MUTATOR_HOOKABLE(AbortSpeedrun, EV_AbortSpeedrun);
686
687 /** called at when a item is touched. Called early, can edit item properties. */
688 #define EV_ItemTouch(i, o) \
689     /** item */    i(entity, MUTATOR_ARGV_0_entity) \
690     /** toucher */ i(entity, MUTATOR_ARGV_1_entity) \
691     /**/           o(entity, MUTATOR_ARGV_1_entity) \
692     /**/
693 MUTATOR_HOOKABLE(ItemTouch, EV_ItemTouch);
694
695 enum {
696         MUT_ITEMTOUCH_CONTINUE, // return this flag to make the function continue as normal
697         MUT_ITEMTOUCH_RETURN, // return this flag to make the function return (handled entirely by mutator)
698         MUT_ITEMTOUCH_PICKUP // return this flag to have the item "picked up" and taken even after mutator handled it
699 };
700
701 /** called after the item has been touched. */
702 #define EV_ItemTouched(i, o) \
703     /** item */    i(entity, MUTATOR_ARGV_0_entity) \
704     /** toucher */ i(entity, MUTATOR_ARGV_1_entity) \
705     /**/
706 MUTATOR_HOOKABLE(ItemTouched, EV_ItemTouched);
707
708 /** Called when the amount of entity resources changes. Can be used to override
709 resource limit. */
710 #define EV_GetResourceLimit(i, o) \
711         /** checked entity */ i(entity, MUTATOR_ARGV_0_entity) \
712         /** resource type */  i(int, MUTATOR_ARGV_1_int) \
713         /** limit */          i(float, MUTATOR_ARGV_2_float) \
714         /**/                  o(float, MUTATOR_ARGV_2_float) \
715         /**/
716 MUTATOR_HOOKABLE(GetResourceLimit, EV_GetResourceLimit);
717
718 /** Called when the amount of resource of an entity changes. See RES_*
719 constants for resource types. Return true to forbid the change. */
720 #define EV_SetResource(i, o) \
721         /** checked entity */ i(entity, MUTATOR_ARGV_0_entity) \
722         /** resource type */  i(int, MUTATOR_ARGV_1_int) \
723         /**/                  o(int, MUTATOR_ARGV_1_int) \
724         /** amount */         i(float, MUTATOR_ARGV_2_float) \
725         /**/                  o(float, MUTATOR_ARGV_2_float) \
726         /**/
727 MUTATOR_HOOKABLE(SetResource, EV_SetResource);
728
729 /** Called after the amount of resource of an entity has changed. See RES_*
730 constants for resource types. Amount wasted is the amount of resource that is
731 above resource limit so it was not given. */
732 #define EV_ResourceAmountChanged(i, o) \
733         /** checked entity */ i(entity, MUTATOR_ARGV_0_entity) \
734         /** resource type */  i(int, MUTATOR_ARGV_1_int) \
735         /** amount */         i(float, MUTATOR_ARGV_2_float) \
736         /**/
737 MUTATOR_HOOKABLE(ResourceAmountChanged, EV_ResourceAmountChanged);
738
739 /** Called when there was an attempt to set entity resources higher than their
740 limit. See RES_* constants for resource types. Amount wasted is the amount
741 of resource that is above resource limit so it was not given. */
742 #define EV_ResourceWasted(i, o) \
743         /** checked entity */ i(entity, MUTATOR_ARGV_0_entity) \
744         /** resource type */  i(int, MUTATOR_ARGV_1_int) \
745         /** amount wasted */  i(float, MUTATOR_ARGV_2_float) \
746         /**/
747 MUTATOR_HOOKABLE(ResourceWasted, EV_ResourceWasted);
748
749 /** Called when entity is being given some resource. See RES_* constants
750 for resource types. Return true to forbid giving.
751 NOTE: This hook is also called by GiveResourceWithLimit */
752 #define EV_GiveResource(i, o) \
753         /** receiver */      i(entity, MUTATOR_ARGV_0_entity) \
754         /** resource type */ i(int, MUTATOR_ARGV_1_int) \
755         /**/                 o(int, MUTATOR_ARGV_1_int) \
756         /** amount */        i(float, MUTATOR_ARGV_2_float) \
757         /**/                 o(float, MUTATOR_ARGV_2_float) \
758         /**/
759 MUTATOR_HOOKABLE(GiveResource, EV_GiveResource);
760
761 /** Called when entity is being given some resource with specified limit. See
762 RES_* constants for resource types. Return true to forbid giving. */
763 #define EV_GiveResourceWithLimit(i, o) \
764         /** receiver */      i(entity, MUTATOR_ARGV_0_entity) \
765         /** resource type */ i(int, MUTATOR_ARGV_1_int) \
766         /**/                 o(int, MUTATOR_ARGV_1_int) \
767         /** amount */        i(float, MUTATOR_ARGV_2_float) \
768         /**/                 o(float, MUTATOR_ARGV_2_float) \
769         /** limit */         i(float, MUTATOR_ARGV_3_float) \
770         /**/                 o(float, MUTATOR_ARGV_3_float) \
771         /**/
772 MUTATOR_HOOKABLE(GiveResourceWithLimit, EV_GiveResourceWithLimit);
773
774 /** Called when some resource is being taken from an entity. See RES_* constants
775 for resource types. Return true to forbid giving.
776 NOTE: This hook is also called by TakeResourceWithLimit */
777 #define EV_TakeResource(i, o) \
778     /** receiver */      i(entity, MUTATOR_ARGV_0_entity) \
779     /** resource type */ i(int, MUTATOR_ARGV_1_int) \
780     /**/                 o(int, MUTATOR_ARGV_1_int) \
781     /** amount */        i(float, MUTATOR_ARGV_2_float) \
782     /**/                 o(float, MUTATOR_ARGV_2_float) \
783     /**/
784 MUTATOR_HOOKABLE(TakeResource, EV_TakeResource);
785
786 /** Called when some resource is being taken from an entity, with a limit. See
787 RES_* constants for resource types. Return true to forbid giving. */
788 #define EV_TakeResourceWithLimit(i, o) \
789     /** receiver */      i(entity, MUTATOR_ARGV_0_entity) \
790     /** resource type */ i(int, MUTATOR_ARGV_1_int) \
791     /**/                 o(int, MUTATOR_ARGV_1_int) \
792     /** amount */        i(float, MUTATOR_ARGV_2_float) \
793     /**/                 o(float, MUTATOR_ARGV_2_float) \
794     /** limit */         i(float, MUTATOR_ARGV_3_float) \
795     /**/                 o(float, MUTATOR_ARGV_3_float) \
796     /**/
797 MUTATOR_HOOKABLE(TakeResourceWithLimit, EV_TakeResourceWithLimit);
798
799 /** called at when a player connect */
800 #define EV_ClientConnect(i, o) \
801     /** player */ i(entity, MUTATOR_ARGV_0_entity) \
802     /**/
803 MUTATOR_HOOKABLE(ClientConnect, EV_ClientConnect);
804
805 #define EV_HavocBot_ChooseRole(i, o) \
806     /** bot */ i(entity, MUTATOR_ARGV_0_entity) \
807     /**/
808 MUTATOR_HOOKABLE(HavocBot_ChooseRole, EV_HavocBot_ChooseRole);
809
810 /** called when a target is checked for accuracy */
811 #define EV_AccuracyTargetValid(i, o) \
812     /** attacker */ i(entity, MUTATOR_ARGV_0_entity) \
813     /** target */ i(entity, MUTATOR_ARGV_1_entity) \
814     /**/
815 MUTATOR_HOOKABLE(AccuracyTargetValid, EV_AccuracyTargetValid);
816 enum {
817         MUT_ACCADD_VALID, // return this flag to make the function continue if target is a client
818         MUT_ACCADD_INVALID, // return this flag to make the function always continue
819         MUT_ACCADD_INDIFFERENT // return this flag to make the function always return
820 };
821
822 /** Called when clearing the global parameters for a model */
823 MUTATOR_HOOKABLE(ClearModelParams, EV_NO_ARGS);
824
825 /** Called when getting the global parameters for a model */
826 #define EV_GetModelParams(i, o) \
827     /** input */   i(string, MUTATOR_ARGV_0_string) \
828     /** command */ i(string, MUTATOR_ARGV_1_string) \
829     /**/
830 MUTATOR_HOOKABLE(GetModelParams, EV_GetModelParams);
831
832 /** called when a bullet has hit a target */
833 #define EV_FireBullet_Hit(i, o) \
834     /** player */       i(entity, MUTATOR_ARGV_0_entity) \
835     /** targ */         i(entity, MUTATOR_ARGV_1_entity) \
836     /** start pos */    i(vector, MUTATOR_ARGV_2_vector) \
837     /** end pos */      i(vector, MUTATOR_ARGV_3_vector) \
838     /** damage */       i(float, MUTATOR_ARGV_4_float) \
839     /**/                o(float, MUTATOR_ARGV_4_float) \
840     /** wep entity */   i(entity, MUTATOR_ARGV_5_entity) \
841     /**/
842 MUTATOR_HOOKABLE(FireBullet_Hit, EV_FireBullet_Hit);
843
844 #define EV_FixPlayermodel(i, o) \
845     /** model */    i(string, MUTATOR_ARGV_0_string) \
846     /**/            o(string, MUTATOR_ARGV_0_string) \
847     /** skin */     i(int, MUTATOR_ARGV_1_int) \
848     /**/            o(int, MUTATOR_ARGV_1_int) \
849     /** player */   i(entity, MUTATOR_ARGV_2_entity) \
850     /**/
851 MUTATOR_HOOKABLE(FixPlayermodel, EV_FixPlayermodel);
852
853 /** Return error to play frag remaining announcements */
854 MUTATOR_HOOKABLE(Scores_CountFragsRemaining, EV_NO_ARGS);
855
856 #define EV_GrappleHookThink(i, o) \
857     /** hook */                i(entity, MUTATOR_ARGV_0_entity) \
858     /** tarzan */              i(int, MUTATOR_ARGV_1_int) \
859     /**/                       o(int, MUTATOR_ARGV_1_int) \
860     /** pulling entity */      i(entity, MUTATOR_ARGV_2_entity) \
861     /**/                       o(entity, MUTATOR_ARGV_2_entity) \
862     /** velocity multiplier */ i(float, MUTATOR_ARGV_3_float) \
863     /**/                       o(float, MUTATOR_ARGV_3_float) \
864     /**/
865 MUTATOR_HOOKABLE(GrappleHookThink, EV_GrappleHookThink);
866
867 #define EV_BuffModel_Customize(i, o) \
868     /** buff */    i(entity, MUTATOR_ARGV_0_entity) \
869     /** player */  i(entity, MUTATOR_ARGV_1_entity) \
870     /**/
871 MUTATOR_HOOKABLE(BuffModel_Customize, EV_BuffModel_Customize);
872
873 /** called at when a buff is touched. Called early, can edit buff properties. */
874 #define EV_BuffTouch(i, o) \
875     /** buff */    i(entity, MUTATOR_ARGV_0_entity) \
876     /** player */  i(entity, MUTATOR_ARGV_1_entity) \
877     /**/           o(entity, MUTATOR_ARGV_1_entity) \
878     /**/
879 MUTATOR_HOOKABLE(BuffTouch, EV_BuffTouch);
880
881 MUTATOR_HOOKABLE(SetNewParms, EV_NO_ARGS);
882
883 MUTATOR_HOOKABLE(SetChangeParms, EV_NO_ARGS);
884
885 MUTATOR_HOOKABLE(DecodeLevelParms, EV_NO_ARGS);
886
887 #define EV_GetRecords(i, o) \
888     /** page */           i(int, MUTATOR_ARGV_0_int) \
889     /** record list */    i(string, MUTATOR_ARGV_1_string) \
890     /**/                  o(string, MUTATOR_ARGV_1_string) \
891     /**/
892 MUTATOR_HOOKABLE(GetRecords, EV_GetRecords);
893
894 #define EV_Race_FinalCheckpoint(i, o) \
895     /** player */ i(entity, MUTATOR_ARGV_0_entity) \
896     /**/
897 MUTATOR_HOOKABLE(Race_FinalCheckpoint, EV_Race_FinalCheckpoint);
898
899 /** called when player triggered kill (or is changing teams), return error to not do anything */
900 #define EV_ClientKill(i, o) \
901     /** player */        i(entity, MUTATOR_ARGV_0_entity) \
902     /** kill delay */    i(float, MUTATOR_ARGV_1_float) \
903     /**/                 o(float, MUTATOR_ARGV_1_float) \
904     /**/
905 MUTATOR_HOOKABLE(ClientKill, EV_ClientKill);
906
907 /** called when player is about to be killed during kill command or changing teams */
908 #define EV_ClientKill_Now(i, o) \
909     /** player */        i(entity, MUTATOR_ARGV_0_entity) \
910     /**/
911 MUTATOR_HOOKABLE(ClientKill_Now, EV_ClientKill_Now);
912
913 #define EV_FixClientCvars(i, o) \
914     /** player */        i(entity, MUTATOR_ARGV_0_entity) \
915     /**/
916 MUTATOR_HOOKABLE(FixClientCvars, EV_FixClientCvars);
917
918 #define EV_SpectateSet(i, o) \
919     /** client */    i(entity, MUTATOR_ARGV_0_entity) \
920     /** target */    i(entity, MUTATOR_ARGV_1_entity) \
921     /**/             o(entity, MUTATOR_ARGV_1_entity) \
922     /**/
923 MUTATOR_HOOKABLE(SpectateSet, EV_SpectateSet);
924
925 #define EV_SpectateNext(i, o) \
926     /** client */    i(entity, MUTATOR_ARGV_0_entity) \
927     /** target */    i(entity, MUTATOR_ARGV_1_entity) \
928     /**/             o(entity, MUTATOR_ARGV_1_entity) \
929     /**/
930 MUTATOR_HOOKABLE(SpectateNext, EV_SpectateNext);
931
932 #define EV_SpectatePrev(i, o) \
933     /** client */    i(entity, MUTATOR_ARGV_0_entity) \
934     /** target */    i(entity, MUTATOR_ARGV_1_entity) \
935     /**/             o(entity, MUTATOR_ARGV_1_entity) \
936         /** first */     i(entity, MUTATOR_ARGV_2_entity) \
937     /**/
938 MUTATOR_HOOKABLE(SpectatePrev, EV_SpectatePrev);
939
940 enum {
941     MUT_SPECPREV_CONTINUE, // return this flag to make the function continue as normal
942     MUT_SPECPREV_RETURN, // return this flag to make the function return (handled entirely by mutator)
943     MUT_SPECPREV_FOUND // return this flag to make the function continue without default functions (handled mostly by mutator)
944 };
945
946 /** called when player triggered kill (or is changing teams), return error to not do anything */
947 #define EV_Bot_FixCount(i, o) \
948         /** active real players */  i(int, MUTATOR_ARGV_0_int) \
949         /**/                                            o(int, MUTATOR_ARGV_0_int) \
950     /** real players */                 i(int, MUTATOR_ARGV_1_int) \
951     /**/                                        o(int, MUTATOR_ARGV_1_int) \
952     /**/
953 MUTATOR_HOOKABLE(Bot_FixCount, EV_Bot_FixCount);
954
955 #define EV_ClientCommand_Spectate(i, o) \
956     /** player */ i(entity, MUTATOR_ARGV_0_entity) \
957     /**/
958 MUTATOR_HOOKABLE(ClientCommand_Spectate, EV_ClientCommand_Spectate);
959
960 enum {
961     MUT_SPECCMD_CONTINUE, // return this flag to make the function continue as normal
962     MUT_SPECCMD_RETURN, // return this flag to make the function return (don't spectate)
963     MUT_SPECCMD_FORCE // return this flag to force the player to spectate, even if they're not a player
964 };
965
966 #define EV_CheckRules_World(i, o) \
967     /** status */    i(float, MUTATOR_ARGV_0_float) \
968     /**/             o(float, MUTATOR_ARGV_0_float) \
969     /* time limit */ i(float, MUTATOR_ARGV_1_float) \
970     /* frag limit */ i(float, MUTATOR_ARGV_2_float) \
971     /**/
972 MUTATOR_HOOKABLE(CheckRules_World, EV_CheckRules_World);
973
974 #define EV_WantWeapon(i, o) \
975     /** weapon info entity */    i(entity, MUTATOR_ARGV_0_entity) \
976     /** do want? */              i(float, MUTATOR_ARGV_1_float) \
977     /**/                         o(float, MUTATOR_ARGV_1_float) \
978     /** want all guns */         i(bool, MUTATOR_ARGV_2_bool) \
979     /**/                         o(bool, MUTATOR_ARGV_2_bool) \
980     /** want mutator blocked */  i(bool, MUTATOR_ARGV_3_bool) \
981     /**/                         o(bool, MUTATOR_ARGV_3_bool) \
982     /**/
983 MUTATOR_HOOKABLE(WantWeapon, EV_WantWeapon);
984
985 #define EV_AddPlayerScore(i, o) \
986     /** score field */  i(entity, MUTATOR_ARGV_0_entity) \
987     /** score */        i(float, MUTATOR_ARGV_1_float) \
988     /**/                o(float, MUTATOR_ARGV_1_float) \
989     /** player */       i(entity, MUTATOR_ARGV_2_entity) \
990     /**/
991 MUTATOR_HOOKABLE(AddPlayerScore, EV_AddPlayerScore);
992
993 #define EV_AddedPlayerScore(i, o) \
994     /** score field */  i(entity, MUTATOR_ARGV_0_entity) \
995     /** score */        i(float, MUTATOR_ARGV_1_float) \
996     /** player */       i(entity, MUTATOR_ARGV_2_entity) \
997     /**/
998 MUTATOR_HOOKABLE(AddedPlayerScore, EV_AddPlayerScore);
999
1000 #define EV_GetPlayerStatus(i, o) \
1001     /** player */    i(entity, MUTATOR_ARGV_0_entity) \
1002     /**/
1003 MUTATOR_HOOKABLE(GetPlayerStatus, EV_GetPlayerStatus);
1004
1005 #define EV_SetWeaponArena(i, o) \
1006     /** arena */     i(string, MUTATOR_ARGV_0_string) \
1007     /**/             o(string, MUTATOR_ARGV_0_string) \
1008     /**/
1009 MUTATOR_HOOKABLE(SetWeaponArena, EV_SetWeaponArena);
1010
1011 #define EV_DropSpecialItems(i, o) \
1012     /** target */ i(entity, MUTATOR_ARGV_0_entity) \
1013     /**/
1014 MUTATOR_HOOKABLE(DropSpecialItems, EV_DropSpecialItems);
1015
1016 /**
1017  * called when an admin tries to kill all monsters
1018  * return 1 to prevent spawning
1019  */
1020 #define EV_AllowMobButcher(i, o) \
1021     /** reason */ o(string, MUTATOR_ARGV_0_string) \
1022     /**/
1023 MUTATOR_HOOKABLE(AllowMobButcher, EV_AllowMobButcher);
1024
1025 MUTATOR_HOOKABLE(ReadLevelCvars, EV_NO_ARGS);
1026
1027 #define EV_SendWaypoint(i, o) \
1028         /** waypoint */     i(entity, MUTATOR_ARGV_0_entity) \
1029         /** to */               i(entity, MUTATOR_ARGV_1_entity) \
1030         /** send flags */   i(int, MUTATOR_ARGV_2_int) \
1031         /**/                            o(int, MUTATOR_ARGV_2_int) \
1032         /** wp flag */      i(int, MUTATOR_ARGV_3_int) \
1033         /**/                            o(int, MUTATOR_ARGV_3_int) \
1034     /**/
1035 MUTATOR_HOOKABLE(SendWaypoint, EV_SendWaypoint);
1036
1037 #define EV_TurretValidateTarget(i, o) \
1038     /** turret */          i(entity, MUTATOR_ARGV_0_entity) \
1039     /** target */          i(entity, MUTATOR_ARGV_1_entity) \
1040     /** validate flags */  i(int, MUTATOR_ARGV_2_int) \
1041     /** target score */    o(float, MUTATOR_ARGV_3_float) \
1042     /**/
1043 MUTATOR_HOOKABLE(TurretValidateTarget, EV_TurretValidateTarget);
1044
1045 #define EV_TurretThink(i, o) \
1046     /** turret */ i(entity, MUTATOR_ARGV_0_entity) \
1047     /**/
1048 MUTATOR_HOOKABLE(TurretThink, EV_TurretThink);
1049
1050 MUTATOR_HOOKABLE(Ent_Init, EV_NO_ARGS);
1051
1052 /** */
1053 #define EV_PrepareExplosionByDamage(i, o) \
1054     /** projectile */ i(entity, MUTATOR_ARGV_0_entity) \
1055     /** attacker */   i(entity, MUTATOR_ARGV_1_entity) \
1056     /**/
1057 MUTATOR_HOOKABLE(PrepareExplosionByDamage, EV_PrepareExplosionByDamage);
1058
1059 /** called when a monster model is about to be set, allows custom paths etc. */
1060 #define EV_MonsterModel(i, o) \
1061         /** model */  i(string, MUTATOR_ARGV_0_string) \
1062         /** output */ i(string, MUTATOR_ARGV_1_string) \
1063         /**/              o(string, MUTATOR_ARGV_1_string) \
1064     /**/
1065 MUTATOR_HOOKABLE(MonsterModel, EV_MonsterModel);
1066
1067 /**
1068  * Called before player changes their team. Return true to block team change.
1069  */
1070 #define EV_Player_ChangeTeam(i, o) \
1071     /** player */             i(entity, MUTATOR_ARGV_0_entity) \
1072     /** current team index */ i(float, MUTATOR_ARGV_1_float) \
1073     /** new team index */     i(float, MUTATOR_ARGV_2_float) \
1074     /**/
1075 MUTATOR_HOOKABLE(Player_ChangeTeam, EV_Player_ChangeTeam);
1076
1077 /**
1078  * Called after player has changed their team.
1079  */
1080 #define EV_Player_ChangedTeam(i, o) \
1081     /** player */             i(entity, MUTATOR_ARGV_0_entity) \
1082     /** old team index */     i(float, MUTATOR_ARGV_1_float) \
1083     /** current team index */ i(float, MUTATOR_ARGV_2_float) \
1084     /**/
1085 MUTATOR_HOOKABLE(Player_ChangedTeam, EV_Player_ChangedTeam);
1086
1087 /**
1088  * Called when player is about to be killed when changing teams. Return true to block killing.
1089  */
1090 #define EV_Player_ChangeTeamKill(i, o) \
1091     /** player */    i(entity, MUTATOR_ARGV_0_entity) \
1092     /**/
1093 MUTATOR_HOOKABLE(Player_ChangeTeamKill, EV_Player_ChangeTeamKill);
1094
1095 /**/
1096 #define EV_URI_GetCallback(i, o) \
1097         /** id */       i(float, MUTATOR_ARGV_0_float) \
1098         /** status */   i(float, MUTATOR_ARGV_1_float) \
1099         /** data */     i(string, MUTATOR_ARGV_2_string) \
1100         /**/
1101 MUTATOR_HOOKABLE(URI_GetCallback, EV_URI_GetCallback);
1102
1103 /**
1104  * return true to lock weapon (can't be used nor changed) for a player
1105  */
1106 #define EV_LockWeapon(i, o) \
1107         /** player */ i(entity, MUTATOR_ARGV_0_entity) \
1108         /**/
1109 MUTATOR_HOOKABLE(LockWeapon, EV_LockWeapon);
1110
1111 /**
1112  * return true to prevent weapon use for a player
1113  */
1114 #define EV_ForbidWeaponUse(i, o) \
1115         /** player */ i(entity, MUTATOR_ARGV_0_entity) \
1116         /**/
1117 MUTATOR_HOOKABLE(ForbidWeaponUse, EV_ForbidWeaponUse);
1118
1119 /** called when creating a clone of the player (usually for corpses that stay after the player has re-spawned) */
1120 #define EV_CopyBody(i, o) \
1121     /** player */               i(entity, MUTATOR_ARGV_0_entity) \
1122     /** newly created clone */  i(entity, MUTATOR_ARGV_1_entity) \
1123     /** keepvelocity? */        i(bool, MUTATOR_ARGV_2_bool) \
1124     /**/
1125 MUTATOR_HOOKABLE(CopyBody, EV_CopyBody);
1126
1127 /** called when sending a chat message, ret argument can be changed to prevent the message */
1128 #define EV_ChatMessage(i, o) \
1129     /** sender */ i(entity, MUTATOR_ARGV_0_entity) \
1130     /** ret */ i(int, MUTATOR_ARGV_1_int) \
1131     /**/ o(int, MUTATOR_ARGV_1_int) \
1132     /**/
1133 MUTATOR_HOOKABLE(ChatMessage, EV_ChatMessage);
1134
1135 /** return true to prevent sending a chat (private, team or regular) message from reaching a certain player */
1136 #define EV_ChatMessageTo(i, o) \
1137     /** destination player */ i(entity, MUTATOR_ARGV_0_entity) \
1138     /** sender */ i(entity, MUTATOR_ARGV_1_entity) \
1139     /**/
1140 MUTATOR_HOOKABLE(ChatMessageTo, EV_ChatMessageTo);
1141
1142 /** return true to just restart the match, for modes that don't support readyrestart */
1143 MUTATOR_HOOKABLE(ReadyRestart_Deny, EV_NO_ARGS);
1144
1145 /** called when a fusion reactor is validating its target */
1146 #define EV_FusionReactor_ValidTarget(i, o) \
1147     /** turret */    i(entity, MUTATOR_ARGV_0_entity) \
1148     /** target */    i(entity, MUTATOR_ARGV_1_entity) \
1149     /**/
1150 MUTATOR_HOOKABLE(FusionReactor_ValidTarget, EV_FusionReactor_ValidTarget);
1151
1152 enum {
1153     MUT_FUSREAC_TARG_CONTINUE, // return this flag to make the function continue as normal
1154     MUT_FUSREAC_TARG_VALID, // return this flag to make the function return true (valid target)
1155     MUT_FUSREAC_TARG_INVALID // return this flag to make the function return false (invalid target)
1156 };
1157
1158 /** return true to hide the 'teamnumbers are imbalanced' message */
1159 #define EV_HideTeamNagger(i, o) \
1160     /** player */ i(entity, MUTATOR_ARGV_0_entity) \
1161     /**/
1162 MUTATOR_HOOKABLE(HideTeamNagger, EV_HideTeamNagger);
1163
1164 /** return true to show a waypoint while the item is spawning */
1165 #define EV_Item_ScheduleRespawn(i, o) \
1166     /** item */             i(entity, MUTATOR_ARGV_0_entity) \
1167     /** respawn time */     i(float, MUTATOR_ARGV_1_float) \
1168     /**/
1169 MUTATOR_HOOKABLE(Item_ScheduleRespawn, EV_Item_ScheduleRespawn);
1170
1171 /** called before physics stats are set on a player, allows limited early customization */
1172 #define EV_PlayerPhysics_UpdateStats(i, o) \
1173     /** player */             i(entity, MUTATOR_ARGV_0_entity) \
1174     /**/
1175 MUTATOR_HOOKABLE(PlayerPhysics_UpdateStats, EV_PlayerPhysics_UpdateStats);
1176
1177 /** called after physics stats are set on a player, allows post-initialization modifications */
1178 #define EV_PlayerPhysics_PostUpdateStats(i, o) \
1179     /** player */             i(entity, MUTATOR_ARGV_0_entity) \
1180     /** maxspeed_mod */       i(float, MUTATOR_ARGV_1_float) \
1181     /**/
1182 MUTATOR_HOOKABLE(PlayerPhysics_PostUpdateStats, EV_PlayerPhysics_PostUpdateStats);
1183
1184 /** return true to use your own aim target (or none at all) */
1185 #define EV_HavocBot_Aim(i, o) \
1186     /** bot */ i(entity, MUTATOR_ARGV_0_entity) \
1187     /**/
1188 MUTATOR_HOOKABLE(HavocBot_Aim, EV_HavocBot_Aim);
1189
1190 /** return true to skip respawn time calculations */
1191 #define EV_CalculateRespawnTime(i, o) \
1192     /** player */ i(entity, MUTATOR_ARGV_0_entity) \
1193     /**/
1194 MUTATOR_HOOKABLE(CalculateRespawnTime, EV_CalculateRespawnTime);
1195
1196 /** called when parsing a vote command. */
1197 #define EV_VoteCommand_Parse(i, o) \
1198     /** caller */                           i(entity, MUTATOR_ARGV_0_entity) \
1199     /** first command */                    i(string, MUTATOR_ARGV_1_string) \
1200     /** vote command */                     i(string, MUTATOR_ARGV_2_string) \
1201     /** start position of vote command */   i(float, MUTATOR_ARGV_3_float) \
1202     /** argument count */                   i(float, MUTATOR_ARGV_4_float) \
1203     /**/
1204 MUTATOR_HOOKABLE(VoteCommand_Parse, EV_VoteCommand_Parse);
1205
1206 enum {
1207     MUT_VOTEPARSE_CONTINUE, // return this flag to make the function continue as normal
1208     MUT_VOTEPARSE_SUCCESS, // return 1 (vote parsed)
1209     MUT_VOTEPARSE_INVALID, // return -1 (vote parsed but counted as invalid, no action or vote)
1210     MUT_VOTEPARSE_UNACCEPTABLE // return 0 (vote parameter counted as unacceptable, warns caller)
1211 };
1212
1213 /**
1214  * Called when freezing an entity (monster or player), return true to force showing a waypoint
1215  */
1216 #define EV_Freeze(i, o) \
1217     /** targ */             i(entity, MUTATOR_ARGV_0_entity) \
1218     /** revive speed */     i(float, MUTATOR_ARGV_1_float) \
1219     /** frozen type */      i(int, MUTATOR_ARGV_2_int) \
1220     /**/
1221 MUTATOR_HOOKABLE(Freeze, EV_Freeze);
1222
1223 /**
1224  * Called when an entity (monster or player) is defrosted
1225  */
1226 #define EV_Unfreeze(i, o) \
1227     /** targ */             i(entity, MUTATOR_ARGV_0_entity) \
1228     /**/
1229 MUTATOR_HOOKABLE(Unfreeze, EV_Unfreeze);
1230
1231 /**
1232  * Called when a player is trying to join, argument is the number of players allowed to join the match
1233  */
1234 #define EV_GetPlayerLimit(i, o) \
1235     /** g_maxplayers */             i(int, MUTATOR_ARGV_0_int) \
1236     /**/                            o(int, MUTATOR_ARGV_0_int) \
1237     /**/
1238 MUTATOR_HOOKABLE(GetPlayerLimit, EV_GetPlayerLimit);
1239
1240 /** include special item codes for a death to the game log */
1241 #define EV_LogDeath_AppendItemCodes(i, o) \
1242     /** player */         i(entity, MUTATOR_ARGV_0_entity) \
1243     /** item codes */     i(string, MUTATOR_ARGV_1_string) \
1244     /**/                  o(string, MUTATOR_ARGV_1_string) \
1245     /**/
1246 MUTATOR_HOOKABLE(LogDeath_AppendItemCodes, EV_LogDeath_AppendItemCodes);
1247
1248 /** Allows disabling or enabling rocket jumping independently of balance, use the parameter to force a preferred setting */
1249 #define EV_AllowRocketJumping(i, o) \
1250     /** allow_rocketjump */         i(bool, MUTATOR_ARGV_0_bool) \
1251     /**/                            o(bool, MUTATOR_ARGV_0_bool) \
1252     /**/
1253 MUTATOR_HOOKABLE(AllowRocketJumping, EV_AllowRocketJumping);
1254
1255 /** Called when weapons are performing their attack, useful for applying bonus attack sounds */
1256 #define EV_W_PlayStrengthSound(i, o) \
1257     /** player */ i(entity, MUTATOR_ARGV_0_entity) \
1258     /**/
1259 MUTATOR_HOOKABLE(W_PlayStrengthSound, EV_W_PlayStrengthSound);