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