1
2/*
3==============================================================================
4
5			SOURCE FOR GLOBALVARS_T C STRUCTURE
6
7==============================================================================
8*/
9
10//
11// system globals
12//
13entity          self;
14entity          other;
15entity          world;
16float           time;
17float           frametime;
18
19entity          newmis;                         // if this is set, the entity that just
20								// run created a new missile that should
21								// be simulated immediately
22
23
24float           force_retouch;          // force all entities to touch triggers
25								// next frame.  this is needed because
26								// non-moving things don't normally scan
27								// for triggers, and when a trigger is
28								// created (like a teleport trigger), it
29								// needs to catch everything.
30								// decremented each frame, so set to 2
31								// to guarantee everything is touched
32string          mapname;
33
34float           serverflags;            // propagated from level to level, used to
35								// keep track of completed episodes
36
37float           total_secrets;
38float           total_monsters;
39
40float           found_secrets;          // number of secrets found
41float           killed_monsters;        // number of monsters killed
42
43
44// spawnparms are used to encode information about clients across server
45// level changes
46float           parm1, parm2, parm3, parm4, parm5, parm6, parm7, parm8, parm9, parm10, parm11, parm12, parm13, parm14, parm15, parm16;
47
48//
49// global variables set by built in functions
50//
51vector          v_forward, v_up, v_right;       // set by makevectors()
52
53// set by traceline / tracebox
54float           trace_allsolid;
55float           trace_startsolid;
56float           trace_fraction;
57vector          trace_endpos;
58vector          trace_plane_normal;
59float           trace_plane_dist;
60entity          trace_ent;
61float           trace_inopen;
62float           trace_inwater;
63
64entity          msg_entity;                             // destination of single entity writes
65
66//
67// required prog functions
68//
69void()          main;                                           // only for testing
70
71void()          StartFrame;
72
73void()          PlayerPreThink;
74void()          PlayerPostThink;
75
76void()          ClientKill;
77void()          ClientConnect;
78void()          PutClientInServer;              // call after setting the parm1... parms
79void()          ClientDisconnect;
80
81void()          SetNewParms;                    // called when a client first connects to
82									// a server. sets parms so they can be
83									// saved off for restarts
84
85void()          SetChangeParms;                 // call to set parms for self so they can
86									// be saved for a level transition
87
88
89//================================================
90void            end_sys_globals;                // flag for structure dumping
91//================================================
92
93/*
94==============================================================================
95
96			SOURCE FOR ENTVARS_T C STRUCTURE
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          lastruntime;    // *** to allow entities to run out of sequence
109
110.float          movetype;
111.float          solid;
112
113.vector         origin;                 // ***
114.vector         oldorigin;              // ***
115.vector         velocity;
116.vector         angles;
117.vector         avelocity;
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
137
138// stats
139.float          health;
140.float          frags;
141.float          weapon;                 // one of the IT_SHOTGUN, etc flags
142.string         weaponmodel;
143.float          weaponframe;
144.float          currentammo;
145.float          ammo_shells, ammo_nails, ammo_rockets, ammo_cells;
146
147.float          items;                  // bit flags
148
149.float          takedamage;
150.entity         chain;
151.float          deadflag;
152
153.vector         view_ofs;                       // add to origin to get eye point
154
155
156.float          button0;                // fire
157.float          button1;                // use
158.float          button2;                // jump
159
160.float          impulse;                // weapon changes
161
162.float          fixangle;
163.vector         v_angle;                // view / targeting angle for players
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//================================================
212void            end_sys_fields;                 // flag for structure dumping
213//================================================
214
215/*
216==============================================================================
217
218				VARS NOT REFERENCED BY C CODE
219
220==============================================================================
221*/
222
223
224//
225// constants
226//
227
228float   FALSE                                   = 0;
229float   TRUE                                    = 1;
230
231// edict.flags
232float   FL_FLY                                  = 1;
233float   FL_SWIM                                 = 2;
234float   FL_CLIENT                               = 8;    // set for all client edicts
235float   FL_INWATER                              = 16;   // for enter / leave water splash
236float   FL_MONSTER                              = 32;
237float   FL_GODMODE                              = 64;   // player cheat
238float   FL_NOTARGET                             = 128;  // player cheat
239float   FL_ITEM                                 = 256;  // extra wide size for bonus items
240float   FL_ONGROUND                             = 512;  // standing on something
241float   FL_PARTIALGROUND                = 1024; // not all corners are valid
242float   FL_WATERJUMP                    = 2048; // player jumping out of water
243float   FL_JUMPRELEASED                 = 4096; // for jump debouncing
244
245// edict.movetype values
246float   MOVETYPE_NONE                   = 0;    // never moves
247//float MOVETYPE_ANGLENOCLIP    = 1;
248//float MOVETYPE_ANGLECLIP              = 2;
249float   MOVETYPE_WALK                   = 3;    // players only
250float   MOVETYPE_STEP                   = 4;    // discrete, not real time unless fall
251float   MOVETYPE_FLY                    = 5;
252float   MOVETYPE_TOSS                   = 6;    // gravity
253float   MOVETYPE_PUSH                   = 7;    // no clip to world, push and crush
254float   MOVETYPE_NOCLIP                 = 8;
255float   MOVETYPE_FLYMISSILE             = 9;    // fly with extra size against monsters
256float   MOVETYPE_BOUNCE                 = 10;
257float   MOVETYPE_BOUNCEMISSILE  = 11;   // bounce with extra size
258
259// edict.solid values
260float   SOLID_NOT                               = 0;    // no interaction with other objects
261float   SOLID_TRIGGER                   = 1;    // touch on edge, but not blocking
262float   SOLID_BBOX                              = 2;    // touch on edge, block
263float   SOLID_SLIDEBOX                  = 3;    // touch on edge, but not an onground
264float   SOLID_BSP                               = 4;    // bsp clip, touch on edge, block
265
266// range values
267float   RANGE_MELEE                             = 0;
268float   RANGE_NEAR                              = 1;
269float   RANGE_MID                               = 2;
270float   RANGE_FAR                               = 3;
271
272// deadflag values
273
274float   DEAD_NO                                 = 0;
275float   DEAD_DYING                              = 1;
276float   DEAD_DEAD                               = 2;
277float   DEAD_RESPAWNABLE                = 3;
278
279// takedamage values
280
281float   DAMAGE_NO                               = 0;
282float   DAMAGE_YES                              = 1;
283float   DAMAGE_AIM                              = 2;
284
285// items
286float   IT_AXE                                  = 4096;
287float   IT_SHOTGUN                              = 1;
288float   IT_SUPER_SHOTGUN                = 2;
289float   IT_NAILGUN                              = 4;
290float   IT_SUPER_NAILGUN                = 8;
291float   IT_GRENADE_LAUNCHER             = 16;
292float   IT_ROCKET_LAUNCHER              = 32;
293float   IT_LIGHTNING                    = 64;
294float   IT_EXTRA_WEAPON                 = 128;
295
296float   IT_SHELLS                               = 256;
297float   IT_NAILS                                = 512;
298float   IT_ROCKETS                              = 1024;
299float   IT_CELLS                                = 2048;
300
301float   IT_ARMOR1                               = 8192;
302float   IT_ARMOR2                               = 16384;
303float   IT_ARMOR3                               = 32768;
304float   IT_SUPERHEALTH                  = 65536;
305
306float   IT_KEY1                                 = 131072;
307float   IT_KEY2                                 = 262144;
308
309float   IT_INVISIBILITY                 = 524288;
310float   IT_INVULNERABILITY              = 1048576;
311float   IT_SUIT                                 = 2097152;
312float   IT_QUAD                                 = 4194304;
313
314// point content values
315
316float   CONTENT_EMPTY                   = -1;
317float   CONTENT_SOLID                   = -2;
318float   CONTENT_WATER                   = -3;
319float   CONTENT_SLIME                   = -4;
320float   CONTENT_LAVA                    = -5;
321float   CONTENT_SKY                             = -6;
322
323float   STATE_TOP               = 0;
324float   STATE_BOTTOM    = 1;
325float   STATE_UP                = 2;
326float   STATE_DOWN              = 3;
327
328vector  VEC_ORIGIN = '0 0 0';
329vector  VEC_HULL_MIN = '-16 -16 -24';
330vector  VEC_HULL_MAX = '16 16 32';
331
332vector  VEC_HULL2_MIN = '-32 -32 -24';
333vector  VEC_HULL2_MAX = '32 32 64';
334
335// protocol bytes
336float   SVC_TEMPENTITY          = 23;
337float   SVC_KILLEDMONSTER       = 27;
338float   SVC_FOUNDSECRET         = 28;
339float   SVC_INTERMISSION        = 30;
340float   SVC_FINALE                      = 31;
341float   SVC_CDTRACK                     = 32;
342float   SVC_SELLSCREEN          = 33;
343float   SVC_SMALLKICK           = 34;
344float   SVC_BIGKICK                     = 35;
345float   SVC_MUZZLEFLASH         = 39;
346
347
348float   TE_SPIKE                = 0;
349float   TE_SUPERSPIKE   = 1;
350float   TE_GUNSHOT              = 2;
351float   TE_EXPLOSION    = 3;
352float   TE_TAREXPLOSION = 4;
353float   TE_LIGHTNING1   = 5;
354float   TE_LIGHTNING2   = 6;
355float   TE_WIZSPIKE             = 7;
356float   TE_KNIGHTSPIKE  = 8;
357float   TE_LIGHTNING3   = 9;
358float   TE_LAVASPLASH   = 10;
359float   TE_TELEPORT             = 11;
360float   TE_BLOOD                = 12;
361float   TE_LIGHTNINGBLOOD = 13;
362
363// sound channels
364// channel 0 never willingly overrides
365// other channels (1-7) allways override a playing sound on that channel
366float   CHAN_AUTO               = 0;
367float   CHAN_WEAPON             = 1;
368float   CHAN_VOICE              = 2;
369float   CHAN_ITEM               = 3;
370float   CHAN_BODY               = 4;
371float   CHAN_NO_PHS_ADD = 8;    // ie: CHAN_BODY+CHAN_NO_PHS_ADD
372
373float   ATTN_NONE               = 0;
374float   ATTN_NORM               = 1;
375float   ATTN_IDLE               = 2;
376float   ATTN_STATIC             = 3;
377
378// update types
379
380float   UPDATE_GENERAL  = 0;
381float   UPDATE_STATIC   = 1;
382float   UPDATE_BINARY   = 2;
383float   UPDATE_TEMP             = 3;
384
385// entity effects
386
387//float EF_BRIGHTFIELD  = 1;
388//float EF_MUZZLEFLASH  = 2;
389float   EF_BRIGHTLIGHT  = 4;
390float   EF_DIMLIGHT     = 8;
391float   EF_FLAG1                = 16;
392float   EF_FLAG2                = 32;
393// GLQuakeWorld Stuff
394float 	EF_BLUE		=	64;	// Blue Globe effect for Quad
395float	EF_RED		=	128;	// Red Globe effect for Pentagram
396// messages
397float   MSG_BROADCAST   = 0;            // unreliable to all
398float   MSG_ONE                 = 1;            // reliable to one (msg_entity)
399float   MSG_ALL                 = 2;            // reliable to all
400float   MSG_INIT                = 3;            // write to the init string
401float   MSG_MULTICAST   = 4;            // for multicast() call
402
403// message levels
404float   PRINT_LOW               = 0;            // pickup messages
405float   PRINT_MEDIUM    	= 1;            // death messages
406float   PRINT_HIGH              = 2;            // critical messages
407float   PRINT_CHAT              = 3;            // also goes to chat console
408
409// multicast sets
410float   MULTICAST_ALL   = 0;            // every client
411float   MULTICAST_PHS   = 1;            // within hearing
412float   MULTICAST_PVS   = 2;            // within sight
413float   MULTICAST_ALL_R = 3;            // every client, reliable
414float   MULTICAST_PHS_R = 4;            // within hearing, reliable
415float   MULTICAST_PVS_R = 5;            // within sight, reliable
416
417
418
419
420//================================================
421
422//
423// globals
424//
425float   movedist;
426
427string  string_null;    // null string, nothing should be held here
428float   empty_float;
429
430entity  activator;              // the entity that activated a trigger or brush
431
432entity  damage_attacker;        // set by T_Damage
433entity  damage_inflictor;
434float   framecount;
435
436//
437// cvars checked each frame
438//
439float           teamplay;
440float           timelimit;
441float           fraglimit;
442float           deathmatch;
443float           rj                      =       1;
444
445//================================================
446
447//
448// world fields (FIXME: make globals)
449//
450.string         wad;
451.string         map;
452.float          worldtype;      // 0=medieval 1=metal 2=base
453
454//================================================
455
456.string         killtarget;
457
458//
459// quakeed fields
460//
461.float          light_lev;              // not used by game, but parsed by light util
462.float          style;
463
464
465//
466// monster ai
467//
468.void()         th_stand;
469.void()         th_walk;
470.void()         th_run;
471.void()         th_missile;
472.void()         th_melee;
473.void(entity attacker, float damage)            th_pain;
474.void()         th_die;
475
476.entity         oldenemy;               // mad at this player before taking damage
477
478.float          speed;
479
480.float  lefty;
481
482.float  search_time;
483.float  attack_state;
484
485float   AS_STRAIGHT             = 1;
486float   AS_SLIDING              = 2;
487float   AS_MELEE                = 3;
488float   AS_MISSILE              = 4;
489
490//
491// player only fields
492//
493.float          voided;
494.float          walkframe;
495
496// Zoid Additions
497.float		maxspeed;		// Used to set Maxspeed on a player
498.float		gravity;		// Gravity Multiplier (0 to 1.0)
499
500
501
502.float          attack_finished;
503.float          pain_finished;
504
505.float          invincible_finished;
506.float          invisible_finished;
507.float          super_damage_finished;
508.float          radsuit_finished;
509
510.float          invincible_time, invincible_sound;
511.float          invisible_time, invisible_sound;
512.float          super_time, super_sound;
513.float          rad_time;
514.float          fly_sound;
515
516.float          axhitme;
517
518.float          show_hostile;   // set to time+0.2 whenever a client fires a
519							// weapon or takes damage.  Used to alert
520							// monsters that otherwise would let the player go
521.float          jump_flag;              // player jump flag
522.float          swim_flag;              // player swimming sound flag
523.float          air_finished;   // when time > air_finished, start drowning
524.float          bubble_count;   // keeps track of the number of bubbles
525.string         deathtype;              // keeps track of how the player died
526
527//
528// object stuff
529//
530.string         mdl;
531.vector         mangle;                 // angle at start
532
533.vector         oldorigin;              // only used by secret door
534
535.float          t_length, t_width;
536
537
538//
539// doors, etc
540//
541.vector         dest, dest1, dest2;
542.float          wait;                   // time from firing to restarting
543.float          delay;                  // time from activation to firing
544.entity         trigger_field;  // door's trigger entity
545.string         noise4;
546
547//
548// monsters
549//
550.float          pausetime;
551.entity         movetarget;
552
553
554//
555// doors
556//
557.float          aflag;
558.float          dmg;                    // damage done by door when hit
559
560//
561// misc
562//
563.float          cnt;                    // misc flag
564
565//
566// subs
567//
568.void()         think1;
569.vector         finaldest, finalangle;
570
571//
572// triggers
573//
574.float          count;                  // for counting triggers
575
576
577//
578// plats / doors / buttons
579//
580.float          lip;
581.float          state;
582.vector         pos1, pos2;             // top and bottom positions
583.float          height;
584
585//
586// sounds
587//
588.float          waitmin, waitmax;
589.float          distance;
590.float          volume;
591
592
593
594
595//===========================================================================
596
597
598//
599// builtin functions
600//
601
602void(vector ang)        makevectors             = #1;           // sets v_forward, etc globals
603void(entity e, vector o) setorigin      = #2;
604void(entity e, string m) setmodel       = #3;           // set movetype and solid first
605void(entity e, vector min, vector max) setsize = #4;
606// #5 was removed
607void() break                                            = #6;
608float() random                                          = #7;           // returns 0 - 1
609void(entity e, float chan, string samp, float vol, float atten) sound = #8;
610vector(vector v) normalize                      = #9;
611void(string e) error                            = #10;
612void(string e) objerror                         = #11;
613float(vector v) vlen                            = #12;
614float(vector v) vectoyaw                        = #13;
615entity() spawn                                          = #14;
616void(entity e) remove                           = #15;
617
618// sets trace_* globals
619// nomonsters can be:
620// An entity will also be ignored for testing if forent == test,
621// forent->owner == test, or test->owner == forent
622// a forent of world is ignored
623void(vector v1, vector v2, float nomonsters, entity forent) traceline = #16;
624
625entity() checkclient                            = #17;  // returns a client to look for
626entity(entity start, .string fld, string match) find = #18;
627string(string s) precache_sound         = #19;
628string(string s) precache_model         = #20;
629void(entity client, string s)stuffcmd = #21;
630entity(vector org, float rad) findradius = #22;
631void(float level, string s) bprint                              = #23;
632void(entity client, float level, string s) sprint = #24;
633void(string s) dprint                           = #25;
634string(float f) ftos                            = #26;
635string(vector v) vtos                           = #27;
636void() coredump                                         = #28;          // prints all edicts
637void() traceon                                          = #29;          // turns statment trace on
638void() traceoff                                         = #30;
639void(entity e) eprint                           = #31;          // prints an entire edict
640float(float yaw, float dist) walkmove   = #32;  // returns TRUE or FALSE
641// #33 was removed
642float(float yaw, float dist) droptofloor= #34;  // TRUE if landed on floor
643void(float style, string value) lightstyle = #35;
644float(float v) rint                                     = #36;          // round to nearest int
645float(float v) floor                            = #37;          // largest integer <= v
646float(float v) ceil                                     = #38;          // smallest integer >= v
647// #39 was removed
648float(entity e) checkbottom                     = #40;          // true if self is on ground
649float(vector v) pointcontents           = #41;          // returns a CONTENT_*
650// #42 was removed
651float(float f) fabs = #43;
652vector(entity e, float speed) aim = #44;                // returns the shooting vector
653float(string s) cvar = #45;                                             // return cvar.value
654void(string s) localcmd = #46;                                  // put string into local que
655entity(entity e) nextent = #47;                                 // for looping through all ents
656// #48 was removed
657void() ChangeYaw = #49;                                         // turn towards self.ideal_yaw
658											// at self.yaw_speed
659// #50 was removed
660vector(vector v) vectoangles                    = #51;
661
662//
663// direct client message generation
664//
665void(float to, float f) WriteByte               = #52;
666void(float to, float f) WriteChar               = #53;
667void(float to, float f) WriteShort              = #54;
668void(float to, float f) WriteLong               = #55;
669void(float to, float f) WriteCoord              = #56;
670void(float to, float f) WriteAngle              = #57;
671void(float to, string s) WriteString    = #58;
672void(float to, entity s) WriteEntity    = #59;
673
674// several removed
675
676void(float step) movetogoal                             = #67;
677
678string(string s) precache_file          = #68;  // no effect except for -copy
679void(entity e) makestatic               = #69;
680void(string s) changelevel = #70;
681
682//#71 was removed
683
684void(string var, string val) cvar_set = #72;    // sets cvar.value
685
686void(entity client, string s) centerprint = #73;        // sprint, but in middle
687
688void(vector pos, string samp, float vol, float atten) ambientsound = #74;
689
690string(string s) precache_model2        = #75;          // registered version only
691string(string s) precache_sound2        = #76;          // registered version only
692string(string s) precache_file2         = #77;          // registered version only
693
694void(entity e) setspawnparms            = #78;          // set parm1... to the
695												// values at level start
696												// for coop respawn
697void(entity killer, entity killee) logfrag = #79;       // add to stats
698
699string(entity e, string key) infokey    = #80;  // get a key value (world = serverinfo)
700float(string s) stof                            = #81;          // convert string to float
701void(vector where, float set) multicast = #82;  // sends the temp message to a set
702												// of clients, possibly in PVS or PHS
703
704//============================================================================
705
706//
707// subs.qc
708//
709void(vector tdest, float tspeed, void() func) SUB_CalcMove;
710void(entity ent, vector tdest, float tspeed, void() func) SUB_CalcMoveEnt;
711void(vector destangle, float tspeed, void() func) SUB_CalcAngleMove;
712void()  SUB_CalcMoveDone;
713void() SUB_CalcAngleMoveDone;
714void() SUB_Null;
715void() SUB_UseTargets;
716void() SUB_Remove;
717
718//
719//      combat.qc
720//
721void(entity targ, entity inflictor, entity attacker, float damage) T_Damage;
722
723
724float (entity e, float healamount, float ignore) T_Heal; // health function
725
726float(entity targ, entity inflictor) CanDamage;
727
728
729