]> de.git.xonotic.org Git - xonotic/darkplaces.git/blob - dpdefs/dpextensions.qc
oops, I hadn't document DP_QC_I18N back then... sorry for that
[xonotic/darkplaces.git] / dpdefs / dpextensions.qc
1
2 //DarkPlaces supported extension list, draft version 1.04
3
4 //things that don't have extensions yet:
5 .float disableclientprediction;
6
7 //definitions that id Software left out:
8 //these are passed as the 'nomonsters' parameter to traceline/tracebox (yes really this was supported in all quake engines, nomonsters is misnamed)
9 float MOVE_NORMAL = 0; // same as FALSE
10 float MOVE_NOMONSTERS = 1; // same as TRUE
11 float MOVE_MISSILE = 2; // save as movement with .movetype == MOVETYPE_FLYMISSILE
12
13 //checkextension function
14 //idea: expected by almost everyone
15 //darkplaces implementation: LordHavoc
16 float(string s) checkextension = #99;
17 //description:
18 //check if (cvar("pr_checkextension")) before calling this, this is the only
19 //guaranteed extension to be present in the extension system, it allows you
20 //to check if an extension is available, by name, to check for an extension
21 //use code like this:
22 //// (it is recommended this code be placed in worldspawn or a worldspawn called function somewhere)
23 //if (cvar("pr_checkextension"))
24 //if (checkextension("DP_SV_SETCOLOR"))
25 //      ext_setcolor = TRUE;
26 //from then on you can check ext_setcolor to know if that extension is available
27
28 //BX_WAL_SUPPORT
29 //idea: id Software
30 //darkplaces implementation: LordHavoc
31 //description:
32 //indicates the engine supports .wal textures for filenames in the textures/ directory
33 //(note: DarkPlaces has supported this since 2001 or 2002, but did not advertise it as an extension, then I noticed Betwix was advertising it and added the extension accordingly)
34
35 //DP_BUTTONCHAT
36 //idea: Vermeulen
37 //darkplaces implementation: LordHavoc
38 //field definitions:
39 .float buttonchat;
40 //description:
41 //true if the player is currently chatting (in messagemode, menus or console)
42
43 //DP_BUTTONUSE
44 //idea: id Software
45 //darkplaces implementation: LordHavoc
46 //field definitions:
47 .float buttonuse;
48 //client console commands:
49 //+use
50 //-use
51 //description:
52 //made +use and -use commands work, they now control the .buttonuse field (.button1 was used by many mods for other purposes).
53
54 //DP_CL_LOADSKY
55 //idea: Nehahra, LordHavoc
56 //darkplaces implementation: LordHavoc
57 //client console commands:
58 //"loadsky" (parameters: "basename", example: "mtnsun_" would load "mtnsun_up.tga" and "mtnsun_rt.tga" and similar names, use "" to revert to quake sky, note: this is the same as Quake2 skybox naming)
59 //description:
60 //sets global skybox for the map for this client (can be stuffed to a client by QC), does not hurt much to repeatedly execute this command, please don't use this in mods if it can be avoided (only if changing skybox is REALLY needed, otherwise please use DP_GFX_SKYBOX).
61
62 //DP_CON_SET
63 //idea: id Software
64 //darkplaces implementation: LordHavoc
65 //description:
66 //indicates this engine supports the "set" console command which creates or sets a non-archived cvar (not saved to config.cfg on exit), it is recommended that set and seta commands be placed in default.cfg for mod-specific cvars.
67
68 //DP_CON_SETA
69 //idea: id Software
70 //darkplaces implementation: LordHavoc
71 //description:
72 //indicates this engine supports the "seta" console command which creates or sets an archived cvar (saved to config.cfg on exit), it is recommended that set and seta commands be placed in default.cfg for mod-specific cvars.
73
74 //DP_CON_ALIASPARAMETERS
75 //idea: many
76 //darkplaces implementation: Black
77 //description:
78 //indicates this engine supports aliases containing $1 through $9 parameter macros (which when called will expand to the parameters passed to the alias, for example alias test "say $2 $1", then you can type test hi there and it will execute say there hi), as well as $0 (name of the alias) and $* (all parameters $1 onward).
79
80 //DP_CON_EXPANDCVAR
81 //idea: many, PHP
82 //darkplaces implementation: Black
83 //description:
84 //indicates this engine supports console commandlines containing $cvarname which will expand to the contents of that cvar as a parameter, for instance say my fov is $fov, will say "my fov is 90", or similar.
85
86 //DP_CON_STARTMAP
87 //idea: LordHavoc
88 //darkplaces implementation: LordHavoc
89 //description:
90 //adds two engine-called aliases named startmap_sp and startmap_dm which are called when the engine tries to start a singleplayer game from the menu (startmap_sp) or the -listen or -dedicated options are used or the engine is a dedicated server (uses startmap_dm), these allow a mod or game to specify their own map instead of start, and also distinguish between singleplayer and -listen/-dedicated, also these need not be a simple "map start" command, they can do other things if desired, startmap_sp and startmap_dm both default to "map start".
91
92 //DP_EF_ADDITIVE
93 //idea: LordHavoc
94 //darkplaces implementation: LordHavoc
95 //effects bit:
96 float   EF_ADDITIVE     = 32;
97 //description:
98 //additive blending when this object is rendered
99
100 //DP_EF_BLUE
101 //idea: id Software
102 //darkplaces implementation: LordHavoc
103 //effects bit:
104 float   EF_BLUE         = 64;
105 //description:
106 //entity emits blue light (used for quad)
107
108 //DP_EF_DOUBLESIDED
109 //idea: LordHavoc
110 //darkplaces implementation: [515] and LordHavoc
111 //effects bit:
112 float EF_DOUBLESIDED = 32768;
113 //description:
114 //render entity as double sided (backfaces are visible, I.E. you see the 'interior' of the model, rather than just the front), can be occasionally useful on transparent stuff.
115
116 //DP_EF_FLAME
117 //idea: LordHavoc
118 //darkplaces implementation: LordHavoc
119 //effects bit:
120 float   EF_FLAME        = 1024;
121 //description:
122 //entity is on fire
123
124 //DP_EF_FULLBRIGHT
125 //idea: LordHavoc
126 //darkplaces implementation: LordHavoc
127 //effects bit:
128 float   EF_FULLBRIGHT   = 512;
129 //description:
130 //entity is always brightly lit
131
132 //DP_EF_NODEPTHTEST
133 //idea: Supa
134 //darkplaces implementation: LordHavoc
135 //effects bit:
136 float   EF_NODEPTHTEST       = 8192;
137 //description:
138 //makes entity show up to client even through walls, useful with EF_ADDITIVE for special indicators like where team bases are in a map, so that people don't get lost
139
140 //DP_EF_NODRAW
141 //idea: id Software
142 //darkplaces implementation: LordHavoc
143 //effects bit:
144 float   EF_NODRAW       = 16;
145 //description:
146 //prevents server from sending entity to client (forced invisible, even if it would have been a light source or other such things)
147
148 //DP_EF_NOGUNBOB
149 //idea: Chris Page, Dresk
150 //darkplaces implementation: LordHAvoc
151 //effects bit:
152 float   EF_NOGUNBOB     = 256;
153 //description:
154 //this has different meanings depending on the entity it is used on:
155 //player entity - prevents gun bobbing on player.viewmodel
156 //viewmodelforclient entity - prevents gun bobbing on an entity attached to the player's view
157 //other entities - no effect
158 //uses:
159 //disabling gun bobbing on a diving mask or other model used as a .viewmodel.
160 //disabling gun bobbing on view-relative models meant to be part of the heads up display.  (note: if fov is changed these entities may be off-screen, or too near the center of the screen, so use fov 90 in this case)
161
162 //DP_EF_NOSHADOW
163 //idea: LordHavoc
164 //darkplaces implementation: LordHavoc
165 //effects bit:
166 float   EF_NOSHADOW     = 4096;
167 //description:
168 //realtime lights will not cast shadows from this entity (but can still illuminate it)
169
170 //DP_EF_RED
171 //idea: id Software
172 //darkplaces implementation: LordHavoc
173 //effects bit:
174 float   EF_RED          = 128;
175 //description:
176 //entity emits red light (used for invulnerability)
177
178 //DP_EF_RESTARTANIM_BIT
179 //idea: id software
180 //darkplaces implementation: divVerent
181 //effects bit:
182 float   EF_RESTARTANIM_BIT = 1048576;
183 //description:
184 //when toggled, the current animation is restarted. Useful for weapon animation.
185 //to toggle this bit in QC, you can do:
186 //  self.effects += (EF_RESTARTANIM_BIT - 2 * (self.effects & EF_RESTARTANIM_BIT));
187
188 //DP_EF_STARDUST
189 //idea: MythWorks Inc
190 //darkplaces implementation: LordHavoc
191 //effects bit:
192 float   EF_STARDUST     = 2048;
193 //description:
194 //entity emits bouncing sparkles in every direction
195
196 //DP_EF_TELEPORT_BIT
197 //idea: id software
198 //darkplaces implementation: divVerent
199 //effects bit:
200 float   EF_TELEPORT_BIT = 2097152;
201 //description:
202 //when toggled, interpolation of the entity is skipped for one frame. Useful for teleporting.
203 //to toggle this bit in QC, you can do:
204 //  self.effects += (EF_TELEPORT_BIT - 2 * (self.effects & EF_TELEPORT_BIT));
205
206 //DP_ENT_ALPHA
207 //idea: Nehahra
208 //darkplaces implementation: LordHavoc
209 //fields:
210 .float alpha;
211 //description:
212 //controls opacity of the entity, 0.0 is forced to be 1.0 (otherwise everything would be invisible), use -1 if you want to make something invisible, 1.0 is solid (like normal).
213
214 //DP_ENT_COLORMOD
215 //idea: LordHavoc
216 //darkplaces implementation: LordHavoc
217 //field definition:
218 .vector colormod;
219 //description:
220 //controls color of the entity, '0 0 0', is forced to be '1 1 1' (otherwise everything would be black), used for tinting objects, for instance using '1 0.6 0.4' on an ogre would give you an orange ogre (order is red green blue), note the colors can go up to '8 8 8' (8x as bright as normal).
221
222 //DP_ENT_CUSTOMCOLORMAP
223 //idea: LordHavoc
224 //darkplaces implementation: LordHavoc
225 //description:
226 //if .colormap is set to 1024 + pants + shirt * 16, those colors will be used for colormapping the entity, rather than looking up a colormap by player number.
227
228 /*
229 //NOTE: no longer supported by darkplaces because all entities are delta compressed now
230 //DP_ENT_DELTACOMPRESS // no longer supported
231 //idea: LordHavoc
232 //darkplaces implementation: LordHavoc
233 //effects bit:
234 float EF_DELTA = 8388608;
235 //description:
236 //(obsolete) applies delta compression to the network updates of the entity, making updates smaller, this might cause some unreliable behavior in packet loss situations, so it should only be used on numerous (nails/plasma shots/etc) or unimportant objects (gibs/shell casings/bullet holes/etc).
237 */
238
239 //DP_ENT_EXTERIORMODELTOCLIENT
240 //idea: LordHavoc
241 //darkplaces implementation: LordHavoc
242 //fields:
243 .entity exteriormodeltoclient;
244 //description:
245 //the entity is visible to all clients with one exception: if the specified client is using first person view (not using chase_active) the entity will not be shown.  Also if tag attachments are supported any entities attached to the player entity will not be drawn in first person.
246
247 //DP_ENT_GLOW
248 //idea: LordHavoc
249 //darkplaces implementation: LordHavoc
250 //field definitions:
251 .float glow_color;
252 .float glow_size;
253 .float glow_trail;
254 //description:
255 //customizable glowing light effect on the entity, glow_color is a paletted (8bit) color in the range 0-255 (note: 0 and 254 are white), glow_size is 0 or higher (up to the engine what limit to cap it to, darkplaces imposes a 1020 limit), if glow_trail is true it will leave a trail of particles of the same color as the light.
256
257 //DP_ENT_GLOWMOD
258 //idea: LordHavoc
259 //darkplaces implementation: LordHavoc
260 //field definition:
261 .vector glowmod;
262 //description:
263 //controls color of the entity's glow texture (fullbrights), '0 0 0', is forced to be '1 1 1' (otherwise everything would be black), used for tinting objects, see colormod (same color restrictions apply).
264
265 //DP_ENT_LOWPRECISION
266 //idea: LordHavoc
267 //darkplaces implementation: LordHavoc
268 //effects bit:
269 float EF_LOWPRECISION = 4194304;
270 //description:
271 //uses low quality origin coordinates, reducing network traffic compared to the default high precision, intended for numerous objects (projectiles/gibs/bullet holes/etc).
272
273 //DP_ENT_SCALE
274 //idea: LordHavoc
275 //darkplaces implementation: LordHavoc
276 //field definitions:
277 .float scale;
278 //description:
279 //controls rendering scale of the object, 0 is forced to be 1, darkplaces uses 1/16th accuracy and a limit of 15.9375, can be used to make an object larger or smaller.
280
281 //DP_ENT_TRAILEFFECTNUM
282 //idea: LordHavoc
283 //darkplaces implementation: LordHavoc
284 //field definitions:
285 .float traileffectnum;
286 //description:
287 //use a custom effectinfo.txt effect on this entity, assign it like this:
288 //self.traileffectnum = particleeffectnum("mycustomeffect");
289 //this will do both the dlight and particle trail as described in the effect, basically equivalent to trailparticles() in CSQC but performed on a server entity.
290
291 //DP_ENT_VIEWMODEL
292 //idea: LordHavoc
293 //darkplaces implementation: LordHavoc
294 //field definitions:
295 .entity viewmodelforclient;
296 //description:
297 //this is a very special capability, attachs the entity to the view of the client specified, origin and angles become relative to the view of that client, all effects can be used (multiple skins on a weapon model etc)...  the entity is not visible to any other client.
298
299 //DP_GFX_EXTERNALTEXTURES
300 //idea: LordHavoc
301 //darkplaces implementation: LordHavoc
302 //description:
303 //loads external textures found in various directories (tenebrae compatible)...
304 /*
305 in all examples .tga is merely the base texture, it can be any of these:
306 .tga (base texture)
307 _glow.tga (fullbrights or other glowing overlay stuff, NOTE: this is done using additive blend, not alpha)
308 _pants.tga (pants overlay for colormapping on models, this should be shades of grey (it is tinted by pants color) and black wherever the base texture is not black, as this is an additive blend)
309 _shirt.tga (same idea as pants, but for shirt color)
310 _diffuse.tga (this may be used instead of base texture for per pixel lighting)
311 _gloss.tga (specular texture for per pixel lighting, note this can be in color (tenebrae only supports greyscale))
312 _norm.tga (normalmap texture for per pixel lighting)
313 _bump.tga (bumpmap, converted to normalmap at load time, supported only for reasons of tenebrae compatibility)
314 _luma.tga (same as _glow but supported only for reasons of tenebrae compatibility)
315
316 due to glquake's incomplete Targa(r) loader, this section describes
317 required Targa(r) features support:
318 types:
319 type 1 (uncompressed 8bit paletted with 24bit/32bit palette)
320 type 2 (uncompressed 24bit/32bit true color, glquake supported this)
321 type 3 (uncompressed 8bit greyscale)
322 type 9 (RLE compressed 8bit paletted with 24bit/32bit palette)
323 type 10 (RLE compressed 24bit/32bit true color, glquake supported this)
324 type 11 (RLE compressed 8bit greyscale)
325 attribute bit 0x20 (Origin At Top Left, top to bottom, left to right)
326
327 image formats guaranteed to be supported: tga, pcx, lmp
328 image formats that are optional: png, jpg
329
330 mdl/spr/spr32 examples:
331 skins are named _A (A being a number) and skingroups are named like _A_B
332 these act as suffixes on the model name...
333 example names for skin _2_1 of model "progs/armor.mdl":
334 game/override/progs/armor.mdl_2_1.tga
335 game/textures/progs/armor.mdl_2_1.tga
336 game/progs/armor.mdl_2_1.tga
337 example names for skin _0 of the model "progs/armor.mdl":
338 game/override/progs/armor.mdl_0.tga
339 game/textures/progs/armor.mdl_0.tga
340 game/progs/armor.mdl_0.tga
341 note that there can be more skins files (of the _0 naming) than the mdl
342 contains, this is only useful to save space in the .mdl file if classic quake
343 compatibility is not a concern.
344
345 bsp/md2/md3 examples:
346 example names for the texture "quake" of model "maps/start.bsp":
347 game/override/quake.tga
348 game/textures/quake.tga
349 game/quake.tga
350
351 sbar/menu/console textures: for example the texture "conchars" (console font) in gfx.wad
352 game/override/gfx/conchars.tga
353 game/textures/gfx/conchars.tga
354 game/gfx/conchars.tga
355 */
356
357 //DP_GFX_EXTERNALTEXTURES_PERMAPTEXTURES
358 //idea: Fuh?
359 //darkplaces implementation: LordHavoc
360 //description:
361 //Q1BSP and HLBSP map loading loads external textures found in textures/<mapname>/ as well as textures/.
362 //Where mapname is the bsp filename minus the extension (typically .bsp) and minus maps/ if it is in maps/ (any other path is not removed)
363 //example:
364 //maps/e1m1.bsp uses textures in the directory textures/e1m1/ and falls back to textures/
365 //maps/b_batt0.bsp uses textures in the directory textures/b_batt0.bsp and falls back to textures/
366 //as a more extreme example:
367 //progs/something/blah.bsp uses textures in the directory textures/progs/something/blah/ and falls back to textures/
368
369 //DP_GFX_FOG
370 //idea: LordHavoc
371 //darkplaces implementation: LordHavoc
372 //worldspawn fields:
373 //"fog" (parameters: "density red green blue", example: "0.1 0.3 0.3 0.3")
374 //description:
375 //global fog for the map, can not be changed by QC
376
377 //DP_GFX_QUAKE3MODELTAGS
378 //idea: id Software
379 //darkplaces implementation: LordHavoc
380 //field definitions:
381 .entity tag_entity; // entity this is attached to (call setattachment to set this)
382 .float tag_index; // which tag on that entity (0 is relative to the entity, > 0 is an index into the tags on the model if it has any) (call setattachment to set this)
383 //builtin definitions:
384 void(entity e, entity tagentity, string tagname) setattachment = #443; // attachs e to a tag on tagentity (note: use "" to attach to entity origin/angles instead of a tag)
385 //description:
386 //allows entities to be visually attached to model tags (which follow animations perfectly) on other entities, for example attaching a weapon to a player's hand, or upper body attached to lower body, allowing it to change angles and frame separately (note: origin and angles are relative to the tag, use '0 0 0' for both if you want it to follow exactly, this is similar to viewmodelforclient's behavior).
387 //note 2: if the tag is not found, it defaults to "" (attach to origin/angles of entity)
388 //note 3: attaching to world turns off attachment
389 //note 4: the entity that this is attached to must be visible for this to work
390 //note 5: if an entity is attached to the player entity it will not be drawn in first person.
391
392 //DP_GFX_SKINFILES
393 //idea: LordHavoc
394 //darkplaces implementation: LordHavoc
395 //description:
396 //alias models (mdl, md2, md3) can have .skin files to replace conventional texture naming, these have a naming format such as:
397 //progs/test.md3_0.skin
398 //progs/test.md3_1.skin
399 //...
400 //
401 //these files contain replace commands (replace meshname shadername), example:
402 //replace "helmet" "progs/test/helmet1.tga" // this is a mesh shader replacement
403 //replace "teamstripes" "progs/test/redstripes.tga"
404 //replace "visor" "common/nodraw" // this makes the visor mesh invisible
405 ////it is not possible to rename tags using this format
406 //
407 //Or the Quake3 syntax (100% compatible with Quake3's .skin files):
408 //helmet,progs/test/helmet1.tga // this is a mesh shader replacement
409 //teamstripes,progs/test/redstripes.tga
410 //visor,common/nodraw // this makes the visor mesh invisible
411 //tag_camera, // this defines that the first tag in the model is called tag_camera
412 //tag_test, // this defines that the second tag in the model is called tag_test
413 //
414 //any names that are not replaced are automatically show up as a grey checkerboard to indicate the error status, and "common/nodraw" is a special case that is invisible.
415 //this feature is intended to allow multiple skin sets on md3 models (which otherwise only have one skin set).
416 //other commands might be added someday but it is not expected.
417
418 //DP_GFX_SKYBOX
419 //idea: LordHavoc
420 //darkplaces implementation: LordHavoc
421 //worldspawn fields:
422 //"sky" (parameters: "basename", example: "mtnsun_" would load "mtnsun_up.tga" and "mtnsun_rt.tga" and similar names, note: "sky" is also used the same way by Quake2)
423 //description:
424 //global skybox for the map, can not be changed by QC
425
426 //DP_UTF8
427 //idea: Blub\0, divVerent
428 //darkplaces implementation: Blub\0
429 //cvar definitions:
430 //   utf8_enable: enable utf8 encoding
431 //description: utf8 characters are allowed inside cvars, protocol strings, files, progs strings, etc., 
432 //and count as 1 char for string functions like strlen, substring, etc.
433 // note: utf8_enable is run-time cvar, could be changed during execution
434 // note: beware that str2chr() could return value bigger than 255 once utf8 is enabled
435
436 //DP_HALFLIFE_MAP
437 //idea: LordHavoc
438 //darkplaces implementation: LordHavoc
439 //description:
440 //simply indicates that the engine supports HalfLife maps (BSP version 30, NOT the QER RGBA ones which are also version 30).
441
442 //DP_HALFLIFE_MAP_CVAR
443 //idea: LordHavoc
444 //darkplaces implementation: LordHavoc
445 //cvars:
446 //halflifebsp 0/1
447 //description:
448 //engine sets this cvar when loading a map to indicate if it is halflife format or not.
449
450 //DP_HALFLIFE_SPRITE
451 //idea: LordHavoc
452 //darkplaces implementation: LordHavoc
453 //description:
454 //simply indicates that the engine supports HalfLife sprites.
455
456 //DP_INPUTBUTTONS
457 //idea: LordHavoc
458 //darkplaces implementation: LordHavoc
459 //field definitions:
460 .float button3;
461 .float button4;
462 .float button5;
463 .float button6;
464 .float button7;
465 .float button8;
466 .float button9;
467 .float button10;
468 .float button11;
469 .float button12;
470 .float button13;
471 .float button14;
472 .float button15;
473 .float button16;
474 //description:
475 //set to the state of the +button3, +button4, +button5, +button6, +button7, and +button8 buttons from the client, this does not involve protocol changes (the extra 6 button bits were simply not used).
476 //the exact mapping of protocol button bits on the server is:
477 //self.button0 = (bits & 1) != 0;
478 ///* button1 is skipped because mods abuse it as a variable, and accordingly it has no bit */
479 //self.button2 = (bits & 2) != 0;
480 //self.button3 = (bits & 4) != 0;
481 //self.button4 = (bits & 8) != 0;
482 //self.button5 = (bits & 16) != 0;
483 //self.button6 = (bits & 32) != 0;
484 //self.button7 = (bits & 64) != 0;
485 //self.button8 = (bits & 128) != 0;
486
487 // DP_LIGHTSTYLE_STATICVALUE
488 // idea: VorteX
489 // darkplaces implementation: VorteX
490 // description: allows alternative 'static' lightstyle syntax : "=value"
491 // examples: "=0.5", "=2.0", "=2.75"
492 // could be used to control switchable lights or making styled lights with brightness > 2
493 // Warning: this extension is experimental. It safely works in CSQC, but SVQC use is limited by the fact 
494 // that other engines (which do not support this extension) could connect to a game and misunderstand this kind of lightstyle syntax
495
496 //DP_LITSPRITES
497 //idea: LordHavoc
498 //darkplaces implementation: LordHavoc
499 //description:
500 //indicates this engine supports lighting on sprites, any sprite with ! in its filename (both on disk and in the qc) will be lit rather than having forced EF_FULLBRIGHT (EF_FULLBRIGHT on the entity can still force these sprites to not be lit).
501
502 //DP_LITSUPPORT
503 //idea: LordHavoc
504 //darkplaces implementation: LordHavoc
505 //description:
506 //indicates this engine loads .lit files for any quake1 format .bsp files it loads to enhance maps with colored lighting.
507 //implementation description: these files begin with the header QLIT followed by version number 1 (as little endian 32bit), the rest of the file is a replacement lightmaps lump, except being 3x as large as the lightmaps lump of the map it matches up with (and yes the between-lightmap padding is expanded 3x to keep this consistent), so the lightmap offset in each surface is simply multiplied by 3 during loading to properly index the lit data, and the lit file is loaded instead of the lightmap lump, other renderer changes are needed to display these of course...  see the litsupport.zip sample code (almost a tutorial) at http://icculus.org/twilight/darkplaces for more information.
508
509 //DP_MONSTERWALK
510 //idea: LordHavoc
511 //darkplaces implementation: LordHavoc
512 //description:
513 //MOVETYPE_WALK is permitted on non-clients, so bots can move smoothly, run off ledges, etc, just like a real player.
514
515 //DP_MOVETYPEBOUNCEMISSILE
516 //idea: id Software
517 //darkplaces implementation: id Software
518 //movetype definitions:
519 //float MOVETYPE_BOUNCEMISSILE = 11; // already in defs.qc
520 //description:
521 //MOVETYPE_BOUNCE but without gravity, and with full reflection (no speed loss like grenades have), in other words - bouncing laser bolts.
522
523 //DP_MOVETYPEFLYWORLDONLY
524 //idea: Samual
525 //darkplaces implementation: Samual
526 //movetype definitions:
527 float MOVETYPE_FLY_WORLDONLY = 33;
528 //description:
529 //like MOVETYPE_FLY, but does all traces with MOVE_WORLDONLY, and is ignored by MOVETYPE_PUSH. Should only be combined with SOLID_NOT and SOLID_TRIGGER.
530
531 //DP_NULL_MODEL
532 //idea: Chris
533 //darkplaces implementation: divVerent
534 //definitions:
535 //string dp_null_model = "null";
536 //description:
537 //setmodel(e, "null"); makes an entity invisible, have a zero bbox, but
538 //networked. useful for shared CSQC entities.
539
540 //DP_MOVETYPEFOLLOW
541 //idea: id Software, LordHavoc (redesigned)
542 //darkplaces implementation: LordHavoc
543 //movetype definitions:
544 float MOVETYPE_FOLLOW = 12;
545 //description:
546 //MOVETYPE_FOLLOW implemented, this uses existing entity fields in unusual ways:
547 //aiment - the entity this is attached to.
548 //punchangle - the original angles when the follow began.
549 //view_ofs - the relative origin (note that this is un-rotated by punchangle, and that is actually the only purpose of punchangle).
550 //v_angle - the relative angles.
551 //here's an example of how you would set a bullet hole sprite to follow a bmodel it was created on, even if the bmodel rotates:
552 //hole.movetype = MOVETYPE_FOLLOW; // make the hole follow
553 //hole.solid = SOLID_NOT; // MOVETYPE_FOLLOW is always non-solid
554 //hole.aiment = bmodel; // make the hole follow bmodel
555 //hole.punchangle = bmodel.angles; // the original angles of bmodel
556 //hole.view_ofs = hole.origin - bmodel.origin; // relative origin
557 //hole.v_angle = hole.angles - bmodel.angles; // relative angles
558
559 //DP_QC_ASINACOSATANATAN2TAN
560 //idea: Urre
561 //darkplaces implementation: LordHavoc
562 //constant definitions:
563 float DEG2RAD = 0.0174532925199432957692369076848861271344287188854172545609719144;
564 float RAD2DEG = 57.2957795130823208767981548141051703324054724665643215491602438612;
565 float PI      = 3.1415926535897932384626433832795028841971693993751058209749445923;
566 //builtin definitions:
567 float(float s) asin = #471; // returns angle in radians for a given sin() value, the result is in the range -PI*0.5 to PI*0.5
568 float(float c) acos = #472; // returns angle in radians for a given cos() value, the result is in the range 0 to PI
569 float(float t) atan = #473; // returns angle in radians for a given tan() value, the result is in the range -PI*0.5 to PI*0.5
570 float(float c, float s) atan2 = #474; // returns angle in radians for a given cos() and sin() value pair, the result is in the range -PI to PI (this is identical to vectoyaw except it returns radians rather than degrees)
571 float(float a) tan = #475; // returns tangent value (which is simply sin(a)/cos(a)) for the given angle in radians, the result is in the range -infinity to +infinity
572 //description:
573 //useful math functions for analyzing vectors, note that these all use angles in radians (just like the cos/sin functions) not degrees unlike makevectors/vectoyaw/vectoangles, so be sure to do the appropriate conversions (multiply by DEG2RAD or RAD2DEG as needed).
574 //note: atan2 can take unnormalized vectors (just like vectoyaw), and the function was included only for completeness (more often you want vectoyaw or vectoangles), atan2(v_x,v_y) * RAD2DEG gives the same result as vectoyaw(v)
575
576 //DP_QC_AUTOCVARS
577 //idea: divVerent
578 //darkplaces implementation: divVerent
579 //description:
580 //allows QC variables to be bound to cvars
581 //(works for float, string, vector types)
582 //example:
583 // float autocvar_developer;
584 // float autocvar_registered;
585 // string autocvar__cl_name;
586 //NOTE: copying a string-typed autocvar to another variable/field, and then
587 //changing the cvar or returning from progs is UNDEFINED. Writing to autocvar
588 //globals is UNDEFINED.  Accessing autocvar globals after cvar_set()ing that
589 //cvar in the same frame is IMPLEMENTATION DEFINED (an implementation may
590 //either yield the previous, or the current, value). Whether autocvar globals,
591 //after restoring a savegame, have the cvar's current value, or the original
592 //value at time of saving, is UNDEFINED. Restoring a savegame however must not
593 //restore the cvar values themselves.
594 //In case the cvar does NOT exist, then it is automatically created with the
595 //value of the autocvar initializer, if given. This is possible with e.g.
596 //frikqcc and fteqcc the following way:
597 // var float autocvar_whatever = 42;
598 //If no initializer is given, the cvar will be initialized to a string
599 //equivalent to the NULL value of the given data type, that is, the empty
600 //string, 0, or '0 0 0'. However, when automatic cvar creation took place, a
601 //warning is printed to the game console.
602 //NOTE: to prevent an ambiguity with float names for vector types, autocvar
603 //names MUST NOT end with _x, _y or _z!
604
605 //DP_QC_CHANGEPITCH
606 //idea: id Software
607 //darkplaces implementation: id Software
608 //field definitions:
609 .float idealpitch;
610 .float pitch_speed;
611 //builtin definitions:
612 void(entity ent) changepitch = #63;
613 //description:
614 //equivalent to changeyaw, ent is normally self. (this was a Q2 builtin)
615
616 //DP_QC_COPYENTITY
617 //idea: LordHavoc
618 //darkplaces implementation: LordHavoc
619 //builtin definitions:
620 void(entity from, entity to) copyentity = #400;
621 //description:
622 //copies all data in the entity to another entity.
623
624 //DP_QC_CVAR_DEFSTRING
625 //idea: id Software (Doom3), LordHavoc
626 //darkplaces implementation: LordHavoc
627 //builtin definitions:
628 string(string s) cvar_defstring = #482;
629 //description:
630 //returns the default value of a cvar, as a tempstring.
631
632 //DP_QC_CVAR_DESCRIPTION
633 //idea: divVerent
634 //DarkPlaces implementation: divVerent
635 //builtin definitions:
636 string(string name) cvar_description = #518;
637 //description:
638 //returns the description of a cvar
639
640 //DP_QC_CVAR_STRING
641 //idea: VorteX
642 //DarkPlaces implementation: VorteX, LordHavoc
643 //builtin definitions:
644 string(string s) cvar_string = #448;
645 //description:
646 //returns the value of a cvar, as a tempstring.
647
648 //DP_QC_CVAR_TYPE
649 //idea: divVerent
650 //DarkPlaces implementation: divVerent
651 //builtin definitions:
652 float(string name) cvar_type = #495;
653 float CVAR_TYPEFLAG_EXISTS = 1;
654 float CVAR_TYPEFLAG_SAVED = 2;
655 float CVAR_TYPEFLAG_PRIVATE = 4;
656 float CVAR_TYPEFLAG_ENGINE = 8;
657 float CVAR_TYPEFLAG_HASDESCRIPTION = 16;
658 float CVAR_TYPEFLAG_READONLY = 32;
659
660 //DP_QC_EDICT_NUM
661 //idea: 515
662 //DarkPlaces implementation: LordHavoc
663 //builtin definitions:
664 entity(float entnum) edict_num = #459;
665 float(entity ent) wasfreed = #353; // same as in EXT_CSQC extension
666 //description:
667 //edict_num returns the entity corresponding to a given number, this works even for freed entities, but you should call wasfreed(ent) to see if is currently active.
668 //wasfreed returns whether an entity slot is currently free (entities that have never spawned are free, entities that have had remove called on them are also free).
669
670 //DP_QC_ENTITYDATA
671 //idea: KrimZon
672 //darkplaces implementation: KrimZon
673 //builtin definitions:
674 float() numentityfields = #496;
675 string(float fieldnum) entityfieldname = #497;
676 float(float fieldnum) entityfieldtype = #498;
677 string(float fieldnum, entity ent) getentityfieldstring = #499;
678 float(float fieldnum, entity ent, string s) putentityfieldstring = #500;
679 //constants:
680 //Returned by entityfieldtype
681 float FIELD_STRING   = 1;
682 float FIELD_FLOAT    = 2;
683 float FIELD_VECTOR   = 3;
684 float FIELD_ENTITY   = 4;
685 float FIELD_FUNCTION = 6;
686 //description:
687 //Versatile functions intended for storing data from specific entities between level changes, but can be customized for some kind of partial savegame.
688 //WARNING: .entity fields cannot be saved and restored between map loads as they will leave dangling pointers.
689 //numentityfields returns the number of entity fields. NOT offsets. Vectors comprise 4 fields: v, v_x, v_y and v_z.
690 //entityfieldname returns the name as a string, eg. "origin" or "classname" or whatever.
691 //entityfieldtype returns a value that the constants represent, but the field may be of another type in more exotic progs.dat formats or compilers.
692 //getentityfieldstring returns data as would be written to a savegame, eg... "0.05" (float), "0 0 1" (vector), or "Hello World!" (string). Function names can also be returned.
693 //putentityfieldstring puts the data returned by getentityfieldstring back into the entity.
694
695 //DP_QC_ENTITYSTRING
696 void(string s) loadfromdata = #529;
697 void(string s) loadfromfile = #530;
698 void(string s) callfunction = #605;
699 void(float fh, entity e) writetofile = #606;
700 float(string s) isfunction = #607;
701 void(entity e, string s) parseentitydata = #608;
702
703 //DP_QC_ETOS
704 //idea: id Software
705 //darkplaces implementation: id Software
706 //builtin definitions:
707 string(entity ent) etos = #65;
708 //description:
709 //prints "entity 1" or similar into a string. (this was a Q2 builtin)
710
711 //DP_QC_EXTRESPONSEPACKET
712 //idea: divVerent
713 //darkplaces implementation: divVerent
714 //builtin definitions:
715 string(void) getextresponse = #624;
716 //description:
717 //returns a string of the form "\"ipaddress:port\" data...", or the NULL string
718 //if no packet was found. Packets can be queued into the client/server by
719 //sending a packet starting with "\xFF\xFF\xFF\xFFextResponse " to the
720 //listening port.
721
722 //DP_QC_FINDCHAIN
723 //idea: LordHavoc
724 //darkplaces implementation: LordHavoc
725 //builtin definitions:
726 entity(.string fld, string match) findchain = #402;
727 //description:
728 //similar to find() but returns a chain of entities like findradius.
729
730 //DP_QC_FINDCHAIN_TOFIELD
731 //idea: divVerent
732 //darkplaces implementation: divVerent
733 //builtin definitions:
734 entity(.string fld, float match, .entity tofield) findradius_tofield = #22;
735 entity(.string fld, string match, .entity tofield) findchain_tofield = #402;
736 entity(.string fld, float match, .entity tofield) findchainflags_tofield = #450;
737 entity(.string fld, float match, .entity tofield) findchainfloat_tofield = #403;
738 //description:
739 //similar to findchain() etc, but stores the chain into .tofield instead of .chain
740 //actually, the .entity tofield is an optional field of the the existing findchain* functions
741
742 //DP_QC_FINDCHAINFLAGS
743 //idea: Sajt
744 //darkplaces implementation: LordHavoc
745 //builtin definitions:
746 entity(.float fld, float match) findchainflags = #450;
747 //description:
748 //similar to findflags() but returns a chain of entities like findradius.
749
750 //DP_QC_FINDCHAINFLOAT
751 //idea: LordHavoc
752 //darkplaces implementation: LordHavoc
753 //builtin definitions:
754 entity(.entity fld, entity match) findchainentity = #403;
755 entity(.float fld, float match) findchainfloat = #403;
756 //description:
757 //similar to findentity()/findfloat() but returns a chain of entities like findradius.
758
759 //DP_QC_FINDFLAGS
760 //idea: Sajt
761 //darkplaces implementation: LordHavoc
762 //builtin definitions:
763 entity(entity start, .float fld, float match) findflags = #449;
764 //description:
765 //finds an entity with the specified flag set in the field, similar to find()
766
767 //DP_QC_FINDFLOAT
768 //idea: LordHavoc
769 //darkplaces implementation: LordHavoc
770 //builtin definitions:
771 entity(entity start, .entity fld, entity match) findentity = #98;
772 entity(entity start, .float fld, float match) findfloat = #98;
773 //description:
774 //finds an entity or float field value, similar to find(), but for entity and float fields.
775
776 //DP_QC_FS_SEARCH
777 //idea: Black
778 //darkplaces implementation: Black
779 //builtin definitions:
780 float(string pattern, float caseinsensitive, float quiet) search_begin = #444;
781 void(float handle) search_end = #445;
782 float(float handle) search_getsize = #446;
783 string(float handle, float num) search_getfilename = #447;
784 //description:
785 //search_begin performs a filename search with the specified pattern (for example "maps/*.bsp") and stores the results in a search slot (minimum of 128 supported by any engine with this extension), the other functions take this returned search slot number, be sure to search_free when done (they are also freed on progs reload).
786 //search_end frees a search slot (also done at progs reload).
787 //search_getsize returns how many filenames were found.
788 //search_getfilename returns a filename from the search.
789
790 //DP_QC_GETLIGHT
791 //idea: LordHavoc
792 //darkplaces implementation: LordHavoc
793 //builtin definitions:
794 vector(vector org) getlight = #92;
795 //description:
796 //returns the lighting at the requested location (in color), 0-255 range (can exceed 255).
797
798 //DP_QC_GETSURFACE
799 //idea: LordHavoc
800 //darkplaces implementation: LordHavoc
801 //builtin definitions:
802 float(entity e, float s) getsurfacenumpoints = #434;
803 vector(entity e, float s, float n) getsurfacepoint = #435;
804 vector(entity e, float s) getsurfacenormal = #436;
805 string(entity e, float s) getsurfacetexture = #437;
806 float(entity e, vector p) getsurfacenearpoint = #438;
807 vector(entity e, float s, vector p) getsurfaceclippedpoint = #439;
808 //description:
809 //functions to query surface information.
810
811 //DP_QC_GETSURFACEPOINTATTRIBUTE
812 //idea: BlackHC
813 //darkplaces implementation: BlackHC
814 // constants
815 float SPA_POSITION = 0;
816 float SPA_S_AXIS = 1;
817 float SPA_T_AXIS = 2;
818 float SPA_R_AXIS = 3; // same as SPA_NORMAL
819 float SPA_TEXCOORDS0 = 4;
820 float SPA_LIGHTMAP0_TEXCOORDS = 5;
821 float SPA_LIGHTMAP0_COLOR = 6;
822 //builtin definitions:
823 vector(entity e, float s, float n, float a) getsurfacepointattribute = #486;
824
825 //description:
826 //function to query extended information about a point on a certain surface
827
828 //DP_QC_GETSURFACETRIANGLE
829 //idea: divVerent
830 //darkplaces implementation: divVerent
831 //builtin definitions:
832 float(entity e, float s) getsurfacenumtriangles = #628;
833 vector(entity e, float s, float n) getsurfacetriangle = #629;
834 //description:
835 //function to query triangles of a surface
836
837 //DP_QC_GETTAGINFO
838 //idea: VorteX, LordHavoc
839 //DarkPlaces implementation: VorteX
840 //builtin definitions:
841 float(entity ent, string tagname) gettagindex = #451;
842 vector(entity ent, float tagindex) gettaginfo = #452;
843 //description:
844 //gettagindex returns the number of a tag on an entity, this number is the same as set by setattachment (in the .tag_index field), allowing the qc to save a little cpu time by keeping the number around if it wishes (this could already be done by calling setattachment and saving off the tag_index).
845 //gettaginfo returns the origin of the tag in worldspace and sets v_forward, v_right, and v_up to the current orientation of the tag in worldspace, this automatically resolves all dependencies (attachments, including viewmodelforclient), this means you could fire a shot from a tag on a gun entity attached to the view for example.
846
847 //DP_QC_GETTAGINFO_BONEPROPERTIES
848 //idea: daemon
849 //DarkPlaces implementation: divVerent
850 //global definitions:
851 float gettaginfo_parent;
852 string gettaginfo_name;
853 vector gettaginfo_offset;
854 vector gettaginfo_forward;
855 vector gettaginfo_right;
856 vector gettaginfo_up;
857 //description:
858 //when this extension is present, gettaginfo fills in some globals with info about the bone that had been queried
859 //gettaginfo_parent is set to the number of the parent bone, or 0 if it is a root bone
860 //gettaginfo_name is set to the name of the bone whose index had been specified in gettaginfo
861 //gettaginfo_offset, gettaginfo_forward, gettaginfo_right, gettaginfo_up contain the transformation matrix of the bone relative to its parent. Note that the matrix may contain a scaling component.
862
863 //DP_QC_GETTIME
864 //idea: tZork
865 //darkplaces implementation: tZork, divVerent
866 //constant definitions:
867 float GETTIME_FRAMESTART = 0; // time of start of frame
868 float GETTIME_REALTIME = 1; // current time (may be OS specific)
869 float GETTIME_HIRES = 2; // like REALTIME, but may reset between QC invocations and thus can be higher precision
870 float GETTIME_UPTIME = 3; // time since start of the engine
871 //builtin definitions:
872 float(float tmr) gettime = #519;
873 //description:
874 //some timers to query...
875
876 //DP_QC_GETTIME_CDTRACK
877 //idea: divVerent
878 //darkplaces implementation: divVerent
879 //constant definitions:
880 float GETTIME_CDTRACK = 4;
881 //description:
882 //returns the playing time of the current cdtrack when passed to gettime()
883 //see DP_END_GETSOUNDTIME for similar functionality but for entity sound channels
884
885 //DP_QC_I18N
886 //idea: divVerent
887 //darkplaces implementation: divVerent
888 //description:
889 //
890 //The engine supports translating by gettext compatible .po files.
891 //progs.dat uses progs.dat.<LANGUAGE>.po
892 //menu.dat uses menu.dat.<LANGUAGE>.po
893 //csprogs.dat uses csprogs.dat.<LANGUAGE>.po
894 //
895 //To create a string that can be translated, define it as
896 //  string dotranslate_FILENOTFOUND = "File not found";
897 //Note: if the compiler does constant folding, this will only work if there is
898 //no other "File not found" string in the progs!
899 //
900 //Alternatively, if using the Xonotic patched fteqcc compiler, you can simplify
901 //this by using _("File not found") directly in the source code.
902 //
903 //The language is set by the "prvm_language" cvar: if prvm_language is set to
904 //"de", it will read progs.dat.de.po for translating strings in progs.dat.
905 //
906 //If prvm_language is set to to the special name "dump", progs.dat.pot which is
907 //a translation template to be edited by filling out the msgstr entries.
908
909 //DP_QC_LOG
910 //darkplaces implementation: divVerent
911 //builtin definitions:
912 float log(float f) = #532;
913 //description:
914 //logarithm
915
916 //DP_QC_MINMAXBOUND
917 //idea: LordHavoc
918 //darkplaces implementation: LordHavoc
919 //builtin definitions:
920 float(float a, float b) min = #94;
921 float(float a, float b, float c) min3 = #94;
922 float(float a, float b, float c, float d) min4 = #94;
923 float(float a, float b, float c, float d, float e) min5 = #94;
924 float(float a, float b, float c, float d, float e, float f) min6 = #94;
925 float(float a, float b, float c, float d, float e, float f, float g) min7 = #94;
926 float(float a, float b, float c, float d, float e, float f, float g, float h) min8 = #94;
927 float(float a, float b) max = #95;
928 float(float a, float b, float c) max3 = #95;
929 float(float a, float b, float c, float d) max4 = #95;
930 float(float a, float b, float c, float d, float e) max5 = #95;
931 float(float a, float b, float c, float d, float e, float f) max6 = #95;
932 float(float a, float b, float c, float d, float e, float f, float g) max7 = #95;
933 float(float a, float b, float c, float d, float e, float f, float g, float h) max8 = #95;
934 float(float minimum, float val, float maximum) bound = #96;
935 //description:
936 //min returns the lowest of all the supplied numbers.
937 //max returns the highest of all the supplied numbers.
938 //bound clamps the value to the range and returns it.
939
940 //DP_QC_MULTIPLETEMPSTRINGS
941 //idea: LordHavoc
942 //darkplaces implementation: LordHavoc
943 //description:
944 //this extension makes all builtins returning tempstrings (ftos for example)
945 //cycle through a pool of multiple tempstrings (at least 16), allowing
946 //multiple ftos results to be gathered before putting them to use, normal
947 //quake only had 1 tempstring, causing many headaches.
948 //
949 //Note that for longer term storage (or compatibility on engines having
950 //FRIK_FILE but not this extension) the FRIK_FILE extension's
951 //strzone/strunzone builtins provide similar functionality (slower though).
952 //
953 //NOTE: this extension is superseded by DP_QC_UNLIMITEDTEMPSTRINGS
954
955 //DP_QC_NUM_FOR_EDICT
956 //idea: Blub\0
957 //darkplaces implementation: Blub\0
958 //Function to get the number of an entity - a clean way.
959 float(entity num) num_for_edict = #512;
960
961 //DP_QC_RANDOMVEC
962 //idea: LordHavoc
963 //darkplaces implementation: LordHavoc
964 //builtin definitions:
965 vector() randomvec = #91;
966 //description:
967 //returns a vector of length < 1, much quicker version of this QC: do {v_x = random()*2-1;v_y = random()*2-1;v_z = random()*2-1;} while(vlen(v) > 1)
968
969 //DP_QC_SINCOSSQRTPOW
970 //idea: id Software, LordHavoc
971 //darkplaces implementation: id Software, LordHavoc
972 //builtin definitions:
973 float(float val) sin = #60;
974 float(float val) cos = #61;
975 float(float val) sqrt = #62;
976 float(float a, float b) pow = #97;
977 //description:
978 //useful math functions, sine of val, cosine of val, square root of val, and raise a to power b, respectively.
979
980 //DP_QC_SPRINTF
981 //idea: divVerent
982 //darkplaces implementation: divVerent
983 //builtin definitions:
984 string(string format, ...) sprintf = #627;
985 //description:
986 //you know sprintf :P
987 //supported stuff:
988 //  %
989 //  optional: <argpos>$ for the argument to format
990 //  flags: #0- +
991 //  optional: <width>, *, or *<argpos>$ for the field width
992 //  optional: .<precision>, .*, or .*<argpos>$ for the precision
993 //  length modifiers: h for forcing a float, l for forcing an int/entity (by default, %d etc. cast a float to int)
994 //  conversions:
995 //    d takes a float if no length is specified or h is, and an int/entity if l is specified as length, and cast it to an int
996 //    i takes an int/entity if no length is specified or i is, and a float if h is specified as length, and cast it to an int
997 //    ouxXc take a float if no length is specified or h is, and an int/entity if l is specified as length, and cast it to an unsigned int
998 //    eEfFgG take a float if no length is specified or h is, and an int/entity if l is specified as length, and cast it to a double
999 //    s takes a string
1000 //    vV takes a vector, and processes the three components as if it were a gG for all three components, separated by space
1001 //    For conversions s and c, the flag # makes precision and width interpreted
1002 //      as byte count, by default it is interpreted as character count in UTF-8
1003 //      enabled engines. No other conversions can create wide characters, and #
1004 //      has another meaning in these.
1005
1006 //DP_QC_STRFTIME
1007 //idea: LordHavoc
1008 //darkplaces implementation: LordHavoc
1009 //builtin definitions:
1010 string(float uselocaltime, string format, ...) strftime = #478;
1011 //description:
1012 //provides the ability to get the local (in your timezone) or world (Universal Coordinated Time) time as a string using the formatting of your choice:
1013 //example: "%Y-%m-%d %H:%M:%S"   (result looks like: 2007-02-08 01:03:15)
1014 //note: "%F %T" gives the same result as "%Y-%m-%d %H:%M:%S" (ISO 8601 date format and 24-hour time)
1015 //for more format codes please do a web search for strftime 3 and you should find the man(3) pages for this standard C function.
1016 //
1017 //practical uses:
1018 //changing day/night cycle (shops closing, monsters going on the prowl) in an RPG, for this you probably want to use s = strftime(TRUE, "%H");hour = stof(s);
1019 //printing current date/time for competitive multiplayer games, such as the beginning/end of each round in real world time.
1020 //activating eastereggs in singleplayer games on certain dates.
1021 //
1022 //note: some codes such as %x and %X use your locale settings and thus may not make sense to international users, it is not advisable to use these as the server and clients may be in different countries.
1023 //note: if you display local time to a player, it would be a good idea to note whether it is local time using a string like "%F %T (local)", and otherwise use "%F %T (UTC)".
1024 //note: be aware that if the game is saved and reloaded a week later the date and time will be different, so if activating eastereggs in a singleplayer game or something you may want to only check when a level is loaded and then keep the same easteregg state throughout the level so that the easteregg does not deactivate when reloading from a savegame (also be aware that precaches should not depend on such date/time code because reloading a savegame often scrambles the precaches if so!).
1025 //note: this function can return a NULL string (you can check for it with if (!s)) if the localtime/gmtime functions returned NULL in the engine code, such as if those functions don't work on this platform (consoles perhaps?), so be aware that this may return nothing.
1026
1027 //DP_QC_STRINGCOLORFUNCTIONS
1028 //idea: Dresk
1029 //darkplaces implementation: Dresk
1030 //builtin definitions:
1031 float(string s) strlennocol = #476; // returns how many characters are in a string, minus color codes
1032 string(string s) strdecolorize = #477; // returns a string minus the color codes of the string provided
1033 //description:
1034 //provides additional functionality to strings by supporting functions that isolate and identify strings with color codes
1035
1036 //DP_QC_STRING_CASE_FUNCTIONS
1037 //idea: Dresk
1038 //darkplaces implementation: LordHavoc / Dresk
1039 //builtin definitions:
1040 string(string s) strtolower = #480; // returns the passed in string in pure lowercase form
1041 string(string s) strtoupper = #481; // returns the passed in string in pure uppercase form
1042 //description:
1043 //provides simple string uppercase and lowercase functions
1044
1045 //DP_QC_TOKENIZEBYSEPARATOR
1046 //idea: Electro, SavageX, LordHavoc
1047 //darkplaces implementation: LordHavoc
1048 //builtin definitions:
1049 float(string s, string separator1, ...) tokenizebyseparator = #479;
1050 //description:
1051 //this function returns tokens separated by any of the supplied separator strings, example:
1052 //numnumbers = tokenizebyseparator("10.2.3.4", ".");
1053 //returns 4 and the tokens are "10" "2" "3" "4"
1054 //possibly useful for parsing IPv4 addresses (such as "1.2.3.4") and IPv6 addresses (such as "[1234:5678:9abc:def0:1234:5678:9abc:def0]:26000")
1055
1056 //DP_QC_TOKENIZE_CONSOLE
1057 //idea: divVerent
1058 //darkplaces implementation: divVerent
1059 //builtin definitions:
1060 float(string s) tokenize_console = #514;
1061 float(float i) argv_start_index = #515;
1062 float(float i) argv_end_index = #516;
1063 //description:
1064 //this function returns tokens separated just like the console does
1065 //also, functions are provided to get the index of the first and last character of each token in the original string
1066 //Passing negative values to them, or to argv, will be treated as indexes from the LAST token (like lists work in Perl). So argv(-1) will return the LAST token.
1067
1068 //DP_QC_TRACEBOX
1069 //idea: id Software
1070 //darkplaces implementation: id Software
1071 //builtin definitions:
1072 void(vector v1, vector min, vector max, vector v2, float nomonsters, entity forent) tracebox = #90;
1073 //description:
1074 //similar to traceline but much more useful, traces a box of the size specified (technical note: in quake1 and halflife bsp maps the mins and maxs will be rounded up to one of the hull sizes, quake3 bsp does not have this problem, this is the case with normal moving entities as well).
1075
1076 //DP_QC_TRACETOSS
1077 //idea: id Software
1078 //darkplaces implementation: id Software
1079 //builtin definitions:
1080 void(entity ent, entity ignore) tracetoss = #64;
1081 //description:
1082 //simulates movement of the entity as if it is MOVETYPE_TOSS and starting with it's current state (location, velocity, etc), returns relevant trace_ variables (trace_fraction is always 0, all other values are supported - trace_ent, trace_endpos, trace_plane_normal), does not actually alter the entity.
1083
1084 //DP_QC_TRACE_MOVETYPE_HITMODEL
1085 //idea: LordHavoc
1086 //darkplaces implementation: LordHavoc
1087 //constant definitions:
1088 float MOVE_HITMODEL = 4;
1089 //description:
1090 //allows traces to hit alias models (not sprites!) instead of entity boxes, use as the nomonsters parameter to trace functions, note that you can hit invisible model entities (alpha < 0 or EF_NODRAW or model "", it only checks modelindex)
1091
1092 //DP_QC_TRACE_MOVETYPE_WORLDONLY
1093 //idea: LordHavoc
1094 //darkplaces implementation: LordHavoc
1095 //constant definitions:
1096 float MOVE_WORLDONLY = 3;
1097 //description:
1098 //allows traces to hit only world (ignoring all entities, unlike MOVE_NOMONSTERS which hits all bmodels), use as the nomonsters parameter to trace functions
1099
1100 //DP_QC_UNLIMITEDTEMPSTRINGS
1101 //idea: divVerent
1102 //darkplaces implementation: LordHavoc
1103 //description:
1104 //this extension alters Quake behavior such that instead of reusing a single
1105 //tempstring (or multiple) there are an unlimited number of tempstrings, which
1106 //are removed only when a QC function invoked by the engine returns,
1107 //eliminating almost all imaginable concerns with string handling in QuakeC.
1108 //
1109 //in short:
1110 //you can now use and abuse tempstrings as much as you like, you still have to
1111 //use strzone (FRIK_FILE) for permanent storage however.
1112 //
1113 //
1114 //
1115 //implementation notes for other engine coders:
1116 //these tempstrings are expected to be stored in a contiguous buffer in memory
1117 //which may be fixed size or controlled by a cvar, or automatically grown on
1118 //demand (in the case of DarkPlaces).
1119 //
1120 //this concept is similar to quake's Zone system, however these are all freed
1121 //when the QC interpreter returns.
1122 //
1123 //this is basically a poor man's garbage collection system for strings.
1124
1125 //DP_QC_VECTOANGLES_WITH_ROLL
1126 //idea: LordHavoc
1127 //darkplaces implementation: LordHavoc
1128 //builtin definitions:
1129 vector(vector forward, vector up) vectoangles2 = #51; // same number as vectoangles
1130 //description:
1131 //variant of vectoangles that takes an up vector to calculate roll angle (also uses this to calculate yaw correctly if the forward is straight up or straight down)
1132 //note: just like normal vectoangles you need to negate the pitch of the returned angles if you want to feed them to makevectors or assign to self.v_angle
1133
1134 //DP_QC_VECTORVECTORS
1135 //idea: LordHavoc
1136 //darkplaces implementation: LordHavoc
1137 //builtin definitions:
1138 void(vector dir) vectorvectors = #432;
1139 //description:
1140 //creates v_forward, v_right, and v_up vectors given a forward vector, similar to makevectors except it takes a forward direction vector instead of angles.
1141
1142 //DP_QC_WHICHPACK
1143 //idea: divVerent
1144 //darkplaces implementation: divVerent
1145 //builtin definitions:
1146 string(string filename) whichpack = #503;
1147 //description:
1148 //returns the name of the pak/pk3/whatever containing the given file, in the same path space as FRIK_FILE functions use (that is, possibly with a path name prefix)
1149
1150 //DP_QC_URI_ESCAPE
1151 //idea: divVerent
1152 //darkplaces implementation: divVerent
1153 //URI::Escape's functionality
1154 string(string in) uri_escape = #510;
1155 string(string in) uri_unescape = #511;
1156
1157 //DP_QC_URI_GET
1158 //idea: divVerent
1159 //darkplaces implementation: divVerent
1160 //loads text from an URL into a string
1161 //returns 1 on success of initiation, 0 if there are too many concurrent
1162 //connections already or if the URL is invalid
1163 //the following callback will receive the data and MUST exist!
1164 //  void(float id, float status, string data) URI_Get_Callback;
1165 //status is either
1166 //  negative for an internal error,
1167 //  0 for success, or
1168 //  the HTTP response code on server error (e.g. 404)
1169 //if 1 is returned by uri_get, the callback will be called in the future
1170 float(string url, float id) uri_get = #513;
1171
1172 //DP_QC_URI_POST
1173 //idea: divVerent
1174 //darkplaces implementation: divVerent
1175 //loads text from an URL into a string after POSTing via HTTP
1176 //works like uri_get, but uri_post sends data with Content-Type: content_type to the server
1177 //and uri_post sends the string buffer buf, joined using the delimiter delim
1178 float(string url, float id, string content_type, string data) uri_post = #513;
1179 float(string url, float id, string content_type, string delim, float buf) uri_postbuf = #513;
1180
1181 //DP_SKELETONOBJECTS
1182 //idea: LordHavoc
1183 //darkplaces implementation: LordHavoc
1184 //description:
1185 //this extension indicates that FTE_CSQC_SKELETONOBJECTS functionality is available in server QC (as well as CSQC).
1186
1187 //DP_SV_SPAWNFUNC_PREFIX
1188 //idea: divVerent
1189 //darkplaces implementation: divVerent
1190 //Make functions whose name start with spawnfunc_ take precedence as spawn function for loading entities.
1191 //Useful if you have a field ammo_shells (required in any Quake mod) but want to support spawn functions called ammo_shells (like in Q3A).
1192 //Optionally, you can declare a global "float require_spawnfunc_prefix;" which will require ANY spawn function to start with that prefix.
1193
1194
1195 //DP_QUAKE2_MODEL
1196 //idea: quake community
1197 //darkplaces implementation: LordHavoc
1198 //description:
1199 //shows that the engine supports Quake2 .md2 files.
1200
1201 //DP_QUAKE2_SPRITE
1202 //idea: LordHavoc
1203 //darkplaces implementation: Elric
1204 //description:
1205 //shows that the engine supports Quake2 .sp2 files.
1206
1207 //DP_QUAKE3_MAP
1208 //idea: quake community
1209 //darkplaces implementation: LordHavoc
1210 //description:
1211 //shows that the engine supports Quake3 .bsp files.
1212
1213 //DP_QUAKE3_MODEL
1214 //idea: quake community
1215 //darkplaces implementation: LordHavoc
1216 //description:
1217 //shows that the engine supports Quake3 .md3 files.
1218
1219 //DP_REGISTERCVAR
1220 //idea: LordHavoc
1221 //darkplaces implementation: LordHavoc
1222 //builtin definitions:
1223 float(string name, string value) registercvar = #93;
1224 //description:
1225 //adds a new console cvar to the server console (in singleplayer this is the player's console), the cvar exists until the mod is unloaded or the game quits.
1226 //NOTE: DP_CON_SET is much better.
1227
1228 //DP_SND_DIRECTIONLESSATTNNONE
1229 //idea: LordHavoc
1230 //darkplaces implementation: LordHavoc
1231 //description:
1232 //make sounds with ATTN_NONE have no spatialization (enabling easy use as music sources).
1233
1234 //DP_SND_FAKETRACKS
1235 //idea: requested
1236 //darkplaces implementation: Elric
1237 //description:
1238 //the engine plays sound/cdtracks/track001.wav instead of cd track 1 and so on if found, this allows games and mods to have music tracks without using ambientsound.
1239 //Note: also plays .ogg with DP_SND_OGGVORBIS extension.
1240
1241 //DP_SND_SOUND7_WIP1
1242 //DP_SND_SOUND7_WIP2
1243 //idea: divVerent
1244 //darkplaces implementation: divVerent
1245 //builtin definitions:
1246 void(entity e, float chan, string samp, float vol, float atten, float speed, float flags) sound7 = #8;
1247 float SOUNDFLAG_RELIABLE = 1;
1248 //description:
1249 //plays a sound, with some more flags
1250 //extensions to sound():
1251 //- channel may be in the range from -128 to 127; channels -128 to 0 are "auto",
1252 //  i.e. support multiple sounds at once, but cannot be stopped/restarted
1253 //- a value 0 in the speed parameter means no change; otherwise, it is a
1254 //  percentage of playback speed ("pitch shifting"). 100 is normal pitch, 50 is
1255 //  half speed, 200 is double speed, etc. (DP_SND_SOUND7_WIP2)
1256 //- the flag SOUNDFLAG_RELIABLE can be specified, which makes the sound send
1257 //  to MSG_ALL (reliable) instead of MSG_BROADCAST (unreliable, default);
1258 //  similarily, SOUNDFLAG_RELIABLE_TO_ONE sends to MSG_ONE
1259 //- channel 0 is controlled by snd_channel0volume; channel 1 and -1 by
1260 //  snd_channel1volume, etc. (so, a channel shares the cvar with its respective
1261 //  auto-channel); however, the mod MUST define snd_channel8volume and upwards
1262 //  in default.cfg if they are to be used, as the engine does not create them
1263 //  to not litter the cvar list
1264 //- this extension applies to CSQC as well; CSQC_Event_Sound will get speed and
1265 //  flags as extra 7th and 8th argument
1266 //- WIP2 ideas: SOUNDFLAG_RELIABLE_TO_ONE, SOUNDFLAG_NOPHS, SOUNDFLAG_FORCELOOP
1267 //- NOTE: to check for this, ALSO OR a check with DP_SND_SOUND7 to also support
1268 //  the finished extension once done
1269
1270 //DP_SND_OGGVORBIS
1271 //idea: Transfusion
1272 //darkplaces implementation: Elric
1273 //description:
1274 //the engine supports loading Ogg Vorbis sound files.  Use either the .ogg filename directly, or a .wav of the same name (will try to load the .wav first and then .ogg).
1275
1276 //DP_SND_STEREOWAV
1277 //idea: LordHavoc
1278 //darkplaces implementation: LordHavoc
1279 //description:
1280 //the engine supports stereo WAV files.  (useful with DP_SND_DIRECTIONLESSATTNNONE for music)
1281
1282 //DP_SND_GETSOUNDTIME
1283 //idea: VorteX
1284 //darkplaces implementation: VorteX
1285 //constant definitions:
1286 float(entity e, float channel) getsoundtime = #533; // get currently sound playing position on entity channel, -1 if not playing or error
1287 float(string sample) soundlength = #534; // returns length of sound sample in seconds, -1 on error (sound not precached, sound system not initialized etc.)
1288 //description: provides opportunity to query length of sound samples and realtime tracking of sound playing on entities (similar to DP_GETTIME_CDTRACK)
1289 //note: beware dedicated server not running sound engine at all, so in dedicated mode this builtins will not work in server progs
1290 //note also: menu progs not supporting getsoundtime() (will give a warning) since it has no sound playing on entities
1291 //examples of use:
1292 //  - QC-driven looped sounds
1293 //  - QC events when sound playing is finished
1294 //  - toggleable ambientsounds
1295 //  - subtitles
1296
1297 //DP_VIDEO_DPV
1298 //idea: LordHavoc
1299 //darkplaces implementation: LordHavoc
1300 //console commands:
1301 //  playvideo <videoname> - start playing video
1302 //  stopvideo - stops current video
1303 //description: indicated that engine support playing videos in DPV format
1304
1305 //DP_VIDEO_SUBTITLES
1306 //idea: VorteX
1307 //darkplaces implementation: VorteX
1308 //cvars:
1309 //  cl_video_subtitles - toggles subtitles showing
1310 //  cl_video_subtitles_lines - how many lines to reserve for subtitles
1311 //  cl_video_subtitles_textsize - font size
1312 //console commands:
1313 //  playvideo <videoname> <custom_subtitles_file> - start playing video
1314 //  stopvideo - stops current video
1315 //description: indicates that engine support subtitles on videos
1316 //subtitles stored in external text files, each video file has it's default subtitles file ( <videoname>.dpsubs )
1317 //example: for video/act1.dpv default subtitles file will be video/act1.dpsubs
1318 //also video could be played with custom subtitles file by utilizing second parm of playvideo command
1319 //syntax of .dpsubs files: each line in .dpsubs file defines 1 subtitle, there are three tokens:
1320 //   <start> <end> "string"
1321 //   start: subtitle start time in seconds
1322 //     end: subtitle time-to-show in seconds, if 0 - subtitle will be showed until next subtitle is started, 
1323 //          if below 0 - show until next subtitles minus this number of seconds
1324 //    text: subtitle text, color codes (Q3-style and ^xRGB) are allowed
1325 //example of subtitle file:
1326 //   3  0       "Vengeance! Vengeance for my eternity of suffering!"
1327 //   9  0       "Whelp! As if you knew what eternity was!"
1328 //   13 0       "Grovel before your true master."
1329 //   17 0       "Never!" 
1330 //   18 7       "I'll hack you from crotch to gizzard and feed what's left of you to your brides..."
1331
1332 //DP_SOLIDCORPSE
1333 //idea: LordHavoc
1334 //darkplaces implementation: LordHavoc
1335 //solid definitions:
1336 float SOLID_CORPSE = 5;
1337 //description:
1338 //the entity will not collide with SOLID_CORPSE and SOLID_SLIDEBOX entities (and likewise they will not collide with it), this is useful if you want dead bodies that are shootable but do not obstruct movement by players and monsters, note that if you traceline with a SOLID_SLIDEBOX entity as the ignoreent, it will ignore SOLID_CORPSE entities, this is desirable for visibility and movement traces, but not for bullets, for the traceline to hit SOLID_CORPSE you must temporarily force the player (or whatever) to SOLID_BBOX and then restore to SOLID_SLIDEBOX after the traceline.
1339
1340 //DP_SPRITE32
1341 //idea: LordHavoc
1342 //darkplaces implementation: LordHavoc
1343 //description:
1344 //the engine supports .spr32 sprites.
1345
1346 //DP_SV_BOTCLIENT
1347 //idea: LordHavoc
1348 //darkplaces implementation: LordHavoc
1349 //constants:
1350 float CLIENTTYPE_DISCONNECTED = 0;
1351 float CLIENTTYPE_REAL = 1;
1352 float CLIENTTYPE_BOT = 2;
1353 float CLIENTTYPE_NOTACLIENT = 3;
1354 //builtin definitions:
1355 entity() spawnclient = #454; // like spawn but for client slots (also calls relevant connect/spawn functions), returns world if no clients available
1356 float(entity clent) clienttype = #455; // returns one of the CLIENTTYPE_* constants
1357 //description:
1358 //spawns a client with no network connection, to allow bots to use client slots with no hacks.
1359 //How to use:
1360 /*
1361         // to spawn a bot
1362         local entity oldself;
1363         oldself = self;
1364         self = spawnclient();
1365         if (!self)
1366         {
1367                 bprint("Can not add bot, server full.\n");
1368                 self = oldself;
1369                 return;
1370         }
1371         self.netname = "Yoyobot";
1372         self.clientcolors = 12 * 16 + 4; // yellow (12) shirt and red (4) pants
1373         ClientConnect();
1374         PutClientInServer();
1375         self = oldself;
1376
1377         // to remove all bots
1378         local entity head;
1379         head = find(world, classname, "player");
1380         while (head)
1381         {
1382                 if (clienttype(head) == CLIENTTYPE_BOT)
1383                         dropclient(head);
1384                 head = find(head, classname, "player");
1385         }
1386
1387         // to identify if a client is a bot (for example in PlayerPreThink)
1388         if (clienttype(self) == CLIENTTYPE_BOT)
1389                 botthink();
1390 */
1391 //see also DP_SV_CLIENTCOLORS DP_SV_CLIENTNAME DP_SV_DROPCLIENT
1392 //How it works:
1393 //creates a new client, calls SetNewParms and stores the parms, and returns the client.
1394 //this intentionally does not call SV_SendServerinfo to allow the QuakeC a chance to set the netname and clientcolors fields before actually spawning the bot by calling ClientConnect and PutClientInServer manually
1395 //on level change ClientConnect and PutClientInServer are called by the engine to spawn in the bot (this is why clienttype() exists to tell you on the next level what type of client this is).
1396 //parms work the same on bot clients as they do on real clients, and do carry from level to level
1397
1398 //DP_SV_BOUNCEFACTOR
1399 //idea: divVerent
1400 //darkplaces implementation: divVerent
1401 //field definitions:
1402 .float bouncefactor; // velocity multiplier after a bounce
1403 .float bouncestop; // bounce stops if velocity to bounce plane is < bouncestop * gravity AFTER the bounce
1404 //description:
1405 //allows qc to customize MOVETYPE_BOUNCE a bit
1406
1407 //DP_SV_CLIENTCAMERA
1408 //idea: LordHavoc, others
1409 //darkplaces implementation: Black
1410 //field definitions:
1411 .entity clientcamera; // override camera entity
1412 //description:
1413 //allows another entity to be the camera for a client, for example a remote camera, this is similar to sending svc_setview manually except that it also changes the network culling appropriately.
1414
1415 //DP_SV_CLIENTCOLORS
1416 //idea: LordHavoc
1417 //darkplaces implementation: LordHavoc
1418 //field definitions:
1419 .float clientcolors; // colors of the client (format: pants + shirt * 16)
1420 //description:
1421 //allows qc to read and modify the client colors associated with a client entity (not particularly useful on other entities), and automatically sends out any appropriate network updates if changed
1422
1423 //DP_SV_CLIENTNAME
1424 //idea: LordHavoc
1425 //darkplaces implementation: LordHavoc
1426 //description:
1427 //allows qc to modify the client's .netname, and automatically sends out any appropriate network updates if changed
1428
1429 //DP_SV_CUSTOMIZEENTITYFORCLIENT
1430 //idea: LordHavoc
1431 //darkplaces implementation: [515] and LordHavoc
1432 //field definitions:
1433 .float() customizeentityforclient; // self = this entity, other = client entity
1434 //description:
1435 //allows qc to modify an entity before it is sent to each client, the function returns TRUE if it should send, FALSE if it should not, and is fully capable of editing the entity's fields, this allows cloaked players to appear less transparent to their teammates, navigation markers to only show to their team, etc
1436 //tips on writing customize functions:
1437 //it is a good idea to return FALSE early in the function if possible to reduce cpu usage, because this function may be called many thousands of times per frame if there are many customized entities on a 64+ player server.
1438 //you are free to change anything in self, but please do not change any other entities (the results may be very inconsistent).
1439 //example ideas for use of this extension:
1440 //making icons over teammates' heads which are only visible to teammates.  for exasmple: float() playericon_customizeentityforclient = {return self.owner.team == other.team;};
1441 //making cloaked players more visible to their teammates than their enemies.  for example: float() player_customizeentityforclient = {if (self.items & IT_CLOAKING) {if (self.team == other.team) self.alpha = 0.6;else self.alpha = 0.1;} return TRUE;};
1442 //making explosion models that face the viewer (does not work well with chase_active).  for example: float() explosion_customizeentityforclient = {self.angles = vectoangles(other.origin + other.view_ofs - self.origin);self.angles_x = 0 - self.angles_x;};
1443 //implementation notes:
1444 //entity customization is done before per-client culling (visibility for instance) because the entity may be doing setorigin to display itself in different locations on different clients, may be altering its .modelindex, .effects and other fields important to culling, so customized entities increase cpu usage (non-customized entities can use all the early culling they want however, as they are not changing on a per client basis).
1445
1446 //DP_SV_DISCARDABLEDEMO
1447 //idea: parasti
1448 //darkplaces implementation: parasti
1449 //field definitions:
1450 .float discardabledemo;
1451 //description:
1452 //when this field is set to a non-zero value on a player entity, a possibly recorded server-side demo for the player is discarded
1453 //Note that this extension only works if:
1454 //  auto demos are enabled (the cvar sv_autodemo_perclient is set)
1455 //  discarding demos is enabled (the cvar sv_autodemo_perclient_discardable is set)
1456
1457 //DP_SV_DRAWONLYTOCLIENT
1458 //idea: LordHavoc
1459 //darkplaces implementation: LordHavoc
1460 //field definitions:
1461 .entity drawonlytoclient;
1462 //description:
1463 //the entity is only visible to the specified client.
1464
1465 //DP_SV_DROPCLIENT
1466 //idea: FrikaC
1467 //darkplaces implementation: LordHavoc
1468 //builtin definitions:
1469 void(entity clent) dropclient = #453;
1470 //description:
1471 //causes the server to immediately drop the client, more reliable than stuffcmd(clent, "disconnect\n"); which could be intentionally ignored by the client engine
1472
1473 //DP_SV_EFFECT
1474 //idea: LordHavoc
1475 //darkplaces implementation: LordHavoc
1476 //builtin definitions:
1477 void(vector org, string modelname, float startframe, float endframe, float framerate) effect = #404;
1478 //SVC definitions:
1479 //float svc_effect = #52; // [vector] org [byte] modelindex [byte] startframe [byte] framecount [byte] framerate
1480 //float svc_effect2 = #53; // [vector] org [short] modelindex [byte] startframe [byte] framecount [byte] framerate
1481 //description:
1482 //clientside playback of simple custom sprite effects (explosion sprites, etc).
1483
1484 //DP_SV_ENTITYCONTENTSTRANSITION
1485 //idea: Dresk
1486 //darkplaces implementation: Dresk
1487 //field definitions:
1488 .void(float nOriginalContents, float nNewContents) contentstransition;
1489 //description:
1490 //This field function, when provided, is triggered on an entity when the contents (ie. liquid / water / etc) is changed.
1491 //The first parameter provides the entities original contents, prior to the transition.  The second parameter provides the new contents.
1492 //NOTE: If this field function is provided on an entity, the standard watersplash sound IS SUPPRESSED to allow for authors to create their own transition sounds.
1493
1494 //DP_SV_MOVETYPESTEP_LANDEVENT
1495 //idea: Dresk
1496 //darkplaces implementation: Dresk
1497 //field definitions:
1498 .void(vector vImpactVelocity) movetypesteplandevent;
1499 //description:
1500 //This field function, when provided, is triggered on a MOVETYPE_STEP entity when it experiences  "land event".
1501 // The standard engine behavior for this event is to play the sv_sound_land CVar sound.
1502 //The parameter provides the velocity of the entity at the time of the impact.  The z value may therefore be used to calculate how "hard" the entity struck the surface.
1503 //NOTE: If this field function is provided on a MOVETYPE_STEP entity, the standard sv_sound_land sound IS SUPPRESSED to allow for authors to create their own feedback.
1504
1505 //DP_SV_POINTSOUND
1506 //idea: Dresk
1507 //darkplaces implementation: Dresk
1508 //builtin definitions:
1509 void(vector origin, string sample, float volume, float attenuation) pointsound = #483;
1510 //description:
1511 //Similar to the standard QC sound function, this function takes an origin instead of an entity and omits the channel parameter.
1512 // This allows sounds to be played at arbitrary origins without spawning entities.
1513
1514 //DP_SV_ONENTITYNOSPAWNFUNCTION
1515 //idea: Dresk
1516 //darkplaces implementation: Dresk
1517 //engine-called QC prototypes:
1518 //void() SV_OnEntityNoSpawnFunction;
1519 //description:
1520 // This function is called whenever an entity on the server has no spawn function, and therefore has no defined QC behavior.
1521 // You may as such dictate the behavior as to what happens to the entity.
1522 // To mimic the engine's default behavior, simply call remove(self).
1523
1524 //DP_SV_ONENTITYPREPOSTSPAWNFUNCTION
1525 //idea: divVerent
1526 //darkplaces implementation: divVerent
1527 //engine-called QC prototypes:
1528 //void() SV_OnEntityPreSpawnFunction;
1529 //void() SV_OnEntityPostSpawnFunction;
1530 //description:
1531 // These functions are called BEFORE or AFTER an entity is spawned the regular way.
1532 // You may as such dictate the behavior as to what happens to the entity.
1533 // SV_OnEntityPreSpawnFunction is called before even looking for the spawn function, so you can even change its classname in there. If it remove()s the entity, the spawn function will not be looked for.
1534 // SV_OnEntityPostSpawnFunction is called ONLY after its spawn function or SV_OnEntityNoSpawnFunction was called, and skipped if the entity got removed by either.
1535
1536 //DP_SV_MODELFLAGS_AS_EFFECTS
1537 //idea: LordHavoc, Dresk
1538 //darkplaces implementation: LordHavoc
1539 //field definitions:
1540 .float modelflags;
1541 //constant definitions:
1542 float EF_NOMODELFLAGS = 8388608; // ignore any effects in a model file and substitute your own
1543 float MF_ROCKET  =   1; // leave a trail
1544 float MF_GRENADE =   2; // leave a trail
1545 float MF_GIB     =   4; // leave a trail
1546 float MF_ROTATE  =   8; // rotate (bonus items)
1547 float MF_TRACER  =  16; // green split trail
1548 float MF_ZOMGIB  =  32; // small blood trail
1549 float MF_TRACER2 =  64; // orange split trail
1550 float MF_TRACER3 = 128; // purple trail
1551 //description:
1552 //this extension allows model flags to be specified on entities so you can add a rocket trail and glow to any entity, etc.
1553 //setting any of these will override the flags the model already has, to disable the model's flags without supplying any of your own you must use EF_NOMODELFLAGS.
1554 //
1555 //silly example modification #1 to W_FireRocket in weapons.qc:
1556 //missile.effects = EF_NOMODELFLAGS; // rocket without a glow/fire trail
1557 //silly example modification #2 to W_FireRocket in weapons.qc:
1558 //missile.modelflags = MF_GIB; // leave a blood trail instead of glow/fire trail
1559 //
1560 //note: you can not combine multiple kinds of trail, only one of them will be active, you can combine MF_ROTATE and the other MF_ flags however, and using EF_NOMODELFLAGS along with these does no harm.
1561 //
1562 //note to engine coders: they are internally encoded in the protocol as extra EF_ flags (shift the values left 24 bits and send them in the protocol that way), so no protocol change was required (however 32bit effects is a protocol extension itself), within the engine they are referred to as EF_ for the 24bit shifted values.
1563
1564 //DP_SV_NETADDRESS
1565 //idea: Dresk
1566 //darkplaces implementation: Dresk
1567 //field definitions:
1568 .string netaddress;
1569 //description:
1570 // provides the netaddress of the associated entity (ie. 127.0.0.1) and "null/botclient" if the netconnection of the entity is invalid
1571
1572 //DP_SV_NODRAWTOCLIENT
1573 //idea: LordHavoc
1574 //darkplaces implementation: LordHavoc
1575 //field definitions:
1576 .entity nodrawtoclient;
1577 //description:
1578 //the entity is not visible to the specified client.
1579
1580 //DP_SV_PING
1581 //idea: LordHavoc
1582 //darkplaces implementation: LordHavoc
1583 //field definitions:
1584 .float ping;
1585 //description:
1586 //continuously updated field indicating client's ping (based on average of last 16 packet time differences).
1587
1588 //DP_SV_PING_PACKETLOSS
1589 //idea: LordHavoc
1590 //darkplaces implementation: LordHavoc
1591 //field definitions:
1592 .float ping_packetloss;
1593 .float ping_movementloss;
1594 //description:
1595 //continuously updated field indicating client's packet loss, and movement loss (i.e. packet loss affecting player movement).
1596
1597 //DP_SV_POINTPARTICLES
1598 //idea: Spike
1599 //darkplaces implementation: LordHavoc
1600 //function definitions:
1601 float(string effectname) particleeffectnum = #335; // same as in CSQC
1602 void(entity ent, float effectnum, vector start, vector end) trailparticles = #336; // same as in CSQC
1603 void(float effectnum, vector org, vector vel, float howmany) pointparticles = #337; // same as in CSQC
1604 //SVC definitions:
1605 //float svc_trailparticles = 60; // [short] entnum [short] effectnum [vector] start [vector] end
1606 //float svc_pointparticles = 61; // [short] effectnum [vector] start [vector] velocity [short] count
1607 //float svc_pointparticles1 = 62; // [short] effectnum [vector] start, same as svc_pointparticles except velocity is zero and count is 1
1608 //description:
1609 //provides the ability to spawn non-standard particle effects, typically these are defined in a particle effect information file such as effectinfo.txt in darkplaces.
1610 //this is a port of particle effect features from clientside QC (EXT_CSQC) to server QC, as these effects are potentially useful to all games even if they do not make use of EXT_CSQC.
1611 //warning: server must have same order of effects in effectinfo.txt as client does or the numbers would not match up, except for standard quake effects which are always the same numbers.
1612
1613 //DP_SV_PUNCHVECTOR
1614 //idea: LordHavoc
1615 //darkplaces implementation: LordHavoc
1616 //field definitions:
1617 .vector punchvector;
1618 //description:
1619 //offsets client view in worldspace, similar to view_ofs but all 3 components are used and are sent with at least 8 bits of fraction, this allows the view to be kicked around by damage or hard landings or whatever else, note that unlike punchangle this is not faded over time, it is up to the mod to fade it (see also DP_SV_PLAYERPHYSICS).
1620
1621 //DP_SV_PLAYERPHYSICS
1622 //idea: LordHavoc
1623 //darkplaces implementation: LordHavoc
1624 //field definitions:
1625 .vector movement;
1626 //cvar definitions:
1627 //"sv_playerphysicsqc" (0/1, default 1, allows user to disable qc player physics)
1628 //engine-called QC prototypes:
1629 //void() SV_PlayerPhysics;
1630 //description:
1631 //.movement vector contains the movement input from the player, allowing QC to do as it wishs with the input, and SV_PlayerPhysics will completely replace the player physics if present (works for all MOVETYPE's), see darkplaces mod source for example of this function (in playermovement.qc, adds HalfLife ladders support, as well as acceleration/deceleration while airborn (rather than the quake sudden-stop while airborn), and simplifies the physics a bit)
1632
1633 //DP_PHYSICS_ODE
1634 //idea: LordHavoc
1635 //darkplaces implementation: LordHavoc
1636 //globals:
1637 //new movetypes:
1638 const float MOVETYPE_PHYSICS = 32; // need to be set before any physics_* builtins applied
1639 //new solid types:
1640 const float SOLID_PHYSICS_BOX = 32;
1641 const float SOLID_PHYSICS_SPHERE = 33;
1642 const float SOLID_PHYSICS_CAPSULE = 34;
1643 const float SOLID_PHYSICS_TRIMESH = 35;
1644 const float SOLID_PHYSICS_CYLINDER = 36;
1645 //SOLID_BSP;
1646 //joint types:
1647 const float JOINTTYPE_POINT = 1;
1648 const float JOINTTYPE_HINGE = 2;
1649 const float JOINTTYPE_SLIDER = 3;
1650 const float JOINTTYPE_UNIVERSAL = 4;
1651 const float JOINTTYPE_HINGE2 = 5;
1652 const float JOINTTYPE_FIXED = -1;
1653 // common joint properties:
1654 // .entity aiment, enemy; // connected objects
1655 // .vector movedir;
1656 //   for a spring:
1657 //     movedir_x = spring constant (force multiplier, must be > 0)
1658 //     movedir_y = spring dampening constant to prevent oscillation (must be > 0)
1659 //     movedir_z = spring stop position (+/-)
1660 //   for a motor:
1661 //     movedir_x = desired motor velocity
1662 //     movedir_y = -1 * max motor force to use
1663 //     movedir_z = stop position (+/-), set to 0 for no stop
1664 //   note that ODE does not support both in one anyway
1665 //field definitions:
1666 .float mass; // ODE mass, standart value is 1
1667 .vector massofs; // offsets a mass center out of object center, if not set a center of model bounds is used
1668 .float friction;
1669 .float bouncefactor;
1670 .float bouncestop;
1671 .float jointtype;
1672 //builtin definitions:
1673 void(entity e, float physics_enabled) physics_enable = #540; // enable or disable physics on object
1674 void(entity e, vector force, vector force_pos) physics_addforce = #541; // apply a force from certain origin, length of force vector is power of force
1675 void(entity e, vector torque) physics_addtorque = #542; // add relative torque
1676 //description: provides Open Dynamics Engine support, requires extenal dll to be present or engine compiled with statical link option
1677 //be sure to checkextension for it to know if library is loaded and ready, also to enable physics set "physics_ode" cvar to 1
1678 //note: this extension is highly experimental and may be unstable
1679
1680 //DP_SV_PRINT
1681 //idea: id Software (QuakeWorld Server)
1682 //darkplaces implementation: Black, LordHavoc
1683 void(string s, ...) print = #339; // same number as in EXT_CSQC
1684 //description:
1685 //this is identical to dprint except that it always prints regardless of the developer cvar.
1686
1687 //DP_SV_PRECACHEANYTIME
1688 //idea: id Software (Quake2)
1689 //darkplaces implementation: LordHavoc
1690 //description:
1691 //this extension allows precache_model and precache_sound (and any variants) to be used during the game (with automatic messages to clients to precache the new model/sound indices), also setmodel/sound/ambientsound can be called without precaching first (they will cause an automatic precache).
1692
1693 //DP_SV_QCSTATUS
1694 //idea: divVerent
1695 //darkplaces implementation: divVerent
1696 //1. A global variable
1697 string worldstatus;
1698 //Its content is set as "qcstatus" field in the rules.
1699 //It may be at most 255 characters, and must not contain newlines or backslashes.
1700 //2. A per-client field
1701 .string clientstatus;
1702 //It is sent instead of the "frags" in status responses.
1703 //It should always be set in a way so that stof(player.clientstatus) is a meaningful score value. Other info may be appended. If used this way, the cvar sv_status_use_qcstatus may be set to 1, and then this value will replace the frags in "status".
1704 //Currently, qstat does not support this and will not show player info if used and set to anything other than ftos(some integer).
1705
1706 //DP_SV_ROTATINGBMODEL
1707 //idea: id Software
1708 //darkplaces implementation: LordHavoc
1709 //description:
1710 //this extension merely indicates that MOVETYPE_PUSH supports avelocity, allowing rotating brush models to be created, they rotate around their origin (needs rotation supporting qbsp/light utilities because id ones expected bmodel entity origins to be '0 0 0', recommend setting "origin" key in the entity fields in the map before compiling, there may be other methods depending on your qbsp, most are more complicated however).
1711 //tip: level designers can create a func_wall with an origin, and avelocity (for example "avelocity" "0 90 0"), and "nextthink" "99999999" to make a rotating bmodel without any qc modifications, such entities will be solid in stock quake but will not rotate)
1712
1713 //DP_SV_SETCOLOR
1714 //idea: LordHavoc
1715 //darkplaces implementation: LordHavoc
1716 //builtin definitions:
1717 void(entity ent, float colors) setcolor = #401;
1718 //engine called QC functions (optional):
1719 //void(float color) SV_ChangeTeam;
1720 //description:
1721 //setcolor sets the color on a client and updates internal color information accordingly (equivalent to stuffing a "color" command but immediate)
1722 //SV_ChangeTeam is called by the engine whenever a "color" command is recieved, it may decide to do anything it pleases with the color passed by the client, including rejecting it (by doing nothing), or calling setcolor to apply it, preventing team changes is one use for this.
1723 //the color format is pants + shirt * 16 (0-255 potentially)
1724
1725 //DP_SV_SLOWMO
1726 //idea: LordHavoc
1727 //darkplaces implementation: LordHavoc
1728 //cvars:
1729 //"slowmo" (0+, default 1)
1730 //description:
1731 //sets the time scale of the server, mainly intended for use in singleplayer by the player, however potentially useful for mods, so here's an extension for it.
1732 //range is 0 to infinite, recommended values to try are 0.1 (very slow, 10% speed), 1 (normal speed), 5 (500% speed).
1733
1734 //DP_SV_WRITEPICTURE
1735 //idea: divVerent
1736 //darkplaces implementation: divVerent
1737 //builtin definitions:
1738 void(float to, string s, float sz) WritePicture = #501;
1739 //description:
1740 //writes a picture to the data stream so CSQC can read it using ReadPicture, which has the definition
1741 //  string(void) ReadPicture = #501;
1742 //The picture data is sent as at most sz bytes, by compressing to low quality
1743 //JPEG. The data being sent will be equivalent to:
1744 //  WriteString(to, s);
1745 //  WriteShort(to, imagesize);
1746 //  for(i = 0; i < imagesize; ++i)
1747 //    WriteByte(to, [the i-th byte of the compressed JPEG image]);
1748
1749 //DP_SV_WRITEUNTERMINATEDSTRING
1750 //idea: FrikaC
1751 //darkplaces implementation: Sajt
1752 //builtin definitions:
1753 void(float to, string s) WriteUnterminatedString = #456;
1754 //description:
1755 //like WriteString, but does not write a terminating 0 after the string. This means you can include things like a player's netname in the middle of a string sent over the network. Just be sure to end it up with either a call to WriteString (which includes the trailing 0) or WriteByte(0) to terminate it yourself.
1756 //A historical note: this extension was suggested by FrikaC years ago, more recently Shadowalker has been badmouthing LordHavoc and Spike for stealing 'his' extension writestring2 which does exactly the same thing but uses a different builtin number and name and extension string, this argument hinges on the idea that it was his idea in the first place, which is incorrect as FrikaC first suggested it and used a rough equivalent of it in his FrikBot mod years ago involving WriteByte calls on each character.
1757
1758 //DP_TE_BLOOD
1759 //idea: LordHavoc
1760 //darkplaces implementation: LordHavoc
1761 //builtin definitions:
1762 void(vector org, vector velocity, float howmany) te_blood = #405;
1763 //temp entity definitions:
1764 float TE_BLOOD = 50;
1765 //protocol:
1766 //vector origin
1767 //byte xvelocity (-128 to +127)
1768 //byte yvelocity (-128 to +127)
1769 //byte zvelocity (-128 to +127)
1770 //byte count (0 to 255, how much blood)
1771 //description:
1772 //creates a blood effect.
1773
1774 //DP_TE_BLOODSHOWER
1775 //idea: LordHavoc
1776 //darkplaces implementation: LordHavoc
1777 //builtin definitions:
1778 void(vector mincorner, vector maxcorner, float explosionspeed, float howmany) te_bloodshower = #406;
1779 //temp entity definitions:
1780 //float TE_BLOODSHOWER = 52;
1781 //protocol:
1782 //vector mins (minimum corner of the cube)
1783 //vector maxs (maximum corner of the cube)
1784 //coord explosionspeed (velocity of blood particles flying out of the center)
1785 //short count (number of blood particles)
1786 //description:
1787 //creates an exploding shower of blood, for making gibbings more convincing.
1788
1789 //DP_TE_CUSTOMFLASH
1790 //idea: LordHavoc
1791 //darkplaces implementation: LordHavoc
1792 //builtin definitions:
1793 void(vector org, float radius, float lifetime, vector color) te_customflash = #417;
1794 //temp entity definitions:
1795 //float TE_CUSTOMFLASH = 73;
1796 //protocol:
1797 //vector origin
1798 //byte radius ((MSG_ReadByte() + 1) * 8, meaning 8-2048 unit radius)
1799 //byte lifetime ((MSG_ReadByte() + 1) / 256.0, meaning approximately 0-1 second lifetime)
1800 //byte red (0.0 to 1.0 converted to 0-255)
1801 //byte green (0.0 to 1.0 converted to 0-255)
1802 //byte blue (0.0 to 1.0 converted to 0-255)
1803 //description:
1804 //creates a customized light flash.
1805
1806 //DP_TE_EXPLOSIONRGB
1807 //idea: LordHavoc
1808 //darkplaces implementation: LordHavoc
1809 //builtin definitions:
1810 void(vector org, vector color) te_explosionrgb = #407;
1811 //temp entity definitions:
1812 //float TE_EXPLOSIONRGB = 53;
1813 //protocol:
1814 //vector origin
1815 //byte red (0.0 to 1.0 converted to 0 to 255)
1816 //byte green (0.0 to 1.0 converted to 0 to 255)
1817 //byte blue (0.0 to 1.0 converted to 0 to 255)
1818 //description:
1819 //creates a colored explosion effect.
1820
1821 //DP_TE_FLAMEJET
1822 //idea: LordHavoc
1823 //darkplaces implementation: LordHavoc
1824 //builtin definitions:
1825 void(vector org, vector vel, float howmany) te_flamejet = #457;
1826 //temp entity definitions:
1827 //float TE_FLAMEJET = 74;
1828 //protocol:
1829 //vector origin
1830 //vector velocity
1831 //byte count (0 to 255, how many flame particles)
1832 //description:
1833 //creates a single puff of flame particles.  (not very useful really)
1834
1835 //DP_TE_PARTICLECUBE
1836 //idea: LordHavoc
1837 //darkplaces implementation: LordHavoc
1838 //builtin definitions:
1839 void(vector mincorner, vector maxcorner, vector vel, float howmany, float color, float gravityflag, float randomveljitter) te_particlecube = #408;
1840 //temp entity definitions:
1841 //float TE_PARTICLECUBE = 54;
1842 //protocol:
1843 //vector mins (minimum corner of the cube)
1844 //vector maxs (maximum corner of the cube)
1845 //vector velocity
1846 //short count
1847 //byte color (palette color)
1848 //byte gravity (TRUE or FALSE, FIXME should this be a scaler instead?)
1849 //coord randomvel (how much to jitter the velocity)
1850 //description:
1851 //creates a cloud of particles, useful for forcefields but quite customizable.
1852
1853 //DP_TE_PARTICLERAIN
1854 //idea: LordHavoc
1855 //darkplaces implementation: LordHavoc
1856 //builtin definitions:
1857 void(vector mincorner, vector maxcorner, vector vel, float howmany, float color) te_particlerain = #409;
1858 //temp entity definitions:
1859 //float TE_PARTICLERAIN = 55;
1860 //protocol:
1861 //vector mins (minimum corner of the cube)
1862 //vector maxs (maximum corner of the cube)
1863 //vector velocity (velocity of particles)
1864 //short count (number of particles)
1865 //byte color (8bit palette color)
1866 //description:
1867 //creates a shower of rain, the rain will appear either at the top (if falling down) or bottom (if falling up) of the cube.
1868
1869 //DP_TE_PARTICLESNOW
1870 //idea: LordHavoc
1871 //darkplaces implementation: LordHavoc
1872 //builtin definitions:
1873 void(vector mincorner, vector maxcorner, vector vel, float howmany, float color) te_particlesnow = #410;
1874 //temp entity definitions:
1875 //float TE_PARTICLERAIN = 56;
1876 //protocol:
1877 //vector mins (minimum corner of the cube)
1878 //vector maxs (maximum corner of the cube)
1879 //vector velocity (velocity of particles)
1880 //short count (number of particles)
1881 //byte color (8bit palette color)
1882 //description:
1883 //creates a shower of snow, the snow will appear either at the top (if falling down) or bottom (if falling up) of the cube, low velocities are advisable for convincing snow.
1884
1885 //DP_TE_PLASMABURN
1886 //idea: LordHavoc
1887 //darkplaces implementation: LordHavoc
1888 //builtin definitions:
1889 void(vector org) te_plasmaburn = #433;
1890 //temp entity definitions:
1891 //float TE_PLASMABURN = 75;
1892 //protocol:
1893 //vector origin
1894 //description:
1895 //creates a small light flash (radius 200, time 0.2) and marks the walls.
1896
1897 //DP_TE_QUADEFFECTS1
1898 //idea: LordHavoc
1899 //darkplaces implementation: LordHavoc
1900 //builtin definitions:
1901 void(vector org) te_gunshotquad = #412;
1902 void(vector org) te_spikequad = #413;
1903 void(vector org) te_superspikequad = #414;
1904 void(vector org) te_explosionquad = #415;
1905 //temp entity definitions:
1906 //float   TE_GUNSHOTQUAD  = 57; // [vector] origin
1907 //float   TE_SPIKEQUAD    = 58; // [vector] origin
1908 //float   TE_SUPERSPIKEQUAD = 59; // [vector] origin
1909 //float   TE_EXPLOSIONQUAD = 70; // [vector] origin
1910 //protocol:
1911 //vector origin
1912 //description:
1913 //all of these just take a location, and are equivalent in function (but not appearance :) to the original TE_GUNSHOT, etc.
1914
1915 //DP_TE_SMALLFLASH
1916 //idea: LordHavoc
1917 //darkplaces implementation: LordHavoc
1918 //builtin definitions:
1919 void(vector org) te_smallflash = #416;
1920 //temp entity definitions:
1921 //float TE_SMALLFLASH = 72;
1922 //protocol:
1923 //vector origin
1924 //description:
1925 //creates a small light flash (radius 200, time 0.2).
1926
1927 //DP_TE_SPARK
1928 //idea: LordHavoc
1929 //darkplaces implementation: LordHavoc
1930 //builtin definitions:
1931 void(vector org, vector vel, float howmany) te_spark = #411;
1932 //temp entity definitions:
1933 //float TE_SPARK = 51;
1934 //protocol:
1935 //vector origin
1936 //byte xvelocity (-128 to 127)
1937 //byte yvelocity (-128 to 127)
1938 //byte zvelocity (-128 to 127)
1939 //byte count (number of sparks)
1940 //description:
1941 //creates a shower of sparks and a smoke puff.
1942
1943 //DP_TE_STANDARDEFFECTBUILTINS
1944 //idea: LordHavoc
1945 //darkplaces implementation: LordHavoc
1946 //builtin definitions:
1947 void(vector org) te_gunshot = #418;
1948 void(vector org) te_spike = #419;
1949 void(vector org) te_superspike = #420;
1950 void(vector org) te_explosion = #421;
1951 void(vector org) te_tarexplosion = #422;
1952 void(vector org) te_wizspike = #423;
1953 void(vector org) te_knightspike = #424;
1954 void(vector org) te_lavasplash = #425;
1955 void(vector org) te_teleport = #426;
1956 void(vector org, float color, float colorlength) te_explosion2 = #427;
1957 void(entity own, vector start, vector end) te_lightning1 = #428;
1958 void(entity own, vector start, vector end) te_lightning2 = #429;
1959 void(entity own, vector start, vector end) te_lightning3 = #430;
1960 void(entity own, vector start, vector end) te_beam = #431;
1961 //description:
1962 //to make life easier on mod coders.
1963
1964 //DP_TRACE_HITCONTENTSMASK_SURFACEINFO
1965 //idea: LordHavoc
1966 //darkplaces implementation: LordHavoc
1967 //globals:
1968 .float dphitcontentsmask; // if non-zero on the entity passed to traceline/tracebox/tracetoss this will override the normal collidable contents rules and instead hit these contents values (for example AI can use tracelines that hit DONOTENTER if it wants to, by simply changing this field on the entity passed to traceline), this affects normal movement as well as trace calls
1969 float trace_dpstartcontents; // DPCONTENTS_ value at start position of trace
1970 float trace_dphitcontents; // DPCONTENTS_ value of impacted surface (not contents at impact point, just contents of the surface that was hit)
1971 float trace_dphitq3surfaceflags; // Q3SURFACEFLAG_ value of impacted surface
1972 string trace_dphittexturename; // texture name of impacted surface
1973 //constants:
1974 float DPCONTENTS_SOLID = 1; // hit a bmodel, not a bounding box
1975 float DPCONTENTS_WATER = 2;
1976 float DPCONTENTS_SLIME = 4;
1977 float DPCONTENTS_LAVA = 8;
1978 float DPCONTENTS_SKY = 16;
1979 float DPCONTENTS_BODY = 32; // hit a bounding box, not a bmodel
1980 float DPCONTENTS_CORPSE = 64; // hit a SOLID_CORPSE entity
1981 float DPCONTENTS_NODROP = 128; // an area where backpacks should not spawn
1982 float DPCONTENTS_PLAYERCLIP = 256; // blocks player movement
1983 float DPCONTENTS_MONSTERCLIP = 512; // blocks monster movement
1984 float DPCONTENTS_DONOTENTER = 1024; // AI hint brush
1985 float DPCONTENTS_LIQUIDSMASK = 14; // WATER | SLIME | LAVA
1986 float DPCONTENTS_BOTCLIP = 2048; // AI hint brush
1987 float DPCONTENTS_OPAQUE = 4096; // only fully opaque brushes get this (may be useful for line of sight checks)
1988 float Q3SURFACEFLAG_NODAMAGE = 1;
1989 float Q3SURFACEFLAG_SLICK = 2; // low friction surface
1990 float Q3SURFACEFLAG_SKY = 4; // sky surface (also has NOIMPACT and NOMARKS set)
1991 float Q3SURFACEFLAG_LADDER = 8; // climbable surface
1992 float Q3SURFACEFLAG_NOIMPACT = 16; // projectiles should remove themselves on impact (this is set on sky)
1993 float Q3SURFACEFLAG_NOMARKS = 32; // projectiles should not leave marks, such as decals (this is set on sky)
1994 float Q3SURFACEFLAG_FLESH = 64; // projectiles should do a fleshy effect (blood?) on impact
1995 float Q3SURFACEFLAG_NODRAW = 128; // compiler hint (not important to qc)
1996 //float Q3SURFACEFLAG_HINT = 256; // compiler hint (not important to qc)
1997 //float Q3SURFACEFLAG_SKIP = 512; // compiler hint (not important to qc)
1998 //float Q3SURFACEFLAG_NOLIGHTMAP = 1024; // compiler hint (not important to qc)
1999 //float Q3SURFACEFLAG_POINTLIGHT = 2048; // compiler hint (not important to qc)
2000 float Q3SURFACEFLAG_METALSTEPS = 4096; // walking on this surface should make metal step sounds
2001 float Q3SURFACEFLAG_NOSTEPS = 8192; // walking on this surface should not make footstep sounds
2002 float Q3SURFACEFLAG_NONSOLID = 16384; // compiler hint (not important to qc)
2003 //float Q3SURFACEFLAG_LIGHTFILTER = 32768; // compiler hint (not important to qc)
2004 //float Q3SURFACEFLAG_ALPHASHADOW = 65536; // compiler hint (not important to qc)
2005 //float Q3SURFACEFLAG_NODLIGHT = 131072; // compiler hint (not important to qc)
2006 //float Q3SURFACEFLAG_DUST = 262144; // translucent 'light beam' effect (not important to qc)
2007 //description:
2008 //adds additional information after a traceline/tracebox/tracetoss call.
2009 //also (very important) sets trace_* globals before calling .touch functions,
2010 //this allows them to inspect the nature of the collision (for example
2011 //determining if a projectile hit sky), clears trace_* variables for the other
2012 //object in a touch event (that is to say, a projectile moving will see the
2013 //trace results in its .touch function, but the player it hit will see very
2014 //little information in the trace_ variables as it was not moving at the time)
2015
2016 //DP_VIEWZOOM
2017 //idea: LordHavoc
2018 //darkplaces implementation: LordHavoc
2019 //field definitions:
2020 .float viewzoom;
2021 //description:
2022 //scales fov and sensitivity of player, valid range is 0 to 1 (intended for sniper rifle zooming, and such)
2023
2024 //EXT_BITSHIFT
2025 //idea: Spike
2026 //darkplaces implementation: [515]
2027 //builtin definitions:
2028 float(float number, float quantity) bitshift = #218;
2029 //description:
2030 //multiplies number by a power of 2 corresponding to quantity (0 = *1, 1 = *2, 2 = *4, 3 = *8, -1 = /2, -2 = /4x, etc), and rounds down (due to integer math) like other bit operations do (& and | and the like).
2031 //note: it is faster to use multiply if you are shifting by a constant, avoiding the quakec function call cost, however that does not do a floor for you.
2032
2033 //FRIK_FILE
2034 //idea: FrikaC
2035 //darkplaces implementation: LordHavoc
2036 //builtin definitions:
2037 float(string s) stof = #81; // get numerical value from a string
2038 float(string filename, float mode) fopen = #110; // opens a file inside quake/gamedir/data/ (mode is FILE_READ, FILE_APPEND, or FILE_WRITE), returns fhandle >= 0 if successful, or fhandle < 0 if unable to open file for any reason
2039 void(float fhandle) fclose = #111; // closes a file
2040 string(float fhandle) fgets = #112; // reads a line of text from the file and returns as a tempstring
2041 void(float fhandle, string s, ...) fputs = #113; // writes a line of text to the end of the file
2042 float(string s) strlen = #114; // returns how many characters are in a string
2043 string(string s1, string s2, ...) strcat = #115; // concatenates two or more strings (for example "abc", "def" would return "abcdef") and returns as a tempstring
2044 string(string s, float start, float length) substring = #116; // returns a section of a string as a tempstring - see FTE_STRINGS for enhanced version
2045 vector(string s) stov = #117; // returns vector value from a string
2046 string(string s, ...) strzone = #118; // makes a copy of a string into the string zone and returns it, this is often used to keep around a tempstring for longer periods of time (tempstrings are replaced often)
2047 void(string s) strunzone = #119; // removes a copy of a string from the string zone (you can not use that string again or it may crash!!!)
2048 //constants:
2049 float FILE_READ = 0;
2050 float FILE_APPEND = 1;
2051 float FILE_WRITE = 2;
2052 //cvars:
2053 //pr_zone_min_strings : default 64 (64k), min 64 (64k), max 8192 (8mb)
2054 //description:
2055 //provides text file access functions and string manipulation functions, note that you may want to set pr_zone_min_strings in the worldspawn function if 64k is not enough string zone space.
2056 //
2057 //NOTE: strzone functionality is partially superseded by
2058 //DP_QC_UNLIMITEDTEMPSTRINGS when longterm storage is not needed
2059 //NOTE: substring is upgraded by FTE_STRINGS extension with negative start/length handling identical to php 5.2.0
2060
2061 //FTE_CSQC_SKELETONOBJECTS
2062 //idea: Spike, LordHavoc
2063 //darkplaces implementation: LordHavoc
2064 //builtin definitions:
2065 // all skeleton numbers are 1-based (0 being no skeleton)
2066 // all bone numbers are 1-based (0 being invalid)
2067 float(float modlindex) skel_create = #263; // create a skeleton (be sure to assign this value into .skeletonindex for use), returns skeleton index (1 or higher) on success, returns 0 on failure (for example if the modelindex is not skeletal), it is recommended that you create a new skeleton if you change modelindex, as the skeleton uses the hierarchy from the model.
2068 float(float skel, entity ent, float modlindex, float retainfrac, float firstbone, float lastbone) skel_build = #264; // blend in a percentage of standard animation, 0 replaces entirely, 1 does nothing, 0.5 blends half, etc, and this only alters the bones in the specified range for which out of bounds values like 0,100000 are safe (uses .frame, .frame2, .frame3, .frame4, .lerpfrac, .lerpfrac3, .lerpfrac4, .frame1time, .frame2time, .frame3time, .frame4time), returns skel on success, 0 on failure
2069 float(float skel) skel_get_numbones = #265; // returns how many bones exist in the created skeleton, 0 if skeleton does not exist
2070 string(float skel, float bonenum) skel_get_bonename = #266; // returns name of bone (as a tempstring), "" if invalid bonenum (< 1 for example) or skeleton does not exist
2071 float(float skel, float bonenum) skel_get_boneparent = #267; // returns parent num for supplied bonenum, 0 if bonenum has no parent or bone does not exist (returned value is always less than bonenum, you can loop on this)
2072 float(float skel, string tagname) skel_find_bone = #268; // get number of bone with specified name, 0 on failure, bonenum (1-based) on success, same as using gettagindex but takes modelindex instead of entity
2073 vector(float skel, float bonenum) skel_get_bonerel = #269; // get matrix of bone in skeleton relative to its parent - sets v_forward, v_right, v_up, returns origin (relative to parent bone)
2074 vector(float skel, float bonenum) skel_get_boneabs = #270; // get matrix of bone in skeleton in model space - sets v_forward, v_right, v_up, returns origin (relative to entity)
2075 void(float skel, float bonenum, vector org) skel_set_bone = #271; // set matrix of bone relative to its parent, reads v_forward, v_right, v_up, takes origin as parameter (relative to parent bone)
2076 void(float skel, float bonenum, vector org) skel_mul_bone = #272; // transform bone matrix (relative to its parent) by the supplied matrix in v_forward, v_right, v_up, takes origin as parameter (relative to parent bone)
2077 void(float skel, float startbone, float endbone, vector org) skel_mul_bones = #273; // transform bone matrices (relative to their parents) by the supplied matrix in v_forward, v_right, v_up, takes origin as parameter (relative to parent bones)
2078 void(float skeldst, float skelsrc, float startbone, float endbone) skel_copybones = #274; // copy bone matrices (relative to their parents) from one skeleton to another, useful for copying a skeleton to a corpse
2079 void(float skel) skel_delete = #275; // deletes skeleton at the beginning of the next frame (you can add the entity, delete the skeleton, renderscene, and it will still work)
2080 float(float modlindex, string framename) frameforname = #276; // finds number of a specified frame in the animation, returns -1 if no match found
2081 float(float modlindex, float framenum) frameduration = #277; // returns the intended play time (in seconds) of the specified framegroup, if it does not exist the result is 0, if it is a single frame it may be a small value around 0.1 or 0.
2082 //fields:
2083 .float skeletonindex; // active skeleton overriding standard animation on model
2084 .float frame; // primary framegroup animation (strength = 1 - lerpfrac - lerpfrac3 - lerpfrac4)
2085 .float frame2; // secondary framegroup animation (strength = lerpfrac)
2086 .float frame3; // tertiary framegroup animation (strength = lerpfrac3)
2087 .float frame4; // quaternary framegroup animation (strength = lerpfrac4)
2088 .float lerpfrac; // strength of framegroup blend
2089 .float lerpfrac3; // strength of framegroup blend
2090 .float lerpfrac4; // strength of framegroup blend
2091 .float frame1time; // start time of framegroup animation
2092 .float frame2time; // start time of framegroup animation
2093 .float frame3time; // start time of framegroup animation
2094 .float frame4time; // start time of framegroup animation
2095 //description:
2096 //this extension provides a way to do complex skeletal animation on an entity.
2097 //
2098 //see also DP_SKELETONOBJECTS (this extension implemented on server as well as client)
2099 //
2100 //notes:
2101 //each model contains its own skeleton, reusing a skeleton with incompatible models will yield garbage (or not render).
2102 //each model contains its own animation data, you can use animations from other model files (for example saving out all character animations as separate model files).
2103 //if an engine supports loading an animation-only file format such as .md5anim in FTEQW, it can be used to animate any model with a compatible skeleton.
2104 //proper use of this extension may require understanding matrix transforms (v_forward, v_right, v_up, origin), and you must keep in mind that v_right is negative for this purpose.
2105 //
2106 //features include:
2107 //multiple animations blended together.
2108 //animating a model with animations from another model with a compatible skeleton.
2109 //restricting animation blends to certain bones of a model - for example independent animation of legs, torso, head.
2110 //custom bone controllers - for example making eyes track a target location.
2111 //
2112 //
2113 //
2114 //example code follows...
2115 //
2116 //this helper function lets you identify (by parentage) what group a bone
2117 //belongs to - for example "torso", "leftarm", would return 1 ("torso") for
2118 //all children of the bone named "torso", unless they are children of
2119 //"leftarm" (which is a child of "torso") which would return 2 instead...
2120 float(float skel, float bonenum, string g1, string g2, string g3, string g4, string g5, string g6) example_skel_findbonegroup =
2121 {
2122         local string bonename;
2123         while (bonenum >= 0)
2124         {
2125                 bonename = skel_get_bonename(skel, bonenum);
2126                 if (bonename == g1) return 1;
2127                 if (bonename == g2) return 2;
2128                 if (bonename == g3) return 3;
2129                 if (bonename == g4) return 4;
2130                 if (bonename == g5) return 5;
2131                 if (bonename == g6) return 6;
2132                 bonenum = skel_get_boneparent(skel, bonenum);
2133         }
2134         return 0;
2135 };
2136 // create a skeletonindex for our player using current modelindex
2137 void() example_skel_player_setup =
2138 {
2139         self.skeletonindex = skel_create(self.modelindex);
2140 };
2141 // setup bones of skeleton based on an animation
2142 // note: animmodelindex can be a different model than self.modelindex
2143 void(float animmodelindex, float framegroup, float framegroupstarttime) example_skel_player_update_begin =
2144 {
2145         // start with our standard animation
2146         self.frame = framegroup;
2147         self.frame2 = 0;
2148         self.frame3 = 0;
2149         self.frame4 = 0;
2150         self.frame1time = framegroupstarttime;
2151         self.frame2time = 0;
2152         self.frame3time = 0;
2153         self.frame4time = 0;
2154         self.lerpfrac = 0;
2155         self.lerpfrac3 = 0;
2156         self.lerpfrac4 = 0;
2157         skel_build(self.skeletonindex, self, animmodelindex, 0, 0, 100000);
2158 };
2159 // apply a different framegroup animation to bones with a specified parent
2160 void(float animmodelindex, float framegroup, float framegroupstarttime, float blendalpha, string groupbonename, string excludegroupname1, string excludegroupname2) example_skel_player_update_applyoverride =
2161 {
2162         local float bonenum;
2163         local float numbones;
2164         self.frame = framegroup;
2165         self.frame2 = 0;
2166         self.frame3 = 0;
2167         self.frame4 = 0;
2168         self.frame1time = framegroupstarttime;
2169         self.frame2time = 0;
2170         self.frame3time = 0;
2171         self.frame4time = 0;
2172         self.lerpfrac = 0;
2173         self.lerpfrac3 = 0;
2174         self.lerpfrac4 = 0;
2175         bonenum = 0;
2176         numbones = skel_get_numbones(self.skeletonindex);
2177         while (bonenum < numbones)
2178         {
2179                 if (example_skel_findbonegroup(self.skeletonindex, bonenum, groupbonename, excludegroupname1, excludegroupname2, "", "", "") == 1)
2180                         skel_build(self.skeletonindex, self, animmodelindex, 1 - blendalpha, bonenum, bonenum + 1);
2181                 bonenum = bonenum + 1;
2182         }
2183 };
2184 // make eyes point at a target location, be sure v_forward, v_right, v_up are set correctly before calling
2185 void(vector eyetarget, string bonename) example_skel_player_update_eyetarget =
2186 {
2187         local float bonenum;
2188         local vector ang;
2189         local vector oldforward, oldright, oldup;
2190         local vector relforward, relright, relup, relorg;
2191         local vector boneforward, boneright, boneup, boneorg;
2192         local vector parentforward, parentright, parentup, parentorg;
2193         local vector u, v;
2194         local vector modeleyetarget;
2195         bonenum = skel_find_bone(self.skeletonindex, bonename) - 1;
2196         if (bonenum < 0)
2197                 return;
2198         oldforward = v_forward;
2199         oldright = v_right;
2200         oldup = v_up;
2201         v = eyetarget - self.origin;
2202         modeleyetarget_x =   v * v_forward;
2203         modeleyetarget_y = 0-v * v_right;
2204         modeleyetarget_z =   v * v_up;
2205         // this is an eyeball, make it point at the target location
2206         // first get all the data we can...
2207         relorg = skel_get_bonerel(self.skeletonindex, bonenum);
2208         relforward = v_forward;
2209         relright = v_right;
2210         relup = v_up;
2211         boneorg = skel_get_boneabs(self.skeletonindex, bonenum);
2212         boneforward = v_forward;
2213         boneright = v_right;
2214         boneup = v_up;
2215         parentorg = skel_get_boneabs(self.skeletonindex, skel_get_boneparent(self.skeletonindex, bonenum));
2216         parentforward = v_forward;
2217         parentright = v_right;
2218         parentup = v_up;
2219         // get the vector from the eyeball to the target
2220         u = modeleyetarget - boneorg;
2221         // now transform it inversely by the parent matrix to produce new rel vectors
2222         v_x = u * parentforward;
2223         v_y = u * parentright;
2224         v_z = u * parentup;
2225         ang = vectoangles2(v, relup);
2226         ang_x = 0 - ang_x;
2227         makevectors(ang);
2228         // set the relative bone matrix
2229         skel_set_bone(self.skeletonindex, bonenum, relorg);
2230         // restore caller's v_ vectors
2231         v_forward = oldforward;
2232         v_right = oldright;
2233         v_up = oldup;
2234 };
2235 // delete skeleton when we're done with it
2236 // note: skeleton remains valid until next frame when it is really deleted
2237 void() example_skel_player_delete =
2238 {
2239         skel_delete(self.skeletonindex);
2240         self.skeletonindex = 0;
2241 };
2242 //
2243 // END OF EXAMPLES FOR FTE_CSQC_SKELETONOBJECTS
2244 //
2245
2246 //KRIMZON_SV_PARSECLIENTCOMMAND
2247 //idea: KrimZon
2248 //darkplaces implementation: KrimZon, LordHavoc
2249 //engine-called QC prototypes:
2250 //void(string s) SV_ParseClientCommand;
2251 //builtin definitions:
2252 void(entity e, string s) clientcommand = #440;
2253 float(string s) tokenize = #441;
2254 string(float n) argv = #442;
2255 //description:
2256 //provides QC the ability to completely control server interpretation of client commands ("say" and "color" for example, clientcommand is necessary for this and substring (FRIK_FILE) is useful) as well as adding new commands (tokenize, argv, and stof (FRIK_FILE) are useful for this)), whenever a clc_stringcmd is received the QC function is called, and it is up to the QC to decide what (if anything) to do with it
2257
2258 //NEH_CMD_PLAY2
2259 //idea: Nehahra
2260 //darkplaces implementation: LordHavoc
2261 //description:
2262 //shows that the engine supports the "play2" console command (plays a sound without spatialization).
2263
2264 //NEH_RESTOREGAME
2265 //idea: Nehahra
2266 //darkplaces implementation: LordHavoc
2267 //engine-called QC prototypes:
2268 //void() RestoreGame;
2269 //description:
2270 //when a savegame is loaded, this function is called
2271
2272 //NEXUIZ_PLAYERMODEL
2273 //idea: Nexuiz
2274 //darkplaces implementation: Black
2275 //console commands:
2276 //playermodel <name> - FIXME: EXAMPLE NEEDED
2277 //playerskin <name> - FIXME: EXAMPLE NEEDED
2278 //field definitions:
2279 .string playermodel; // name of player model sent by client
2280 .string playerskin; // name of player skin sent by client
2281 //description:
2282 //these client properties are used by Nexuiz.
2283
2284 //NXQ_GFX_LETTERBOX
2285 //idea: nxQuake
2286 //darkplaces implementation: LordHavoc
2287 //description:
2288 //shows that the engine supports the "r_letterbox" console variable, set to values in the range 0-100 this restricts the view vertically (and turns off sbar and crosshair), value is a 0-100 percentage of how much to constrict the view, <=0 = normal view height, 25 = 75% of normal view height, 50 = 50%, 75 = 25%, >=100 = no view
2289
2290 //PRYDON_CLIENTCURSOR
2291 //idea: FrikaC
2292 //darkplaces implementation: LordHavoc
2293 //effects bit:
2294 float EF_SELECTABLE = 16384; // allows cursor to highlight entity (brighten)
2295 //field definitions:
2296 .float cursor_active; // true if cl_prydoncursor mode is on
2297 .vector cursor_screen; // screen position of cursor as -1 to +1 in _x and _y (_z unused)
2298 .vector cursor_trace_start; // position of camera
2299 .vector cursor_trace_endpos; // position of cursor in world (as traced from camera)
2300 .entity cursor_trace_ent; // entity the cursor is pointing at (server forces this to world if the entity is currently free at time of receipt)
2301 //cvar definitions:
2302 //cl_prydoncursor (0/1+, default 0, 1 and above use cursors named gfx/prydoncursor%03i.lmp - or .tga and such if DP_GFX_EXTERNALTEXTURES is implemented)
2303 //description:
2304 //shows that the engine supports the cl_prydoncursor cvar, this puts a clientside mouse pointer on the screen and feeds input to the server for the QuakeC to use as it sees fit.
2305 //the mouse pointer triggers button4 if cursor is at left edge of screen, button5 if at right edge of screen, button6 if at top edge of screen, button7 if at bottom edge of screen.
2306 //the clientside trace skips transparent entities (except those marked EF_SELECTABLE).
2307 //the selected entity highlights only if EF_SELECTABLE is set, a typical selection method would be doubling the brightness of the entity by some means (such as colormod[] *= 2).
2308 //intended to be used by Prydon Gate.
2309
2310 //TENEBRAE_GFX_DLIGHTS
2311 //idea: Tenebrae
2312 //darkplaces implementation: LordHavoc
2313 //fields:
2314 .float light_lev; // radius (does not affect brightness), typical value 350
2315 .vector color; // color (does not affect radius), typical value '1 1 1' (bright white), can be up to '255 255 255' (nuclear blast)
2316 .float style; // light style (like normal light entities, flickering torches or switchable, etc)
2317 .float pflags; // flags (see PFLAGS_ constants)
2318 .vector angles; // orientation of the light
2319 .float skin; // cubemap filter number, can be 1-255 (0 is assumed to be none, and tenebrae only allows 16-255), this selects a projective light filter, a value of 1 loads cubemaps/1posx.tga and cubemaps/1negx.tga and posy, negy, posz, and negz, similar to skybox but some sides need to be rotated or flipped
2320 //constants:
2321 float PFLAGS_NOSHADOW = 1; // light does not cast shadows
2322 float PFLAGS_CORONA = 2; // light has a corona flare
2323 float PFLAGS_FULLDYNAMIC = 128; // light enable (without this set no light is produced!)
2324 //description:
2325 //more powerful dynamic light settings
2326 //warning: it is best not to use cubemaps on a light entity that has a model, as using a skin number that a model does not have will cause issues in glquake, and produce warnings in darkplaces (use developer 1 to see them)
2327 //changes compared to tenebrae (because they're too 'leet' for standards):
2328 //note: networking should send entities with PFLAGS_FULLDYNAMIC set even if they have no model (lights in general do not have a model, nor should they)
2329 //EF_FULLDYNAMIC effects flag replaced by PFLAGS_FULLDYNAMIC flag (EF_FULLDYNAMIC conflicts with EF_NODRAW)
2330
2331 //TW_SV_STEPCONTROL
2332 //idea: Transfusion
2333 //darkplaces implementation: LordHavoc
2334 //cvars:
2335 //sv_jumpstep (0/1, default 1)
2336 //sv_stepheight (default 18)
2337 //description:
2338 //sv_jumpstep allows stepping up onto stairs while airborn, sv_stepheight controls how high a single step can be.
2339
2340 //FTE_QC_CHECKPVS
2341 //idea: Urre
2342 //darkplaces implementation: divVerent
2343 //builtin definitions:
2344 float checkpvs(vector viewpos, entity viewee) = #240;
2345 //description:
2346 //returns true if viewee can be seen from viewpos according to PVS data
2347
2348 //FTE_STRINGS
2349 //idea: many
2350 //darkplaces implementation: KrimZon
2351 //builtin definitions:
2352 float(string str, string sub, float startpos) strstrofs = #221; // returns the offset into a string of the matching text, or -1 if not found, case sensitive
2353 float(string str, float ofs) str2chr = #222; // returns the character at the specified offset as an integer, or 0 if an invalid index, or byte value - 256 if the engine supports UTF8 and the byte is part of an extended character
2354 string(float c, ...) chr2str = #223; // returns a string representing the character given, if the engine supports UTF8 this may be a multi-byte sequence (length may be more than 1) for characters over 127.
2355 string(float ccase, float calpha, float cnum, string s, ...) strconv = #224; // reformat a string with special color characters in the font, DO NOT USE THIS ON UTF8 ENGINES (if you are lucky they will emit ^4 and such color codes instead), the parameter values are 0=same/1=lower/2=upper for ccase, 0=same/1=white/2=red/5=alternate/6=alternate-alternate for redalpha, 0=same/1=white/2=red/3=redspecial/4=whitespecial/5=alternate/6=alternate-alternate for rednum.
2356 string(float chars, string s, ...) strpad = #225; // pad string with spaces to a specified length, < 0 = left padding, > 0 = right padding
2357 string(string info, string key, string value, ...) infoadd = #226; // sets or adds a key/value pair to an infostring - note: forbidden characters are \ and "
2358 string(string info, string key) infoget = #227; // gets a key/value pair in an infostring, returns value or null if not found
2359 float(string s1, string s2, float len) strncmp = #228; // compare two strings up to the specified number of characters, if their length differs and is within the specified limit the result will be negative, otherwise it is the difference in value of their first non-matching character.
2360 float(string s1, string s2) strcasecmp = #229; // compare two strings with case-insensitive matching, characters a-z are considered equivalent to the matching A-Z character, no other differences, and this does not consider special characters equal even if they look similar
2361 float(string s1, string s2, float len) strncasecmp = #230; // same as strcasecmp but with a length limit, see strncmp
2362 //string(string s, float start, float length) substring = #116; // see note below
2363 //description:
2364 //various string manipulation functions
2365 //note: substring also exists in FRIK_FILE but this extension adds negative start and length as valid cases (see note above), substring is consistent with the php 5.2.0 substr function (not 5.2.3 behavior)
2366 //substring returns a section of a string as a tempstring, if given negative
2367 // start the start is measured back from the end of the string, if given a
2368 // negative length the length is the offset back from the end of the string to
2369 // stop at, rather than being relative to start, if start is negative and
2370 // larger than length it is treated as 0.
2371 // examples of substring:
2372 // substring("blah", -3, 3) returns "lah"
2373 // substring("blah", 3, 3) returns "h"
2374 // substring("blah", -10, 3) returns "bla"
2375 // substring("blah", -10, -3) returns "b"
2376
2377 //DP_CON_BESTWEAPON
2378 //idea: many
2379 //darkplaces implementation: divVerent
2380 //description:
2381 //allows QC to register weapon properties for use by the bestweapon command, for mods that change required ammo count or type for the weapons
2382 //it is done using console commands sent via stuffcmd:
2383 //  register_bestweapon quake
2384 //  register_bestweapon clear
2385 //  register_bestweapon <shortname> <impulse> <itemcode> <activeweaponcode> <ammostat> <ammomin>
2386 //for example, this is what Quake uses:
2387 //  register_bestweapon 1 1 4096 4096 6 0 // STAT_SHELLS is 6
2388 //  register_bestweapon 2 2    1    1 6 1
2389 //  register_bestweapon 3 3    2    2 6 1
2390 //  register_bestweapon 4 4    4    4 7 1 // STAT_NAILS is 7
2391 //  register_bestweapon 5 5    8    8 7 1
2392 //  register_bestweapon 6 6   16   16 8 1 // STAT_ROCKETS is 8
2393 //  register_bestweapon 7 7   32   32 8 1
2394 //  register_bestweapon 8 8   64   64 9 1 // STAT_CELLS is 9
2395 //after each map client initialization, this is reset back to Quake settings. So you should send these data in ClientConnect.
2396 //also, this extension introduces a new "cycleweapon" command to the user.
2397
2398 //DP_QC_STRINGBUFFERS
2399 //idea: ??
2400 //darkplaces implementation: LordHavoc
2401 //functions to manage string buffer objects - that is, arbitrary length string arrays that are handled by the engine
2402 float() buf_create = #460;
2403 void(float bufhandle) buf_del = #461;
2404 float(float bufhandle) buf_getsize = #462;
2405 void(float bufhandle_from, float bufhandle_to) buf_copy = #463;
2406 void(float bufhandle, float sortpower, float backward) buf_sort = #464;
2407 string(float bufhandle, string glue) buf_implode = #465;
2408 string(float bufhandle, float string_index) bufstr_get = #466;
2409 void(float bufhandle, float string_index, string str) bufstr_set = #467;
2410 float(float bufhandle, string str, float order) bufstr_add = #468;
2411 void(float bufhandle, float string_index) bufstr_free = #469;
2412
2413 //DP_QC_STRINGBUFFERS_CVARLIST
2414 //idea: divVerent
2415 //darkplaces implementation: divVerent
2416 //functions to list cvars and store their names into a stringbuffer
2417 //cvars that start with pattern but not with antipattern will be stored into the buffer
2418 void(float bufhandle, string pattern, string antipattern) buf_cvarlist = #517;
2419
2420 //DP_QC_STRREPLACE
2421 //idea: Sajt
2422 //darkplaces implementation: Sajt
2423 //builtin definitions:
2424 string(string search, string replace, string subject) strreplace = #484;
2425 string(string search, string replace, string subject) strireplace = #485;
2426 //description:
2427 //strreplace replaces all occurrences of 'search' with 'replace' in the string 'subject', and returns the result as a tempstring.
2428 //strireplace does the same but uses case-insensitive matching of the 'search' term
2429 //
2430 //DP_QC_CRC16
2431 //idea: divVerent
2432 //darkplaces implementation: divVerent
2433 //Some hash function to build hash tables with. This has to be be the CRC-16-CCITT that is also required for the QuakeWorld download protocol.
2434 //When caseinsensitive is set, the CRC is calculated of the lower cased string.
2435 float(float caseinsensitive, string s, ...) crc16 = #494;
2436
2437 //DP_SV_SHUTDOWN
2438 //idea: divVerent
2439 //darkplaces implementation: divVerent
2440 //A function that gets called just before progs exit. To save persistent data from.
2441 //It is not called on a crash or error.
2442 //void SV_Shutdown();
2443
2444 //EXT_CSQC
2445 // #232 void(float index, float type, .void field) SV_AddStat (EXT_CSQC)
2446 void(float index, float type, ...) addstat = #232;
2447
2448 //ZQ_PAUSE
2449 //idea: ZQuake
2450 //darkplaces implementation: GreEn`mArine
2451 //builtin definitions:
2452 void(float pause) setpause = #531;
2453 //function definitions:
2454 //void(float elapsedtime) SV_PausedTic;
2455 //description:
2456 //during pause the world is not updated (time does not advance), SV_PausedTic is the only function you can be sure will be called at regular intervals during the pause, elapsedtime is the current system time in seconds since the pause started (not affected by slowmo or anything else).
2457 //
2458 //calling setpause(0) will end a pause immediately.
2459 //
2460 //Note: it is worth considering that network-related functions may be called during the pause (including customizeentityforclient for example), and it is also important to consider the continued use of the KRIMZON_SV_PARSECLIENTCOMMAND extension while paused (chatting players, etc), players may also join/leave during the pause.  In other words, the only things that are not called are think and other time-related functions.
2461
2462
2463
2464
2465 // EXPERIMENTAL (not finalized) EXTENSIONS:
2466
2467 //DP_CRYPTO
2468 //idea: divVerent
2469 //darkplaces implementation: divVerent
2470 //field definitions: (SVQC)
2471 .string crypto_keyfp; // fingerprint of CA key the player used to authenticate, or string_null if not verified
2472 .string crypto_mykeyfp; // fingerprint of CA key the server used to authenticate to the player, or string_null if not verified
2473 .string crypto_idfp; // fingerprint of ID used by the player entity, or string_null if not identified
2474 .string crypto_encryptmethod; // the string "AES128" if encrypting, and string_null if plaintext
2475 .string crypto_signmethod; // the string "HMAC-SHA256" if signing, and string_null if plaintext
2476 // there is no field crypto_myidfp, as that info contains no additional information the QC may have a use for
2477 //builtin definitions: (SVQC)
2478 float(string url, float id, string content_type, string delim, float buf, float keyid) crypto_uri_postbuf = #513;
2479 //description:
2480 //use -1 as buffer handle to justs end delim as postdata