]> git.xonotic.org Git - xonotic/xonotic.wiki.git/blob - Functions-and-other-programming-QuakeC-things-in-Xonotic.md
Added and fixed some nade cvars
[xonotic/xonotic.wiki.git] / Functions-and-other-programming-QuakeC-things-in-Xonotic.md
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`.
2
3
4 # MUTATOR functions (from: `qcsrc/client/mutators/events.qh`, `qcsrc/common/mutators/events.qh`, `qcsrc/server/mutators/events.qh`)
5
6 ### Introduction
7
8 How to use MUTATOR functions:
9
10 **Attention:** to use a hook, first register your mutator using `REGISTER_MUTATOR`, then create your function using `MUTATOR_HOOKFUNCTION`.
11
12
13 - **`REGISTER_MUTATOR`**
14
15 Registers a new `MUTATOR_HOOKFUNCTION`.
16 ```c
17 REGISTER_MUTATOR(new_mutator_name, some_variable);
18 ```
19
20
21 - **`MUTATOR_HOOKFUNCTION`**
22
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).
24
25 Example:
26 ```c
27 MUTATOR_HOOKFUNCTION(new_mutator_name, events.qh_main_hook)
28 {
29     // whatever does
30 }
31 ```
32
33 - **`MUTATOR_CALLHOOK`**
34
35 Calls some `MUTATOR_HOOKFUNCTION`.
36 ```c
37 MUTATOR_CALLHOOK(name_of_MUTATOR_HOOKFUNCTION_or_events.qh_main_hook);
38 ```
39
40 There are different versions and depends how many variables need to be called in a `MUTATOR_HOOKFUNCTION`:
41
42 1 `MUTATOR_HOOKFUNCTION` and 1 variable:
43
44 ```c
45 MUTATOR_CALLHOOK(name_of_MUTATOR_HOOKFUNCTION_or_events.qh_main_hook, some_variable);
46 ```
47
48 1 `MUTATOR_HOOKFUNCTION` and 2 variables:
49
50 ```c
51 MUTATOR_CALLHOOK(name_of_MUTATOR_HOOKFUNCTION_or_events.qh_main_hook, some_variable, some_variable);
52 ```
53
54 1 `MUTATOR_HOOKFUNCTION` and 3 variables:
55
56 ```c
57 MUTATOR_CALLHOOK(name_of_MUTATOR_HOOKFUNCTION_or_events.qh_main_hook, some_variable, some_variable, some_variable);
58 ```
59
60 1 `MUTATOR_HOOKFUNCTION` and multiple variables:
61
62 ```c
63 MUTATOR_CALLHOOK(name_of_MUTATOR_HOOKFUNCTION_or_events.qh_main_hook, some_variable, some_variable, some_variable, some_variable, ...);
64 ```
65
66 <br />
67 <br />
68
69
70 ## List of MUTATOR functions
71
72 You can look the MUTATOR functions in:
73
74 **COMMON**:
75
76 **`qcsrc/common/mutators/events.qh`** :
77 https://timepath.github.io/scratchspace/d4/d95/common_2mutators_2events_8qh.html
78
79
80 **CLIENT**:
81
82 **`qcsrc/client/mutators/events.qh`** :
83 https://timepath.github.io/scratchspace/d8/d0e/client_2mutators_2events_8qh.html
84
85
86 **SERVER**:
87
88 **`qcsrc/server/mutators/events.qh`** :
89 https://timepath.github.io/scratchspace/d6/ddd/server_2mutators_2events_8qh.html
90
91
92 <br />
93 <br />
94
95
96 ## List of WEAPON functions
97
98 This is a created functions list to modify/create weapons. There are incomplete explanations for each function.
99
100 There are contents taken from `qcsrc/common/weapons/all.qh`.
101
102 **WARNING:** The contents may content wonky code, and the interactions can change and not do the same what happens here.
103
104 <br />
105 <br />
106
107 - [**W_SetupShot_Dir**](https://timepath.github.io/scratchspace/d4/d3f/tracing_8qh.html#aff0ea351757ee6caf83b25d12d18656c)
108
109 ```c
110 W_SetupShot_Dir(
111         ent,
112         wepent,
113         s_forward,
114         antilag,
115         recoil,
116         snd,
117         chan,
118         maxdamage,
119         deathtype 
120 )
121 ```
122
123 - [**W_SetupProjVelocity_Explicit**](https://timepath.github.io/scratchspace/d7/d31/tracing_8qc.html#a55f8f2b1828413bfb123a5fcb61b9f8e)
124
125 ```c
126 void W_SetupProjVelocity_Explicit(
127     entity      proj,
128     vector      dir,
129     vector      upDir,
130     float       pSpeed,
131     float       pUpSpeed,
132     float       pZSpeed,
133     float       spread,
134     float       forceAbsolute 
135 )
136 ```
137
138 - [**W_MuzzleFlash**](https://timepath.github.io/scratchspace/d0/ddd/weapons_2all_8qh_source.html)(located in `qcsrc/common/weapons/all.qh` line 406)
139
140 In the moment when player shots the weapon, weapon flashes.
141 *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).
142
143 ```c
144 void W_MuzzleFlash(Weapon thiswep, entity actor, .entity weaponentity, vector shotorg, vector shotdir);
145 ```
146
147 - [**Weapon selection functions**](https://timepath.github.io/scratchspace/d8/d6b/selection_8qh.html)
148 (located in `qcsrc/server/weapons/selection.qh`)
149
150 - [**Weapon decrease ammo, speed factor, rate factor, reload functions**](https://timepath.github.io/scratchspace/d5/de0/weaponsystem_8qc.html)
151 (located in `qcsrc/server/weapons/weaponsystem.qh`)
152
153
154 AND.... STILL in process