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