]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/mutators/events.qh
09e1cf70bd212497b69907be4ec13c31e97d33ca
[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 /** called when a player becomes observer, after shared setup */
8 #define EV_MakePlayerObserver(i, o) \
9     /** player */ i(entity, MUTATOR_ARGV_0_entity) \
10     /**/
11 MUTATOR_HOOKABLE(MakePlayerObserver, EV_MakePlayerObserver)
12
13 /** */
14 #define EV_PutClientInServer(i, o) \
15         /** client wanting to spawn */ i(entity, MUTATOR_ARGV_0_entity) \
16     /**/
17 MUTATOR_HOOKABLE(PutClientInServer, EV_PutClientInServer);
18
19 /**
20  * return true to prevent a spectator/observer to spawn as player
21  */
22  #define EV_ForbidSpawn(i, o) \
23     /** player */ i(entity, MUTATOR_ARGV_0_entity) \
24     /**/
25 MUTATOR_HOOKABLE(ForbidSpawn, EV_ForbidSpawn);
26
27 /** called when a player spawns as player, after shared setup, before his weapon is chosen (so items may be changed in here) */
28 #define EV_PlayerSpawn(i, o) \
29         /** player spawning */ i(entity, MUTATOR_ARGV_0_entity) \
30     /** spot that was used, or NULL */ i(entity, MUTATOR_ARGV_1_entity) \
31     /**/
32 MUTATOR_HOOKABLE(PlayerSpawn, EV_PlayerSpawn);
33
34 /** called in reset_map */
35 #define EV_reset_map_global(i, o) \
36     /**/
37 MUTATOR_HOOKABLE(reset_map_global, EV_reset_map_global);
38
39 /** called in reset_map */
40 #define EV_reset_map_players(i, o) \
41     /**/
42 MUTATOR_HOOKABLE(reset_map_players, EV_reset_map_players);
43
44 /** returns 1 if clearing player score shall not be allowed */
45 #define EV_ForbidPlayerScore_Clear(i, o) \
46     /**/
47 MUTATOR_HOOKABLE(ForbidPlayerScore_Clear, EV_ForbidPlayerScore_Clear);
48
49 /** called when a player disconnects */
50 #define EV_ClientDisconnect(i, o) \
51     /** player */ i(entity, MUTATOR_ARGV_0_entity) \
52     /**/
53 MUTATOR_HOOKABLE(ClientDisconnect, EV_ClientDisconnect);
54
55 /** called when a player dies to e.g. remove stuff he was carrying. */
56 #define EV_PlayerDies(i, o) \
57         /** inflictor           */ i(entity, MUTATOR_ARGV_0_entity) \
58     /** attacker        */ i(entity, MUTATOR_ARGV_1_entity) \
59     /** target                  */ i(entity, MUTATOR_ARGV_2_entity) \
60     /** deathtype       */ i(float,  MUTATOR_ARGV_3_float) \
61     /** damage          */ i(float,  MUTATOR_ARGV_4_float) \
62     /** damage                  */ o(float,  MUTATOR_ARGV_4_float) \
63     /**/
64 MUTATOR_HOOKABLE(PlayerDies, EV_PlayerDies);
65
66 /** allows overriding the frag centerprint messages */
67 #define EV_FragCenterMessage(i, o) \
68     /** attacker       */ i(entity, MUTATOR_ARGV_0_entity) \
69     /** target         */ i(entity, MUTATOR_ARGV_1_entity) \
70     /** deathtype      */ i(float, MUTATOR_ARGV_2_float) \
71     /** attacker kcount*/ i(int,  MUTATOR_ARGV_3_int) \
72     /** targ killcount */ i(int,  MUTATOR_ARGV_4_int) \
73     /**/
74 MUTATOR_HOOKABLE(FragCenterMessage, EV_FragCenterMessage);
75
76 /** called when a player dies to e.g. remove stuff he was carrying */
77 #define EV_PlayHitsound(i, o) \
78     /** victim */ i(entity, MUTATOR_ARGV_0_entity) \
79     /** attacker */ i(entity, MUTATOR_ARGV_1_entity) \
80     /**/
81 MUTATOR_HOOKABLE(PlayHitsound, EV_PlayHitsound);
82
83 /** called when a weapon sound is about to be played, allows custom paths etc. */
84 #define EV_WeaponSound(i, o) \
85     /** sound       */ i(string, MUTATOR_ARGV_0_string) \
86     /** output      */ i(string, MUTATOR_ARGV_1_string) \
87     /**/               o(string, MUTATOR_ARGV_1_string) \
88     /**/
89 MUTATOR_HOOKABLE(WeaponSound, EV_WeaponSound);
90
91 /** called when an item model is about to be set, allows custom paths etc. */
92 #define EV_ItemModel(i, o) \
93     /** model       */ i(string, MUTATOR_ARGV_0_string) \
94     /** output      */ i(string, MUTATOR_ARGV_1_string) \
95     /**/               o(string, MUTATOR_ARGV_1_string) \
96     /**/
97 MUTATOR_HOOKABLE(ItemModel, EV_ItemModel);
98
99 /** called when an item sound is about to be played, allows custom paths etc. */
100 #define EV_ItemSound(i, o) \
101     /** sound       */ i(string, MUTATOR_ARGV_0_string) \
102     /** output      */ i(string, MUTATOR_ARGV_1_string) \
103     /**/               o(string, MUTATOR_ARGV_1_string) \
104     /**/
105 MUTATOR_HOOKABLE(ItemSound, EV_ItemSound);
106
107 /** called when someone was fragged by "self", and is expected to change frag_score to adjust scoring for the kill */
108 #define EV_GiveFragsForKill(i, o) \
109     /** attacker   */ i(entity, MUTATOR_ARGV_0_entity) \
110     /** target     */ i(entity, MUTATOR_ARGV_1_entity) \
111     /** frag score */ i(float, MUTATOR_ARGV_2_float) \
112     /**            */ o(float, MUTATOR_ARGV_2_float) \
113     /**/
114 MUTATOR_HOOKABLE(GiveFragsForKill, EV_GiveFragsForKill);
115
116 /** called when the match ends */
117 MUTATOR_HOOKABLE(MatchEnd, EV_NO_ARGS);
118
119 /** allows adjusting allowed teams */
120 #define EV_CheckAllowedTeams(i, o) \
121     /** mask of teams      */ i(float, MUTATOR_ARGV_0_float) \
122     /**/                      o(float, MUTATOR_ARGV_0_float) \
123     /** team entity name   */ i(string, MUTATOR_ARGV_1_string) \
124     /**/                      o(string, MUTATOR_ARGV_1_string) \
125     /**/
126 MUTATOR_HOOKABLE(CheckAllowedTeams, EV_CheckAllowedTeams);
127
128 /** copies variables for spectating "spectatee" to "this" */
129 #define EV_SpectateCopy(i, o) \
130     /** spectatee   */ i(entity, MUTATOR_ARGV_0_entity) \
131     /** client      */ i(entity, MUTATOR_ARGV_1_entity) \
132     /**/
133 MUTATOR_HOOKABLE(SpectateCopy, EV_SpectateCopy);
134
135 /** called when formatting a chat message to replace fancy functions */
136 #define EV_FormatMessage(i, o) \
137     /** player        */ i(entity, MUTATOR_ARGV_0_entity) \
138     /** escape        */ i(string, MUTATOR_ARGV_1_string) \
139     /** replacement   */ i(string, MUTATOR_ARGV_2_string) \
140     /**/                 o(string, MUTATOR_ARGV_2_string) \
141     /** message       */ i(string, MUTATOR_ARGV_3_string) \
142     /**/
143 MUTATOR_HOOKABLE(FormatMessage, EV_FormatMessage);
144
145 /** called before any formatting is applied, handy for tweaking the message before scripts get ahold of it */
146 #define EV_PreFormatMessage(i, o) \
147     /** player        */ i(entity, MUTATOR_ARGV_0_entity) \
148     /** message       */ i(string, MUTATOR_ARGV_1_string) \
149     /**/                 o(string, MUTATOR_ARGV_1_string) \
150     /**/
151 MUTATOR_HOOKABLE(PreFormatMessage, EV_PreFormatMessage);
152
153 /** returns true if throwing the current weapon shall not be allowed */
154 #define EV_ForbidThrowCurrentWeapon(i, o) \
155     /** player        */ i(entity, MUTATOR_ARGV_0_entity) \
156     /**/
157 MUTATOR_HOOKABLE(ForbidThrowCurrentWeapon, EV_ForbidThrowCurrentWeapon);
158
159 /** returns true if dropping the current weapon shall not be allowed at any time including death */
160 #define EV_ForbidDropCurrentWeapon(i, o) \
161     /** player */ i(entity, MUTATOR_ARGV_0_entity) \
162     /**/
163 MUTATOR_HOOKABLE(ForbidDropCurrentWeapon, EV_ForbidDropCurrentWeapon);
164
165 /**  */
166 MUTATOR_HOOKABLE(SetDefaultAlpha, EV_NO_ARGS);
167
168 /** allows changing attack rate */
169 #define EV_WeaponRateFactor(i, o) \
170     /** weapon rate */  i(float, MUTATOR_ARGV_0_float) \
171     /**/                o(float, MUTATOR_ARGV_0_float) \
172     /** player */       i(entity, MUTATOR_ARGV_1_entity) \
173     /**/
174 MUTATOR_HOOKABLE(WeaponRateFactor, EV_WeaponRateFactor);
175
176 /** allows changing weapon speed (projectiles mostly) */
177 #define EV_WeaponSpeedFactor(i, o) \
178     /** weapon speed */ i(float, MUTATOR_ARGV_0_float) \
179     /**/                o(float, MUTATOR_ARGV_0_float) \
180     /** player */       i(entity, MUTATOR_ARGV_1_entity) \
181     /**/
182 MUTATOR_HOOKABLE(WeaponSpeedFactor, EV_WeaponSpeedFactor);
183
184 /** adjusts {warmup_}start_{items,weapons,ammo_{cells,plasma,rockets,nails,shells,fuel}} */
185 MUTATOR_HOOKABLE(SetStartItems, EV_NO_ARGS);
186
187 /** called every frame. customizes the waypoint for spectators */
188 #define EV_CustomizeWaypoint(i, o) \
189     /** waypoint                        */ i(entity, MUTATOR_ARGV_0_entity) \
190     /** player; other.enemy = spectator */ i(entity, MUTATOR_ARGV_1_entity) \
191     /**/
192 MUTATOR_HOOKABLE(CustomizeWaypoint, EV_CustomizeWaypoint);
193
194 /**
195  * checks if the current item may be spawned (.items and .weapons may be read and written to, as well as the ammo_ fields)
196  * return error to request removal
197  */
198 #define EV_FilterItem(i, o) \
199     /** item        */ i(entity, MUTATOR_ARGV_0_entity) \
200     /**/
201 MUTATOR_HOOKABLE(FilterItem, EV_FilterItem);
202
203 /** return error to request removal */
204 #define EV_TurretSpawn(i, o) \
205     /** turret        */ i(entity, MUTATOR_ARGV_0_entity) \
206     /**/
207 MUTATOR_HOOKABLE(TurretSpawn, EV_TurretSpawn);
208
209 /** return error to not attack */
210 #define EV_TurretFire(i, o) \
211     /** turret        */ i(entity, MUTATOR_ARGV_0_entity) \
212     /**/
213 MUTATOR_HOOKABLE(TurretFire, EV_TurretFire);
214
215 /** return error to not attack */
216 #define EV_Turret_CheckFire(i, o) \
217     /** turret                      */ i(entity, MUTATOR_ARGV_0_entity) \
218     /** to fire or not to fire      */ o(bool, MUTATOR_ARGV_1_bool) \
219     /**/
220 MUTATOR_HOOKABLE(Turret_CheckFire, EV_Turret_CheckFire);
221
222 /** return error to prevent entity spawn, or modify the entity */
223 #define EV_OnEntityPreSpawn(i, o) \
224    /** entity  */ i(entity, MUTATOR_ARGV_0_entity) \
225     /**/
226 MUTATOR_HOOKABLE(OnEntityPreSpawn, EV_OnEntityPreSpawn);
227
228 /** runs in the event loop for players; is called for ALL player entities, also bots, also the dead, or spectators */
229 #define EV_PlayerPreThink(i, o) \
230     /** player */ i(entity, MUTATOR_ARGV_0_entity) \
231     /**/
232 MUTATOR_HOOKABLE(PlayerPreThink, EV_PlayerPreThink);
233
234 /** TODO change this into a general PlayerPostThink hook? */
235 #define EV_GetPressedKeys(i, o) \
236     /** player */ i(entity, MUTATOR_ARGV_0_entity) \
237     /**/
238 MUTATOR_HOOKABLE(GetPressedKeys, EV_GetPressedKeys);
239
240 /** is meant to call GetCvars_handle*(get_cvars_s, get_cvars_f, cvarfield, "cvarname") for cvars this mutator needs from the client */
241 #define EV_GetCvars(i, o) \
242     /**/ i(float, get_cvars_f) \
243     /**/ i(string, get_cvars_s) \
244     /**/
245 float get_cvars_f;
246 string get_cvars_s;
247 MUTATOR_HOOKABLE(GetCvars, EV_NO_ARGS); // NOTE: Can't use EV_GetCvars because of `SZ_GetSpace: overflow`
248
249 /** can edit any "just fired" projectile */
250 #define EV_EditProjectile(i, o) \
251     /** projectile owner */ i(entity, MUTATOR_ARGV_0_entity) \
252     /** projectile */ i(entity, MUTATOR_ARGV_1_entity) \
253     /**/
254 MUTATOR_HOOKABLE(EditProjectile, EV_EditProjectile);
255
256 /** called when a monster spawns */
257 #define EV_MonsterSpawn(i, o) \
258     /** monster */ i(entity, MUTATOR_ARGV_0_entity) \
259     /**/
260 MUTATOR_HOOKABLE(MonsterSpawn, EV_MonsterSpawn);
261
262 /** called when a monster dies */
263 #define EV_MonsterDies(i, o) \
264     /** target       */ i(entity, MUTATOR_ARGV_0_entity) \
265     /** attacker     */ i(entity, MUTATOR_ARGV_1_entity) \
266     /** deathtype    */ i(float, MUTATOR_ARGV_2_float) \
267     /**/
268 MUTATOR_HOOKABLE(MonsterDies, EV_MonsterDies);
269
270 /** called when a monster dies */
271 #define EV_MonsterRemove(i, o) \
272     /** monster */ i(entity, MUTATOR_ARGV_0_entity) \
273     /**/
274 MUTATOR_HOOKABLE(MonsterRemove, EV_MonsterRemove);
275
276 /** called when a monster wants to respawn */
277 #define EV_MonsterRespawn(i, o) \
278     /** monster */ i(entity, MUTATOR_ARGV_0_entity) \
279     /**/
280 MUTATOR_HOOKABLE(MonsterRespawn, EV_MonsterRespawn);
281
282 /** called when a monster is dropping loot */
283 #define EV_MonsterDropItem(i, o) \
284     /* monster */                          i(entity, MUTATOR_ARGV_0_entity) \
285     /* item (can be removed or changed) */ i(entity, MUTATOR_ARGV_1_entity) \
286     /**/                                   o(entity, MUTATOR_ARGV_1_entity) \
287     /* attacker */                         i(entity, MUTATOR_ARGV_2_entity) \
288     /**/
289 .void(entity this) monster_loot;
290 MUTATOR_HOOKABLE(MonsterDropItem, EV_MonsterDropItem);
291
292 /**
293  * called when a monster moves
294  * returning true makes the monster stop
295  */
296 #define EV_MonsterMove(i, o) \
297     /** monster */       i(entity, MUTATOR_ARGV_0_entity) \
298     /** run speed */     i(float, MUTATOR_ARGV_1_float) \
299     /**/                 o(float, MUTATOR_ARGV_1_float) \
300     /** walk speed */    i(float, MUTATOR_ARGV_2_float) \
301     /**/                 o(float, MUTATOR_ARGV_2_float) \
302     /** move target */   i(entity, MUTATOR_ARGV_3_entity) \
303     /**/
304 MUTATOR_HOOKABLE(MonsterMove, EV_MonsterMove);
305
306 /** called when a monster looks for another target */
307 MUTATOR_HOOKABLE(MonsterFindTarget, EV_NO_ARGS);
308
309 /**
310  * called when validating a monster's target
311  */
312 #define EV_MonsterValidTarget(i, o) \
313     /** monster */       i(entity, MUTATOR_ARGV_0_entity) \
314     /** target */        i(entity, MUTATOR_ARGV_1_entity) \
315     /**/
316 MUTATOR_HOOKABLE(MonsterValidTarget, EV_MonsterValidTarget);
317
318 /** called to change a random monster to a miniboss */
319 #define EV_MonsterCheckBossFlag(i, o) \
320     /** monster */ i(entity, MUTATOR_ARGV_0_entity) \
321     /**/
322 MUTATOR_HOOKABLE(MonsterCheckBossFlag, EV_MonsterCheckBossFlag);
323
324 /**
325  * called when a player tries to spawn a monster
326  * return 1 to prevent spawning
327  * NOTE: requires reason if disallowed
328  */
329  #define EV_AllowMobSpawning(i, o) \
330     /** caller */ i(entity, MUTATOR_ARGV_0_entity) \
331     /** reason */ o(string, MUTATOR_ARGV_1_string) \
332     /**/
333 MUTATOR_HOOKABLE(AllowMobSpawning, EV_AllowMobSpawning);
334
335 /** called when a player gets damaged to e.g. remove stuff he was carrying. */
336 #define EV_PlayerDamage_SplitHealthArmor(i, o) \
337         /** inflictor           */ i(entity, MUTATOR_ARGV_0_entity) \
338     /** attacker        */ i(entity, MUTATOR_ARGV_1_entity) \
339     /** target                  */ i(entity, MUTATOR_ARGV_2_entity) \
340     /** force (no out)  */ i(vector, MUTATOR_ARGV_3_vector) \
341     /** damage take     */ i(float,  MUTATOR_ARGV_4_float) \
342     /** damage take     */ o(float,  MUTATOR_ARGV_4_float) \
343     /** damage save     */ i(float,  MUTATOR_ARGV_5_float) \
344     /** damage save     */ o(float,  MUTATOR_ARGV_5_float) \
345     /** deathtype               */ i(float,  MUTATOR_ARGV_6_float) \
346     /** damage              */ i(float,  MUTATOR_ARGV_7_float) \
347     /**/
348 MUTATOR_HOOKABLE(PlayerDamage_SplitHealthArmor, EV_PlayerDamage_SplitHealthArmor);
349
350 /**
351  * called to adjust damage and force values which are applied to the player, used for e.g. strength damage/force multiplier
352  * i'm not sure if I should change this around slightly (Naming of the entities, and also how they're done in g_damage).
353  */
354 #define EV_PlayerDamage_Calculate(i, o) \
355     /** inflictor               */ i(entity, MUTATOR_ARGV_0_entity) \
356     /** attacker        */ i(entity, MUTATOR_ARGV_1_entity) \
357     /** target                  */ i(entity, MUTATOR_ARGV_2_entity) \
358     /** deathtype       */ i(float,  MUTATOR_ARGV_3_float) \
359     /** damage          */ i(float,  MUTATOR_ARGV_4_float) \
360     /** damage                  */ o(float,  MUTATOR_ARGV_4_float) \
361     /** mirrordamage    */ i(float,  MUTATOR_ARGV_5_float) \
362     /** mirrordamage    */ o(float,  MUTATOR_ARGV_5_float) \
363     /** force           */ i(vector, MUTATOR_ARGV_6_vector) \
364     /** force                   */ o(vector, MUTATOR_ARGV_6_vector) \
365     /**/
366 MUTATOR_HOOKABLE(PlayerDamage_Calculate, EV_PlayerDamage_Calculate);
367
368 /**
369  * Called when a player is damaged
370  */
371 #define EV_PlayerDamaged(i, o) \
372     /** attacker  */ i(entity, MUTATOR_ARGV_0_entity) \
373     /** target    */ i(entity, MUTATOR_ARGV_1_entity) \
374     /** health    */ i(float,    MUTATOR_ARGV_2_float) \
375     /** armor     */ i(float,    MUTATOR_ARGV_3_float) \
376     /** location  */ i(vector, MUTATOR_ARGV_4_vector) \
377     /** deathtype */ i(int,    MUTATOR_ARGV_5_int) \
378     /** potential_damage     */ i(float,    MUTATOR_ARGV_6_float) \
379     /**/
380 MUTATOR_HOOKABLE(PlayerDamaged, EV_PlayerDamaged);
381
382 /**
383  * Called by W_DecreaseAmmo
384  */
385 #define EV_W_DecreaseAmmo(i, o) \
386     /** actor */ i(entity, MUTATOR_ARGV_0_entity) \
387     /**/
388 MUTATOR_HOOKABLE(W_DecreaseAmmo, EV_W_DecreaseAmmo);
389
390 /**
391  * Called by W_Reload
392  */
393 #define EV_W_Reload(i, o) \
394     /** actor */ i(entity, MUTATOR_ARGV_0_entity) \
395     /**/
396 MUTATOR_HOOKABLE(W_Reload, EV_W_Reload);
397
398 /** called at the end of player_powerups() in client.qc, used for manipulating the values which are set by powerup items. */
399 #define EV_PlayerPowerups(i, o) \
400     /** player */    i(entity, MUTATOR_ARGV_0_entity) \
401     /** old items */ i(int, MUTATOR_ARGV_1_int) \
402     /**/
403 MUTATOR_HOOKABLE(PlayerPowerups, EV_PlayerPowerups);
404
405 /**
406  * called every player think frame
407  * return 1 to disable regen
408  */
409  #define EV_PlayerRegen(i, o) \
410     /** player */               i(entity, MUTATOR_ARGV_0_entity) \
411     /** max_mod */              i(float, MUTATOR_ARGV_1_float) \
412     /**/                        o(float, MUTATOR_ARGV_1_float) \
413     /** regen_mod */            i(float, MUTATOR_ARGV_2_float) \
414     /**/                        o(float, MUTATOR_ARGV_2_float) \
415     /** rot_mod */              i(float, MUTATOR_ARGV_3_float) \
416     /**/                        o(float, MUTATOR_ARGV_3_float) \
417     /** limit_mod */            i(float, MUTATOR_ARGV_4_float) \
418     /**/                        o(float, MUTATOR_ARGV_4_float) \
419     /** health_regen */         i(float, MUTATOR_ARGV_5_float) \
420     /**/                        o(float, MUTATOR_ARGV_5_float) \
421     /** health_regenlinear */   i(float, MUTATOR_ARGV_6_float) \
422     /**/                        o(float, MUTATOR_ARGV_6_float) \
423     /** health_rot */           i(float, MUTATOR_ARGV_7_float) \
424     /**/                        o(float, MUTATOR_ARGV_7_float) \
425     /** health_rotlinear */     i(float, MUTATOR_ARGV_8_float) \
426     /**/                        o(float, MUTATOR_ARGV_8_float) \
427     /** health_stable */        i(float, MUTATOR_ARGV_9_float) \
428     /**/                        o(float, MUTATOR_ARGV_9_float) \
429     /** health_rotstable */     i(float, MUTATOR_ARGV_10_float) \
430     /**/                        o(float, MUTATOR_ARGV_10_float) \
431     /**/
432 MUTATOR_HOOKABLE(PlayerRegen, EV_PlayerRegen);
433
434 /**
435  * called when the use key is pressed
436  * if MUTATOR_RETURNVALUE is 1, don't do anything
437  * return 1 if the use key actually did something
438  */
439  #define EV_PlayerUseKey(i, o) \
440     /** player */ i(entity, MUTATOR_ARGV_0_entity) \
441     /**/
442 MUTATOR_HOOKABLE(PlayerUseKey, EV_PlayerUseKey);
443
444 /**
445  * called when a client command is parsed
446  * NOTE: hooks MUST start with if (MUTATOR_RETURNVALUE) return false;
447  * NOTE: return true if you handled the command, return false to continue handling
448  * NOTE: THESE HOOKS MUST NEVER EVER CALL tokenize()
449  * // example:
450  * MUTATOR_HOOKFUNCTION(foo_SV_ParseClientCommand)
451  * {
452  *     if (MUTATOR_RETURNVALUE) // command was already handled?
453  *         return false;
454  *     if (cmd_name == "echocvar" && cmd_argc >= 2)
455  *     {
456  *         print(cvar_string(argv(1)), "\n");
457  *         return true;
458  *     }
459  *     if (cmd_name == "echostring" && cmd_argc >= 2)
460  *     {
461  *         print(substring(cmd_string, argv_start_index(1), argv_end_index(-1) - argv_start_index(1)), "\n");
462  *         return true;
463  *     }
464  *     return false;
465  * }
466  */
467 #define EV_SV_ParseClientCommand(i, o) \
468         /** client sending the command */       i(entity, MUTATOR_ARGV_0_entity) \
469     /** command name */                     i(string, MUTATOR_ARGV_1_string) \
470         /** argc (also, argv() can be used) */  i(int, MUTATOR_ARGV_2_int) \
471         /** whole command, use only if you really have to */ i(string, MUTATOR_ARGV_3_string) \
472     /**/
473 MUTATOR_HOOKABLE(SV_ParseClientCommand, EV_SV_ParseClientCommand);
474
475 /** please read EV_SV_ParseClientCommand description before using */
476 #define EV_SV_ParseServerCommand(i, o) \
477    /** command name */ i(string, MUTATOR_ARGV_0_string) \
478         /** argc (also, argv() can be used) */ i(int, MUTATOR_ARGV_1_int) \
479         /** whole command, use only if you really have to */ i(string, MUTATOR_ARGV_2_string) \
480     /**/
481 MUTATOR_HOOKABLE(SV_ParseServerCommand, EV_SV_ParseServerCommand);
482
483 /**
484  * called when a spawnpoint is being evaluated
485  * return 1 to make the spawnpoint unusable
486  */
487 #define EV_Spawn_Score(i, o) \
488     /** player wanting to spawn */ i(entity, MUTATOR_ARGV_0_entity) \
489     /** spot to be evaluated */ i(entity, MUTATOR_ARGV_1_entity) \
490     /** spot score, _x is priority, _y is "distance" */ i(vector, MUTATOR_ARGV_2_vector) \
491     /**/ o(vector, MUTATOR_ARGV_2_vector) \
492     /**/
493 MUTATOR_HOOKABLE(Spawn_Score, EV_Spawn_Score);
494
495 /** runs globally each server frame */
496 MUTATOR_HOOKABLE(SV_StartFrame, EV_NO_ARGS);
497
498 #define EV_SetModname(i, o) \
499     /** name of the mutator/mod if it warrants showing as such in the server browser */ \
500     /**/ i(string, MUTATOR_ARGV_0_string) \
501     /**/ o(string, MUTATOR_ARGV_0_string) \
502     /**/
503 MUTATOR_HOOKABLE(SetModname, EV_SetModname);
504
505 /**
506  * called for each item being spawned on a map, including dropped weapons
507  * return 1 to remove an item
508  */
509 #define EV_Item_Spawn(i, o) \
510     /** item */ i(entity, MUTATOR_ARGV_0_entity) \
511     /**/
512 MUTATOR_HOOKABLE(Item_Spawn, EV_Item_Spawn);
513
514 #define EV_SetWeaponreplace(i, o) \
515     /** map entity */  i(entity, MUTATOR_ARGV_0_entity) \
516     /** weapon info */ i(entity, MUTATOR_ARGV_1_entity) \
517     /** replacement */ i(string, MUTATOR_ARGV_2_string) \
518     /**/               o(string, MUTATOR_ARGV_2_string) \
519     /**/
520 MUTATOR_HOOKABLE(SetWeaponreplace, EV_SetWeaponreplace);
521
522 /** called when an item is about to respawn */
523 #define EV_Item_RespawnCountdown(i, o) \
524     /** item name */   i(string, MUTATOR_ARGV_0_string) \
525     /**/               o(string, MUTATOR_ARGV_0_string) \
526     /** item colour */ i(vector, MUTATOR_ARGV_1_vector) \
527     /**/               o(vector, MUTATOR_ARGV_1_vector) \
528     /**/
529 MUTATOR_HOOKABLE(Item_RespawnCountdown, EV_Item_RespawnCountdown);
530
531 /** called when a bot checks a target to attack */
532 #define EV_BotShouldAttack(i, o) \
533     /** bot */    i(entity, MUTATOR_ARGV_0_entity) \
534     /** target */ i(entity, MUTATOR_ARGV_1_entity) \
535     /**/
536 MUTATOR_HOOKABLE(BotShouldAttack, EV_BotShouldAttack);
537
538 /**
539  * called whenever a player goes through a portal gun teleport
540  * allows you to strip a player of an item if they go through the teleporter to help prevent cheating
541  */
542 #define EV_PortalTeleport(i, o) \
543     /** player */ i(entity, MUTATOR_ARGV_0_entity) \
544     /**/
545 MUTATOR_HOOKABLE(PortalTeleport, EV_PortalTeleport);
546
547 /**
548  * called whenever a player uses impulse 33 (help me) in impulse.qc
549  * normally help me ping uses .waypointsprite_attachedforcarrier,
550  * but if your mutator uses something different then you can handle it
551  * in a special manner using this hook
552  */
553 #define EV_HelpMePing(i, o) \
554     /** the player who pressed impulse 33 */ i(entity, MUTATOR_ARGV_0_entity) \
555     /**/
556 MUTATOR_HOOKABLE(HelpMePing, EV_HelpMePing);
557
558 /**
559  * called when a vehicle initializes
560  * return true to remove the vehicle
561  */
562 #define EV_VehicleInit(i, o) \
563     /** vehicle */ i(entity, MUTATOR_ARGV_0_entity) \
564     /**/
565 MUTATOR_HOOKABLE(VehicleInit, EV_VehicleInit);
566
567 /**
568  * called when a player enters a vehicle
569  * allows mutators to set special settings in this event
570  */
571 #define EV_VehicleEnter(i, o) \
572     /** player */ i(entity, MUTATOR_ARGV_0_entity) \
573     /** vehicle */ i(entity, MUTATOR_ARGV_1_entity) \
574     /**/
575 MUTATOR_HOOKABLE(VehicleEnter, EV_VehicleEnter);
576
577 /**
578  * called when a player touches a vehicle
579  * return true to stop player from entering the vehicle
580  */
581 #define EV_VehicleTouch(i, o) \
582     /** vehicle */ i(entity, MUTATOR_ARGV_0_entity) \
583     /** player */ i(entity, MUTATOR_ARGV_1_entity) \
584     /**/
585 MUTATOR_HOOKABLE(VehicleTouch, EV_VehicleTouch);
586
587 /**
588  * called when a player exits a vehicle
589  * allows mutators to set special settings in this event
590  */
591 #define EV_VehicleExit(i, o) \
592     /** player */ i(entity, MUTATOR_ARGV_0_entity) \
593     /** vehicle */ i(entity, MUTATOR_ARGV_1_entity) \
594     /**/
595 MUTATOR_HOOKABLE(VehicleExit, EV_VehicleExit);
596
597 /** called when a speedrun is aborted and the player is teleported back to start position */
598 #define EV_AbortSpeedrun(i, o) \
599     /** player */ i(entity, MUTATOR_ARGV_0_entity) \
600     /**/
601 MUTATOR_HOOKABLE(AbortSpeedrun, EV_AbortSpeedrun);
602
603 /** called at when a item is touched. Called early, can edit item properties. */
604 #define EV_ItemTouch(i, o) \
605     /** item */    i(entity, MUTATOR_ARGV_0_entity) \
606     /** toucher */ i(entity, MUTATOR_ARGV_1_entity) \
607     /**/           o(entity, MUTATOR_ARGV_1_entity) \
608     /**/
609 MUTATOR_HOOKABLE(ItemTouch, EV_ItemTouch);
610
611 enum {
612         MUT_ITEMTOUCH_CONTINUE, // return this flag to make the function continue as normal
613         MUT_ITEMTOUCH_RETURN, // return this flag to make the function return (handled entirely by mutator)
614         MUT_ITEMTOUCH_PICKUP // return this flag to have the item "picked up" and taken even after mutator handled it
615 };
616
617 /** called at when a player connect */
618 #define EV_ClientConnect(i, o) \
619     /** player */ i(entity, MUTATOR_ARGV_0_entity) \
620     /**/
621 MUTATOR_HOOKABLE(ClientConnect, EV_ClientConnect);
622
623 #define EV_HavocBot_ChooseRole(i, o) \
624     /** bot */ i(entity, MUTATOR_ARGV_0_entity) \
625     /**/
626 MUTATOR_HOOKABLE(HavocBot_ChooseRole, EV_HavocBot_ChooseRole);
627
628 /** called when a target is checked for accuracy */
629 #define EV_AccuracyTargetValid(i, o) \
630     /** attacker */ i(entity, MUTATOR_ARGV_0_entity) \
631     /** target */ i(entity, MUTATOR_ARGV_1_entity) \
632     /**/
633 MUTATOR_HOOKABLE(AccuracyTargetValid, EV_AccuracyTargetValid);
634 enum {
635         MUT_ACCADD_VALID, // return this flag to make the function continue if target is a client
636         MUT_ACCADD_INVALID, // return this flag to make the function always continue
637         MUT_ACCADD_INDIFFERENT // return this flag to make the function always return
638 };
639
640 /** Called when clearing the global parameters for a model */
641 MUTATOR_HOOKABLE(ClearModelParams, EV_NO_ARGS);
642
643 /** Called when getting the global parameters for a model */
644 #define EV_GetModelParams(i, o) \
645     /** input */   i(string, MUTATOR_ARGV_0_string) \
646     /** command */ i(string, MUTATOR_ARGV_1_string) \
647     /**/
648 MUTATOR_HOOKABLE(GetModelParams, EV_GetModelParams);
649
650 /** called when a bullet has hit a target */
651 #define EV_FireBullet_Hit(i, o) \
652     /** player */       i(entity, MUTATOR_ARGV_0_entity) \
653     /** targ */         i(entity, MUTATOR_ARGV_1_entity) \
654     /** start pos */    i(vector, MUTATOR_ARGV_2_vector) \
655     /** end pos */      i(vector, MUTATOR_ARGV_3_vector) \
656     /** damage */       i(float, MUTATOR_ARGV_4_float) \
657     /**/                o(float, MUTATOR_ARGV_4_float) \
658     /**/
659 MUTATOR_HOOKABLE(FireBullet_Hit, EV_FireBullet_Hit);
660
661 #define EV_FixPlayermodel(i, o) \
662     /** model */    i(string, MUTATOR_ARGV_0_string) \
663     /**/            o(string, MUTATOR_ARGV_0_string) \
664     /** skin */     i(int, MUTATOR_ARGV_1_int) \
665     /**/            o(int, MUTATOR_ARGV_1_int) \
666     /** player */   i(entity, MUTATOR_ARGV_2_entity) \
667     /**/
668 MUTATOR_HOOKABLE(FixPlayermodel, EV_FixPlayermodel);
669
670 /** Return error to play frag remaining announcements */
671 MUTATOR_HOOKABLE(Scores_CountFragsRemaining, EV_NO_ARGS);
672
673 #define EV_GrappleHookThink(i, o) \
674     /** hook */                i(entity, MUTATOR_ARGV_0_entity) \
675     /** tarzan */              i(int, MUTATOR_ARGV_1_int) \
676     /**/                       o(int, MUTATOR_ARGV_1_int) \
677     /** pulling entity */      i(entity, MUTATOR_ARGV_2_entity) \
678     /**/                       o(entity, MUTATOR_ARGV_2_entity) \
679     /** velocity multiplier */ i(float, MUTATOR_ARGV_3_float) \
680     /**/                       o(float, MUTATOR_ARGV_3_float) \
681     /**/
682 MUTATOR_HOOKABLE(GrappleHookThink, EV_GrappleHookThink);
683
684 #define EV_BuffModel_Customize(i, o) \
685     /** buff */    i(entity, MUTATOR_ARGV_0_entity) \
686     /** player */  i(entity, MUTATOR_ARGV_1_entity) \
687     /**/
688 MUTATOR_HOOKABLE(BuffModel_Customize, EV_BuffModel_Customize);
689
690 /** called at when a buff is touched. Called early, can edit buff properties. */
691 #define EV_BuffTouch(i, o) \
692     /** buff */    i(entity, MUTATOR_ARGV_0_entity) \
693     /** player */  i(entity, MUTATOR_ARGV_1_entity) \
694     /**/           o(entity, MUTATOR_ARGV_1_entity) \
695     /**/
696 MUTATOR_HOOKABLE(BuffTouch, EV_BuffTouch);
697
698 MUTATOR_HOOKABLE(SetNewParms, EV_NO_ARGS);
699
700 MUTATOR_HOOKABLE(SetChangeParms, EV_NO_ARGS);
701
702 MUTATOR_HOOKABLE(DecodeLevelParms, EV_NO_ARGS);
703
704 #define EV_GetRecords(i, o) \
705     /** page */           i(int, MUTATOR_ARGV_0_int) \
706     /** record list */    i(string, MUTATOR_ARGV_1_string) \
707     /**/                  o(string, MUTATOR_ARGV_1_string) \
708     /**/
709 MUTATOR_HOOKABLE(GetRecords, EV_GetRecords);
710
711 #define EV_Race_FinalCheckpoint(i, o) \
712     /** player */ i(entity, MUTATOR_ARGV_0_entity) \
713     /**/
714 MUTATOR_HOOKABLE(Race_FinalCheckpoint, EV_Race_FinalCheckpoint);
715
716 /** called when player triggered kill (or is changing teams), return error to not do anything */
717 #define EV_ClientKill(i, o) \
718     /** player */        i(entity, MUTATOR_ARGV_0_entity) \
719     /** kill delay */    i(float, MUTATOR_ARGV_1_float) \
720     /**/                 o(float, MUTATOR_ARGV_1_float) \
721     /**/
722 MUTATOR_HOOKABLE(ClientKill, EV_ClientKill);
723
724 #define EV_FixClientCvars(i, o) \
725     /** player */        i(entity, MUTATOR_ARGV_0_entity) \
726     /**/
727 MUTATOR_HOOKABLE(FixClientCvars, EV_FixClientCvars);
728
729 #define EV_SpectateSet(i, o) \
730     /** client */    i(entity, MUTATOR_ARGV_0_entity) \
731     /** target */    i(entity, MUTATOR_ARGV_1_entity) \
732     /**/             o(entity, MUTATOR_ARGV_1_entity) \
733     /**/
734 MUTATOR_HOOKABLE(SpectateSet, EV_SpectateSet);
735
736 #define EV_SpectateNext(i, o) \
737     /** client */    i(entity, MUTATOR_ARGV_0_entity) \
738     /** target */    i(entity, MUTATOR_ARGV_1_entity) \
739     /**/             o(entity, MUTATOR_ARGV_1_entity) \
740     /**/
741 MUTATOR_HOOKABLE(SpectateNext, EV_SpectateNext);
742
743 #define EV_SpectatePrev(i, o) \
744     /** client */    i(entity, MUTATOR_ARGV_0_entity) \
745     /** target */    i(entity, MUTATOR_ARGV_1_entity) \
746     /**/             o(entity, MUTATOR_ARGV_1_entity) \
747         /** first */     i(entity, MUTATOR_ARGV_2_entity) \
748     /**/
749 MUTATOR_HOOKABLE(SpectatePrev, EV_SpectatePrev);
750
751 enum {
752     MUT_SPECPREV_CONTINUE, // return this flag to make the function continue as normal
753     MUT_SPECPREV_RETURN, // return this flag to make the function return (handled entirely by mutator)
754     MUT_SPECPREV_FOUND // return this flag to make the function continue without default functions (handled mostly by mutator)
755 };
756
757 /** called when player triggered kill (or is changing teams), return error to not do anything */
758 #define EV_Bot_FixCount(i, o) \
759         /** active real players */  i(int, MUTATOR_ARGV_0_int) \
760         /**/                                            o(int, MUTATOR_ARGV_0_int) \
761     /** real players */                 i(int, MUTATOR_ARGV_1_int) \
762     /**/                                        o(int, MUTATOR_ARGV_1_int) \
763     /**/
764 MUTATOR_HOOKABLE(Bot_FixCount, EV_Bot_FixCount);
765
766 #define EV_ClientCommand_Spectate(i, o) \
767     /** player */ i(entity, MUTATOR_ARGV_0_entity) \
768     /**/
769 MUTATOR_HOOKABLE(ClientCommand_Spectate, EV_ClientCommand_Spectate);
770
771 enum {
772     MUT_SPECCMD_CONTINUE, // return this flag to make the function continue as normal
773     MUT_SPECCMD_RETURN, // return this flag to make the function return (don't spectate)
774     MUT_SPECCMD_FORCE // return this flag to force the player to spectate, even if they're not a player
775 };
776
777 #define EV_CheckRules_World(i, o) \
778     /** status */    i(float, MUTATOR_ARGV_0_float) \
779     /**/             o(float, MUTATOR_ARGV_0_float) \
780     /* time limit */ i(float, MUTATOR_ARGV_1_float) \
781     /* frag limit */ i(float, MUTATOR_ARGV_2_float) \
782     /**/
783 MUTATOR_HOOKABLE(CheckRules_World, EV_CheckRules_World);
784
785 #define EV_WantWeapon(i, o) \
786     /** weapon info entity */    i(entity, MUTATOR_ARGV_0_entity) \
787     /** do want? */              i(float, MUTATOR_ARGV_1_float) \
788     /**/                         o(float, MUTATOR_ARGV_1_float) \
789     /** want all guns */         i(bool, MUTATOR_ARGV_2_bool) \
790     /**/                         o(bool, MUTATOR_ARGV_2_bool) \
791     /** want mutator blocked */  i(bool, MUTATOR_ARGV_3_bool) \
792     /**/                         o(bool, MUTATOR_ARGV_3_bool) \
793     /**/
794 MUTATOR_HOOKABLE(WantWeapon, EV_WantWeapon);
795
796 #define EV_AddPlayerScore(i, o) \
797     /** score field */  i(PlayerScoreField, MUTATOR_ARGV_0_entity) \
798     /** score */        i(float, MUTATOR_ARGV_1_float) \
799     /**/                o(float, MUTATOR_ARGV_1_float) \
800     /** player */       i(entity, MUTATOR_ARGV_2_entity) \
801     /**/
802 MUTATOR_HOOKABLE(AddPlayerScore, EV_AddPlayerScore);
803
804 #define EV_GetPlayerStatus(i, o) \
805     /** player */    i(entity, MUTATOR_ARGV_0_entity) \
806     /**/
807 MUTATOR_HOOKABLE(GetPlayerStatus, EV_GetPlayerStatus);
808
809 #define EV_SetWeaponArena(i, o) \
810     /** arena */     i(string, MUTATOR_ARGV_0_string) \
811     /**/             o(string, MUTATOR_ARGV_0_string) \
812     /**/
813 MUTATOR_HOOKABLE(SetWeaponArena, EV_SetWeaponArena);
814
815 #define EV_DropSpecialItems(i, o) \
816     /** target */ i(entity, MUTATOR_ARGV_0_entity) \
817     /**/
818 MUTATOR_HOOKABLE(DropSpecialItems, EV_DropSpecialItems);
819
820 /**
821  * called when an admin tries to kill all monsters
822  * return 1 to prevent spawning
823  */
824 #define EV_AllowMobButcher(i, o) \
825     /** reason */ o(string, MUTATOR_ARGV_0_string) \
826     /**/
827 MUTATOR_HOOKABLE(AllowMobButcher, EV_AllowMobButcher);
828
829 MUTATOR_HOOKABLE(ReadLevelCvars, EV_NO_ARGS);
830
831 #define EV_SendWaypoint(i, o) \
832         /** waypoint */     i(entity, MUTATOR_ARGV_0_entity) \
833         /** to */               i(entity, MUTATOR_ARGV_1_entity) \
834         /** send flags */   i(int, MUTATOR_ARGV_2_int) \
835         /**/                            o(int, MUTATOR_ARGV_2_int) \
836         /** wp flag */      i(int, MUTATOR_ARGV_3_int) \
837         /**/                            o(int, MUTATOR_ARGV_3_int) \
838     /**/
839 MUTATOR_HOOKABLE(SendWaypoint, EV_SendWaypoint);
840
841 #define EV_TurretValidateTarget(i, o) \
842     /** turret */          i(entity, MUTATOR_ARGV_0_entity) \
843     /** target */          i(entity, MUTATOR_ARGV_1_entity) \
844     /** validate flags */  i(int, MUTATOR_ARGV_2_int) \
845     /** target score */    o(float, MUTATOR_ARGV_3_float) \
846     /**/
847 MUTATOR_HOOKABLE(TurretValidateTarget, EV_TurretValidateTarget);
848
849 #define EV_TurretThink(i, o) \
850     /** turret */ i(entity, MUTATOR_ARGV_0_entity) \
851     /**/
852 MUTATOR_HOOKABLE(TurretThink, EV_TurretThink);
853
854 MUTATOR_HOOKABLE(Ent_Init, EV_NO_ARGS);
855
856 /** */
857 #define EV_PrepareExplosionByDamage(i, o) \
858     /** projectile */ i(entity, MUTATOR_ARGV_0_entity) \
859     /** attacker */   i(entity, MUTATOR_ARGV_1_entity) \
860     /**/
861 MUTATOR_HOOKABLE(PrepareExplosionByDamage, EV_PrepareExplosionByDamage);
862
863 /** called when a monster model is about to be set, allows custom paths etc. */
864 #define EV_MonsterModel(i, o) \
865         /** model */  i(string, MUTATOR_ARGV_0_string) \
866         /** output */ i(string, MUTATOR_ARGV_1_string) \
867         /**/              o(string, MUTATOR_ARGV_1_string) \
868     /**/
869 MUTATOR_HOOKABLE(MonsterModel, EV_MonsterModel);
870
871 /**/
872 #define EV_Player_ChangeTeam(i, o) \
873     /** player */         i(entity, MUTATOR_ARGV_0_entity) \
874         /** current team */   i(float, MUTATOR_ARGV_1_float) \
875         /** new team */       i(float, MUTATOR_ARGV_2_float) \
876     /**/
877 MUTATOR_HOOKABLE(Player_ChangeTeam, EV_Player_ChangeTeam);
878
879 /**/
880 #define EV_URI_GetCallback(i, o) \
881         /** id */       i(float, MUTATOR_ARGV_0_float) \
882         /** status */   i(float, MUTATOR_ARGV_1_float) \
883         /** data */     i(string, MUTATOR_ARGV_2_string) \
884     /**/
885 MUTATOR_HOOKABLE(URI_GetCallback, EV_URI_GetCallback);
886
887 /**
888  * return true to prevent weapon use for a player
889  */
890  #define EV_ForbidWeaponUse(i, o) \
891     /** player */ i(entity, MUTATOR_ARGV_0_entity) \
892     /**/
893 MUTATOR_HOOKABLE(ForbidWeaponUse, EV_ForbidWeaponUse);
894
895 /** called when creating a clone of the player (usually for corpses that stay after the player has re-spawned) */
896 #define EV_CopyBody(i, o) \
897     /** player */               i(entity, MUTATOR_ARGV_0_entity) \
898     /** newly created clone */  i(entity, MUTATOR_ARGV_1_entity) \
899     /** keepvelocity? */        i(bool, MUTATOR_ARGV_2_bool) \
900     /**/
901 MUTATOR_HOOKABLE(CopyBody, EV_CopyBody);
902
903 /** called when sending a chat message, ret argument can be changed to prevent the message */
904 #define EV_ChatMessage(i, o) \
905     /** sender */ i(entity, MUTATOR_ARGV_0_entity) \
906     /** ret */ i(int, MUTATOR_ARGV_1_int) \
907     /**/ o(int, MUTATOR_ARGV_1_int) \
908     /**/
909 MUTATOR_HOOKABLE(ChatMessage, EV_ChatMessage);
910
911 /** return true to prevent sending a chat (private, team or regular) message from reaching a certain player */
912 #define EV_ChatMessageTo(i, o) \
913     /** destination player */ i(entity, MUTATOR_ARGV_0_entity) \
914     /** sender */ i(entity, MUTATOR_ARGV_1_entity) \
915     /**/
916 MUTATOR_HOOKABLE(ChatMessageTo, EV_ChatMessageTo);
917
918 /** return true to just restart the match, for modes that don't support readyrestart */
919 MUTATOR_HOOKABLE(ReadyRestart_Deny, EV_NO_ARGS);