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