]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/dpdefs/doc.md
Merge branch 'master' into TimePath/scoreboard_elo
[xonotic/xonotic-data.pk3dir.git] / qcsrc / dpdefs / doc.md
1 # CSQC
2
3 ```
4
5 // input:
6 //   self
7 .void() predraw;
8
9 // input:
10 //   time
11 //   self
12 .void() think;
13
14 // 0 = keydown, key, character (EXT_CSQC)
15 // 1 = keyup, key, character (EXT_CSQC)
16 // 2 = mousemove relative, x, y (EXT_CSQC)
17 // 3 = mousemove absolute, x, y (DP_CSQC)
18 bool CSQC_InputEvent(int eventtype, int x, int y);
19
20 void CSQC_UpdateView(int width, int height);
21 // catch commands registered with registercommand
22 bool CSQC_ConsoleCommand(string cmd);
23 bool CSQC_Parse_TempEntity();
24 bool CSQC_Parse_StuffCmd(string msg);
25 bool CSQC_Parse_Print(string msg);
26 bool CSQC_Parse_CenterPrint(string msg);
27 bool CSQC_Event_Sound(int ent, int channel, string sample, float volume, float attenuation, vector pos, float speed, int flags);
28
29 entity CSQC_Ent_Spawn(int entnum);
30 void CSQC_Ent_Update(bool isnew);
31 void CSQC_Ent_Remove();
32
33 void CSQC_Init();
34 void CSQC_Shutdown();
35
36 // input:
37 //   time
38 //   self
39 //   v_forward: forward
40 //   v_right: right
41 //   v_up: up
42 // output:
43 //   origin
44 //   v_forward: forward
45 //   v_right: right
46 //   v_up: up
47 //   trace_endpos: visorigin
48 .vector camera_transform(vector pos, vector ang);
49
50 // control start position of sound()
51 // calculated as ofs = time - sound_starttime
52 float sound_starttime;
53
54 ```
55
56 # SVQC
57
58 Main loop:
59 * SV_Physics()
60     * StartFrame()
61     * if (force_retouch)
62         * foreach entity:
63             * .touch()
64     * foreach client:
65         * PlayerPreThink()
66         * .think()
67         * PlayerPostThink()
68     * foreach nonclient:
69         * .think()
70     * EndFrame()
71
72
73 ```
74
75 .entity clientcamera;
76
77 // input:
78 //   time
79 //   self
80 void ClientDisconnect();
81
82 // input:
83 //   time
84 void SV_Shutdown();
85
86 // input:
87 //   time
88 void SV_PausedTic(float elapsed);
89
90 // input:
91 //   time
92 //   self
93 void SV_ChangeTeam(int color);
94
95 // input:
96 //   time
97 //   self
98 void ClientKill();
99
100 // input:
101 //   time
102 //   self
103 void RestoreGame();
104
105 // Called when a client connects to the server
106 // input:
107 //   time
108 //   self
109 //   parm1..n
110 void ClientConnect();
111
112 // Called when a client spawns in the server
113 // input:
114 //   time
115 //   self
116 //   parm1..n
117 void PutClientInServer();
118
119 // return false to remove
120 .bool SendEntity(entity to, int sf);
121
122 // input:
123 //   time
124 //   self
125 void SV_OnEntityPreSpawnFunction();
126
127 // input:
128 //   time
129 //   self
130 void SV_OnEntityNoSpawnFunction();
131
132 // input:
133 //   time
134 //   self
135 void SV_OnEntityPostSpawnFunction();
136
137 // input:
138 //   time
139 // output:
140 //   parm1..n
141 void SetNewParms();
142
143 // Runs every frame
144 // input:
145 //
146 .bool customizeentityforclient();
147
148 // input:
149 //   time
150 //   self
151 // output:
152 //   parm1..n
153 void SetChangeParms();
154
155 // input:
156 //   time
157 //   self
158 //   other
159 //   trace_allsolid
160 //   trace_startsolid
161 //   trace_fraction
162 //   trace_inwater
163 //   trace_inopen
164 //   trace_endpos: self.origin
165 //   trace_plane_normal
166 //   trace_plane_dist
167 //   trace_ent: other
168 //   trace_dpstartcontents
169 //   trace_dphitcontents
170 //   trace_dphitq3surfaceflags
171 //   trace_dphittexturename
172 .void touch();
173
174 // when .watertype changes:
175 .void contentstransition(int prev, int current);
176
177 // input:
178 //   time
179 //   self
180 //   other
181 .void blocked();
182
183 // input:
184 //   time
185 //   self
186 .void movetypesteplandevent(vector vel);
187
188 // input:
189 //   time
190 //   self
191 void PlayerPreThink();
192
193 // input:
194 //   time
195 //   self
196 void PlayerPostThink();
197
198 // input:
199 //   time
200 //   frametime
201 void StartFrame();
202
203 // input:
204 //   time
205 void EndFrame();
206
207 // input:
208 //   time
209 //   self
210 void SV_PlayerPhysics();
211
212 // input:
213 //   time
214 //   self
215 void SV_ParseClientCommand(string cmd);
216
217 // qcstatus server field
218 string worldstatus;
219 .string clientstatus;
220
221 ```
222
223 # MENUQC
224
225 ```
226
227 void m_keydown(int key, int ascii);
228
229 void m_keyup(int key, int ascii);
230
231 void m_draw(int width, int height);
232
233 void m_toggle(int mode);
234
235 int m_gethostcachecategory(int entry);
236
237 void m_shutdown();
238
239 void m_init();
240
241 ```
242
243 # All
244
245 ```
246
247 void URI_Get_Callback(int id, int status, string data);
248
249 void GameCommand(string cmd);
250
251 ```
252
253 # Misc
254
255 ## Trace
256
257 ### tracebox
258
259     void tracebox(vector v1, vector min, vector max, vector v2, int tryents, entity ignoreentity);
260
261 attempt to move an object from v1 to v2 of given size
262
263 tryents:
264  * MOVE_NORMAL (0)
265  * MOVE_NOMONSTERS (1): ignore monsters
266  * MOVE_MISSILE (2): +15 to every extent
267  * MOVE_WORLDONLY (3): ignore everything except bsp
268  * MOVE_HITMODEL (4): hit model, not bbox
269
270 ### traceline
271
272     void traceline(vector v1, vector v2, int tryents, entity ignoreentity);
273
274 degenerate case of tracebox when min and max are equal
275
276 ### result globals
277
278     bool trace_allsolid;
279
280 trace never left solid
281
282     bool trace_startsolid;
283
284 trace started inside solid
285
286     float trace_fraction;
287
288 distance before collision: 0..1, 1 if no collision
289
290     vector trace_endpos;
291
292 v1 + (v2 - v1) * trace_fraction
293
294     vector trace_plane_normal;
295
296 normalized plane normal, '0 0 0' if no collision.
297 May be present if edges touch without clipping, use `trace_fraction < 1` as a determinant instead
298
299     float trace_plane_dist;
300
301
302
303     entity trace_ent;
304
305 entity hit, if any
306
307     bool trace_inopen;
308
309
310
311     bool trace_inwater;
312
313
314
315     int trace_dpstartcontents;
316
317 DPCONTENTS_ value at start position of trace
318
319     int trace_dphitcontents;
320
321 DPCONTENTS_ value of impacted surface (not contents at impact point, just contents of the surface that was hit)
322
323     int trace_dphitq3surfaceflags;
324
325 Q3SURFACEFLAG_ value of impacted surface
326
327     string trace_dphittexturename;
328
329 texture name of impacted surface
330
331     int trace_networkentity;
332
333