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