1 **Note:** The article is written as developer notes to ease developer tasks and save QuakeC function terms here. Some references are taken from `events.qh`.
4 # MUTATOR functions (from: `qcsrc/server/mutators/events.qh`)
8 How to use MUTATOR functions:
10 **Attention:** to use a hook, first register your mutator using `REGISTER_MUTATOR`, then create your function using `MUTATOR_HOOKFUNCTION`.
13 **`REGISTER_MUTATOR`**
15 Registers a new `MUTATOR_HOOKFUNCTION`.
17 REGISTER_MUTATOR(new_mutator_name, some_variable);
21 **`MUTATOR_HOOKFUNCTION`**
23 Creates a function and calls `new_mutator_name` (from `REGISTER_MUTATOR`) and one of `#define MUTATOR()` (from `qcsrc/server/mutators/events.qh` main hooks).
27 MUTATOR_HOOKFUNCTION(helloworld, PlayerSpawn)
33 **`MUTATOR_CALLHOOK`**
35 Calls some `MUTATOR_HOOKFUNCTION`.
37 MUTATOR_CALLHOOK(name_of_MUTATOR_HOOKFUNCTION_or_events.qh_main_hooks);
40 There are different versions and depends how many variables need to be called in a `MUTATOR_HOOKFUNCTION`:
42 1 `MUTATOR_HOOKFUNCTION` and 1 variable:
45 MUTATOR_CALLHOOK(name_of_MUTATOR_HOOKFUNCTION_or_events.qh_main_hooks, some_variable);
48 1 `MUTATOR_HOOKFUNCTION` and 2 variables:
51 MUTATOR_CALLHOOK(name_of_MUTATOR_HOOKFUNCTION_or_events.qh_main_hooks, some_variable, some_variable);
54 1 `MUTATOR_HOOKFUNCTION` and 3 variables:
57 MUTATOR_CALLHOOK(name_of_MUTATOR_HOOKFUNCTION_or_events.qh_main_hooks, some_variable, some_variable, some_variable);
60 1 `MUTATOR_HOOKFUNCTION` and multiple variables:
63 MUTATOR_CALLHOOK(name_of_MUTATOR_HOOKFUNCTION_or_events.qh_main_hooks, some_variable, some_variable, some_variable, some_variable, ...);
70 ## List of MUTATOR functions
72 **`MakePlayerObserver`**
74 Called when a player becomes observer, after shared setup.
76 #define EV_MakePlayerObserver(i, o) \
77 /** player */ i(entity, MUTATOR_ARGV_0_entity) \
79 MUTATOR_HOOKABLE(MakePlayerObserver, EV_MakePlayerObserver)
82 **`PutClientInServer`**
84 Called when client spawns in server. (Not sure described)
86 #define EV_PutClientInServer(i, o) \
87 /** client wanting to spawn */ i(entity, MUTATOR_ARGV_0_entity) \
89 MUTATOR_HOOKABLE(PutClientInServer, EV_PutClientInServer);
94 Returns true to prevent a spectator/observer to spawn as player.
96 #define EV_ForbidSpawn(i, o) \
97 /** player */ i(entity, MUTATOR_ARGV_0_entity) \
99 MUTATOR_HOOKABLE(ForbidSpawn, EV_ForbidSpawn);
102 **`AutoJoinOnConnection`**
104 Returns true if client should be put as player on connection.
106 #define EV_AutoJoinOnConnection(i, o) \
107 /** player */ i(entity, MUTATOR_ARGV_0_entity) \
109 MUTATOR_HOOKABLE(AutoJoinOnConnection, EV_AutoJoinOnConnection);
112 **`ForbidRandomStartWeapons`**
114 Called when player spawns to determine whether to give them random start weapons. Return true to forbid giving them.
116 #define EV_ForbidRandomStartWeapons(i, o) \
117 /** player */ i(entity, MUTATOR_ARGV_0_entity) \
119 MUTATOR_HOOKABLE(ForbidRandomStartWeapons, EV_ForbidRandomStartWeapons);
124 Called when a player spawns as player, after shared setup, before his weapon is chosen (so items may be changed in here)
127 #define EV_PlayerSpawn(i, o) \
128 /** player spawning */ i(entity, MUTATOR_ARGV_0_entity) \
129 /** spot that was used, or NULL */ i(entity, MUTATOR_ARGV_1_entity) \
131 MUTATOR_HOOKABLE(PlayerSpawn, EV_PlayerSpawn);
134 **`PlayerWeaponSelect`**
136 Called after a player's weapon is chosen so it can be overriden here.
138 #define EV_PlayerWeaponSelect(i, o) \
139 /** player spawning */ i(entity, MUTATOR_ARGV_0_entity) \
141 MUTATOR_HOOKABLE(PlayerWeaponSelect, EV_PlayerWeaponSelect);
144 **`reset_map_global`**
148 #define EV_reset_map_global(i, o) \
150 MUTATOR_HOOKABLE(reset_map_global, EV_reset_map_global);
153 **`reset_map_players`**
157 #define EV_reset_map_players(i, o) \
159 MUTATOR_HOOKABLE(reset_map_players, EV_reset_map_players);
166 **`Damage_Calculate`**
168 Called to adjust damage and force values which are applied to the player, used for e.g. strength damage/force multiplier, I'm not sure if I should change this around slightly (Naming of the entities, and also how they're done in g_damage).
171 #define EV_Damage_Calculate(i, o) \
172 /** inflictor */ i(entity, MUTATOR_ARGV_0_entity) \
173 /** attacker */ i(entity, MUTATOR_ARGV_1_entity) \
174 /** target */ i(entity, MUTATOR_ARGV_2_entity) \
175 /** deathtype */ i(float, MUTATOR_ARGV_3_float) \
176 /** damage */ i(float, MUTATOR_ARGV_4_float) \
177 /** damage */ o(float, MUTATOR_ARGV_4_float) \
178 /** mirrordamage */ i(float, MUTATOR_ARGV_5_float) \
179 /** mirrordamage */ o(float, MUTATOR_ARGV_5_float) \
180 /** force */ i(vector, MUTATOR_ARGV_6_vector) \
181 /** force */ o(vector, MUTATOR_ARGV_6_vector) \
183 MUTATOR_HOOKABLE(Damage_Calculate, EV_Damage_Calculate);
188 AND.... STILL in process