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