defs.qc 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729
  1. /*
  2. ==============================================================================
  3. SOURCE FOR GLOBALVARS_T C STRUCTURE
  4. ==============================================================================
  5. */
  6. //
  7. // system globals
  8. //
  9. entity self;
  10. entity other;
  11. entity world;
  12. float time;
  13. float frametime;
  14. entity newmis; // if this is set, the entity that just
  15. // run created a new missile that should
  16. // be simulated immediately
  17. float force_retouch; // force all entities to touch triggers
  18. // next frame. this is needed because
  19. // non-moving things don't normally scan
  20. // for triggers, and when a trigger is
  21. // created (like a teleport trigger), it
  22. // needs to catch everything.
  23. // decremented each frame, so set to 2
  24. // to guarantee everything is touched
  25. string mapname;
  26. float serverflags; // propagated from level to level, used to
  27. // keep track of completed episodes
  28. float total_secrets;
  29. float total_monsters;
  30. float found_secrets; // number of secrets found
  31. float killed_monsters; // number of monsters killed
  32. // spawnparms are used to encode information about clients across server
  33. // level changes
  34. float parm1, parm2, parm3, parm4, parm5, parm6, parm7, parm8, parm9, parm10, parm11, parm12, parm13, parm14, parm15, parm16;
  35. //
  36. // global variables set by built in functions
  37. //
  38. vector v_forward, v_up, v_right; // set by makevectors()
  39. // set by traceline / tracebox
  40. float trace_allsolid;
  41. float trace_startsolid;
  42. float trace_fraction;
  43. vector trace_endpos;
  44. vector trace_plane_normal;
  45. float trace_plane_dist;
  46. entity trace_ent;
  47. float trace_inopen;
  48. float trace_inwater;
  49. entity msg_entity; // destination of single entity writes
  50. //
  51. // required prog functions
  52. //
  53. void() main; // only for testing
  54. void() StartFrame;
  55. void() PlayerPreThink;
  56. void() PlayerPostThink;
  57. void() ClientKill;
  58. void() ClientConnect;
  59. void() PutClientInServer; // call after setting the parm1... parms
  60. void() ClientDisconnect;
  61. void() SetNewParms; // called when a client first connects to
  62. // a server. sets parms so they can be
  63. // saved off for restarts
  64. void() SetChangeParms; // call to set parms for self so they can
  65. // be saved for a level transition
  66. //================================================
  67. void end_sys_globals; // flag for structure dumping
  68. //================================================
  69. /*
  70. ==============================================================================
  71. SOURCE FOR ENTVARS_T C STRUCTURE
  72. ==============================================================================
  73. */
  74. //
  75. // system fields (*** = do not set in prog code, maintained by C code)
  76. //
  77. .float modelindex; // *** model index in the precached list
  78. .vector absmin, absmax; // *** origin + mins / maxs
  79. .float ltime; // local time for entity
  80. .float lastruntime; // *** to allow entities to run out of sequence
  81. .float movetype;
  82. .float solid;
  83. .vector origin; // ***
  84. .vector oldorigin; // ***
  85. .vector velocity;
  86. .vector angles;
  87. .vector avelocity;
  88. .string classname; // spawn function
  89. .string model;
  90. .float frame;
  91. .float skin;
  92. .float effects;
  93. .vector mins, maxs; // bounding box extents reletive to origin
  94. .vector size; // maxs - mins
  95. .void() touch;
  96. .void() use;
  97. .void() think;
  98. .void() blocked; // for doors or plats, called when can't push other
  99. .float nextthink;
  100. .entity groundentity;
  101. // stats
  102. .float health;
  103. .float frags;
  104. .float weapon; // one of the IT_SHOTGUN, etc flags
  105. .string weaponmodel;
  106. .float weaponframe;
  107. .float currentammo;
  108. .float ammo_shells, ammo_nails, ammo_rockets, ammo_cells;
  109. .float items; // bit flags
  110. .float takedamage;
  111. .entity chain;
  112. .float deadflag;
  113. .vector view_ofs; // add to origin to get eye point
  114. .float button0; // fire
  115. .float button1; // use
  116. .float button2; // jump
  117. .float impulse; // weapon changes
  118. .float fixangle;
  119. .vector v_angle; // view / targeting angle for players
  120. .string netname;
  121. .entity enemy;
  122. .float flags;
  123. .float colormap;
  124. .float team;
  125. .float max_health; // players maximum health is stored here
  126. .float teleport_time; // don't back up
  127. .float armortype; // save this fraction of incoming damage
  128. .float armorvalue;
  129. .float waterlevel; // 0 = not in, 1 = feet, 2 = wast, 3 = eyes
  130. .float watertype; // a contents value
  131. .float ideal_yaw;
  132. .float yaw_speed;
  133. .entity aiment;
  134. .entity goalentity; // a movetarget or an enemy
  135. .float spawnflags;
  136. .string target;
  137. .string targetname;
  138. // damage is accumulated through a frame. and sent as one single
  139. // message, so the super shotgun doesn't generate huge messages
  140. .float dmg_take;
  141. .float dmg_save;
  142. .entity dmg_inflictor;
  143. .entity owner; // who launched a missile
  144. .vector movedir; // mostly for doors, but also used for waterjump
  145. .string message; // trigger messages
  146. .float sounds; // either a cd track number or sound number
  147. .string noise, noise1, noise2, noise3; // contains names of wavs to play
  148. //================================================
  149. void end_sys_fields; // flag for structure dumping
  150. //================================================
  151. /*
  152. ==============================================================================
  153. VARS NOT REFERENCED BY C CODE
  154. ==============================================================================
  155. */
  156. //
  157. // constants
  158. //
  159. float FALSE = 0;
  160. float TRUE = 1;
  161. // edict.flags
  162. float FL_FLY = 1;
  163. float FL_SWIM = 2;
  164. float FL_CLIENT = 8; // set for all client edicts
  165. float FL_INWATER = 16; // for enter / leave water splash
  166. float FL_MONSTER = 32;
  167. float FL_GODMODE = 64; // player cheat
  168. float FL_NOTARGET = 128; // player cheat
  169. float FL_ITEM = 256; // extra wide size for bonus items
  170. float FL_ONGROUND = 512; // standing on something
  171. float FL_PARTIALGROUND = 1024; // not all corners are valid
  172. float FL_WATERJUMP = 2048; // player jumping out of water
  173. float FL_JUMPRELEASED = 4096; // for jump debouncing
  174. // edict.movetype values
  175. float MOVETYPE_NONE = 0; // never moves
  176. //float MOVETYPE_ANGLENOCLIP = 1;
  177. //float MOVETYPE_ANGLECLIP = 2;
  178. float MOVETYPE_WALK = 3; // players only
  179. float MOVETYPE_STEP = 4; // discrete, not real time unless fall
  180. float MOVETYPE_FLY = 5;
  181. float MOVETYPE_TOSS = 6; // gravity
  182. float MOVETYPE_PUSH = 7; // no clip to world, push and crush
  183. float MOVETYPE_NOCLIP = 8;
  184. float MOVETYPE_FLYMISSILE = 9; // fly with extra size against monsters
  185. float MOVETYPE_BOUNCE = 10;
  186. float MOVETYPE_BOUNCEMISSILE = 11; // bounce with extra size
  187. // edict.solid values
  188. float SOLID_NOT = 0; // no interaction with other objects
  189. float SOLID_TRIGGER = 1; // touch on edge, but not blocking
  190. float SOLID_BBOX = 2; // touch on edge, block
  191. float SOLID_SLIDEBOX = 3; // touch on edge, but not an onground
  192. float SOLID_BSP = 4; // bsp clip, touch on edge, block
  193. // range values
  194. float RANGE_MELEE = 0;
  195. float RANGE_NEAR = 1;
  196. float RANGE_MID = 2;
  197. float RANGE_FAR = 3;
  198. // deadflag values
  199. float DEAD_NO = 0;
  200. float DEAD_DYING = 1;
  201. float DEAD_DEAD = 2;
  202. float DEAD_RESPAWNABLE = 3;
  203. // takedamage values
  204. float DAMAGE_NO = 0;
  205. float DAMAGE_YES = 1;
  206. float DAMAGE_AIM = 2;
  207. // items
  208. float IT_AXE = 4096;
  209. float IT_SHOTGUN = 1;
  210. float IT_SUPER_SHOTGUN = 2;
  211. float IT_NAILGUN = 4;
  212. float IT_SUPER_NAILGUN = 8;
  213. float IT_GRENADE_LAUNCHER = 16;
  214. float IT_ROCKET_LAUNCHER = 32;
  215. float IT_LIGHTNING = 64;
  216. float IT_EXTRA_WEAPON = 128;
  217. float IT_SHELLS = 256;
  218. float IT_NAILS = 512;
  219. float IT_ROCKETS = 1024;
  220. float IT_CELLS = 2048;
  221. float IT_ARMOR1 = 8192;
  222. float IT_ARMOR2 = 16384;
  223. float IT_ARMOR3 = 32768;
  224. float IT_SUPERHEALTH = 65536;
  225. float IT_KEY1 = 131072;
  226. float IT_KEY2 = 262144;
  227. float IT_INVISIBILITY = 524288;
  228. float IT_INVULNERABILITY = 1048576;
  229. float IT_SUIT = 2097152;
  230. float IT_QUAD = 4194304;
  231. // point content values
  232. float CONTENT_EMPTY = -1;
  233. float CONTENT_SOLID = -2;
  234. float CONTENT_WATER = -3;
  235. float CONTENT_SLIME = -4;
  236. float CONTENT_LAVA = -5;
  237. float CONTENT_SKY = -6;
  238. float STATE_TOP = 0;
  239. float STATE_BOTTOM = 1;
  240. float STATE_UP = 2;
  241. float STATE_DOWN = 3;
  242. vector VEC_ORIGIN = '0 0 0';
  243. vector VEC_HULL_MIN = '-16 -16 -24';
  244. vector VEC_HULL_MAX = '16 16 32';
  245. vector VEC_HULL2_MIN = '-32 -32 -24';
  246. vector VEC_HULL2_MAX = '32 32 64';
  247. // protocol bytes
  248. float SVC_TEMPENTITY = 23;
  249. float SVC_KILLEDMONSTER = 27;
  250. float SVC_FOUNDSECRET = 28;
  251. float SVC_INTERMISSION = 30;
  252. float SVC_FINALE = 31;
  253. float SVC_CDTRACK = 32;
  254. float SVC_SELLSCREEN = 33;
  255. float SVC_SMALLKICK = 34;
  256. float SVC_BIGKICK = 35;
  257. float SVC_MUZZLEFLASH = 39;
  258. float TE_SPIKE = 0;
  259. float TE_SUPERSPIKE = 1;
  260. float TE_GUNSHOT = 2;
  261. float TE_EXPLOSION = 3;
  262. float TE_TAREXPLOSION = 4;
  263. float TE_LIGHTNING1 = 5;
  264. float TE_LIGHTNING2 = 6;
  265. float TE_WIZSPIKE = 7;
  266. float TE_KNIGHTSPIKE = 8;
  267. float TE_LIGHTNING3 = 9;
  268. float TE_LAVASPLASH = 10;
  269. float TE_TELEPORT = 11;
  270. float TE_BLOOD = 12;
  271. float TE_LIGHTNINGBLOOD = 13;
  272. // sound channels
  273. // channel 0 never willingly overrides
  274. // other channels (1-7) allways override a playing sound on that channel
  275. float CHAN_AUTO = 0;
  276. float CHAN_WEAPON = 1;
  277. float CHAN_VOICE = 2;
  278. float CHAN_ITEM = 3;
  279. float CHAN_BODY = 4;
  280. float CHAN_NO_PHS_ADD = 8; // ie: CHAN_BODY+CHAN_NO_PHS_ADD
  281. float ATTN_NONE = 0;
  282. float ATTN_NORM = 1;
  283. float ATTN_IDLE = 2;
  284. float ATTN_STATIC = 3;
  285. // update types
  286. float UPDATE_GENERAL = 0;
  287. float UPDATE_STATIC = 1;
  288. float UPDATE_BINARY = 2;
  289. float UPDATE_TEMP = 3;
  290. // entity effects
  291. //float EF_BRIGHTFIELD = 1;
  292. //float EF_MUZZLEFLASH = 2;
  293. float EF_BRIGHTLIGHT = 4;
  294. float EF_DIMLIGHT = 8;
  295. float EF_FLAG1 = 16;
  296. float EF_FLAG2 = 32;
  297. // GLQuakeWorld Stuff
  298. float EF_BLUE = 64; // Blue Globe effect for Quad
  299. float EF_RED = 128; // Red Globe effect for Pentagram
  300. // messages
  301. float MSG_BROADCAST = 0; // unreliable to all
  302. float MSG_ONE = 1; // reliable to one (msg_entity)
  303. float MSG_ALL = 2; // reliable to all
  304. float MSG_INIT = 3; // write to the init string
  305. float MSG_MULTICAST = 4; // for multicast() call
  306. // message levels
  307. float PRINT_LOW = 0; // pickup messages
  308. float PRINT_MEDIUM = 1; // death messages
  309. float PRINT_HIGH = 2; // critical messages
  310. float PRINT_CHAT = 3; // also goes to chat console
  311. // multicast sets
  312. float MULTICAST_ALL = 0; // every client
  313. float MULTICAST_PHS = 1; // within hearing
  314. float MULTICAST_PVS = 2; // within sight
  315. float MULTICAST_ALL_R = 3; // every client, reliable
  316. float MULTICAST_PHS_R = 4; // within hearing, reliable
  317. float MULTICAST_PVS_R = 5; // within sight, reliable
  318. //================================================
  319. //
  320. // globals
  321. //
  322. float movedist;
  323. string string_null; // null string, nothing should be held here
  324. float empty_float;
  325. entity activator; // the entity that activated a trigger or brush
  326. entity damage_attacker; // set by T_Damage
  327. entity damage_inflictor;
  328. float framecount;
  329. //
  330. // cvars checked each frame
  331. //
  332. float teamplay;
  333. float timelimit;
  334. float fraglimit;
  335. float deathmatch;
  336. float rj = 1;
  337. //================================================
  338. //
  339. // world fields (FIXME: make globals)
  340. //
  341. .string wad;
  342. .string map;
  343. .float worldtype; // 0=medieval 1=metal 2=base
  344. //================================================
  345. .string killtarget;
  346. //
  347. // quakeed fields
  348. //
  349. .float light_lev; // not used by game, but parsed by light util
  350. .float style;
  351. //
  352. // monster ai
  353. //
  354. .void() th_stand;
  355. .void() th_walk;
  356. .void() th_run;
  357. .void() th_missile;
  358. .void() th_melee;
  359. .void(entity attacker, float damage) th_pain;
  360. .void() th_die;
  361. .entity oldenemy; // mad at this player before taking damage
  362. .float speed;
  363. .float lefty;
  364. .float search_time;
  365. .float attack_state;
  366. float AS_STRAIGHT = 1;
  367. float AS_SLIDING = 2;
  368. float AS_MELEE = 3;
  369. float AS_MISSILE = 4;
  370. //
  371. // player only fields
  372. //
  373. .float voided;
  374. .float walkframe;
  375. // Zoid Additions
  376. .float maxspeed; // Used to set Maxspeed on a player
  377. .float gravity; // Gravity Multiplier (0 to 1.0)
  378. .float attack_finished;
  379. .float pain_finished;
  380. .float invincible_finished;
  381. .float invisible_finished;
  382. .float super_damage_finished;
  383. .float radsuit_finished;
  384. .float invincible_time, invincible_sound;
  385. .float invisible_time, invisible_sound;
  386. .float super_time, super_sound;
  387. .float rad_time;
  388. .float fly_sound;
  389. .float axhitme;
  390. .float show_hostile; // set to time+0.2 whenever a client fires a
  391. // weapon or takes damage. Used to alert
  392. // monsters that otherwise would let the player go
  393. .float jump_flag; // player jump flag
  394. .float swim_flag; // player swimming sound flag
  395. .float air_finished; // when time > air_finished, start drowning
  396. .float bubble_count; // keeps track of the number of bubbles
  397. .string deathtype; // keeps track of how the player died
  398. //
  399. // object stuff
  400. //
  401. .string mdl;
  402. .vector mangle; // angle at start
  403. .vector oldorigin; // only used by secret door
  404. .float t_length, t_width;
  405. //
  406. // doors, etc
  407. //
  408. .vector dest, dest1, dest2;
  409. .float wait; // time from firing to restarting
  410. .float delay; // time from activation to firing
  411. .entity trigger_field; // door's trigger entity
  412. .string noise4;
  413. //
  414. // monsters
  415. //
  416. .float pausetime;
  417. .entity movetarget;
  418. //
  419. // doors
  420. //
  421. .float aflag;
  422. .float dmg; // damage done by door when hit
  423. //
  424. // misc
  425. //
  426. .float cnt; // misc flag
  427. //
  428. // subs
  429. //
  430. .void() think1;
  431. .vector finaldest, finalangle;
  432. //
  433. // triggers
  434. //
  435. .float count; // for counting triggers
  436. //
  437. // plats / doors / buttons
  438. //
  439. .float lip;
  440. .float state;
  441. .vector pos1, pos2; // top and bottom positions
  442. .float height;
  443. //
  444. // sounds
  445. //
  446. .float waitmin, waitmax;
  447. .float distance;
  448. .float volume;
  449. //===========================================================================
  450. //
  451. // builtin functions
  452. //
  453. void(vector ang) makevectors = #1; // sets v_forward, etc globals
  454. void(entity e, vector o) setorigin = #2;
  455. void(entity e, string m) setmodel = #3; // set movetype and solid first
  456. void(entity e, vector min, vector max) setsize = #4;
  457. // #5 was removed
  458. void() break = #6;
  459. float() random = #7; // returns 0 - 1
  460. void(entity e, float chan, string samp, float vol, float atten) sound = #8;
  461. vector(vector v) normalize = #9;
  462. void(string e) error = #10;
  463. void(string e) objerror = #11;
  464. float(vector v) vlen = #12;
  465. float(vector v) vectoyaw = #13;
  466. entity() spawn = #14;
  467. void(entity e) remove = #15;
  468. // sets trace_* globals
  469. // nomonsters can be:
  470. // An entity will also be ignored for testing if forent == test,
  471. // forent->owner == test, or test->owner == forent
  472. // a forent of world is ignored
  473. void(vector v1, vector v2, float nomonsters, entity forent) traceline = #16;
  474. entity() checkclient = #17; // returns a client to look for
  475. entity(entity start, .string fld, string match) find = #18;
  476. string(string s) precache_sound = #19;
  477. string(string s) precache_model = #20;
  478. void(entity client, string s)stuffcmd = #21;
  479. entity(vector org, float rad) findradius = #22;
  480. void(float level, string s) bprint = #23;
  481. void(entity client, float level, string s) sprint = #24;
  482. void(string s) dprint = #25;
  483. string(float f) ftos = #26;
  484. string(vector v) vtos = #27;
  485. void() coredump = #28; // prints all edicts
  486. void() traceon = #29; // turns statment trace on
  487. void() traceoff = #30;
  488. void(entity e) eprint = #31; // prints an entire edict
  489. float(float yaw, float dist) walkmove = #32; // returns TRUE or FALSE
  490. // #33 was removed
  491. float(float yaw, float dist) droptofloor= #34; // TRUE if landed on floor
  492. void(float style, string value) lightstyle = #35;
  493. float(float v) rint = #36; // round to nearest int
  494. float(float v) floor = #37; // largest integer <= v
  495. float(float v) ceil = #38; // smallest integer >= v
  496. // #39 was removed
  497. float(entity e) checkbottom = #40; // true if self is on ground
  498. float(vector v) pointcontents = #41; // returns a CONTENT_*
  499. // #42 was removed
  500. float(float f) fabs = #43;
  501. vector(entity e, float speed) aim = #44; // returns the shooting vector
  502. float(string s) cvar = #45; // return cvar.value
  503. void(string s) localcmd = #46; // put string into local que
  504. entity(entity e) nextent = #47; // for looping through all ents
  505. // #48 was removed
  506. void() ChangeYaw = #49; // turn towards self.ideal_yaw
  507. // at self.yaw_speed
  508. // #50 was removed
  509. vector(vector v) vectoangles = #51;
  510. //
  511. // direct client message generation
  512. //
  513. void(float to, float f) WriteByte = #52;
  514. void(float to, float f) WriteChar = #53;
  515. void(float to, float f) WriteShort = #54;
  516. void(float to, float f) WriteLong = #55;
  517. void(float to, float f) WriteCoord = #56;
  518. void(float to, float f) WriteAngle = #57;
  519. void(float to, string s) WriteString = #58;
  520. void(float to, entity s) WriteEntity = #59;
  521. // several removed
  522. void(float step) movetogoal = #67;
  523. string(string s) precache_file = #68; // no effect except for -copy
  524. void(entity e) makestatic = #69;
  525. void(string s) changelevel = #70;
  526. //#71 was removed
  527. void(string var, string val) cvar_set = #72; // sets cvar.value
  528. void(entity client, string s) centerprint = #73; // sprint, but in middle
  529. void(vector pos, string samp, float vol, float atten) ambientsound = #74;
  530. string(string s) precache_model2 = #75; // registered version only
  531. string(string s) precache_sound2 = #76; // registered version only
  532. string(string s) precache_file2 = #77; // registered version only
  533. void(entity e) setspawnparms = #78; // set parm1... to the
  534. // values at level start
  535. // for coop respawn
  536. void(entity killer, entity killee) logfrag = #79; // add to stats
  537. string(entity e, string key) infokey = #80; // get a key value (world = serverinfo)
  538. float(string s) stof = #81; // convert string to float
  539. void(vector where, float set) multicast = #82; // sends the temp message to a set
  540. // of clients, possibly in PVS or PHS
  541. //============================================================================
  542. //
  543. // subs.qc
  544. //
  545. void(vector tdest, float tspeed, void() func) SUB_CalcMove;
  546. void(entity ent, vector tdest, float tspeed, void() func) SUB_CalcMoveEnt;
  547. void(vector destangle, float tspeed, void() func) SUB_CalcAngleMove;
  548. void() SUB_CalcMoveDone;
  549. void() SUB_CalcAngleMoveDone;
  550. void() SUB_Null;
  551. void() SUB_UseTargets;
  552. void() SUB_Remove;
  553. //
  554. // combat.qc
  555. //
  556. void(entity targ, entity inflictor, entity attacker, float damage) T_Damage;
  557. float (entity e, float healamount, float ignore) T_Heal; // health function
  558. float(entity targ, entity inflictor) CanDamage;