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 in reset_map */
35 #define EV_reset_map_global(i, o) \
37 MUTATOR_HOOKABLE(reset_map_global, EV_reset_map_global);
39 /** called in reset_map */
40 #define EV_reset_map_players(i, o) \
42 MUTATOR_HOOKABLE(reset_map_players, EV_reset_map_players);
44 /** returns 1 if clearing player score shall not be allowed */
45 #define EV_ForbidPlayerScore_Clear(i, o) \
47 MUTATOR_HOOKABLE(ForbidPlayerScore_Clear, EV_ForbidPlayerScore_Clear);
49 /** called when a player disconnects */
50 #define EV_ClientDisconnect(i, o) \
51 /** player */ i(entity, MUTATOR_ARGV_0_entity) \
53 MUTATOR_HOOKABLE(ClientDisconnect, EV_ClientDisconnect);
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) \
64 MUTATOR_HOOKABLE(PlayerDies, EV_PlayerDies);
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) \
74 MUTATOR_HOOKABLE(FragCenterMessage, EV_FragCenterMessage);
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) \
81 MUTATOR_HOOKABLE(PlayHitsound, EV_PlayHitsound);
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) \
89 MUTATOR_HOOKABLE(WeaponSound, EV_WeaponSound);
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) \
97 MUTATOR_HOOKABLE(ItemModel, EV_ItemModel);
99 /** called when an item sound is about to be played, allows custom paths etc. */
100 #define EV_ItemSound(i, o) \
101 /** sound */ i(string, MUTATOR_ARGV_0_string) \
102 /** output */ i(string, MUTATOR_ARGV_1_string) \
103 /**/ o(string, MUTATOR_ARGV_1_string) \
105 MUTATOR_HOOKABLE(ItemSound, EV_ItemSound);
107 /** called when someone was fragged by "self", and is expected to change frag_score to adjust scoring for the kill */
108 #define EV_GiveFragsForKill(i, o) \
109 /** attacker */ i(entity, MUTATOR_ARGV_0_entity) \
110 /** target */ i(entity, MUTATOR_ARGV_1_entity) \
111 /** frag score */ i(float, MUTATOR_ARGV_2_float) \
112 /** */ o(float, MUTATOR_ARGV_2_float) \
114 MUTATOR_HOOKABLE(GiveFragsForKill, EV_GiveFragsForKill);
116 /** called when the match ends */
117 MUTATOR_HOOKABLE(MatchEnd, EV_NO_ARGS);
119 /** allows adjusting allowed teams */
120 #define EV_CheckAllowedTeams(i, o) \
121 /** mask of teams */ i(float, MUTATOR_ARGV_0_float) \
122 /**/ o(float, MUTATOR_ARGV_0_float) \
123 /** team entity name */ i(string, MUTATOR_ARGV_1_string) \
124 /**/ o(string, MUTATOR_ARGV_1_string) \
126 MUTATOR_HOOKABLE(CheckAllowedTeams, EV_CheckAllowedTeams);
128 /** copies variables for spectating "spectatee" to "this" */
129 #define EV_SpectateCopy(i, o) \
130 /** spectatee */ i(entity, MUTATOR_ARGV_0_entity) \
131 /** client */ i(entity, MUTATOR_ARGV_1_entity) \
133 MUTATOR_HOOKABLE(SpectateCopy, EV_SpectateCopy);
135 /** called when formatting a chat message to replace fancy functions */
136 #define EV_FormatMessage(i, o) \
137 /** player */ i(entity, MUTATOR_ARGV_0_entity) \
138 /** escape */ i(string, MUTATOR_ARGV_1_string) \
139 /** replacement */ i(string, MUTATOR_ARGV_2_string) \
140 /**/ o(string, MUTATOR_ARGV_2_string) \
141 /** message */ i(string, MUTATOR_ARGV_3_string) \
143 MUTATOR_HOOKABLE(FormatMessage, EV_FormatMessage);
145 /** called before any formatting is applied, handy for tweaking the message before scripts get ahold of it */
146 #define EV_PreFormatMessage(i, o) \
147 /** player */ i(entity, MUTATOR_ARGV_0_entity) \
148 /** message */ i(string, MUTATOR_ARGV_1_string) \
149 /**/ o(string, MUTATOR_ARGV_1_string) \
151 MUTATOR_HOOKABLE(PreFormatMessage, EV_PreFormatMessage);
153 /** returns true if throwing the current weapon shall not be allowed */
154 #define EV_ForbidThrowCurrentWeapon(i, o) \
155 /** player */ i(entity, MUTATOR_ARGV_0_entity) \
156 /** weapon entity */ i(entity, MUTATOR_ARGV_1_entity) \
158 MUTATOR_HOOKABLE(ForbidThrowCurrentWeapon, EV_ForbidThrowCurrentWeapon);
160 /** returns true if dropping the current weapon shall not be allowed at any time including death */
161 #define EV_ForbidDropCurrentWeapon(i, o) \
162 /** player */ i(entity, MUTATOR_ARGV_0_entity) \
163 /** weapon id */ i(int, MUTATOR_ARGV_1_int) \
165 MUTATOR_HOOKABLE(ForbidDropCurrentWeapon, EV_ForbidDropCurrentWeapon);
168 MUTATOR_HOOKABLE(SetDefaultAlpha, EV_NO_ARGS);
170 /** allows changing attack rate */
171 #define EV_WeaponRateFactor(i, o) \
172 /** weapon rate */ i(float, MUTATOR_ARGV_0_float) \
173 /**/ o(float, MUTATOR_ARGV_0_float) \
174 /** player */ i(entity, MUTATOR_ARGV_1_entity) \
176 MUTATOR_HOOKABLE(WeaponRateFactor, EV_WeaponRateFactor);
178 /** allows changing weapon speed (projectiles mostly) */
179 #define EV_WeaponSpeedFactor(i, o) \
180 /** weapon speed */ i(float, MUTATOR_ARGV_0_float) \
181 /**/ o(float, MUTATOR_ARGV_0_float) \
182 /** player */ i(entity, MUTATOR_ARGV_1_entity) \
184 MUTATOR_HOOKABLE(WeaponSpeedFactor, EV_WeaponSpeedFactor);
186 /** adjusts {warmup_}start_{items,weapons,ammo_{cells,plasma,rockets,nails,shells,fuel}} */
187 MUTATOR_HOOKABLE(SetStartItems, EV_NO_ARGS);
189 /** called every frame. customizes the waypoint for spectators */
190 #define EV_CustomizeWaypoint(i, o) \
191 /** waypoint */ i(entity, MUTATOR_ARGV_0_entity) \
192 /** player; other.enemy = spectator */ i(entity, MUTATOR_ARGV_1_entity) \
194 MUTATOR_HOOKABLE(CustomizeWaypoint, EV_CustomizeWaypoint);
197 * checks if the current item may be spawned (.items and .weapons may be read and written to, as well as the ammo_ fields)
198 * return error to request removal
200 #define EV_FilterItem(i, o) \
201 /** item */ i(entity, MUTATOR_ARGV_0_entity) \
203 MUTATOR_HOOKABLE(FilterItem, EV_FilterItem);
205 /** return error to request removal */
206 #define EV_TurretSpawn(i, o) \
207 /** turret */ i(entity, MUTATOR_ARGV_0_entity) \
209 MUTATOR_HOOKABLE(TurretSpawn, EV_TurretSpawn);
211 /** return error to not attack */
212 #define EV_TurretFire(i, o) \
213 /** turret */ i(entity, MUTATOR_ARGV_0_entity) \
215 MUTATOR_HOOKABLE(TurretFire, EV_TurretFire);
217 /** return error to not attack */
218 #define EV_Turret_CheckFire(i, o) \
219 /** turret */ i(entity, MUTATOR_ARGV_0_entity) \
220 /** to fire or not to fire */ o(bool, MUTATOR_ARGV_1_bool) \
222 MUTATOR_HOOKABLE(Turret_CheckFire, EV_Turret_CheckFire);
224 /** return error to prevent entity spawn, or modify the entity */
225 #define EV_OnEntityPreSpawn(i, o) \
226 /** entity */ i(entity, MUTATOR_ARGV_0_entity) \
228 MUTATOR_HOOKABLE(OnEntityPreSpawn, EV_OnEntityPreSpawn);
230 /** runs in the event loop for players; is called for ALL player entities, also bots, also the dead, or spectators */
231 #define EV_PlayerPreThink(i, o) \
232 /** player */ i(entity, MUTATOR_ARGV_0_entity) \
234 MUTATOR_HOOKABLE(PlayerPreThink, EV_PlayerPreThink);
236 /** TODO change this into a general PlayerPostThink hook? */
237 #define EV_GetPressedKeys(i, o) \
238 /** player */ i(entity, MUTATOR_ARGV_0_entity) \
240 MUTATOR_HOOKABLE(GetPressedKeys, EV_GetPressedKeys);
242 /** is meant to call GetCvars_handle*(get_cvars_s, get_cvars_f, cvarfield, "cvarname") for cvars this mutator needs from the client */
243 #define EV_GetCvars(i, o) \
244 /**/ i(float, get_cvars_f) \
245 /**/ i(string, get_cvars_s) \
249 MUTATOR_HOOKABLE(GetCvars, EV_NO_ARGS); // NOTE: Can't use EV_GetCvars because of `SZ_GetSpace: overflow`
251 /** can edit any "just fired" projectile */
252 #define EV_EditProjectile(i, o) \
253 /** projectile owner */ i(entity, MUTATOR_ARGV_0_entity) \
254 /** projectile */ i(entity, MUTATOR_ARGV_1_entity) \
256 MUTATOR_HOOKABLE(EditProjectile, EV_EditProjectile);
258 /** called when a monster spawns */
259 #define EV_MonsterSpawn(i, o) \
260 /** monster */ i(entity, MUTATOR_ARGV_0_entity) \
262 MUTATOR_HOOKABLE(MonsterSpawn, EV_MonsterSpawn);
264 /** called when a monster dies */
265 #define EV_MonsterDies(i, o) \
266 /** target */ i(entity, MUTATOR_ARGV_0_entity) \
267 /** attacker */ i(entity, MUTATOR_ARGV_1_entity) \
268 /** deathtype */ i(float, MUTATOR_ARGV_2_float) \
270 MUTATOR_HOOKABLE(MonsterDies, EV_MonsterDies);
272 /** called when a monster dies */
273 #define EV_MonsterRemove(i, o) \
274 /** monster */ i(entity, MUTATOR_ARGV_0_entity) \
276 MUTATOR_HOOKABLE(MonsterRemove, EV_MonsterRemove);
278 /** called when a monster wants to respawn */
279 #define EV_MonsterRespawn(i, o) \
280 /** monster */ i(entity, MUTATOR_ARGV_0_entity) \
282 MUTATOR_HOOKABLE(MonsterRespawn, EV_MonsterRespawn);
284 /** called when a monster is dropping loot */
285 #define EV_MonsterDropItem(i, o) \
286 /* monster */ i(entity, MUTATOR_ARGV_0_entity) \
287 /* item (can be removed or changed) */ i(entity, MUTATOR_ARGV_1_entity) \
288 /**/ o(entity, MUTATOR_ARGV_1_entity) \
289 /* attacker */ i(entity, MUTATOR_ARGV_2_entity) \
291 .void(entity this) monster_loot;
292 MUTATOR_HOOKABLE(MonsterDropItem, EV_MonsterDropItem);
295 * called when a monster moves
296 * returning true makes the monster stop
298 #define EV_MonsterMove(i, o) \
299 /** monster */ i(entity, MUTATOR_ARGV_0_entity) \
300 /** run speed */ i(float, MUTATOR_ARGV_1_float) \
301 /**/ o(float, MUTATOR_ARGV_1_float) \
302 /** walk speed */ i(float, MUTATOR_ARGV_2_float) \
303 /**/ o(float, MUTATOR_ARGV_2_float) \
304 /** move target */ i(entity, MUTATOR_ARGV_3_entity) \
306 MUTATOR_HOOKABLE(MonsterMove, EV_MonsterMove);
308 /** called when a monster looks for another target */
309 MUTATOR_HOOKABLE(MonsterFindTarget, EV_NO_ARGS);
312 * called when validating a monster's target
314 #define EV_MonsterValidTarget(i, o) \
315 /** monster */ i(entity, MUTATOR_ARGV_0_entity) \
316 /** target */ i(entity, MUTATOR_ARGV_1_entity) \
318 MUTATOR_HOOKABLE(MonsterValidTarget, EV_MonsterValidTarget);
320 /** called to change a random monster to a miniboss */
321 #define EV_MonsterCheckBossFlag(i, o) \
322 /** monster */ i(entity, MUTATOR_ARGV_0_entity) \
324 MUTATOR_HOOKABLE(MonsterCheckBossFlag, EV_MonsterCheckBossFlag);
327 * called when a player tries to spawn a monster
328 * return 1 to prevent spawning
329 * NOTE: requires reason if disallowed
331 #define EV_AllowMobSpawning(i, o) \
332 /** caller */ i(entity, MUTATOR_ARGV_0_entity) \
333 /** reason */ o(string, MUTATOR_ARGV_1_string) \
335 MUTATOR_HOOKABLE(AllowMobSpawning, EV_AllowMobSpawning);
337 /** called when a player gets damaged to e.g. remove stuff he was carrying. */
338 #define EV_PlayerDamage_SplitHealthArmor(i, o) \
339 /** inflictor */ i(entity, MUTATOR_ARGV_0_entity) \
340 /** attacker */ i(entity, MUTATOR_ARGV_1_entity) \
341 /** target */ i(entity, MUTATOR_ARGV_2_entity) \
342 /** force (no out) */ i(vector, MUTATOR_ARGV_3_vector) \
343 /** damage take */ i(float, MUTATOR_ARGV_4_float) \
344 /** damage take */ o(float, MUTATOR_ARGV_4_float) \
345 /** damage save */ i(float, MUTATOR_ARGV_5_float) \
346 /** damage save */ o(float, MUTATOR_ARGV_5_float) \
347 /** deathtype */ i(float, MUTATOR_ARGV_6_float) \
348 /** damage */ i(float, MUTATOR_ARGV_7_float) \
350 MUTATOR_HOOKABLE(PlayerDamage_SplitHealthArmor, EV_PlayerDamage_SplitHealthArmor);
353 * called to adjust damage and force values which are applied to the player, used for e.g. strength damage/force multiplier
354 * i'm not sure if I should change this around slightly (Naming of the entities, and also how they're done in g_damage).
356 #define EV_Damage_Calculate(i, o) \
357 /** inflictor */ i(entity, MUTATOR_ARGV_0_entity) \
358 /** attacker */ i(entity, MUTATOR_ARGV_1_entity) \
359 /** target */ i(entity, MUTATOR_ARGV_2_entity) \
360 /** deathtype */ i(float, MUTATOR_ARGV_3_float) \
361 /** damage */ i(float, MUTATOR_ARGV_4_float) \
362 /** damage */ o(float, MUTATOR_ARGV_4_float) \
363 /** mirrordamage */ i(float, MUTATOR_ARGV_5_float) \
364 /** mirrordamage */ o(float, MUTATOR_ARGV_5_float) \
365 /** force */ i(vector, MUTATOR_ARGV_6_vector) \
366 /** force */ o(vector, MUTATOR_ARGV_6_vector) \
368 MUTATOR_HOOKABLE(Damage_Calculate, EV_Damage_Calculate);
371 * Called when a player is damaged
373 #define EV_PlayerDamaged(i, o) \
374 /** attacker */ i(entity, MUTATOR_ARGV_0_entity) \
375 /** target */ i(entity, MUTATOR_ARGV_1_entity) \
376 /** health */ i(float, MUTATOR_ARGV_2_float) \
377 /** armor */ i(float, MUTATOR_ARGV_3_float) \
378 /** location */ i(vector, MUTATOR_ARGV_4_vector) \
379 /** deathtype */ i(int, MUTATOR_ARGV_5_int) \
380 /** potential_damage */ i(float, MUTATOR_ARGV_6_float) \
382 MUTATOR_HOOKABLE(PlayerDamaged, EV_PlayerDamaged);
385 * Called by W_DecreaseAmmo
387 #define EV_W_DecreaseAmmo(i, o) \
388 /** actor */ i(entity, MUTATOR_ARGV_0_entity) \
389 /** weapon entity */ i(entity, MUTATOR_ARGV_1_entity) \
391 MUTATOR_HOOKABLE(W_DecreaseAmmo, EV_W_DecreaseAmmo);
396 #define EV_W_Reload(i, o) \
397 /** actor */ i(entity, MUTATOR_ARGV_0_entity) \
399 MUTATOR_HOOKABLE(W_Reload, EV_W_Reload);
401 /** called at the end of player_powerups() in client.qc, used for manipulating the values which are set by powerup items. */
402 #define EV_PlayerPowerups(i, o) \
403 /** player */ i(entity, MUTATOR_ARGV_0_entity) \
404 /** old items */ i(int, MUTATOR_ARGV_1_int) \
406 MUTATOR_HOOKABLE(PlayerPowerups, EV_PlayerPowerups);
409 * called every player think frame
410 * return 1 to disable regen
412 #define EV_PlayerRegen(i, o) \
413 /** player */ i(entity, MUTATOR_ARGV_0_entity) \
414 /** max_mod */ i(float, MUTATOR_ARGV_1_float) \
415 /**/ o(float, MUTATOR_ARGV_1_float) \
416 /** regen_mod */ i(float, MUTATOR_ARGV_2_float) \
417 /**/ o(float, MUTATOR_ARGV_2_float) \
418 /** rot_mod */ i(float, MUTATOR_ARGV_3_float) \
419 /**/ o(float, MUTATOR_ARGV_3_float) \
420 /** limit_mod */ i(float, MUTATOR_ARGV_4_float) \
421 /**/ o(float, MUTATOR_ARGV_4_float) \
422 /** health_regen */ i(float, MUTATOR_ARGV_5_float) \
423 /**/ o(float, MUTATOR_ARGV_5_float) \
424 /** health_regenlinear */ i(float, MUTATOR_ARGV_6_float) \
425 /**/ o(float, MUTATOR_ARGV_6_float) \
426 /** health_rot */ i(float, MUTATOR_ARGV_7_float) \
427 /**/ o(float, MUTATOR_ARGV_7_float) \
428 /** health_rotlinear */ i(float, MUTATOR_ARGV_8_float) \
429 /**/ o(float, MUTATOR_ARGV_8_float) \
430 /** health_stable */ i(float, MUTATOR_ARGV_9_float) \
431 /**/ o(float, MUTATOR_ARGV_9_float) \
432 /** health_rotstable */ i(float, MUTATOR_ARGV_10_float) \
433 /**/ o(float, MUTATOR_ARGV_10_float) \
435 MUTATOR_HOOKABLE(PlayerRegen, EV_PlayerRegen);
438 * called when the use key is pressed
439 * if MUTATOR_RETURNVALUE is 1, don't do anything
440 * return 1 if the use key actually did something
442 #define EV_PlayerUseKey(i, o) \
443 /** player */ i(entity, MUTATOR_ARGV_0_entity) \
445 MUTATOR_HOOKABLE(PlayerUseKey, EV_PlayerUseKey);
448 * called when a client command is parsed
449 * NOTE: hooks MUST start with if (MUTATOR_RETURNVALUE) return false;
450 * NOTE: return true if you handled the command, return false to continue handling
451 * NOTE: THESE HOOKS MUST NEVER EVER CALL tokenize()
453 * MUTATOR_HOOKFUNCTION(foo_SV_ParseClientCommand)
455 * if (MUTATOR_RETURNVALUE) // command was already handled?
457 * if (cmd_name == "echocvar" && cmd_argc >= 2)
459 * print(cvar_string(argv(1)), "\n");
462 * if (cmd_name == "echostring" && cmd_argc >= 2)
464 * print(substring(cmd_string, argv_start_index(1), argv_end_index(-1) - argv_start_index(1)), "\n");
470 #define EV_SV_ParseClientCommand(i, o) \
471 /** client sending the command */ i(entity, MUTATOR_ARGV_0_entity) \
472 /** command name */ i(string, MUTATOR_ARGV_1_string) \
473 /** argc (also, argv() can be used) */ i(int, MUTATOR_ARGV_2_int) \
474 /** whole command, use only if you really have to */ i(string, MUTATOR_ARGV_3_string) \
476 MUTATOR_HOOKABLE(SV_ParseClientCommand, EV_SV_ParseClientCommand);
478 /** please read EV_SV_ParseClientCommand description before using */
479 #define EV_SV_ParseServerCommand(i, o) \
480 /** command name */ i(string, MUTATOR_ARGV_0_string) \
481 /** argc (also, argv() can be used) */ i(int, MUTATOR_ARGV_1_int) \
482 /** whole command, use only if you really have to */ i(string, MUTATOR_ARGV_2_string) \
484 MUTATOR_HOOKABLE(SV_ParseServerCommand, EV_SV_ParseServerCommand);
487 * called when a spawnpoint is being evaluated
488 * return 1 to make the spawnpoint unusable
490 #define EV_Spawn_Score(i, o) \
491 /** player wanting to spawn */ i(entity, MUTATOR_ARGV_0_entity) \
492 /** spot to be evaluated */ i(entity, MUTATOR_ARGV_1_entity) \
493 /** spot score, _x is priority, _y is "distance" */ i(vector, MUTATOR_ARGV_2_vector) \
494 /**/ o(vector, MUTATOR_ARGV_2_vector) \
496 MUTATOR_HOOKABLE(Spawn_Score, EV_Spawn_Score);
498 /** runs globally each server frame */
499 MUTATOR_HOOKABLE(SV_StartFrame, EV_NO_ARGS);
501 #define EV_SetModname(i, o) \
502 /** name of the mutator/mod if it warrants showing as such in the server browser */ \
503 /**/ i(string, MUTATOR_ARGV_0_string) \
504 /**/ o(string, MUTATOR_ARGV_0_string) \
506 MUTATOR_HOOKABLE(SetModname, EV_SetModname);
509 * called for each item being spawned on a map, including dropped weapons
510 * return 1 to remove an item
512 #define EV_Item_Spawn(i, o) \
513 /** item */ i(entity, MUTATOR_ARGV_0_entity) \
515 MUTATOR_HOOKABLE(Item_Spawn, EV_Item_Spawn);
517 #define EV_SetWeaponreplace(i, o) \
518 /** map entity */ i(entity, MUTATOR_ARGV_0_entity) \
519 /** weapon info */ i(entity, MUTATOR_ARGV_1_entity) \
520 /** replacement */ i(string, MUTATOR_ARGV_2_string) \
521 /**/ o(string, MUTATOR_ARGV_2_string) \
523 MUTATOR_HOOKABLE(SetWeaponreplace, EV_SetWeaponreplace);
525 /** called when an item is about to respawn */
526 #define EV_Item_RespawnCountdown(i, o) \
527 /** item name */ i(string, MUTATOR_ARGV_0_string) \
528 /**/ o(string, MUTATOR_ARGV_0_string) \
529 /** item colour */ i(vector, MUTATOR_ARGV_1_vector) \
530 /**/ o(vector, MUTATOR_ARGV_1_vector) \
532 MUTATOR_HOOKABLE(Item_RespawnCountdown, EV_Item_RespawnCountdown);
534 /** called when a bot checks a target to attack */
535 #define EV_BotShouldAttack(i, o) \
536 /** bot */ i(entity, MUTATOR_ARGV_0_entity) \
537 /** target */ i(entity, MUTATOR_ARGV_1_entity) \
539 MUTATOR_HOOKABLE(BotShouldAttack, EV_BotShouldAttack);
542 * called whenever a player goes through a portal gun teleport
543 * allows you to strip a player of an item if they go through the teleporter to help prevent cheating
545 #define EV_PortalTeleport(i, o) \
546 /** player */ i(entity, MUTATOR_ARGV_0_entity) \
548 MUTATOR_HOOKABLE(PortalTeleport, EV_PortalTeleport);
551 * called whenever a player uses impulse 33 (help me) in impulse.qc
552 * normally help me ping uses .waypointsprite_attachedforcarrier,
553 * but if your mutator uses something different then you can handle it
554 * in a special manner using this hook
556 #define EV_HelpMePing(i, o) \
557 /** the player who pressed impulse 33 */ i(entity, MUTATOR_ARGV_0_entity) \
559 MUTATOR_HOOKABLE(HelpMePing, EV_HelpMePing);
562 * called when a vehicle initializes
563 * return true to remove the vehicle
565 #define EV_VehicleInit(i, o) \
566 /** vehicle */ i(entity, MUTATOR_ARGV_0_entity) \
568 MUTATOR_HOOKABLE(VehicleInit, EV_VehicleInit);
571 * called when a player enters a vehicle
572 * allows mutators to set special settings in this event
574 #define EV_VehicleEnter(i, o) \
575 /** player */ i(entity, MUTATOR_ARGV_0_entity) \
576 /** vehicle */ i(entity, MUTATOR_ARGV_1_entity) \
578 MUTATOR_HOOKABLE(VehicleEnter, EV_VehicleEnter);
581 * called when a player touches a vehicle
582 * return true to stop player from entering the vehicle
584 #define EV_VehicleTouch(i, o) \
585 /** vehicle */ i(entity, MUTATOR_ARGV_0_entity) \
586 /** player */ i(entity, MUTATOR_ARGV_1_entity) \
588 MUTATOR_HOOKABLE(VehicleTouch, EV_VehicleTouch);
591 * called when a player exits a vehicle
592 * allows mutators to set special settings in this event
594 #define EV_VehicleExit(i, o) \
595 /** player */ i(entity, MUTATOR_ARGV_0_entity) \
596 /** vehicle */ i(entity, MUTATOR_ARGV_1_entity) \
598 MUTATOR_HOOKABLE(VehicleExit, EV_VehicleExit);
600 /** called when a speedrun is aborted and the player is teleported back to start position */
601 #define EV_AbortSpeedrun(i, o) \
602 /** player */ i(entity, MUTATOR_ARGV_0_entity) \
604 MUTATOR_HOOKABLE(AbortSpeedrun, EV_AbortSpeedrun);
606 /** called at when a item is touched. Called early, can edit item properties. */
607 #define EV_ItemTouch(i, o) \
608 /** item */ i(entity, MUTATOR_ARGV_0_entity) \
609 /** toucher */ i(entity, MUTATOR_ARGV_1_entity) \
610 /**/ o(entity, MUTATOR_ARGV_1_entity) \
612 MUTATOR_HOOKABLE(ItemTouch, EV_ItemTouch);
615 MUT_ITEMTOUCH_CONTINUE, // return this flag to make the function continue as normal
616 MUT_ITEMTOUCH_RETURN, // return this flag to make the function return (handled entirely by mutator)
617 MUT_ITEMTOUCH_PICKUP // return this flag to have the item "picked up" and taken even after mutator handled it
620 /** called at when a player connect */
621 #define EV_ClientConnect(i, o) \
622 /** player */ i(entity, MUTATOR_ARGV_0_entity) \
624 MUTATOR_HOOKABLE(ClientConnect, EV_ClientConnect);
626 #define EV_HavocBot_ChooseRole(i, o) \
627 /** bot */ i(entity, MUTATOR_ARGV_0_entity) \
629 MUTATOR_HOOKABLE(HavocBot_ChooseRole, EV_HavocBot_ChooseRole);
631 /** called when a target is checked for accuracy */
632 #define EV_AccuracyTargetValid(i, o) \
633 /** attacker */ i(entity, MUTATOR_ARGV_0_entity) \
634 /** target */ i(entity, MUTATOR_ARGV_1_entity) \
636 MUTATOR_HOOKABLE(AccuracyTargetValid, EV_AccuracyTargetValid);
638 MUT_ACCADD_VALID, // return this flag to make the function continue if target is a client
639 MUT_ACCADD_INVALID, // return this flag to make the function always continue
640 MUT_ACCADD_INDIFFERENT // return this flag to make the function always return
643 /** Called when clearing the global parameters for a model */
644 MUTATOR_HOOKABLE(ClearModelParams, EV_NO_ARGS);
646 /** Called when getting the global parameters for a model */
647 #define EV_GetModelParams(i, o) \
648 /** input */ i(string, MUTATOR_ARGV_0_string) \
649 /** command */ i(string, MUTATOR_ARGV_1_string) \
651 MUTATOR_HOOKABLE(GetModelParams, EV_GetModelParams);
653 /** called when a bullet has hit a target */
654 #define EV_FireBullet_Hit(i, o) \
655 /** player */ i(entity, MUTATOR_ARGV_0_entity) \
656 /** targ */ i(entity, MUTATOR_ARGV_1_entity) \
657 /** start pos */ i(vector, MUTATOR_ARGV_2_vector) \
658 /** end pos */ i(vector, MUTATOR_ARGV_3_vector) \
659 /** damage */ i(float, MUTATOR_ARGV_4_float) \
660 /**/ o(float, MUTATOR_ARGV_4_float) \
662 MUTATOR_HOOKABLE(FireBullet_Hit, EV_FireBullet_Hit);
664 #define EV_FixPlayermodel(i, o) \
665 /** model */ i(string, MUTATOR_ARGV_0_string) \
666 /**/ o(string, MUTATOR_ARGV_0_string) \
667 /** skin */ i(int, MUTATOR_ARGV_1_int) \
668 /**/ o(int, MUTATOR_ARGV_1_int) \
669 /** player */ i(entity, MUTATOR_ARGV_2_entity) \
671 MUTATOR_HOOKABLE(FixPlayermodel, EV_FixPlayermodel);
673 /** Return error to play frag remaining announcements */
674 MUTATOR_HOOKABLE(Scores_CountFragsRemaining, EV_NO_ARGS);
676 #define EV_GrappleHookThink(i, o) \
677 /** hook */ i(entity, MUTATOR_ARGV_0_entity) \
678 /** tarzan */ i(int, MUTATOR_ARGV_1_int) \
679 /**/ o(int, MUTATOR_ARGV_1_int) \
680 /** pulling entity */ i(entity, MUTATOR_ARGV_2_entity) \
681 /**/ o(entity, MUTATOR_ARGV_2_entity) \
682 /** velocity multiplier */ i(float, MUTATOR_ARGV_3_float) \
683 /**/ o(float, MUTATOR_ARGV_3_float) \
685 MUTATOR_HOOKABLE(GrappleHookThink, EV_GrappleHookThink);
687 #define EV_BuffModel_Customize(i, o) \
688 /** buff */ i(entity, MUTATOR_ARGV_0_entity) \
689 /** player */ i(entity, MUTATOR_ARGV_1_entity) \
691 MUTATOR_HOOKABLE(BuffModel_Customize, EV_BuffModel_Customize);
693 /** called at when a buff is touched. Called early, can edit buff properties. */
694 #define EV_BuffTouch(i, o) \
695 /** buff */ i(entity, MUTATOR_ARGV_0_entity) \
696 /** player */ i(entity, MUTATOR_ARGV_1_entity) \
697 /**/ o(entity, MUTATOR_ARGV_1_entity) \
699 MUTATOR_HOOKABLE(BuffTouch, EV_BuffTouch);
701 MUTATOR_HOOKABLE(SetNewParms, EV_NO_ARGS);
703 MUTATOR_HOOKABLE(SetChangeParms, EV_NO_ARGS);
705 MUTATOR_HOOKABLE(DecodeLevelParms, EV_NO_ARGS);
707 #define EV_GetRecords(i, o) \
708 /** page */ i(int, MUTATOR_ARGV_0_int) \
709 /** record list */ i(string, MUTATOR_ARGV_1_string) \
710 /**/ o(string, MUTATOR_ARGV_1_string) \
712 MUTATOR_HOOKABLE(GetRecords, EV_GetRecords);
714 #define EV_Race_FinalCheckpoint(i, o) \
715 /** player */ i(entity, MUTATOR_ARGV_0_entity) \
717 MUTATOR_HOOKABLE(Race_FinalCheckpoint, EV_Race_FinalCheckpoint);
719 /** called when player triggered kill (or is changing teams), return error to not do anything */
720 #define EV_ClientKill(i, o) \
721 /** player */ i(entity, MUTATOR_ARGV_0_entity) \
722 /** kill delay */ i(float, MUTATOR_ARGV_1_float) \
723 /**/ o(float, MUTATOR_ARGV_1_float) \
725 MUTATOR_HOOKABLE(ClientKill, EV_ClientKill);
727 #define EV_FixClientCvars(i, o) \
728 /** player */ i(entity, MUTATOR_ARGV_0_entity) \
730 MUTATOR_HOOKABLE(FixClientCvars, EV_FixClientCvars);
732 #define EV_SpectateSet(i, o) \
733 /** client */ i(entity, MUTATOR_ARGV_0_entity) \
734 /** target */ i(entity, MUTATOR_ARGV_1_entity) \
735 /**/ o(entity, MUTATOR_ARGV_1_entity) \
737 MUTATOR_HOOKABLE(SpectateSet, EV_SpectateSet);
739 #define EV_SpectateNext(i, o) \
740 /** client */ i(entity, MUTATOR_ARGV_0_entity) \
741 /** target */ i(entity, MUTATOR_ARGV_1_entity) \
742 /**/ o(entity, MUTATOR_ARGV_1_entity) \
744 MUTATOR_HOOKABLE(SpectateNext, EV_SpectateNext);
746 #define EV_SpectatePrev(i, o) \
747 /** client */ i(entity, MUTATOR_ARGV_0_entity) \
748 /** target */ i(entity, MUTATOR_ARGV_1_entity) \
749 /**/ o(entity, MUTATOR_ARGV_1_entity) \
750 /** first */ i(entity, MUTATOR_ARGV_2_entity) \
752 MUTATOR_HOOKABLE(SpectatePrev, EV_SpectatePrev);
755 MUT_SPECPREV_CONTINUE, // return this flag to make the function continue as normal
756 MUT_SPECPREV_RETURN, // return this flag to make the function return (handled entirely by mutator)
757 MUT_SPECPREV_FOUND // return this flag to make the function continue without default functions (handled mostly by mutator)
760 /** called when player triggered kill (or is changing teams), return error to not do anything */
761 #define EV_Bot_FixCount(i, o) \
762 /** active real players */ i(int, MUTATOR_ARGV_0_int) \
763 /**/ o(int, MUTATOR_ARGV_0_int) \
764 /** real players */ i(int, MUTATOR_ARGV_1_int) \
765 /**/ o(int, MUTATOR_ARGV_1_int) \
767 MUTATOR_HOOKABLE(Bot_FixCount, EV_Bot_FixCount);
769 #define EV_ClientCommand_Spectate(i, o) \
770 /** player */ i(entity, MUTATOR_ARGV_0_entity) \
772 MUTATOR_HOOKABLE(ClientCommand_Spectate, EV_ClientCommand_Spectate);
775 MUT_SPECCMD_CONTINUE, // return this flag to make the function continue as normal
776 MUT_SPECCMD_RETURN, // return this flag to make the function return (don't spectate)
777 MUT_SPECCMD_FORCE // return this flag to force the player to spectate, even if they're not a player
780 #define EV_CheckRules_World(i, o) \
781 /** status */ i(float, MUTATOR_ARGV_0_float) \
782 /**/ o(float, MUTATOR_ARGV_0_float) \
783 /* time limit */ i(float, MUTATOR_ARGV_1_float) \
784 /* frag limit */ i(float, MUTATOR_ARGV_2_float) \
786 MUTATOR_HOOKABLE(CheckRules_World, EV_CheckRules_World);
788 #define EV_WantWeapon(i, o) \
789 /** weapon info entity */ i(entity, MUTATOR_ARGV_0_entity) \
790 /** do want? */ i(float, MUTATOR_ARGV_1_float) \
791 /**/ o(float, MUTATOR_ARGV_1_float) \
792 /** want all guns */ i(bool, MUTATOR_ARGV_2_bool) \
793 /**/ o(bool, MUTATOR_ARGV_2_bool) \
794 /** want mutator blocked */ i(bool, MUTATOR_ARGV_3_bool) \
795 /**/ o(bool, MUTATOR_ARGV_3_bool) \
797 MUTATOR_HOOKABLE(WantWeapon, EV_WantWeapon);
799 #define EV_AddPlayerScore(i, o) \
800 /** score field */ i(PlayerScoreField, MUTATOR_ARGV_0_entity) \
801 /** score */ i(float, MUTATOR_ARGV_1_float) \
802 /**/ o(float, MUTATOR_ARGV_1_float) \
803 /** player */ i(entity, MUTATOR_ARGV_2_entity) \
805 MUTATOR_HOOKABLE(AddPlayerScore, EV_AddPlayerScore);
807 #define EV_GetPlayerStatus(i, o) \
808 /** player */ i(entity, MUTATOR_ARGV_0_entity) \
810 MUTATOR_HOOKABLE(GetPlayerStatus, EV_GetPlayerStatus);
812 #define EV_SetWeaponArena(i, o) \
813 /** arena */ i(string, MUTATOR_ARGV_0_string) \
814 /**/ o(string, MUTATOR_ARGV_0_string) \
816 MUTATOR_HOOKABLE(SetWeaponArena, EV_SetWeaponArena);
818 #define EV_DropSpecialItems(i, o) \
819 /** target */ i(entity, MUTATOR_ARGV_0_entity) \
821 MUTATOR_HOOKABLE(DropSpecialItems, EV_DropSpecialItems);
824 * called when an admin tries to kill all monsters
825 * return 1 to prevent spawning
827 #define EV_AllowMobButcher(i, o) \
828 /** reason */ o(string, MUTATOR_ARGV_0_string) \
830 MUTATOR_HOOKABLE(AllowMobButcher, EV_AllowMobButcher);
832 MUTATOR_HOOKABLE(ReadLevelCvars, EV_NO_ARGS);
834 #define EV_SendWaypoint(i, o) \
835 /** waypoint */ i(entity, MUTATOR_ARGV_0_entity) \
836 /** to */ i(entity, MUTATOR_ARGV_1_entity) \
837 /** send flags */ i(int, MUTATOR_ARGV_2_int) \
838 /**/ o(int, MUTATOR_ARGV_2_int) \
839 /** wp flag */ i(int, MUTATOR_ARGV_3_int) \
840 /**/ o(int, MUTATOR_ARGV_3_int) \
842 MUTATOR_HOOKABLE(SendWaypoint, EV_SendWaypoint);
844 #define EV_TurretValidateTarget(i, o) \
845 /** turret */ i(entity, MUTATOR_ARGV_0_entity) \
846 /** target */ i(entity, MUTATOR_ARGV_1_entity) \
847 /** validate flags */ i(int, MUTATOR_ARGV_2_int) \
848 /** target score */ o(float, MUTATOR_ARGV_3_float) \
850 MUTATOR_HOOKABLE(TurretValidateTarget, EV_TurretValidateTarget);
852 #define EV_TurretThink(i, o) \
853 /** turret */ i(entity, MUTATOR_ARGV_0_entity) \
855 MUTATOR_HOOKABLE(TurretThink, EV_TurretThink);
857 MUTATOR_HOOKABLE(Ent_Init, EV_NO_ARGS);
860 #define EV_PrepareExplosionByDamage(i, o) \
861 /** projectile */ i(entity, MUTATOR_ARGV_0_entity) \
862 /** attacker */ i(entity, MUTATOR_ARGV_1_entity) \
864 MUTATOR_HOOKABLE(PrepareExplosionByDamage, EV_PrepareExplosionByDamage);
866 /** called when a monster model is about to be set, allows custom paths etc. */
867 #define EV_MonsterModel(i, o) \
868 /** model */ i(string, MUTATOR_ARGV_0_string) \
869 /** output */ i(string, MUTATOR_ARGV_1_string) \
870 /**/ o(string, MUTATOR_ARGV_1_string) \
872 MUTATOR_HOOKABLE(MonsterModel, EV_MonsterModel);
875 #define EV_Player_ChangeTeam(i, o) \
876 /** player */ i(entity, MUTATOR_ARGV_0_entity) \
877 /** current team */ i(float, MUTATOR_ARGV_1_float) \
878 /** new team */ i(float, MUTATOR_ARGV_2_float) \
880 MUTATOR_HOOKABLE(Player_ChangeTeam, EV_Player_ChangeTeam);
883 #define EV_URI_GetCallback(i, o) \
884 /** id */ i(float, MUTATOR_ARGV_0_float) \
885 /** status */ i(float, MUTATOR_ARGV_1_float) \
886 /** data */ i(string, MUTATOR_ARGV_2_string) \
888 MUTATOR_HOOKABLE(URI_GetCallback, EV_URI_GetCallback);
891 * return true to prevent weapon use for a player
893 #define EV_ForbidWeaponUse(i, o) \
894 /** player */ i(entity, MUTATOR_ARGV_0_entity) \
896 MUTATOR_HOOKABLE(ForbidWeaponUse, EV_ForbidWeaponUse);
898 /** called when creating a clone of the player (usually for corpses that stay after the player has re-spawned) */
899 #define EV_CopyBody(i, o) \
900 /** player */ i(entity, MUTATOR_ARGV_0_entity) \
901 /** newly created clone */ i(entity, MUTATOR_ARGV_1_entity) \
902 /** keepvelocity? */ i(bool, MUTATOR_ARGV_2_bool) \
904 MUTATOR_HOOKABLE(CopyBody, EV_CopyBody);
906 /** called when sending a chat message, ret argument can be changed to prevent the message */
907 #define EV_ChatMessage(i, o) \
908 /** sender */ i(entity, MUTATOR_ARGV_0_entity) \
909 /** ret */ i(int, MUTATOR_ARGV_1_int) \
910 /**/ o(int, MUTATOR_ARGV_1_int) \
912 MUTATOR_HOOKABLE(ChatMessage, EV_ChatMessage);
914 /** return true to prevent sending a chat (private, team or regular) message from reaching a certain player */
915 #define EV_ChatMessageTo(i, o) \
916 /** destination player */ i(entity, MUTATOR_ARGV_0_entity) \
917 /** sender */ i(entity, MUTATOR_ARGV_1_entity) \
919 MUTATOR_HOOKABLE(ChatMessageTo, EV_ChatMessageTo);
921 /** return true to just restart the match, for modes that don't support readyrestart */
922 MUTATOR_HOOKABLE(ReadyRestart_Deny, EV_NO_ARGS);