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