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/client/mutators/events.qh`, `qcsrc/common/mutators/events.qh`, `qcsrc/server/mutators/events.qh`)
6 ### How to use MUTATOR functions:
8 **Attention:** to use a hook, first register your mutator using `REGISTER_MUTATOR`, then create your function using `MUTATOR_HOOKFUNCTION`.
11 - **`REGISTER_MUTATOR`**
13 Registers a new `MUTATOR_HOOKFUNCTION`.
15 REGISTER_MUTATOR(new_mutator_name, some_variable);
19 - **`MUTATOR_HOOKFUNCTION`**
21 Creates a function and calls `new_mutator_name` (from `REGISTER_MUTATOR`) and one of `#define MUTATOR()` (from `qcsrc/server/mutators/events.qh` main hooks).
25 MUTATOR_HOOKFUNCTION(new_mutator_name, events.qh_main_hook)
31 - **`MUTATOR_CALLHOOK`**
33 Calls some `MUTATOR_HOOKFUNCTION`.
35 MUTATOR_CALLHOOK(name_of_MUTATOR_HOOKFUNCTION_or_events.qh_main_hook);
38 There are different versions and depends how many variables need to be called in a `MUTATOR_HOOKFUNCTION`:
40 1 `MUTATOR_HOOKFUNCTION` and 1 variable:
43 MUTATOR_CALLHOOK(name_of_MUTATOR_HOOKFUNCTION_or_events.qh_main_hook, some_variable);
46 1 `MUTATOR_HOOKFUNCTION` and 2 variables:
49 MUTATOR_CALLHOOK(name_of_MUTATOR_HOOKFUNCTION_or_events.qh_main_hook, some_variable, some_variable);
52 1 `MUTATOR_HOOKFUNCTION` and 3 variables:
55 MUTATOR_CALLHOOK(name_of_MUTATOR_HOOKFUNCTION_or_events.qh_main_hook, some_variable, some_variable, some_variable);
58 1 `MUTATOR_HOOKFUNCTION` and multiple variables:
61 MUTATOR_CALLHOOK(name_of_MUTATOR_HOOKFUNCTION_or_events.qh_main_hook, some_variable, some_variable, some_variable, some_variable, ...);
68 ## List of MUTATOR functions
70 You can look the MUTATOR functions in:
74 **`qcsrc/common/mutators/events.qh`** :
75 https://timepath.github.io/scratchspace/d4/d95/common_2mutators_2events_8qh.html
80 **`qcsrc/client/mutators/events.qh`** :
81 https://timepath.github.io/scratchspace/d8/d0e/client_2mutators_2events_8qh.html
86 **`qcsrc/server/mutators/events.qh`** :
87 https://timepath.github.io/scratchspace/d6/ddd/server_2mutators_2events_8qh.html
95 ## A bit of introduction
97 You'll need understand that weapons can be interacted with **autocvars** variables(example: `float autocvar_g_balance_someweapon_speed;`) and each weapon with .qh file where cvars are declared without the need to declare using `autocvar_blabla...`. *Think*, *touch*, *explode* and those types of functions can be declared within an *attack* function and *whatever* it is called. Note that there are also METHODs that are necessary for the weapon to work.
99 - **Think** function makes the weapon shot react on what to do.
100 - **Touch** function makes the weapon shot react against some element where touch (like player, monster, vehicle, ...).
101 - **Explode** function makes the weapon explosion react.
102 - **Attack/Whatever** function is where the weapon attack executes, keep in mind that it has the other functions attached to be executed.
104 You can look the example of this weapon code:
105 - [**devastator.qh**](https://timepath.github.io/scratchspace/d9/dfa/devastator_8qh_source.html)
106 - [**devastator.qc**](https://timepath.github.io/scratchspace/d9/d5d/devastator_8qc_source.html)
110 ## List of WEAPON functions
112 This is a created list of functions to modify/create weapons. There are incomplete explanations for each function.
114 There are contents taken from `qcsrc/common/weapons/all.qh`.
116 **WARNING:** The contents may content wonky code, and the interactions can change and not do the same what happens here.
120 - [**W_SetupShot_Dir**](https://timepath.github.io/scratchspace/d4/d3f/tracing_8qh.html#aff0ea351757ee6caf83b25d12d18656c)
136 - [**W_SetupProjVelocity_Explicit**](https://timepath.github.io/scratchspace/d7/d31/tracing_8qc.html#a55f8f2b1828413bfb123a5fcb61b9f8e)
139 void W_SetupProjVelocity_Explicit(
151 - [**W_MuzzleFlash**](https://timepath.github.io/scratchspace/d0/ddd/weapons_2all_8qh_source.html)(located in `qcsrc/common/weapons/all.qh` line 406)
153 In the moment when player shots the weapon, weapon flashes.
155 *Note:* write `#ifdef SVQC` at the start of using this function, and write with `#endif` after declared the function(only can do this if the code which needs execute can do this, although maybe you need more functions/things in the code inside this).
158 void W_MuzzleFlash(Weapon thiswep, entity actor, .entity weaponentity, vector shotorg, vector shotdir);
161 - [**Weapon selection functions**](https://timepath.github.io/scratchspace/d8/d6b/selection_8qh.html)
162 (located in `qcsrc/server/weapons/selection.qh`)
164 - [**Weapon decrease ammo, speed factor, rate factor, reload functions**](https://timepath.github.io/scratchspace/d5/de0/weaponsystem_8qc.html)
165 (located in `qcsrc/server/weapons/weaponsystem.qh`)
170 # Menu and Draw functions
172 You can look the draw functions where HUD is being drawn:
173 - [**Draw functions and macros (`qcsrc/client/draw.qh`)**](https://timepath.github.io/scratchspace/d5/d8d/client_2draw_8qh_source.html)
175 More info inside the code where you can draw/print HUD and menu:
176 - [**Globals, constants, fonts, prints, error cmds, vector stuff, conversion functions and all drawing/printing HUDs/menus/characters related (`qcsrc/dpdefs/upstream/menudefs.qc`)**](https://timepath.github.io/scratchspace/d8/de2/menudefs_8qc_source.html)
180 AND... STILL more things in process