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