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