]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/dpdefs/progsdefs.qc
210ad1b8d68a2967cf386dece0addc2a4db487dd
[xonotic/xonotic-data.pk3dir.git] / qcsrc / dpdefs / progsdefs.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           force_retouch;          // force all entities to touch triggers
20                                                                 // next frame.  this is needed because
21                                                                 // non-moving things don't normally scan
22                                                                 // for triggers, and when a trigger is
23                                                                 // created (like a teleport trigger), it
24                                                                 // needs to catch everything.
25                                                                 // decremented each frame, so set to 2
26                                                                 // to guarantee everything is touched
27 string          mapname;
28
29 float           deathmatch;
30 float           coop;
31 float           teamplay;
32
33 float           serverflags;            // propagated from level to level, used to
34                                                                 // keep track of completed episodes
35
36 float           total_secrets;
37 float           total_monsters;
38
39 float           found_secrets;          // number of secrets found
40 float           killed_monsters;        // number of monsters killed
41
42
43 // spawnparms are used to encode information about clients across server
44 // level changes
45 float           parm1, parm2, parm3, parm4, parm5, parm6, parm7, parm8, parm9, parm10, parm11, parm12, parm13, parm14, parm15, parm16;
46
47 //
48 // global variables set by built in functions
49 //
50 vector          v_forward, v_up, v_right;       // set by makevectors()
51
52 // set by traceline / tracebox
53 float           trace_allsolid;
54 float           trace_startsolid;
55 float           trace_fraction;
56 vector          trace_endpos;
57 vector          trace_plane_normal;
58 float           trace_plane_dist;
59 entity          trace_ent;
60 float           trace_inopen;
61 float           trace_inwater;
62
63 entity          msg_entity;                             // destination of single entity writes
64
65 //
66 // required prog functions
67 //
68 void()          main;                                           // only for testing
69
70 void()          StartFrame;
71
72 void()          PlayerPreThink;
73 void()          PlayerPostThink;
74
75 void()          ClientKill;
76 void()          ClientConnect;
77 void()          PutClientInServer;              // call after setting the parm1... parms
78 void()          ClientDisconnect;
79
80 void()          SetNewParms;                    // called when a client first connects to
81                                                                         // a server. sets parms so they can be
82                                                                         // saved off for restarts
83
84 void()          SetChangeParms;                 // call to set parms for self so they can
85                                                                         // be saved for a level transition
86
87
88 //================================================
89 void            end_sys_globals;                // flag for structure dumping
90 //================================================
91
92 /*
93 ==============================================================================
94
95                         SOURCE FOR ENTVARS_T C STRUCTURE
96                         MUST NOT BE MODIFIED, OR CRC ERRORS WILL APPEAR
97
98 ==============================================================================
99 */
100
101 //
102 // system fields (*** = do not set in prog code, maintained by C code)
103 //
104 .float          modelindex;             // *** model index in the precached list
105 .vector         absmin, absmax; // *** origin + mins / maxs
106
107 .float          ltime;                  // local time for entity
108 .float          movetype;
109 .float          solid;
110
111 .vector         origin;                 // ***
112 .vector         oldorigin;              // ***
113 .vector         velocity;
114 .vector         angles;
115 .vector         avelocity;
116
117 .vector         punchangle;             // temp angle adjust from damage or recoil
118
119 .string         classname;              // spawn function
120 .string         model;
121 .float          frame;
122 .float          skin;
123 .float          effects;
124
125 .vector         mins, maxs;             // bounding box extents reletive to origin
126 .vector         size;                   // maxs - mins
127
128 .void()         touch;
129 .void()         use;
130 .void()         think;
131 .void()         blocked;                // for doors or plats, called when can't push other
132
133 .float          nextthink;
134 .entity         groundentity;
135
136 // stats
137 .float          health;
138 .float          frags;
139 .float          weapon;                 // one of the IT_SHOTGUN, etc flags
140 .string         weaponmodel;
141 .float          weaponframe;
142 .float          currentammo;
143 .float          ammo_shells, ammo_nails, ammo_rockets, ammo_cells;
144
145 .float          items;                  // bit flags
146
147 .float          takedamage;
148 .entity         chain;
149 .float          deadflag;
150
151 .vector         view_ofs;                       // add to origin to get eye point
152
153
154 .float          button0;                // fire
155 .float          button1;                // use
156 .float          button2;                // jump
157
158 .float          impulse;                // weapon changes
159
160 .float          fixangle;
161 .vector         v_angle;                // view / targeting angle for players
162 .float          idealpitch;             // calculated pitch angle for lookup up slopes
163
164
165 .string         netname;
166
167 .entity         enemy;
168
169 .float          flags;
170
171 .float          colormap;
172 .float          team;
173
174 .float          max_health;             // players maximum health is stored here
175
176 .float          teleport_time;  // don't back up
177
178 .float          armortype;              // save this fraction of incoming damage
179 .float          armorvalue;
180
181 .float          waterlevel;             // 0 = not in, 1 = feet, 2 = wast, 3 = eyes
182 .float          watertype;              // a contents value
183
184 .float          ideal_yaw;
185 .float          yaw_speed;
186
187 .entity         aiment;
188
189 .entity         goalentity;             // a movetarget or an enemy
190
191 .float          spawnflags;
192
193 .string         target;
194 .string         targetname;
195
196 // damage is accumulated through a frame. and sent as one single
197 // message, so the super shotgun doesn't generate huge messages
198 .float          dmg_take;
199 .float          dmg_save;
200 .entity         dmg_inflictor;
201
202 .entity         owner;          // who launched a missile
203 .vector         movedir;        // mostly for doors, but also used for waterjump
204
205 .string         message;                // trigger messages
206
207 .float          sounds;         // either a cd track number or sound number
208
209 .string         noise, noise1, noise2, noise3;  // contains names of wavs to play
210
211 //================================================
212 void            end_sys_fields;                 // flag for structure dumping
213 //================================================
214
215 /*
216 ==============================================================================
217
218                                 CONSTANT DEFINITIONS
219
220 ==============================================================================
221 */
222
223
224 //
225 // constants
226 //
227
228 // edict.flags
229 const int FL_FLY                                = 1;
230 const int FL_SWIM                               = 2;
231 const int FL_CLIENT                             = 8;    // set for all client edicts
232 const int FL_INWATER                    = 16;   // for enter / leave water splash
233 const int FL_MONSTER                    = 32;
234 const int FL_GODMODE                    = 64;   // player cheat
235 const int FL_NOTARGET                   = 128;  // player cheat
236 const int FL_ITEM                               = 256;  // extra wide size for bonus items
237 const int FL_ONGROUND                   = 512;  // standing on something
238 const int FL_PARTIALGROUND              = 1024; // not all corners are valid
239 const int FL_WATERJUMP                  = 2048; // player jumping out of water
240 const int FL_JUMPRELEASED               = 4096; // for jump debouncing
241
242 // edict.movetype values
243 const int MOVETYPE_NONE                 = 0;    // never moves
244 //const int     MOVETYPE_ANGLENOCLIP= 1;
245 //const int     MOVETYPE_ANGLECLIP      = 2;
246 const int MOVETYPE_WALK                 = 3;    // players only
247 const int MOVETYPE_STEP                 = 4;    // discrete, not real time unless fall
248 const int MOVETYPE_FLY                  = 5;
249 const int MOVETYPE_TOSS                 = 6;    // gravity
250 const int MOVETYPE_PUSH                 = 7;    // no clip to world, push and crush
251 const int MOVETYPE_NOCLIP               = 8;
252 const int MOVETYPE_FLYMISSILE   = 9;    // fly with extra size against monsters
253 const int MOVETYPE_BOUNCE               = 10;
254 const int MOVETYPE_BOUNCEMISSILE= 11;   // bounce with extra size
255
256 // edict.solid values
257 const int SOLID_NOT                             = 0;    // no interaction with other objects
258 const int SOLID_TRIGGER                 = 1;    // touch on edge, but not blocking
259 const int SOLID_BBOX                    = 2;    // touch on edge, block
260 const int SOLID_SLIDEBOX                = 3;    // touch on edge, but not an onground
261 const int SOLID_BSP                             = 4;    // bsp clip, touch on edge, block
262
263 // range values
264 const int RANGE_MELEE                   = 0;
265 const int RANGE_NEAR                    = 1;
266 const int RANGE_MID                             = 2;
267 const int RANGE_FAR                             = 3;
268
269 // deadflag values
270
271 const int DEAD_NO                               = 0;
272 const int DEAD_DYING                    = 1;
273 const int DEAD_DEAD                             = 2;
274 const int DEAD_RESPAWNABLE              = 3;
275 const int DEAD_RESPAWNING               = 4; // dead, waiting for buttons to be released
276
277 // takedamage values
278
279 const int DAMAGE_NO                             = 0;
280 const int DAMAGE_YES                    = 1;
281 const int DAMAGE_AIM                    = 2;
282
283 // items
284 const int IT_AXE                                = 4096;
285 const int IT_SHOTGUN                    = 1;
286 const int IT_SUPER_SHOTGUN              = 2;
287 const int IT_NAILGUN                    = 4;
288 const int IT_SUPER_NAILGUN              = 8;
289 const int IT_GRENADE_LAUNCHER   = 16;
290 const int IT_ROCKET_LAUNCHER    = 32;
291 const int IT_LIGHTNING                  = 64;
292 const int IT_EXTRA_WEAPON               = 128;
293
294 //const int IT_SHELLS                   = 256;
295 //const int IT_NAILS                    = 512;
296 //const int IT_ROCKETS                  = 1024;
297 //const int IT_CELLS                    = 2048;
298
299 const int IT_ARMOR1                             = 8192;
300 const int IT_ARMOR2                             = 16384;
301 const int IT_ARMOR3                             = 32768;
302 const int IT_SUPERHEALTH                = 65536;
303
304 //const int IT_KEY1                             = 131072;
305 //const int IT_KEY2                             = 262144;
306
307 const int IT_INVISIBILITY               = 524288;
308 const int IT_INVULNERABILITY    = 1048576;
309 const int IT_SUIT                               = 2097152;
310 const int IT_QUAD                               = 4194304;
311
312 // point content values
313
314 const int CONTENT_EMPTY                 = -1;
315 const int CONTENT_SOLID                 = -2;
316 const int CONTENT_WATER                 = -3;
317 const int CONTENT_SLIME                 = -4;
318 const int CONTENT_LAVA                  = -5;
319 const int CONTENT_SKY                   = -6;
320
321 const int STATE_TOP                             = 0;
322 const int STATE_BOTTOM                  = 1;
323 const int STATE_UP                              = 2;
324 const int STATE_DOWN                    = 3;
325
326 const vector VEC_ORIGIN                 = '0 0 0';
327 const vector VEC_HULL_MIN               = '-16 -16 -24';
328 const vector VEC_HULL_MAX               = '16 16 32';
329
330 const vector VEC_HULL2_MIN              = '-32 -32 -24';
331 const vector VEC_HULL2_MAX              = '32 32 64';
332
333 // protocol bytes
334 const int SVC_TEMPENTITY                = 23;
335 const int SVC_KILLEDMONSTER             = 27;
336 const int SVC_FOUNDSECRET               = 28;
337 const int SVC_INTERMISSION              = 30;
338 const int SVC_FINALE                    = 31;
339 const int SVC_CDTRACK                   = 32;
340 const int SVC_SELLSCREEN                = 33;
341
342
343 const int TE_SPIKE                              = 0;
344 const int TE_SUPERSPIKE                 = 1;
345 const int TE_GUNSHOT                    = 2;
346 const int TE_EXPLOSION                  = 3;
347 const int TE_TAREXPLOSION               = 4;
348 const int TE_LIGHTNING1                 = 5;
349 const int TE_LIGHTNING2                 = 6;
350 const int TE_WIZSPIKE                   = 7;
351 const int TE_KNIGHTSPIKE                = 8;
352 const int TE_LIGHTNING3                 = 9;
353 const int TE_LAVASPLASH                 = 10;
354 const int TE_TELEPORT                   = 11;
355
356 // sound channels
357 // channel 0 never willingly overrides
358 // other channels (1-7) allways override a playing sound on that channel
359 const int CHAN_AUTO                             = 0;
360 const int CHAN_WEAPON                   = 1;
361 const int CHAN_VOICE                    = 2;
362 const int CHAN_ITEM                             = 3;
363 const int CHAN_BODY                             = 4;
364
365 const int ATTN_NONE                             = 0;
366 const int ATTN_NORM                             = 1;
367 const int ATTN_IDLE                             = 2;
368 const int ATTN_STATIC                   = 3;
369
370 // update types
371
372 const int UPDATE_GENERAL                = 0;
373 const int UPDATE_STATIC                 = 1;
374 const int UPDATE_BINARY                 = 2;
375 const int UPDATE_TEMP                   = 3;
376
377 // entity effects
378
379 const int EF_BRIGHTFIELD                = 1;
380 const int EF_MUZZLEFLASH                = 2;
381 const int EF_BRIGHTLIGHT                = 4;
382 const int EF_DIMLIGHT                   = 8;
383
384
385 // messages
386 const int MSG_BROADCAST                 = 0;            // unreliable to all
387 const int MSG_ONE                               = 1;            // reliable to one (msg_entity)
388 const int MSG_ALL                               = 2;            // reliable to all
389 const int MSG_INIT                              = 3;            // write to the init string
390
391 //===========================================================================
392
393 //
394 // builtin functions
395 //
396
397 void(vector ang)        makevectors             = #1;           // sets v_forward, etc globals
398 void(entity e, vector o) setorigin      = #2;
399 void(entity e, string m) setmodel       = #3;           // set movetype and solid first
400 void(entity e, vector min, vector max) setsize = #4;
401 // #5 was removed
402 void() break_to_debugger                                                = #6;
403 float() random                                          = #7;           // returns 0 - 1
404 void(entity e, float chan, string samp, float vol, float atten) sound = #8;
405 vector(vector v) normalize                      = #9;
406 void(string e, ...) error                               = #10;
407 void(string e, ...) objerror                            = #11;
408 float(vector v) vlen                            = #12;
409 float(vector v) vectoyaw                        = #13;
410 entity() spawn                                          = #14;
411 void(entity e) remove                           = #15;
412
413 // sets trace_* globals
414 // nomonsters can be:
415 // An entity will also be ignored for testing if forent == test,
416 // forent->owner == test, or test->owner == forent
417 // a forent of world is ignored
418 void(vector v1, vector v2, float nomonsters, entity forent) traceline = #16;
419
420 entity() checkclient                            = #17;  // returns a client to look for
421 entity(entity start, .string fld, string match) find = #18;
422 string(string s) precache_sound         = #19;
423 string(string s) precache_model         = #20;
424 void(entity client, string s, ...)stuffcmd = #21;
425 entity(vector org, float rad) findradius = #22;
426 void(string s, ...) bprint                              = #23;
427 void(entity client, string s, ...) sprint = #24;
428 void(string s, ...) dprint                              = #25;
429 string(float f) ftos                            = #26;
430 string(vector v) vtos                           = #27;
431 void() coredump                                         = #28;          // prints all edicts
432 void() traceon                                          = #29;          // turns statment trace on
433 void() traceoff                                         = #30;
434 void(entity e) eprint                           = #31;          // prints an entire edict
435 float(float yaw, float dist) walkmove   = #32;  // returns true or false
436 // #33 was removed
437 float() droptofloor= #34;       // true if landed on floor
438 void(float style, string value) lightstyle = #35;
439 float(float v) rint                                     = #36;          // round to nearest int
440 float(float v) floor                            = #37;          // largest integer <= v
441 float(float v) ceil                                     = #38;          // smallest integer >= v
442 // #39 was removed
443 float(entity e) checkbottom                     = #40;          // true if self is on ground
444 float(vector v) pointcontents           = #41;          // returns a CONTENT_*
445 // #42 was removed
446 float(float f) fabs = #43;
447 vector(entity e, float speed) aim = #44;                // returns the shooting vector
448 float(string s) cvar = #45;                                             // return cvar.value
449 void(string s, ...) localcmd = #46;                                     // put string into local que
450 entity(entity e) nextent = #47;                                 // for looping through all ents
451 void(vector o, vector d, float color, float count) particle = #48;// start a particle effect
452 void() ChangeYaw = #49;                                         // turn towards self.ideal_yaw
453                                                                                         // at self.yaw_speed
454 // #50 was removed
455 vector(vector v) vectoangles                    = #51;
456
457 //
458 // direct client message generation
459 //
460 void(float to, float f) WriteByte               = #52;
461 void(float to, float f) WriteChar               = #53;
462 void(float to, float f) WriteShort              = #54;
463 void(float to, float f) WriteLong               = #55;
464 void(float to, float f) WriteCoord              = #56;
465 void(float to, float f) WriteAngle              = #57;
466 void(float to, string s, ...) WriteString       = #58;
467 void(float to, entity s) WriteEntity    = #59;
468
469 //
470 // broadcast client message generation
471 //
472
473 // void(float f) bWriteByte             = #59;
474 // void(float f) bWriteChar             = #60;
475 // void(float f) bWriteShort            = #61;
476 // void(float f) bWriteLong             = #62;
477 // void(float f) bWriteCoord            = #63;
478 // void(float f) bWriteAngle            = #64;
479 // void(string s) bWriteString  = #65;
480 // void(entity e) bWriteEntity = #66;
481
482 void(float step) movetogoal                             = #67;
483
484 string(string s) precache_file          = #68;  // no effect except for -copy
485 void(entity e) makestatic               = #69;
486 void(string s) changelevel = #70;
487
488 //#71 was removed
489
490 void(string name, string value) cvar_set = #72; // sets cvar.value
491
492 void(entity client, string s, ...) centerprint = #73;   // sprint, but in middle
493
494 void(vector pos, string samp, float vol, float atten) ambientsound = #74;
495
496 string(string s) precache_model2        = #75;          // registered version only
497 string(string s) precache_sound2        = #76;          // registered version only
498 string(string s) precache_file2         = #77;          // registered version only
499
500 void(entity e) setspawnparms            = #78;          // set parm1... to the
501                                                                                                 // values at level start
502                                                                                                 // for coop respawn
503
504 //============================================================================