]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/dpdefs/csprogsdefs.qc
Merge remote branch 'origin/terencehill/powerups_respawntime_fix'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / dpdefs / csprogsdefs.qc
1 /*
2 ==============================================================================
3
4                         SOURCE FOR GLOBALVARS_T C STRUCTURE
5                         MUST NOT BE MODIFIED, OR CRC ERRORS WILL APPEAR
6
7 ==============================================================================
8 */
9
10 //
11 // system globals
12 //
13 entity          self;
14 entity          other;
15 entity          world;
16 float           time;
17 float           frametime;
18
19 float           player_localentnum;     //the entnum
20 float           player_localnum;        //the playernum
21 float           maxclients;     //a constant filled in by the engine. gah, portability eh?
22
23 float           clientcommandframe;     //player movement
24 float           servercommandframe;     //clientframe echoed off the server
25
26 string          mapname;
27
28 //
29 // global variables set by built in functions
30 //
31 vector          v_forward, v_up, v_right;       // set by makevectors()
32
33 // set by traceline / tracebox
34 float           trace_allsolid;
35 float           trace_startsolid;
36 float           trace_fraction;
37 vector          trace_endpos;
38 vector          trace_plane_normal;
39 float           trace_plane_dist;
40 entity          trace_ent;
41 float           trace_inopen;
42 float           trace_inwater;
43
44 //
45 // required prog functions
46 //
47 void()          CSQC_Init;
48 void()          CSQC_Shutdown;
49 float(float f, float t, float n)        CSQC_InputEvent;
50 void(float w, float h)          CSQC_UpdateView;
51 float(string s) CSQC_ConsoleCommand;
52
53 //these fields are read and set by the default player physics
54 vector          pmove_org;
55 vector          pmove_vel;
56 vector          pmove_mins;
57 vector          pmove_maxs;
58 //retrieved from the current movement commands (read by player physics)
59 float           input_timelength;
60 vector          input_angles;
61 vector          input_movevalues;       //forwards, right, up.
62 float           input_buttons;          //attack, use, jump (default physics only uses jump)
63
64 float           movevar_gravity;
65 float           movevar_stopspeed;
66 float           movevar_maxspeed;
67 float           movevar_spectatormaxspeed;      //used by NOCLIP movetypes.
68 float           movevar_accelerate;
69 float           movevar_airaccelerate;
70 float           movevar_wateraccelerate;
71 float           movevar_friction;
72 float           movevar_waterfriction;
73 float           movevar_entgravity;     //the local player's gravity field. Is a multiple (1 is the normal value)
74
75 //================================================
76 void            end_sys_globals;                // flag for structure dumping
77 //================================================
78
79 /*
80 ==============================================================================
81
82                         SOURCE FOR ENTVARS_T C STRUCTURE
83                         MUST NOT BE MODIFIED, OR CRC ERRORS WILL APPEAR
84
85 ==============================================================================
86 */
87
88 //
89 // system fields (*** = do not set in prog code, maintained by C code)
90 //
91 .float          modelindex;             // *** model index in the precached list
92 .vector         absmin, absmax; // *** origin + mins / maxs
93
94 .float          entnum; // *** the ent number as on the server
95 .float          drawmask;
96 .void()         predraw;
97
98 .float          movetype;
99 .float          solid;
100
101 .vector         origin;                 // ***
102 .vector         oldorigin;              // ***
103 .vector         velocity;
104 .vector         angles;
105 .vector         avelocity;
106
107 .string         classname;              // spawn function
108 .string         model;
109 .float          frame;
110 .float          skin;
111 .float          effects;
112
113 .vector         mins, maxs;             // bounding box extents reletive to origin
114 .vector         size;                   // maxs - mins
115
116 .void()         touch;
117 .void()         use;
118 .void()         think;
119 .void()         blocked;                // for doors or plats, called when can't push other
120
121 .float          nextthink;
122
123 .entity         chain;
124
125 .string         netname;
126
127 .entity         enemy;
128
129 .float          flags;
130
131 .float          colormap;
132
133 .entity         owner;          // who launched a missile
134
135 //================================================
136 void            end_sys_fields;                 // flag for structure dumping
137 //================================================
138
139 /*
140 ==============================================================================
141
142                         OPTIONAL FIELDS AND GLOBALS
143
144 ==============================================================================
145 */
146
147 // Additional OPTIONAL Fields and Globals
148 float           intermission; // indicates intermission state (0 = normal, 1 = scores, 2 = finale text)
149
150 vector          view_angles; // same as input_angles
151 vector          view_punchangle; // from server
152 vector          view_punchvector; // from server
153
154 /*
155 ==============================================================================
156
157                         CONSTANT DEFINITIONS
158
159 ==============================================================================
160 */
161
162 const float MASK_ENGINE                 = 1;
163 const float MASK_ENGINEVIEWMODELS       = 2;
164 const float MASK_NORMAL                 = 4;
165
166 const float RF_VIEWMODEL        = 1;
167 const float RF_EXTERNALMODEL    = 2;
168 const float RF_DEPTHHACK        = 4;
169 const float RF_ADDITIVE         = 8;
170 const float RF_USEAXIS          = 16;
171
172 const float VF_MIN              = 1;    //(vector)
173 const float VF_MIN_X            = 2;    //(float)
174 const float VF_MIN_Y            = 3;    //(float)
175 const float VF_SIZE             = 4;    //(vector) (viewport size)
176 const float VF_SIZE_Y           = 5;    //(float)
177 const float VF_SIZE_X           = 6;    //(float)
178 const float VF_VIEWPORT         = 7;    //(vector, vector)
179 const float VF_FOV              = 8;    //(vector)
180 const float VF_FOVX             = 9;    //(float)
181 const float VF_FOVY             = 10;   //(float)
182 const float VF_ORIGIN           = 11;   //(vector)
183 const float VF_ORIGIN_X         = 12;   //(float)
184 const float VF_ORIGIN_Y         = 13;   //(float)
185 const float VF_ORIGIN_Z         = 14;   //(float)
186 const float VF_ANGLES           = 15;   //(vector)
187 const float VF_ANGLES_X         = 16;   //(float)
188 const float VF_ANGLES_Y         = 17;   //(float)
189 const float VF_ANGLES_Z         = 18;   //(float)
190 const float VF_DRAWWORLD        = 19;   //(float)
191 const float VF_DRAWENGINESBAR   = 20;   //(float)
192 const float VF_DRAWCROSSHAIR    = 21;   //(float)
193
194 const float VF_CL_VIEWANGLES    = 33;   //(vector)
195 const float VF_CL_VIEWANGLES_X  = 34;   //(float)
196 const float VF_CL_VIEWANGLES_Y  = 35;   //(float)
197 const float VF_CL_VIEWANGLES_Z  = 36;   //(float) 
198
199 const float VF_PERSPECTIVE      = 200;
200
201 const float STAT_HEALTH         = 0;
202 const float STAT_WEAPONMODEL    = 2;
203 const float STAT_AMMO           = 3;
204 const float STAT_ARMOR          = 4;
205 const float STAT_WEAPONFRAME    = 5;
206 const float STAT_SHELLS         = 6;
207 const float STAT_NAILS          = 7;
208 const float STAT_ROCKETS        = 8;
209 const float STAT_CELLS          = 9;
210 const float STAT_ACTIVEWEAPON   = 10;
211 const float STAT_TOTALSECRETS   = 11;
212 const float STAT_TOTALMONSTERS  = 12;
213 const float STAT_SECRETS                = 13;
214 const float STAT_MONSTERS               = 14;
215 const float STAT_ITEMS          = 15;
216 const float STAT_VIEWHEIGHT     = 16;
217
218 // Quake Sound Constants
219 const float CHAN_AUTO                   = 0;
220 const float CHAN_WEAPON                 = 1;
221 const float CHAN_VOICE                  = 2;
222 const float CHAN_ITEM                   = 3;
223 const float CHAN_BODY                   = 4;
224
225 const float ATTN_NONE                   = 0;
226 const float ATTN_NORM                   = 1;
227 const float ATTN_IDLE                   = 2;
228 const float ATTN_STATIC                 = 3;
229
230 // Frik File Constants
231 const float FILE_READ                   = 0;
232 const float FILE_APPEND                 = 1;
233 const float FILE_WRITE                  = 2;
234
235 // Quake Point Contents
236 const float CONTENT_EMPTY                                       = -1;
237 const float CONTENT_SOLID                                       = -2;
238 const float CONTENT_WATER                                       = -3;
239 const float CONTENT_SLIME                                       = -4;
240 const float CONTENT_LAVA                                        = -5;
241 const float CONTENT_SKY                                         = -6;
242
243 // Quake Solid Constants
244 const float SOLID_NOT                                           = 0;
245 const float SOLID_TRIGGER                                       = 1;
246 const float SOLID_BBOX                                          = 2;
247 const float SOLID_SLIDEBOX                                      = 3;
248 const float SOLID_BSP                                           = 4;
249 const float SOLID_CORPSE                                        = 5;
250
251 // Quake Move Constants
252 const float MOVE_NORMAL                                         = 0;
253 const float MOVE_NOMONSTERS                                     = 1;
254 const float MOVE_MISSILE                                        = 2;
255
256 // Boolean Constants
257 const float true        = 1;
258 const float false       = 0;
259 const float TRUE        = 1;
260 const float FALSE       = 0;
261
262 const float EXTRA_LOW = -99999999;
263 const float EXTRA_HIGH = 99999999;
264
265 const vector VEC_1      = '1 1 1';
266 const vector VEC_0      = '0 0 0';
267 const vector VEC_M1     = '-1 -1 -1';
268
269 const float M_PI = 3.14159265358979323846;
270
271 vector  VEC_HULL_MIN = '-16 -16 -24';
272 vector  VEC_HULL_MAX = '16 16 32';
273
274 // Quake Temporary Entity Constants
275 const float TE_SPIKE                                            = 0;
276 const float TE_SUPERSPIKE                                       = 1;
277 const float TE_GUNSHOT                                          = 2;
278 const float TE_EXPLOSION                                        = 3;
279 const float TE_TAREXPLOSION                                     = 4;
280 const float TE_LIGHTNING1                                       = 5;
281 const float TE_LIGHTNING2                                       = 6;
282 const float TE_WIZSPIKE                                         = 7;
283 const float TE_KNIGHTSPIKE                                      = 8;
284 const float TE_LIGHTNING3                                       = 9;
285 const float TE_LAVASPLASH                                       = 10;
286 const float TE_TELEPORT                                         = 11;
287 const float TE_EXPLOSION2                                       = 12;
288         // Darkplaces Additions
289         const float TE_EXPLOSIONRGB                                     = 53;
290         const float TE_GUNSHOTQUAD                                      = 57;
291         const float TE_EXPLOSIONQUAD                            = 70;
292         const float TE_SPIKEQUAD                                        = 58;
293         const float TE_SUPERSPIKEQUAD                           = 59;
294         
295 // PFlags for Dynamic Lights
296 const float PFLAGS_NOSHADOW                                     = 1;
297 const float PFLAGS_CORONA                                       = 2;
298 const float PFLAGS_FULLDYNAMIC                          = 128;
299
300 const float EF_ADDITIVE         = 32;
301 const float EF_BLUE             = 64;
302 const float EF_FLAME            = 1024;
303 const float EF_FULLBRIGHT       = 512;
304 const float EF_NODEPTHTEST      = 8192;
305 const float EF_NODRAW           = 16;
306 const float EF_NOSHADOW         = 4096;
307 const float EF_RED              = 128;
308 const float EF_STARDUST         = 2048;
309 const float EF_SELECTABLE       = 16384;
310
311 const float PFL_ONGROUND        = 1;
312 const float PFL_CROUCH          = 2;
313 const float PFL_DEAD            = 4;
314 const float PFL_GIBBED          = 8;
315
316 // draw flags
317 const float DRAWFLAG_NORMAL = 0;
318 const float DRAWFLAG_ADDITIVE = 1;
319 const float DRAWFLAG_MODULATE = 2;
320 const float DRAWFLAG_2XMODULATE = 3;
321 const float DRAWFLAG_SCREEN = 4;
322 const float DRAWFLAG_MIPMAP = 0x100; // only for R_BeginPolygon
323
324 /*
325 ==============================================================================
326
327                         BUILTIN DEFINITIONS
328                         EXTENSIONS ARE NOT ADDED HERE, BUT BELOW!
329
330 ==============================================================================
331 */
332
333 void(vector ang) makevectors = #1;
334 void(entity e, vector o) setorigin = #2;
335 void(entity e, string m) setmodel = #3;
336 void(entity e, vector min, vector max) setsize = #4;
337
338 void() break = #6;
339 float() random = #7;
340 void(entity e, float chan, string samp) sound = #8;
341 vector(vector v) normalize = #9;
342 void(string e) error = #10;
343 void(string e) objerror = #11;
344 float(vector v) vlen = #12;
345 float(vector v) vectoyaw = #13;
346 entity() spawn = #14;
347 void(entity e) remove = #15;
348 float(vector v1, vector v2, float tryents, entity ignoreentity) traceline = #16;
349
350 entity(entity start, .string fld, string match) find = #18;
351 void(string s) precache_sound = #19;
352 void(string s) precache_model = #20;
353
354 entity(vector org, float rad) findradius = #22;
355
356 void(string s, ...) dprint = #25;
357 string(float f) ftos = #26;
358 string(vector v) vtos = #27;
359 void() coredump = #28;
360 void() traceon = #29;
361 void() traceoff = #30;
362 void(entity e) eprint = #31;
363 // settrace optional
364 float(float yaw, float dist, float settrace) walkmove = #32;
365
366 float() droptofloor = #34;
367 void(float style, string value) lightstyle = #35;
368 float(float v) rint = #36;
369 float(float v) floor = #37;
370 float(float v) ceil = #38;
371
372 float(entity e) checkbottom = #40;
373 float(vector v) pointcontents = #41;
374
375 float(float f) fabs = #43;
376
377 float(string s) cvar = #45;
378 void(string s, ...) localcmd = #46;
379 entity(entity e) nextent = #47;
380 void(vector o, vector d, float color, float count) particle = #48;
381 void() ChangeYaw = #49;
382
383 vector(vector v) vectoangles = #51;
384 vector(vector v, vector w) vectoangles2 = #51;
385
386 float(float f) sin = #60;
387 float(float f) cos = #61;
388 float(float f) sqrt = #62;
389 void(entity ent) changepitch = #63;
390 void(entity e, entity ignore) tracetoss = #64;
391 string(entity ent) etos = #65;
392
393 string(string s) precache_file = #68;
394 void(entity e) makestatic = #69;
395
396 void(string var, string val) cvar_set = #72;
397
398 void(vector pos, string samp, float vol, float atten) ambientsound = #74;
399 string(string s) precache_model2 = #75;
400 string(string s) precache_sound2 = #76;
401 string(string s) precache_file2 = #77;
402
403 float(string s) stof = #81;
404
405
406 void(vector v1, vector min, vector max, vector v2, float nomonsters, entity forent) tracebox = #90;
407 vector() randomvec = #91;
408 vector(vector org) getlight = #92;
409 vector(vector org, float lpflags) getlight2 = #92;
410 vector getlight_dir;
411 vector getlight_ambient;
412 vector getlight_diffuse;
413 const float LP_LIGHTMAP = 1;
414 const float LP_RTWORLD = 2;
415 const float LP_DYNLIGHT = 4;
416 const float LP_COMPLETE = 7;
417
418 float(string name, string value) registercvar = #93;
419 float( float a, ... ) min = #94;
420 float( float b, ... ) max = #95;
421 float(float minimum, float val, float maximum) bound = #96;
422 float(float f, float f) pow = #97;
423 entity(entity start, .float fld, float match) findfloat = #98;
424 float(string s) checkextension = #99;
425 // FrikaC and Telejano range #100-#199
426
427 float(string filename, float mode) fopen = #110;
428 void(float fhandle) fclose = #111;
429 string(float fhandle) fgets = #112;
430 void(float fhandle, string s) fputs = #113;
431 float(string s) strlen = #114;
432 string(...) strcat = #115;
433 string(string s, float start, float length) substring = #116;
434 vector(string) stov = #117;
435 string(string s) strzone = #118;
436 void(string s) strunzone = #119;
437
438 // FTEQW range #200-#299
439
440 float(float number, float quantity) bitshift = #218;
441
442 //float(string str, string sub[, float startpos]) strstrofs = #221;
443 float(string str, string sub, float startpos) strstrofs = #221;
444 float(string str, float ofs) str2chr = #222;
445 string(float c, ...) chr2str = #223;
446 string(float ccase, float calpha, float cnum, string s, ...) strconv = #224;
447 string(float chars, string s, ...) strpad = #225;
448 string(string info, string key, string value, ...) infoadd = #226;
449 string(string info, string key) infoget = #227;
450 float(string s1, string s2, float len) strncmp = #228;
451 float(string s1, string s2) strcasecmp = #229;
452 float(string s1, string s2, float len) strncasecmp = #230;
453
454 // CSQC range #300-#399
455 void() clearscene = #300;
456 void(float mask) addentities = #301;
457 void(entity ent) addentity = #302;
458 float(float property, ...) setproperty = #303;
459 float(float property) getproperty = #309;
460 vector(float property) getpropertyvec = #309;
461 void() renderscene = #304;
462 void(vector org, float radius, vector lightcolours) adddynamiclight = #305;
463 void(vector org, float radius, vector lightcolours, float style, string cubemapname, float pflags) adddynamiclight2 = #305;
464 //void(string texturename, float flag[, float is2d, float lines]) R_BeginPolygon = #306;
465 void(string texturename, float flag, ...) R_BeginPolygon = #306;
466 void(vector org, vector texcoords, vector rgb, float alpha) R_PolygonVertex = #307;
467 void() R_EndPolygon = #308;
468 vector (vector v) cs_unproject = #310;
469 vector (vector v) cs_project = #311;
470
471 void(float width, vector pos1, vector pos2, float flag) drawline = #315;
472 float(string name) iscachedpic = #316;
473 string(string name, ...) precache_pic = #317;
474 string(string name) precache_cubemap = #317;
475 vector(string picname) draw_getimagesize = #318;
476 void(string name) freepic = #319;
477 float(vector position, float character, vector scale, vector rgb, float alpha, float flag) drawcharacter = #320;
478 float(vector position, string text, vector scale, vector rgb, float alpha, float flag) drawstring = #321;
479 float(vector position, string pic, vector size, vector rgb, float alpha, float flag) drawpic = #322;
480 float(vector position, vector size, vector rgb, float alpha, float flag) drawfill = #323;
481 void(float x, float y, float width, float height) drawsetcliparea = #324;
482 void(void) drawresetcliparea = #325;
483 float(vector position, string text, vector scale, float alpha, float flag) drawcolorcodedstring = #326;
484 vector(vector position, string text, vector scale, vector rgb, float alpha, float flag) drawcolorcodedstring2 = #326;
485
486 float(float stnum) getstatf = #330;
487 float(float stnum, ...) getstati = #331; // can optionally take first bit and count
488 string(float firststnum) getstats = #332;
489 void(entity e, float mdlindex) setmodelindex = #333;
490 string(float mdlindex) modelnameforindex = #334;
491 float(string effectname) particleeffectnum = #335;
492 void(entity ent, float effectnum, vector start, vector end) trailparticles = #336;
493 //void(float effectnum, vector origin [, vector dir, float count]) pointparticles = #337;
494 void(float effectnum, vector origin , vector dir, float count) pointparticles = #337;
495 void(string s, ...) centerprint = #338;
496 void(string s, ...) print = #339;
497 string(float keynum) keynumtostring = #340;
498 float(string keyname) stringtokeynum = #341;
499 string(float keynum) getkeybind = #342;
500 void(float usecursor) setcursormode = #343;
501 vector() getmousepos = #344;
502 float(float framenum) getinputstate = #345;
503 void(float sens) setsensitivityscale = #346;
504 void(...) runstandardplayerphysics = #347; // this may or may not take a player ent
505 string(float playernum, string keyname) getplayerkeyvalue = #348;
506 float() isdemo = #349;
507 float() isserver = #350;
508 void(vector origin, vector forward, vector right, vector up) SetListener = #351;
509 void(string cmdname) registercommand = #352;
510 float(entity ent) wasfreed = #353;
511 string(string key) serverkey = #354;
512
513 // Use proper case; refer to the id1 Write* functions!
514 float() ReadByte = #360;
515 float() ReadChar = #361;
516 float() ReadShort = #362;
517 float() ReadLong = #363;
518 float() ReadCoord = #364;
519 float() ReadAngle = #365;
520 string() ReadString = #366;
521 float() ReadFloat = #367;
522
523 // LordHavoc's range #400-#499
524 void(entity from, entity to) copyentity = #400;
525
526 entity(.string fld, string match) findchain = #402;
527 entity(.float fld, float match) findchainfloat = #403;
528 void(vector org, string modelname, float startframe, float endframe, float framerate) effect = #404;
529 void(vector org, vector velocity, float howmany) te_blood = #405;
530 void(vector mincorner, vector maxcorner, float explosionspeed, float howmany) te_bloodshower = #406;
531 void(vector org, vector color) te_explosionrgb = #407;
532 void(vector mincorner, vector maxcorner, vector vel, float howmany, float color, float gravityflag, float randomveljitter) te_particlecube = #408;
533 void(vector mincorner, vector maxcorner, vector vel, float howmany, float color) te_particlerain = #409;
534 void(vector mincorner, vector maxcorner, vector vel, float howmany, float color) te_particlesnow = #410;
535 void(vector org, vector vel, float howmany) te_spark = #411;
536 void(vector org) te_gunshotquad = #412;
537 void(vector org) te_spikequad = #413;
538 void(vector org) te_superspikequad = #414;
539 void(vector org) te_explosionquad = #415;
540 void(vector org) te_smallflash = #416;
541 void(vector org, float radius, float lifetime, vector color) te_customflash = #417;
542 void(vector org) te_gunshot = #418;
543 void(vector org) te_spike = #419;
544 void(vector org) te_superspike = #420;
545 void(vector org) te_explosion = #421;
546 void(vector org) te_tarexplosion = #422;
547 void(vector org) te_wizspike = #423;
548 void(vector org) te_knightspike = #424;
549 void(vector org) te_lavasplash = #425;
550 void(vector org) te_teleport = #426;
551 void(vector org, float colorstart, float colorlength) te_explosion2 = #427;
552 void(entity own, vector start, vector end) te_lightning1 = #428;
553 void(entity own, vector start, vector end) te_lightning2 = #429;
554 void(entity own, vector start, vector end) te_lightning3 = #430;
555 void(entity own, vector start, vector end) te_beam = #431;
556 void(vector dir) vectorvectors = #432;
557 void(vector org) te_plasmaburn = #433;
558 float(entity e, float s) getsurfacenumpoints = #434;
559 vector(entity e, float s, float n) getsurfacepoint = #435;
560 vector(entity e, float s) getsurfacenormal = #436;
561 string(entity e, float s) getsurfacetexture = #437;
562 float(entity e, vector p) getsurfacenearpoint = #438;
563 vector(entity e, float s, vector p) getsurfaceclippedpoint = #439;
564
565 float(string s) tokenize = #441;
566 string(float n) argv = #442;
567 void(entity e, entity tagentity, string tagname) setattachment = #443;
568 float(string pattern, float caseinsensitive, float quiet) search_begin = #444;
569 void(float handle) search_end = #445;
570 float(float handle) search_getsize = #446;
571 string(float handle, float num) search_getfilename = #447;
572 string(string s) cvar_string = #448;
573 entity(entity start, .float fld, float match) findflags = #449;
574 entity(.float fld, float match) findchainflags = #450;
575 float(entity ent, string tagname) gettagindex = #451;
576 vector(entity ent, float tagindex) gettaginfo = #452;
577
578 void(vector org, vector vel, float howmany) te_flamejet = #457;
579
580 entity(float num) entitybyindex = #459;
581 float() buf_create = #460;
582 void(float bufhandle) buf_del = #461;
583 float(float bufhandle) buf_getsize = #462;
584 void(float bufhandle_from, float bufhandle_to) buf_copy = #463;
585 void(float bufhandle, float sortpower, float backward) buf_sort = #464;
586 string(float bufhandle, string glue) buf_implode = #465;
587 string(float bufhandle, float string_index) bufstr_get = #466;
588 void(float bufhandle, float string_index, string str) bufstr_set = #467;
589 float(float bufhandle, string str, float order) bufstr_add = #468;
590 void(float bufhandle, float string_index) bufstr_free = #469;
591
592 float(float s) asin = #471;
593 float(float c) acos = #472;
594 float(float t) atan = #473;
595 float(float c, float s) atan2 = #474;
596 float(float a) tan = #475;
597 float(string s) strippedstringlen = #476;
598 float(string s) strlennocol = #476; // This is the correct name for the function, but not removing the decolorizedstring mapping.
599 string(string s) decolorizedstring = #477;
600 string(string s) strdecolorize = #477; // This is the correct name for the function, but not removing the decolorizedstring mapping.
601 string(float uselocaltime, string format, ...) strftime = #478;
602 string(string s) strtolower = #480;
603 string(string s) strtoupper = #481;
604 string(string s) cvar_defstring = #482;
605 void(vector origin, string sample, float volume, float attenuation) pointsound = #483;
606 string(string search, string replace, string subject) strreplace = #484;
607 string(string search, string replace, string subject) strireplace = #485;
608 vector(entity e, float s, float n, float a) getsurfacepointattribute = #486;
609 #ifdef SUPPORT_GECKO
610 float gecko_create( string name ) = #487;
611 void gecko_destroy( string name ) = #488;
612 void gecko_navigate( string name, string URI ) = #489;
613 float gecko_keyevent( string name, float key, float eventtype ) = #490;
614 void gecko_mousemove( string name, float x, float y ) = #491;
615 void gecko_resize( string name, float w, float h ) = #492;
616 vector gecko_get_texture_extent( string name ) = #493;
617 #else
618
619 #endif
620
621 /*
622 ==============================================================================
623
624                         EXTENSION DEFINITIONS
625
626 ==============================================================================
627 */
628
629 // DP_CSQC_SPAWNPARTICLE
630 // idea: VorteX
631 // darkplaces implementation: VorteX
632 // constant definitions:
633 // particle base behavior:
634 float PT_ALPHASTATIC = 1;
635 float PT_STATIC = 2;
636 float PT_SPARK = 3;
637 float PT_BEAM = 4;
638 float PT_RAIN = 5;
639 float PT_RAINDECAL = 6;
640 float PT_SNOW = 7;
641 float PT_BUBBLE = 8;
642 float PT_BLOOD = 9;
643 float PT_SMOKE = 10;
644 float PT_DECAL = 11;
645 float PT_ENTITYPARTICLE = 12;
646 // particle blendtypes:
647 float PBLEND_ALPHA = 0;
648 float PBLEND_ADD = 1;
649 float PBLEND_INVMOD = 2;
650 // particle orientation:
651 float PARTICLE_BILLBOARD = 0;
652 float PARTICLE_SPARK = 1;
653 float PARTICLE_ORIENTED_DOUBLESIDED = 2;
654 float PARTICLE_BEAM = 3;
655 // global definitions:
656 float particle_type; // one of PT_
657 float particle_blendmode; // one of PBLEND_ values
658 float particle_orientation; // one of PARTICLE_ values
659 vector particle_color1; 
660 vector particle_color2;
661 float particle_tex; // number of chunk in particlefont
662 float particle_size;
663 float particle_sizeincrease; 
664 float particle_alpha;
665 float particle_alphafade;
666 float particle_time;
667 float particle_gravity;
668 float particle_bounce;
669 float particle_airfriction;
670 float particle_liquidfriction;
671 float particle_originjitter;
672 float particle_velocityjitter;
673 float particle_qualityreduction; // enable culling of this particle when FPS is low
674 float particle_stretch;
675 vector particle_staincolor1;
676 vector particle_staincolor2;
677 float particle_staintex;
678 float particle_stainalpha;
679 float particle_stainsize;
680 float particle_delayspawn;
681 float particle_delaycollision;
682 float particle_angle;
683 float particle_spin;
684 // builtin definitions:
685 float(float max_themes) initparticlespawner = #522; // check fields/globals for integration and enable particle spawner, return 1 is succeded, otherwise returns 0
686 void() resetparticle = #523; // reset p_ globals to default theme #0
687 void(float theme) particletheme = #524; // restore p_ globals from saved theme
688 float() particlethemesave = #525; // save p_ globals to new particletheme and return it's index
689 void(float theme) particlethemeupdate = #525; // save p_ globals to new particletheme and return it's index
690 void(float theme) particlethemefree = #526; // delete a particle theme
691 float(vector org, vector vel) spawnparticle = #527; // returns 0 when failed, 1 when spawned
692 float(vector org, vector vel, float theme) quickparticle = #527; // not reading globals, just theme, returns 0 when failed, 1 when spawned
693 float(vector org, vector vel, float delay, float collisiondelay) delayedparticle = #528;
694 float(vector org, vector vel, float delay, float collisiondelay, float theme) quickdelayedparticle = #528;
695 // description: this builtin provides an easy and flexible way to spawn particles, 
696 // it is not created as replace for DP_SV_POINTPARTICLES but as an addition to it. 
697 // With this extension you can create a specific particles like rain particles, or entity particles
698 // notes: 
699 // 1) 0 is default particle template, it could be changed
700 // 2) color vectors could have value 0-255 of each component
701 // restrictions: max themes could be between 4 and 2048
702 // warning: you should call initparticlespawner() at very beginning BEFORE all other particle spawner functions
703 // function to query particle info
704 // don't remove this function as it protects all particle_ globals from FTEQCC/FRIKQCC non-referenced removal optimisation
705 void() printparticle =
706 {
707         // vortex: this also protects from 'non-referenced' optimisation on some compilers
708         print("PARTICLE:\n");
709         print(strcat("  type: ", ftos(particle_type), "\n"));
710         print(strcat("  blendmode: ", ftos(particle_blendmode), "\n"));
711         print(strcat("  orientation: ", ftos(particle_orientation), "\n"));
712         print(strcat("  color1: ", vtos(particle_color1), "\n"));
713         print(strcat("  color2: ", vtos(particle_color2), "\n"));
714         print(strcat("  tex: ", ftos(particle_tex), "\n"));
715         print(strcat("  size: ", ftos(particle_size), "\n"));
716         print(strcat("  sizeincrease: ", ftos(particle_sizeincrease), "\n"));
717         print(strcat("  alpha: ", ftos(particle_alpha), "\n"));
718         print(strcat("  alphafade: ", ftos(particle_alphafade), "\n"));
719         print(strcat("  time: ", ftos(particle_time), "\n"));
720         print(strcat("  gravity: ", ftos(particle_gravity), "\n"));
721         print(strcat("  bounce: ", ftos(particle_bounce), "\n"));
722         print(strcat("  airfriction: ", ftos(particle_airfriction), "\n"));
723         print(strcat("  liquidfriction: ", ftos(particle_liquidfriction), "\n"));
724         print(strcat("  originjitter: ", ftos(particle_originjitter), "\n"));
725         print(strcat("  velocityjitter: ", ftos(particle_velocityjitter), "\n"));
726         print(strcat("  qualityreduction: ", ftos(particle_qualityreduction), "\n"));
727         print(strcat("  stretch: ", ftos(particle_stretch), "\n"));
728         print(strcat("  staincolor1: ", vtos(particle_staincolor1), "\n"));
729         print(strcat("  staincolor2: ", vtos(particle_staincolor2), "\n"));
730         print(strcat("  staintex: ", ftos(particle_staintex), "\n"));
731         print(strcat("  stainalpha: ", ftos(particle_stainalpha), "\n"));
732         print(strcat("  stainsize: ", ftos(particle_stainsize), "\n"));
733         print(strcat("  delayspawn: ", ftos(particle_delayspawn), "\n"));
734         print(strcat("  delaycollision: ", ftos(particle_delaycollision), "\n"));
735         print(strcat("  angle: ", ftos(particle_angle), "\n"));
736         print(strcat("  spin: ", ftos(particle_spin), "\n"));
737 }
738
739 // DP_CSQC_ENTITYTRANSPARENTSORTING_OFFSET
740 // idea: VorteX
741 // darkplaces implementation: VorteX
742 float RF_USETRANSPARENTOFFSET = 64; // enables transparent origin offsetting
743 // global definitions
744 float transparent_offset; // should be set before entity is added
745 // description: offset a model's meshes origin used for transparent sorting. Could be used to tweak sorting bugs on very large transparent entities or hacking transparent sorting order for certain objects
746 // example: transparent_offset = 1000000; // entity always appear on background of other transparents
747 // note: offset is done in view forward axis
748
749 // DP_CSQC_ENTITYWORLDOBJECT
750 // idea: VorteX
751 // darkplaces implementation: VorteX
752 const float RF_WORLDOBJECT = 128;
753 // description: when renderflag is set, engine will not use culling methods for this entity, e.g. it will always be drawn
754 // useful for large outdoor objects (like asteroids on sky horizon or sky models)
755
756 // DP_CSQC_ENTITYMODELLIGHT
757 // idea: VorteX
758 // darkplaces implementation: VorteX
759 const float RF_MODELLIGHT = 4096;
760 .vector modellight_ambient;
761 .vector modellight_diffuse;
762 .vector modellight_dir;
763 // description: allows CSQC to override directional model lightning on entity
764
765 // DP_CSQC_SETPAUSE
766 // idea: VorteX
767 // darkplaces implementation: VorteX
768 // builtin definitions:
769 void(float ispaused) setpause = #531;
770 // description: provides ability to set pause in local games (similar to one set once console is activated)
771 // not stopping sound/cd track, useful for inventory screens, ingame menus with input etc.
772
773 // DP_CSQC_QUERYRENDERENTITY
774 // idea: VorteX
775 // darkplaces implementation: VorteX
776 // constant definitions:
777 // render entity fields:
778 float E_ACTIVE      = 0; // float 0/1
779 float E_ORIGIN      = 1; // vector
780 float E_FORWARD     = 2; // vector
781 float E_RIGHT       = 3; // vector
782 float E_UP          = 4; // vector
783 float E_SCALE       = 5; // float
784 float E_ORIGINANDVECTORS = 6; // returns origin, + sets v_* vectors to orientation
785 float E_ALPHA       = 7; // float
786 float E_COLORMOD    = 8; // vector
787 float E_PANTSCOLOR  = 9; // vector
788 float E_SHIRTCOLOR  = 10; // vector
789 float E_SKIN        = 11; // float
790 float E_MINS        = 12; // vector
791 float E_MAXS        = 13; // vector
792 float E_ABSMIN      = 14; // vector
793 float E_ABSMAX      = 15; // vector
794 float E_LIGHT       = 16; // vector - modellight
795 // builtin definitions:
796 float(float entitynum, float fldnum) getentity = #504;
797 vector(float entitynum, float fldnum) getentityvec = #504;
798 // description: allows to query parms from render entities, especially useful with attaching CSQC ents to
799 // server entities networked and interpolated by engine (monsters, players), number of entity is it's SVQC number
800 // you can send it via tempentity/CSQC entity message. Note that this builtin doesnt know about entity removing/reallocating
801 // so it's meaning to work for short period of time, dont use it on missiles/grenades whatever will be removed next five seconds
802
803 //DP_GFX_FONTS
804 //idea: Blub\0, divVerent
805 //darkplaces implementation: Blub\0
806 //console commands:
807 //  loadfont fontname fontmaps size1 size2 ...
808 //   A font can simply be gfx/tgafile (freetype fonts doent need extension), 
809 //   or alternatively you can specify multiple fonts and faces
810 //   Like this: gfx/vera-sans:2,gfx/fallback:1
811 //   to load face 2 of the font gfx/vera-sans and use face 1
812 //   of gfx/fallback as fallback font
813 //   You can also specify a list of font sizes to load, like this:
814 //   loadfont console gfx/conchars,gfx/fallback 8 12 16 24 32
815 //   In many cases, 8 12 16 24 32 should be a good choice.
816 //   for slots see:
817 //constant definitions:
818 float drawfont;            // set it before drawstring()/drawchar() calls
819 float FONT_DEFAULT = 0;    // 'default'
820 float FONT_CONSOLE = 1;    // 'console', REALLY should be fixed width (ls!)
821 float FONT_SBAR = 2;       // 'sbar', used on hud, must be fixed width
822 float FONT_NOTIFY = 3;     // 'notify', used on sprint/bprint
823 float FONT_CHAT = 4;       // 'chat'
824 float FONT_CENTERPRINT = 5;// 'centerprint'
825 float FONT_INFOBAR = 6;    // 'infobar'
826 float FONT_MENU = 7;       // 'menu', should be fixed width
827 float FONT_USER0 = 8;      // 'user0', userdefined fonts
828 float FONT_USER1 = 9;      // 'user1', userdefined fonts
829 float FONT_USER2 = 10;     // 'user2', userdefined fonts
830 float FONT_USER3 = 11;     // 'user3', userdefined fonts
831 float FONT_USER4 = 12;     // 'user4', userdefined fonts
832 float FONT_USER5 = 13;     // 'user5', userdefined fonts
833 float FONT_USER6 = 14;     // 'user6', userdefined fonts
834 float FONT_USER7 = 15;     // 'user7' slot, userdefined fonts
835 //builtin definitions:
836 float findfont(string s) = #356; // find font by fontname and return it's index
837 float loadfont(string fontname, string fontmaps, string sizes, float slot, float fix_scale, float fix_voffset) = #357; 
838 // loads font immediately so stringwidth() function can be used just after builtin call
839 // returns a font slotnum (which is used to set drawfont to)
840 // first 3 parms are identical to "loadfont" console command ones
841 // slot could be one of FONT_ constants or result of findfont() or -1 to not use it
842 // if slot is given, font will be loaded to this slotnum and fontname become new title for it
843 // this way you can rename user* fonts to something more usable
844 // fix_* parms let you fix badly made fonts by applying some transformations to them
845 // fix_scale : per-character center-oriented scale (doesn't change line height at all)
846 // fix_voffset : vertical offset for each character, it's a multiplier to character height
847 float stringwidth(string text, float allowColorCodes, vector size) = #327; // get a width of string with given font and char size
848 float stringwidth_menu(string text, float allowColorCodes, vector size) = #468; // in menu.dat it has different builtin #
849 //description: engine support for custom fonts in console, hud, qc etc.
850 // limits:
851 //  max 128 chars for font name
852 //  max 3 font fallbacks
853 //  max 8 sizes per font
854
855 //DP_GFX_FONTS_FREETYPE
856 //idea: Blub\0, divVerent
857 //darkplaces implementation: Blub\0
858 //cvar definitions:
859 //   r_font_disable_freetype 0/1 : disable freetype fonts loading (uttetly disables freetype library initialization)
860 //   r_font_antialias 0/1 : antialiasing when loading font
861 //   r_font_hint 0/1/2/3  : hinting when loading font, 0 is no hinting, 1 light autohinting , 2 full autohinting, 3 full hinting
862 //   r_font_postprocess_blur X      : font outline blur amount
863 //   r_font_postprocess_outline X   : font outline width
864 //   r_font_postprocess_shadow_x X  : font outline shadow x shift amount, applied during outlining
865 //   r_font_postprocess_shadow_y X  : font outline shadow y shift amount, applied during outlining
866 //   r_font_postprocess_shadow_z X  : font outline shadow z shift amount, applied during blurring
867 //description: engine support for truetype/freetype fonts
868 //so .AFM+.PFB/.OTF/.TTF files could be stuffed as fontmaps in loadfont() 
869 //(console command version will support them as well)
870
871 //DP_CSQC_BINDMAPS
872 //idea: daemon, motorsep
873 //darkplaces implementation: divVerent
874 //builtin definitions:
875 string(float key, float bindmap) getkeybind_bindmap = #342;
876 float(float key, string bind, float bindmap) setkeybind_bindmap = #630;
877 vector(void) getbindmaps = #631;
878 float(vector bm) setbindmaps = #632;
879 string(string command, float bindmap) findkeysforcommand = #610;
880 //<already in EXT_CSQC> float(string key) stringtokeynum = #341;
881 //<already in EXT_CSQC> string(float keynum) keynumtostring = #340;
882 //description: key bind setting/getting including support for switchable
883 //bindmaps.
884
885 //DP_CRYPTO
886 //idea: divVerent
887 //darkplaces implementation: divVerent
888 //builtin definitions: (CSQC)
889 float(string url, float id, string content_type, string delim, float buf, float keyid) crypto_uri_postbuf = #513;
890 //description:
891 //use -1 as buffer handle to justs end delim as postdata
892
893 //DP_CSQC_MAINVIEW
894 //idea: divVerent
895 //darkplaces implementation: divVerent
896 //constant definitions:
897 const float VF_MAINVIEW         = 400;
898 //use setproperty(VF_MAINVIEW, 1); before calling R_RenderView for the render
899 //that shall become the "main" view, which is e.g. used by PRYDON_CLIENTCURSOR 
900 //this flag is set for the first scene, and not cleared by R_ClearScene
901 //this flag is automatically cleared by R_RenderView
902 //so when not using this extension, the first view rendered is the main view
903
904 //DP_CSQC_MINFPS_QUALITY
905 //idea: divVerent
906 //darkplaces implementation: divVerent
907 //constant definitions:
908 const float VF_MINFPS_QUALITY   = 401;
909 //use getproperty(VF_MINFPS_QUALITY); to do CSQC based LOD based on cl_minfps
910 //1 should lead to an unmodified view
911
912 //DP_CSQC_V_CALCREFDEF_WIP1
913 //DP_CSQC_V_CALCREFDEF_WIP2
914 //idea: divVerent
915 //darkplaces implementation: divVerent
916 //builtin definitions:
917 void(entity e, float refdefflags) V_CalcRefdef = #640;
918 //constant definitions:
919 float PMF_DUCKED = 4;
920 float PMF_ONGROUND = 8;
921 float REFDEFFLAG_TELEPORTED = 1;
922 float REFDEFFLAG_JUMPING = 2;
923 float REFDEFFLAG_DEAD = 4;
924 float REFDEFFLAG_INTERMISSION = 8;
925 //- use this on the player entity after performing prediction
926 //- pass REFDEFFLAG_TELEPORTED if the player teleported since last frame
927 //- pass REFDEFFLAG_JUMPING if jump button is pressed
928 //- pass REFDEFFLAG_DEAD if dead (DP_CSQC_V_CALCREFDEF_WIP2)
929 //- pass REFDEFFLAG_INTERMISSION if in intermission (DP_CSQC_V_CALCREFDEF_WIP2)
930 //- the player entity needs to have origin, velocity, pmove_flags set according
931 //  to prediction (the above two PMF_ flags are used in the player's pmove_flags)
932 //- NOTE: to check for this, ALSO OR a check with DP_CSQC_V_CALCREFDEF to also support
933 //  the finished extension once done
934
935 // assorted builtins
936 float   drawsubpic(vector position, vector size, string pic, vector srcPosition, vector srcSize, vector rgb, float alpha, float flag) = #328;
937 vector  drawgetimagesize(string pic) = #318;
938 #define SPA_POSITION 0
939 #define SPA_S_AXIS 1
940 #define SPA_T_AXIS 2
941 #define SPA_R_AXIS 3
942 #define SPA_TEXCOORDS0 4
943 #define SPA_LIGHTMAP0_TEXCOORDS 5
944 #define SPA_LIGHTMAP_COLOR 6
945 float (entity e, float s)                                               getsurfacenumpoints = #434;
946 vector (entity e, float s, float n)                                     getsurfacepoint = #435;
947 vector (entity e, float s)                                              getsurfacenormal = #436;
948 string (entity e, float s)                                              getsurfacetexture = #437;
949 float (entity e, vector p)                                              getsurfacenearpoint = #438;
950 vector (entity e, float s, vector p)                                    getsurfaceclippedpoint = #439;
951 vector(entity e, float s, float n, float a) getsurfacepointattribute = #486;
952 float(entity e, float s) getsurfacenumtriangles = #628;
953 vector(entity e, float s, float n) getsurfacetriangle = #629;
954
955 //DP_QC_ASINACOSATANATAN2TAN
956 //idea: Urre
957 //darkplaces implementation: LordHavoc
958 //constant definitions:
959 float DEG2RAD = 0.0174532925199432957692369076848861271344287188854172545609719144;
960 float RAD2DEG = 57.2957795130823208767981548141051703324054724665643215491602438612;
961 float PI      = 3.1415926535897932384626433832795028841971693993751058209749445923;
962 //builtin definitions:
963 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
964 float(float c) acos = #472; // returns angle in radians for a given cos() value, the result is in the range 0 to PI
965 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
966 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)
967 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
968 //description:
969 //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).
970 //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)
971
972 //DP_QC_SPRINTF
973 //idea: divVerent
974 //darkplaces implementation: divVerent
975 //builtin definitions:
976 string(string format, ...) sprintf = #627;
977 //description:
978 //you know sprintf :P
979 //supported stuff:
980 //  %
981 //  optional: <argpos>$ for the argument to format
982 //  flags: #0- +
983 //  optional: <width>, *, or *<argpos>$ for the field width
984 //  optional: .<precision>, .*, or .*<argpos>$ for the precision
985 //  length modifiers: h for forcing a float, l for forcing an int/entity (by default, %d etc. cast a float to int)
986 //  conversions:
987 //    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
988 //    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
989 //    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
990 //    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
991 //    s takes a string
992 //    vV takes a vector, and processes the three components as if it were a gG for all three components, separated by space
993 //    For conversions s and c, the flag # makes precision and width interpreted
994 //      as byte count, by default it is interpreted as character count in UTF-8
995 //      enabled engines. No other conversions can create wide characters, and #
996 //      has another meaning in these.
997
998 //DP_QC_GETTIME
999 //idea: tZork
1000 //darkplaces implementation: tZork, divVerent
1001 //constant definitions:
1002 float GETTIME_FRAMESTART = 0; // time of start of frame
1003 float GETTIME_REALTIME = 1; // current time (may be OS specific)
1004 float GETTIME_HIRES = 2; // like REALTIME, but may reset between QC invocations and thus can be higher precision
1005 float GETTIME_UPTIME = 3; // time since start of the engine
1006 //builtin definitions:
1007 float(float tmr) gettime = #519;
1008 //description:
1009 //some timers to query...
1010
1011 //DP_QC_GETTIME_CDTRACK
1012 //idea: divVerent
1013 //darkplaces implementation: divVerent
1014 //constant definitions:
1015 float GETTIME_CDTRACK = 4;
1016 //description:
1017 //returns the playing time of the current cdtrack when passed to gettime()
1018 //see DP_END_GETSOUNDTIME for similar functionality but for entity sound channels
1019
1020 //DP_QC_TOKENIZEBYSEPARATOR
1021 //idea: Electro, SavageX, LordHavoc
1022 //darkplaces implementation: LordHavoc
1023 //builtin definitions:
1024 float(string s, string separator1, ...) tokenizebyseparator = #479;
1025 //description:
1026 //this function returns tokens separated by any of the supplied separator strings, example:
1027 //numnumbers = tokenizebyseparator("10.2.3.4", ".");
1028 //returns 4 and the tokens are "10" "2" "3" "4"
1029 //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")
1030
1031 //DP_QC_TOKENIZE_CONSOLE
1032 //idea: divVerent
1033 //darkplaces implementation: divVerent
1034 //builtin definitions:
1035 float(string s) tokenize_console = #514;
1036 float(float i) argv_start_index = #515;
1037 float(float i) argv_end_index = #516;
1038 //description:
1039 //this function returns tokens separated just like the console does
1040 //also, functions are provided to get the index of the first and last character of each token in the original string
1041 //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.
1042
1043 //DP_SND_SOUND7_WIP1
1044 //DP_SND_SOUND7_WIP2
1045 //idea: divVerent
1046 //darkplaces implementation: divVerent
1047 //builtin definitions:
1048 void(entity e, float chan, string samp, float vol, float atten, float speed, float flags) sound7 = #8;
1049 float SOUNDFLAG_RELIABLE = 1;
1050 //description:
1051 //plays a sound, with some more flags
1052 //extensions to sound():
1053 //- channel may be in the range from -128 to 127; channels -128 to 0 are "auto",
1054 //  i.e. support multiple sounds at once, but cannot be stopped/restarted
1055 //- a value 0 in the speed parameter means no change; otherwise, it is a
1056 //  percentage of playback speed ("pitch shifting"). 100 is normal pitch, 50 is
1057 //  half speed, 200 is double speed, etc. (DP_SND_SOUND7_WIP2)
1058 //- the flag SOUNDFLAG_RELIABLE can be specified, which makes the sound send
1059 //  to MSG_ALL (reliable) instead of MSG_BROADCAST (unreliable, default);
1060 //  similarily, SOUNDFLAG_RELIABLE_TO_ONE sends to MSG_ONE
1061 //- channel 0 is controlled by snd_channel0volume; channel 1 and -1 by
1062 //  snd_channel1volume, etc. (so, a channel shares the cvar with its respective
1063 //  auto-channel); however, the mod MUST define snd_channel8volume and upwards
1064 //  in default.cfg if they are to be used, as the engine does not create them
1065 //  to not litter the cvar list
1066 //- this extension applies to CSQC as well; CSQC_Event_Sound will get speed and
1067 //  flags as extra 7th and 8th argument
1068 //- WIP2 ideas: SOUNDFLAG_RELIABLE_TO_ONE, SOUNDFLAG_NOPHS, SOUNDFLAG_FORCELOOP
1069 //- NOTE: to check for this, ALSO OR a check with DP_SND_SOUND7 to also support
1070 //  the finished extension once done
1071
1072 //DP_MOVETYPEFLYWORLDONLY
1073 //idea: Samual
1074 //darkplaces implementation: Samual
1075 //movetype definitions:
1076 float MOVETYPE_FLY_WORLDONLY = 33;
1077 //description:
1078 //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.
1079
1080 //DP_PRECACHE_PIC_FLAGS
1081 //idea: divVerent
1082 //darkplaces implementation: divVerent
1083 //constant definitions:
1084 float PRECACHE_PIC_FROMWAD = 1; // this one actually is part of EXT_CSQC
1085 float PRECACHE_PIC_NOTPERSISTENT = 2; // picture may get deallocated when unused
1086 float PRECACHE_PIC_MIPMAP = 8; // mipmap the texture for possibly better downscaling at memory expense
1087 //notes: these constants are given as optional second argument to precache_pic()
1088
1089 //DP_QC_TRACE_MOVETYPE_WORLDONLY
1090 //idea: LordHavoc
1091 //darkplaces implementation: LordHavoc
1092 //constant definitions:
1093 float MOVE_WORLDONLY = 3;
1094 //description:
1095 //allows traces to hit only world (ignoring all entities, unlike MOVE_NOMONSTERS which hits all bmodels), use as the nomonsters parameter to trace functions
1096
1097 //DP_SND_GETSOUNDTIME
1098 //idea: VorteX
1099 //darkplaces implementation: VorteX
1100 //constant definitions:
1101 float(entity e, float channel) getsoundtime = #533; // get currently sound playing position on entity channel, -1 if not playing or error
1102 float(string sample) soundlength = #534; // returns length of sound sample in seconds, -1 on error (sound not precached, sound system not initialized etc.)
1103 //description: provides opportunity to query length of sound samples and realtime tracking of sound playing on entities (similar to DP_GETTIME_CDTRACK)
1104 //note: beware dedicated server not running sound engine at all, so in dedicated mode this builtins will not work in server progs
1105 //note also: menu progs not supporting getsoundtime() (will give a warning) since it has no sound playing on entities
1106 //examples of use:
1107 //  - QC-driven looped sounds
1108 //  - QC events when sound playing is finished
1109 //  - toggleable ambientsounds
1110 //  - subtitles
1111
1112 //DP_QC_NUM_FOR_EDICT
1113 //idea: Blub\0
1114 //darkplaces implementation: Blub\0
1115 //Function to get the number of an entity - a clean way.
1116 float(entity num) num_for_edict = #512;
1117
1118 //DP_TRACE_HITCONTENTSMASK_SURFACEINFO
1119 //idea: LordHavoc
1120 //darkplaces implementation: LordHavoc
1121 //globals:
1122 .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
1123 float trace_dpstartcontents; // DPCONTENTS_ value at start position of trace
1124 float trace_dphitcontents; // DPCONTENTS_ value of impacted surface (not contents at impact point, just contents of the surface that was hit)
1125 float trace_dphitq3surfaceflags; // Q3SURFACEFLAG_ value of impacted surface
1126 string trace_dphittexturename; // texture name of impacted surface
1127 //constants:
1128 float DPCONTENTS_SOLID = 1; // hit a bmodel, not a bounding box
1129 float DPCONTENTS_WATER = 2;
1130 float DPCONTENTS_SLIME = 4;
1131 float DPCONTENTS_LAVA = 8;
1132 float DPCONTENTS_SKY = 16;
1133 float DPCONTENTS_BODY = 32; // hit a bounding box, not a bmodel
1134 float DPCONTENTS_CORPSE = 64; // hit a SOLID_CORPSE entity
1135 float DPCONTENTS_NODROP = 128; // an area where backpacks should not spawn
1136 float DPCONTENTS_PLAYERCLIP = 256; // blocks player movement
1137 float DPCONTENTS_MONSTERCLIP = 512; // blocks monster movement
1138 float DPCONTENTS_DONOTENTER = 1024; // AI hint brush
1139 float DPCONTENTS_LIQUIDSMASK = 14; // WATER | SLIME | LAVA
1140 float DPCONTENTS_BOTCLIP = 2048; // AI hint brush
1141 float DPCONTENTS_OPAQUE = 4096; // only fully opaque brushes get this (may be useful for line of sight checks)
1142 float Q3SURFACEFLAG_NODAMAGE = 1;
1143 float Q3SURFACEFLAG_SLICK = 2; // low friction surface
1144 float Q3SURFACEFLAG_SKY = 4; // sky surface (also has NOIMPACT and NOMARKS set)
1145 float Q3SURFACEFLAG_LADDER = 8; // climbable surface
1146 float Q3SURFACEFLAG_NOIMPACT = 16; // projectiles should remove themselves on impact (this is set on sky)
1147 float Q3SURFACEFLAG_NOMARKS = 32; // projectiles should not leave marks, such as decals (this is set on sky)
1148 float Q3SURFACEFLAG_FLESH = 64; // projectiles should do a fleshy effect (blood?) on impact
1149 float Q3SURFACEFLAG_NODRAW = 128; // compiler hint (not important to qc)
1150 //float Q3SURFACEFLAG_HINT = 256; // compiler hint (not important to qc)
1151 //float Q3SURFACEFLAG_SKIP = 512; // compiler hint (not important to qc)
1152 //float Q3SURFACEFLAG_NOLIGHTMAP = 1024; // compiler hint (not important to qc)
1153 //float Q3SURFACEFLAG_POINTLIGHT = 2048; // compiler hint (not important to qc)
1154 float Q3SURFACEFLAG_METALSTEPS = 4096; // walking on this surface should make metal step sounds
1155 float Q3SURFACEFLAG_NOSTEPS = 8192; // walking on this surface should not make footstep sounds
1156 float Q3SURFACEFLAG_NONSOLID = 16384; // compiler hint (not important to qc)
1157 //float Q3SURFACEFLAG_LIGHTFILTER = 32768; // compiler hint (not important to qc)
1158 //float Q3SURFACEFLAG_ALPHASHADOW = 65536; // compiler hint (not important to qc)
1159 //float Q3SURFACEFLAG_NODLIGHT = 131072; // compiler hint (not important to qc)
1160 //float Q3SURFACEFLAG_DUST = 262144; // translucent 'light beam' effect (not important to qc)
1161 //description:
1162 //adds additional information after a traceline/tracebox/tracetoss call.
1163 //also (very important) sets trace_* globals before calling .touch functions,
1164 //this allows them to inspect the nature of the collision (for example
1165 //determining if a projectile hit sky), clears trace_* variables for the other
1166 //object in a touch event (that is to say, a projectile moving will see the
1167 //trace results in its .touch function, but the player it hit will see very
1168 //little information in the trace_ variables as it was not moving at the time)
1169
1170 //DP_QC_CVAR_TYPE
1171 //idea: divVerent
1172 //DarkPlaces implementation: divVerent
1173 //builtin definitions:
1174 float(string name) cvar_type = #495;
1175 float CVAR_TYPEFLAG_EXISTS = 1;
1176 float CVAR_TYPEFLAG_SAVED = 2;
1177 float CVAR_TYPEFLAG_PRIVATE = 4;
1178 float CVAR_TYPEFLAG_ENGINE = 8;
1179 float CVAR_TYPEFLAG_HASDESCRIPTION = 16;
1180 float CVAR_TYPEFLAG_READONLY = 32;
1181
1182 //DP_QC_CRC16
1183 //idea: divVerent
1184 //darkplaces implementation: divVerent
1185 //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.
1186 //When caseinsensitive is set, the CRC is calculated of the lower cased string.
1187 float(float caseinsensitive, string s, ...) crc16 = #494;
1188
1189 //DP_QC_URI_ESCAPE
1190 //idea: divVerent
1191 //darkplaces implementation: divVerent
1192 //URI::Escape's functionality
1193 string(string in) uri_escape = #510;
1194 string(string in) uri_unescape = #511;
1195
1196 //DP_QC_DIGEST
1197 //idea: motorsep, Spike
1198 //DarkPlaces implementation: divVerent
1199 //builtin definitions:
1200 string(string digest, string data, ...) digest_hex = #639;
1201 //description:
1202 //returns a given hex digest of given data
1203 //the returned digest is always encoded in hexadecimal
1204 //only the "MD4" digest is always supported!
1205 //if the given digest is not supported, string_null is returned
1206 //the digest string is matched case sensitively, use "MD4", not "md4"!
1207
1208 //DP_QC_DIGEST_SHA256
1209 //idea: motorsep, Spike
1210 //DarkPlaces implementation: divVerent
1211 //description:
1212 //"SHA256" is also an allowed digest type
1213
1214 //DP_QC_LOG
1215 //darkplaces implementation: divVerent
1216 //builtin definitions:
1217 float log(float f) = #532;
1218 //description:
1219 //logarithm
1220
1221 //FTE_CSQC_SKELETONOBJECTS
1222 //idea: Spike, LordHavoc
1223 //darkplaces implementation: LordHavoc
1224 //builtin definitions:
1225 // all skeleton numbers are 1-based (0 being no skeleton)
1226 // all bone numbers are 1-based (0 being invalid)
1227 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.
1228 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
1229 float(float skel) skel_get_numbones = #265; // returns how many bones exist in the created skeleton, 0 if skeleton does not exist
1230 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
1231 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)
1232 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
1233 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)
1234 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)
1235 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)
1236 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)
1237 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)
1238 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
1239 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)
1240 float(float modlindex, string framename) frameforname = #276; // finds number of a specified frame in the animation, returns -1 if no match found
1241 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.
1242 //fields:
1243 .float skeletonindex; // active skeleton overriding standard animation on model
1244 .float frame; // primary framegroup animation (strength = 1 - lerpfrac - lerpfrac3 - lerpfrac4)
1245 .float frame2; // secondary framegroup animation (strength = lerpfrac)
1246 .float frame3; // tertiary framegroup animation (strength = lerpfrac3)
1247 .float frame4; // quaternary framegroup animation (strength = lerpfrac4)
1248 .float lerpfrac; // strength of framegroup blend
1249 .float lerpfrac3; // strength of framegroup blend
1250 .float lerpfrac4; // strength of framegroup blend
1251 .float frame1time; // start time of framegroup animation
1252 .float frame2time; // start time of framegroup animation
1253 .float frame3time; // start time of framegroup animation
1254 .float frame4time; // start time of framegroup animation
1255 //description:
1256 //this extension provides a way to do complex skeletal animation on an entity.
1257 //
1258 //see also DP_SKELETONOBJECTS (this extension implemented on server as well as client)
1259 //
1260 //notes:
1261 //each model contains its own skeleton, reusing a skeleton with incompatible models will yield garbage (or not render).
1262 //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).
1263 //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.
1264 //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.
1265 //
1266 //features include:
1267 //multiple animations blended together.
1268 //animating a model with animations from another model with a compatible skeleton.
1269 //restricting animation blends to certain bones of a model - for example independent animation of legs, torso, head.
1270 //custom bone controllers - for example making eyes track a target location.
1271 //
1272 //
1273 //
1274 //example code follows...
1275 //
1276 //this helper function lets you identify (by parentage) what group a bone
1277 //belongs to - for example "torso", "leftarm", would return 1 ("torso") for
1278 //all children of the bone named "torso", unless they are children of
1279 //"leftarm" (which is a child of "torso") which would return 2 instead...
1280 float(float skel, float bonenum, string g1, string g2, string g3, string g4, string g5, string g6) example_skel_findbonegroup =
1281 {
1282         local string bonename;
1283         while (bonenum >= 0)
1284         {
1285                 bonename = skel_get_bonename(skel, bonenum);
1286                 if (bonename == g1) return 1;
1287                 if (bonename == g2) return 2;
1288                 if (bonename == g3) return 3;
1289                 if (bonename == g4) return 4;
1290                 if (bonename == g5) return 5;
1291                 if (bonename == g6) return 6;
1292                 bonenum = skel_get_boneparent(skel, bonenum);
1293         }
1294         return 0;
1295 };
1296 // create a skeletonindex for our player using current modelindex
1297 void() example_skel_player_setup =
1298 {
1299         self.skeletonindex = skel_create(self.modelindex);
1300 };
1301 // setup bones of skeleton based on an animation
1302 // note: animmodelindex can be a different model than self.modelindex
1303 void(float animmodelindex, float framegroup, float framegroupstarttime) example_skel_player_update_begin =
1304 {
1305         // start with our standard animation
1306         self.frame = framegroup;
1307         self.frame2 = 0;
1308         self.frame3 = 0;
1309         self.frame4 = 0;
1310         self.frame1time = framegroupstarttime;
1311         self.frame2time = 0;
1312         self.frame3time = 0;
1313         self.frame4time = 0;
1314         self.lerpfrac = 0;
1315         self.lerpfrac3 = 0;
1316         self.lerpfrac4 = 0;
1317         skel_build(self.skeletonindex, self, animmodelindex, 0, 0, 100000);
1318 };
1319 // apply a different framegroup animation to bones with a specified parent
1320 void(float animmodelindex, float framegroup, float framegroupstarttime, float blendalpha, string groupbonename, string excludegroupname1, string excludegroupname2) example_skel_player_update_applyoverride =
1321 {
1322         local float bonenum;
1323         local float numbones;
1324         self.frame = framegroup;
1325         self.frame2 = 0;
1326         self.frame3 = 0;
1327         self.frame4 = 0;
1328         self.frame1time = framegroupstarttime;
1329         self.frame2time = 0;
1330         self.frame3time = 0;
1331         self.frame4time = 0;
1332         self.lerpfrac = 0;
1333         self.lerpfrac3 = 0;
1334         self.lerpfrac4 = 0;
1335         bonenum = 0;
1336         numbones = skel_get_numbones(self.skeletonindex);
1337         while (bonenum < numbones)
1338         {
1339                 if (example_skel_findbonegroup(self.skeletonindex, bonenum, groupbonename, excludegroupname1, excludegroupname2, "", "", "") == 1)
1340                         skel_build(self.skeletonindex, self, animmodelindex, 1 - blendalpha, bonenum, bonenum + 1);
1341                 bonenum = bonenum + 1;
1342         }
1343 };
1344 // make eyes point at a target location, be sure v_forward, v_right, v_up are set correctly before calling
1345 void(vector eyetarget, string bonename) example_skel_player_update_eyetarget =
1346 {
1347         local float bonenum;
1348         local vector ang;
1349         local vector oldforward, oldright, oldup;
1350         local vector relforward, relright, relup, relorg;
1351         local vector boneforward, boneright, boneup, boneorg;
1352         local vector parentforward, parentright, parentup, parentorg;
1353         local vector u, v;
1354         local vector modeleyetarget;
1355         bonenum = skel_find_bone(self.skeletonindex, bonename) - 1;
1356         if (bonenum < 0)
1357                 return;
1358         oldforward = v_forward;
1359         oldright = v_right;
1360         oldup = v_up;
1361         v = eyetarget - self.origin;
1362         modeleyetarget_x =   v * v_forward;
1363         modeleyetarget_y = 0-v * v_right;
1364         modeleyetarget_z =   v * v_up;
1365         // this is an eyeball, make it point at the target location
1366         // first get all the data we can...
1367         relorg = skel_get_bonerel(self.skeletonindex, bonenum);
1368         relforward = v_forward;
1369         relright = v_right;
1370         relup = v_up;
1371         boneorg = skel_get_boneabs(self.skeletonindex, bonenum);
1372         boneforward = v_forward;
1373         boneright = v_right;
1374         boneup = v_up;
1375         parentorg = skel_get_boneabs(self.skeletonindex, skel_get_boneparent(self.skeletonindex, bonenum));
1376         parentforward = v_forward;
1377         parentright = v_right;
1378         parentup = v_up;
1379         // get the vector from the eyeball to the target
1380         u = modeleyetarget - boneorg;
1381         // now transform it inversely by the parent matrix to produce new rel vectors
1382         v_x = u * parentforward;
1383         v_y = u * parentright;
1384         v_z = u * parentup;
1385         ang = vectoangles2(v, relup);
1386         ang_x = 0 - ang_x;
1387         makevectors(ang);
1388         // set the relative bone matrix
1389         skel_set_bone(self.skeletonindex, bonenum, relorg);
1390         // restore caller's v_ vectors
1391         v_forward = oldforward;
1392         v_right = oldright;
1393         v_up = oldup;
1394 };
1395 // delete skeleton when we're done with it
1396 // note: skeleton remains valid until next frame when it is really deleted
1397 void() example_skel_player_delete =
1398 {
1399         skel_delete(self.skeletonindex);
1400         self.skeletonindex = 0;
1401 };
1402 //
1403 // END OF EXAMPLES FOR FTE_CSQC_SKELETONOBJECTS
1404 //
1405
1406 // assorted builtins
1407 const float             STAT_MOVEVARS_TICRATE           = 240;
1408 const float             STAT_MOVEVARS_TIMESCALE         = 241;
1409 const float             STAT_FRAGLIMIT                                  = 235;
1410 const float             STAT_TIMELIMIT                                  = 236;
1411 const float     STAT_MOVEVARS_GRAVITY           = 242;
1412 string(void)                                            ReadPicture = #501;
1413 float PARTICLES_USEALPHA = 1;
1414 float particles_alphamin, particles_alphamax;
1415 float PARTICLES_USECOLOR = 2;
1416 vector particles_colormin, particles_colormax;
1417 void(float effectindex, entity own, vector org_from, vector org_to, vector dir_from, vector dir_to, float countmultiplier, float flags) boxparticles = #502;
1418 float trace_networkentity;
1419 const float RF_FULLBRIGHT       = 256;
1420 const float RF_NOSHADOW = 512;
1421 float RF_DYNAMICMODELLIGHT = 8192;
1422
1423 float gettaginfo_parent;
1424 string gettaginfo_name;
1425 vector gettaginfo_offset;
1426 vector gettaginfo_forward;
1427 vector gettaginfo_right;
1428 vector gettaginfo_up;