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