g_local.h 28 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114
  1. /*
  2. Copyright (C) 1997-2001 Id Software, Inc.
  3. This program is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU General Public License
  5. as published by the Free Software Foundation; either version 2
  6. of the License, or (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. See the GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, write to the Free Software
  13. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  14. */
  15. // g_local.h -- local definitions for game module
  16. #include "q_shared.h"
  17. // define GAME_INCLUDE so that game.h does not define the
  18. // short, server-visible gclient_t and edict_t structures,
  19. // because we define the full size ones in this file
  20. #define GAME_INCLUDE
  21. #include "game.h"
  22. // the "gameversion" client command will print this plus compile date
  23. #define GAMEVERSION "baseq2"
  24. // protocol bytes that can be directly added to messages
  25. #define svc_muzzleflash 1
  26. #define svc_muzzleflash2 2
  27. #define svc_temp_entity 3
  28. #define svc_layout 4
  29. #define svc_inventory 5
  30. #define svc_stufftext 11
  31. //==================================================================
  32. // view pitching times
  33. #define DAMAGE_TIME 0.5
  34. #define FALL_TIME 0.3
  35. // edict->spawnflags
  36. // these are set with checkboxes on each entity in the map editor
  37. #define SPAWNFLAG_NOT_EASY 0x00000100
  38. #define SPAWNFLAG_NOT_MEDIUM 0x00000200
  39. #define SPAWNFLAG_NOT_HARD 0x00000400
  40. #define SPAWNFLAG_NOT_DEATHMATCH 0x00000800
  41. #define SPAWNFLAG_NOT_COOP 0x00001000
  42. // edict->flags
  43. #define FL_FLY 0x00000001
  44. #define FL_SWIM 0x00000002 // implied immunity to drowining
  45. #define FL_IMMUNE_LASER 0x00000004
  46. #define FL_INWATER 0x00000008
  47. #define FL_GODMODE 0x00000010
  48. #define FL_NOTARGET 0x00000020
  49. #define FL_IMMUNE_SLIME 0x00000040
  50. #define FL_IMMUNE_LAVA 0x00000080
  51. #define FL_PARTIALGROUND 0x00000100 // not all corners are valid
  52. #define FL_WATERJUMP 0x00000200 // player jumping out of water
  53. #define FL_TEAMSLAVE 0x00000400 // not the first on the team
  54. #define FL_NO_KNOCKBACK 0x00000800
  55. #define FL_POWER_ARMOR 0x00001000 // power armor (if any) is active
  56. #define FL_RESPAWN 0x80000000 // used for item respawning
  57. #define FRAMETIME 0.1
  58. // memory tags to allow dynamic memory to be cleaned up
  59. #define TAG_GAME 765 // clear when unloading the dll
  60. #define TAG_LEVEL 766 // clear when loading a new level
  61. #define MELEE_DISTANCE 80
  62. #define BODY_QUEUE_SIZE 8
  63. typedef enum
  64. {
  65. DAMAGE_NO,
  66. DAMAGE_YES, // will take damage if hit
  67. DAMAGE_AIM // auto targeting recognizes this
  68. } damage_t;
  69. typedef enum
  70. {
  71. WEAPON_READY,
  72. WEAPON_ACTIVATING,
  73. WEAPON_DROPPING,
  74. WEAPON_FIRING
  75. } weaponstate_t;
  76. typedef enum
  77. {
  78. AMMO_BULLETS,
  79. AMMO_SHELLS,
  80. AMMO_ROCKETS,
  81. AMMO_GRENADES,
  82. AMMO_CELLS,
  83. AMMO_SLUGS
  84. } ammo_t;
  85. //deadflag
  86. #define DEAD_NO 0
  87. #define DEAD_DYING 1
  88. #define DEAD_DEAD 2
  89. #define DEAD_RESPAWNABLE 3
  90. //range
  91. #define RANGE_MELEE 0
  92. #define RANGE_NEAR 1
  93. #define RANGE_MID 2
  94. #define RANGE_FAR 3
  95. //gib types
  96. #define GIB_ORGANIC 0
  97. #define GIB_METALLIC 1
  98. //monster ai flags
  99. #define AI_STAND_GROUND 0x00000001
  100. #define AI_TEMP_STAND_GROUND 0x00000002
  101. #define AI_SOUND_TARGET 0x00000004
  102. #define AI_LOST_SIGHT 0x00000008
  103. #define AI_PURSUIT_LAST_SEEN 0x00000010
  104. #define AI_PURSUE_NEXT 0x00000020
  105. #define AI_PURSUE_TEMP 0x00000040
  106. #define AI_HOLD_FRAME 0x00000080
  107. #define AI_GOOD_GUY 0x00000100
  108. #define AI_BRUTAL 0x00000200
  109. #define AI_NOSTEP 0x00000400
  110. #define AI_DUCKED 0x00000800
  111. #define AI_COMBAT_POINT 0x00001000
  112. #define AI_MEDIC 0x00002000
  113. #define AI_RESURRECTING 0x00004000
  114. //monster attack state
  115. #define AS_STRAIGHT 1
  116. #define AS_SLIDING 2
  117. #define AS_MELEE 3
  118. #define AS_MISSILE 4
  119. // armor types
  120. #define ARMOR_NONE 0
  121. #define ARMOR_JACKET 1
  122. #define ARMOR_COMBAT 2
  123. #define ARMOR_BODY 3
  124. #define ARMOR_SHARD 4
  125. // power armor types
  126. #define POWER_ARMOR_NONE 0
  127. #define POWER_ARMOR_SCREEN 1
  128. #define POWER_ARMOR_SHIELD 2
  129. // handedness values
  130. #define RIGHT_HANDED 0
  131. #define LEFT_HANDED 1
  132. #define CENTER_HANDED 2
  133. // game.serverflags values
  134. #define SFL_CROSS_TRIGGER_1 0x00000001
  135. #define SFL_CROSS_TRIGGER_2 0x00000002
  136. #define SFL_CROSS_TRIGGER_3 0x00000004
  137. #define SFL_CROSS_TRIGGER_4 0x00000008
  138. #define SFL_CROSS_TRIGGER_5 0x00000010
  139. #define SFL_CROSS_TRIGGER_6 0x00000020
  140. #define SFL_CROSS_TRIGGER_7 0x00000040
  141. #define SFL_CROSS_TRIGGER_8 0x00000080
  142. #define SFL_CROSS_TRIGGER_MASK 0x000000ff
  143. // noise types for PlayerNoise
  144. #define PNOISE_SELF 0
  145. #define PNOISE_WEAPON 1
  146. #define PNOISE_IMPACT 2
  147. // edict->movetype values
  148. typedef enum
  149. {
  150. MOVETYPE_NONE, // never moves
  151. MOVETYPE_NOCLIP, // origin and angles change with no interaction
  152. MOVETYPE_PUSH, // no clip to world, push on box contact
  153. MOVETYPE_STOP, // no clip to world, stops on box contact
  154. MOVETYPE_WALK, // gravity
  155. MOVETYPE_STEP, // gravity, special edge handling
  156. MOVETYPE_FLY,
  157. MOVETYPE_TOSS, // gravity
  158. MOVETYPE_FLYMISSILE, // extra size to monsters
  159. MOVETYPE_BOUNCE
  160. } movetype_t;
  161. typedef struct
  162. {
  163. int base_count;
  164. int max_count;
  165. float normal_protection;
  166. float energy_protection;
  167. int armor;
  168. } gitem_armor_t;
  169. // gitem_t->flags
  170. #define IT_WEAPON 1 // use makes active weapon
  171. #define IT_AMMO 2
  172. #define IT_ARMOR 4
  173. #define IT_STAY_COOP 8
  174. #define IT_KEY 16
  175. #define IT_POWERUP 32
  176. // gitem_t->weapmodel for weapons indicates model index
  177. #define WEAP_BLASTER 1
  178. #define WEAP_SHOTGUN 2
  179. #define WEAP_SUPERSHOTGUN 3
  180. #define WEAP_MACHINEGUN 4
  181. #define WEAP_CHAINGUN 5
  182. #define WEAP_GRENADES 6
  183. #define WEAP_GRENADELAUNCHER 7
  184. #define WEAP_ROCKETLAUNCHER 8
  185. #define WEAP_HYPERBLASTER 9
  186. #define WEAP_RAILGUN 10
  187. #define WEAP_BFG 11
  188. typedef struct gitem_s
  189. {
  190. char *classname; // spawning name
  191. qboolean (*pickup)(struct edict_s *ent, struct edict_s *other);
  192. void (*use)(struct edict_s *ent, struct gitem_s *item);
  193. void (*drop)(struct edict_s *ent, struct gitem_s *item);
  194. void (*weaponthink)(struct edict_s *ent);
  195. char *pickup_sound;
  196. char *world_model;
  197. int world_model_flags;
  198. char *view_model;
  199. // client side info
  200. char *icon;
  201. char *pickup_name; // for printing on pickup
  202. int count_width; // number of digits to display by icon
  203. int quantity; // for ammo how much, for weapons how much is used per shot
  204. char *ammo; // for weapons
  205. int flags; // IT_* flags
  206. int weapmodel; // weapon model index (for weapons)
  207. void *info;
  208. int tag;
  209. char *precaches; // string of all models, sounds, and images this item will use
  210. } gitem_t;
  211. //
  212. // this structure is left intact through an entire game
  213. // it should be initialized at dll load time, and read/written to
  214. // the server.ssv file for savegames
  215. //
  216. typedef struct
  217. {
  218. char helpmessage1[512];
  219. char helpmessage2[512];
  220. int helpchanged; // flash F1 icon if non 0, play sound
  221. // and increment only if 1, 2, or 3
  222. gclient_t *clients; // [maxclients]
  223. // can't store spawnpoint in level, because
  224. // it would get overwritten by the savegame restore
  225. char spawnpoint[512]; // needed for coop respawns
  226. // store latched cvars here that we want to get at often
  227. int maxclients;
  228. int maxentities;
  229. // cross level triggers
  230. int serverflags;
  231. // items
  232. int num_items;
  233. qboolean autosaved;
  234. } game_locals_t;
  235. //
  236. // this structure is cleared as each map is entered
  237. // it is read/written to the level.sav file for savegames
  238. //
  239. typedef struct
  240. {
  241. int framenum;
  242. float time;
  243. char level_name[MAX_QPATH]; // the descriptive name (Outer Base, etc)
  244. char mapname[MAX_QPATH]; // the server name (base1, etc)
  245. char nextmap[MAX_QPATH]; // go here when fraglimit is hit
  246. // intermission state
  247. float intermissiontime; // time the intermission was started
  248. char *changemap;
  249. int exitintermission;
  250. vec3_t intermission_origin;
  251. vec3_t intermission_angle;
  252. edict_t *sight_client; // changed once each frame for coop games
  253. edict_t *sight_entity;
  254. int sight_entity_framenum;
  255. edict_t *sound_entity;
  256. int sound_entity_framenum;
  257. edict_t *sound2_entity;
  258. int sound2_entity_framenum;
  259. int pic_health;
  260. int total_secrets;
  261. int found_secrets;
  262. int total_goals;
  263. int found_goals;
  264. int total_monsters;
  265. int killed_monsters;
  266. edict_t *current_entity; // entity running from G_RunFrame
  267. int body_que; // dead bodies
  268. int power_cubes; // ugly necessity for coop
  269. } level_locals_t;
  270. // spawn_temp_t is only used to hold entity field values that
  271. // can be set from the editor, but aren't actualy present
  272. // in edict_t during gameplay
  273. typedef struct
  274. {
  275. // world vars
  276. char *sky;
  277. float skyrotate;
  278. vec3_t skyaxis;
  279. char *nextmap;
  280. int lip;
  281. int distance;
  282. int height;
  283. char *noise;
  284. float pausetime;
  285. char *item;
  286. char *gravity;
  287. float minyaw;
  288. float maxyaw;
  289. float minpitch;
  290. float maxpitch;
  291. } spawn_temp_t;
  292. typedef struct
  293. {
  294. // fixed data
  295. vec3_t start_origin;
  296. vec3_t start_angles;
  297. vec3_t end_origin;
  298. vec3_t end_angles;
  299. int sound_start;
  300. int sound_middle;
  301. int sound_end;
  302. float accel;
  303. float speed;
  304. float decel;
  305. float distance;
  306. float wait;
  307. // state data
  308. int state;
  309. vec3_t dir;
  310. float current_speed;
  311. float move_speed;
  312. float next_speed;
  313. float remaining_distance;
  314. float decel_distance;
  315. void (*endfunc)(edict_t *);
  316. } moveinfo_t;
  317. typedef struct
  318. {
  319. void (*aifunc)(edict_t *self, float dist);
  320. float dist;
  321. void (*thinkfunc)(edict_t *self);
  322. } mframe_t;
  323. typedef struct
  324. {
  325. int firstframe;
  326. int lastframe;
  327. mframe_t *frame;
  328. void (*endfunc)(edict_t *self);
  329. } mmove_t;
  330. typedef struct
  331. {
  332. mmove_t *currentmove;
  333. int aiflags;
  334. int nextframe;
  335. float scale;
  336. void (*stand)(edict_t *self);
  337. void (*idle)(edict_t *self);
  338. void (*search)(edict_t *self);
  339. void (*walk)(edict_t *self);
  340. void (*run)(edict_t *self);
  341. void (*dodge)(edict_t *self, edict_t *other, float eta);
  342. void (*attack)(edict_t *self);
  343. void (*melee)(edict_t *self);
  344. void (*sight)(edict_t *self, edict_t *other);
  345. qboolean (*checkattack)(edict_t *self);
  346. float pausetime;
  347. float attack_finished;
  348. vec3_t saved_goal;
  349. float search_time;
  350. float trail_time;
  351. vec3_t last_sighting;
  352. int attack_state;
  353. int lefty;
  354. float idle_time;
  355. int linkcount;
  356. int power_armor_type;
  357. int power_armor_power;
  358. } monsterinfo_t;
  359. extern game_locals_t game;
  360. extern level_locals_t level;
  361. extern game_import_t gi;
  362. extern game_export_t globals;
  363. extern spawn_temp_t st;
  364. extern int sm_meat_index;
  365. extern int snd_fry;
  366. extern int jacket_armor_index;
  367. extern int combat_armor_index;
  368. extern int body_armor_index;
  369. // means of death
  370. #define MOD_UNKNOWN 0
  371. #define MOD_BLASTER 1
  372. #define MOD_SHOTGUN 2
  373. #define MOD_SSHOTGUN 3
  374. #define MOD_MACHINEGUN 4
  375. #define MOD_CHAINGUN 5
  376. #define MOD_GRENADE 6
  377. #define MOD_G_SPLASH 7
  378. #define MOD_ROCKET 8
  379. #define MOD_R_SPLASH 9
  380. #define MOD_HYPERBLASTER 10
  381. #define MOD_RAILGUN 11
  382. #define MOD_BFG_LASER 12
  383. #define MOD_BFG_BLAST 13
  384. #define MOD_BFG_EFFECT 14
  385. #define MOD_HANDGRENADE 15
  386. #define MOD_HG_SPLASH 16
  387. #define MOD_WATER 17
  388. #define MOD_SLIME 18
  389. #define MOD_LAVA 19
  390. #define MOD_CRUSH 20
  391. #define MOD_TELEFRAG 21
  392. #define MOD_FALLING 22
  393. #define MOD_SUICIDE 23
  394. #define MOD_HELD_GRENADE 24
  395. #define MOD_EXPLOSIVE 25
  396. #define MOD_BARREL 26
  397. #define MOD_BOMB 27
  398. #define MOD_EXIT 28
  399. #define MOD_SPLASH 29
  400. #define MOD_TARGET_LASER 30
  401. #define MOD_TRIGGER_HURT 31
  402. #define MOD_HIT 32
  403. #define MOD_TARGET_BLASTER 33
  404. #define MOD_FRIENDLY_FIRE 0x8000000
  405. extern int meansOfDeath;
  406. extern edict_t *g_edicts;
  407. #define FOFS(x) (int)&(((edict_t *)0)->x)
  408. #define STOFS(x) (int)&(((spawn_temp_t *)0)->x)
  409. #define LLOFS(x) (int)&(((level_locals_t *)0)->x)
  410. #define CLOFS(x) (int)&(((gclient_t *)0)->x)
  411. #define random() ((rand () & 0x7fff) / ((float)0x7fff))
  412. #define crandom() (2.0 * (random() - 0.5))
  413. extern cvar_t *maxentities;
  414. extern cvar_t *deathmatch;
  415. extern cvar_t *coop;
  416. extern cvar_t *dmflags;
  417. extern cvar_t *skill;
  418. extern cvar_t *fraglimit;
  419. extern cvar_t *timelimit;
  420. extern cvar_t *password;
  421. extern cvar_t *spectator_password;
  422. extern cvar_t *g_select_empty;
  423. extern cvar_t *dedicated;
  424. extern cvar_t *filterban;
  425. extern cvar_t *sv_gravity;
  426. extern cvar_t *sv_maxvelocity;
  427. extern cvar_t *gun_x, *gun_y, *gun_z;
  428. extern cvar_t *sv_rollspeed;
  429. extern cvar_t *sv_rollangle;
  430. extern cvar_t *run_pitch;
  431. extern cvar_t *run_roll;
  432. extern cvar_t *bob_up;
  433. extern cvar_t *bob_pitch;
  434. extern cvar_t *bob_roll;
  435. extern cvar_t *sv_cheats;
  436. extern cvar_t *maxclients;
  437. extern cvar_t *maxspectators;
  438. extern cvar_t *flood_msgs;
  439. extern cvar_t *flood_persecond;
  440. extern cvar_t *flood_waitdelay;
  441. extern cvar_t *sv_maplist;
  442. #define world (&g_edicts[0])
  443. // item spawnflags
  444. #define ITEM_TRIGGER_SPAWN 0x00000001
  445. #define ITEM_NO_TOUCH 0x00000002
  446. // 6 bits reserved for editor flags
  447. // 8 bits used as power cube id bits for coop games
  448. #define DROPPED_ITEM 0x00010000
  449. #define DROPPED_PLAYER_ITEM 0x00020000
  450. #define ITEM_TARGETS_USED 0x00040000
  451. //
  452. // fields are needed for spawning from the entity string
  453. // and saving / loading games
  454. //
  455. #define FFL_SPAWNTEMP 1
  456. #define FFL_NOSPAWN 2
  457. typedef enum {
  458. F_INT,
  459. F_FLOAT,
  460. F_LSTRING, // string on disk, pointer in memory, TAG_LEVEL
  461. F_GSTRING, // string on disk, pointer in memory, TAG_GAME
  462. F_VECTOR,
  463. F_ANGLEHACK,
  464. F_EDICT, // index on disk, pointer in memory
  465. F_ITEM, // index on disk, pointer in memory
  466. F_CLIENT, // index on disk, pointer in memory
  467. F_FUNCTION,
  468. F_MMOVE,
  469. F_IGNORE
  470. } fieldtype_t;
  471. typedef struct
  472. {
  473. char *name;
  474. int ofs;
  475. fieldtype_t type;
  476. int flags;
  477. } field_t;
  478. extern field_t fields[];
  479. extern gitem_t itemlist[];
  480. //
  481. // g_cmds.c
  482. //
  483. void Cmd_Help_f (edict_t *ent);
  484. void Cmd_Score_f (edict_t *ent);
  485. //
  486. // g_items.c
  487. //
  488. void PrecacheItem (gitem_t *it);
  489. void InitItems (void);
  490. void SetItemNames (void);
  491. gitem_t *FindItem (char *pickup_name);
  492. gitem_t *FindItemByClassname (char *classname);
  493. #define ITEM_INDEX(x) ((x)-itemlist)
  494. edict_t *Drop_Item (edict_t *ent, gitem_t *item);
  495. void SetRespawn (edict_t *ent, float delay);
  496. void ChangeWeapon (edict_t *ent);
  497. void SpawnItem (edict_t *ent, gitem_t *item);
  498. void Think_Weapon (edict_t *ent);
  499. int ArmorIndex (edict_t *ent);
  500. int PowerArmorType (edict_t *ent);
  501. gitem_t *GetItemByIndex (int index);
  502. qboolean Add_Ammo (edict_t *ent, gitem_t *item, int count);
  503. void Touch_Item (edict_t *ent, edict_t *other, cplane_t *plane, csurface_t *surf);
  504. //
  505. // g_utils.c
  506. //
  507. qboolean KillBox (edict_t *ent);
  508. void G_ProjectSource (vec3_t point, vec3_t distance, vec3_t forward, vec3_t right, vec3_t result);
  509. edict_t *G_Find (edict_t *from, int fieldofs, char *match);
  510. edict_t *findradius (edict_t *from, vec3_t org, float rad);
  511. edict_t *G_PickTarget (char *targetname);
  512. void G_UseTargets (edict_t *ent, edict_t *activator);
  513. void G_SetMovedir (vec3_t angles, vec3_t movedir);
  514. void G_InitEdict (edict_t *e);
  515. edict_t *G_Spawn (void);
  516. void G_FreeEdict (edict_t *e);
  517. void G_TouchTriggers (edict_t *ent);
  518. void G_TouchSolids (edict_t *ent);
  519. char *G_CopyString (char *in);
  520. float *tv (float x, float y, float z);
  521. char *vtos (vec3_t v);
  522. float vectoyaw (vec3_t vec);
  523. void vectoangles (vec3_t vec, vec3_t angles);
  524. //
  525. // g_combat.c
  526. //
  527. qboolean OnSameTeam (edict_t *ent1, edict_t *ent2);
  528. qboolean CanDamage (edict_t *targ, edict_t *inflictor);
  529. void T_Damage (edict_t *targ, edict_t *inflictor, edict_t *attacker, vec3_t dir, vec3_t point, vec3_t normal, int damage, int knockback, int dflags, int mod);
  530. void T_RadiusDamage (edict_t *inflictor, edict_t *attacker, float damage, edict_t *ignore, float radius, int mod);
  531. // damage flags
  532. #define DAMAGE_RADIUS 0x00000001 // damage was indirect
  533. #define DAMAGE_NO_ARMOR 0x00000002 // armour does not protect from this damage
  534. #define DAMAGE_ENERGY 0x00000004 // damage is from an energy based weapon
  535. #define DAMAGE_NO_KNOCKBACK 0x00000008 // do not affect velocity, just view angles
  536. #define DAMAGE_BULLET 0x00000010 // damage is from a bullet (used for ricochets)
  537. #define DAMAGE_NO_PROTECTION 0x00000020 // armor, shields, invulnerability, and godmode have no effect
  538. #define DEFAULT_BULLET_HSPREAD 300
  539. #define DEFAULT_BULLET_VSPREAD 500
  540. #define DEFAULT_SHOTGUN_HSPREAD 1000
  541. #define DEFAULT_SHOTGUN_VSPREAD 500
  542. #define DEFAULT_DEATHMATCH_SHOTGUN_COUNT 12
  543. #define DEFAULT_SHOTGUN_COUNT 12
  544. #define DEFAULT_SSHOTGUN_COUNT 20
  545. //
  546. // g_monster.c
  547. //
  548. void monster_fire_bullet (edict_t *self, vec3_t start, vec3_t dir, int damage, int kick, int hspread, int vspread, int flashtype);
  549. void monster_fire_shotgun (edict_t *self, vec3_t start, vec3_t aimdir, int damage, int kick, int hspread, int vspread, int count, int flashtype);
  550. void monster_fire_blaster (edict_t *self, vec3_t start, vec3_t dir, int damage, int speed, int flashtype, int effect);
  551. void monster_fire_grenade (edict_t *self, vec3_t start, vec3_t aimdir, int damage, int speed, int flashtype);
  552. void monster_fire_rocket (edict_t *self, vec3_t start, vec3_t dir, int damage, int speed, int flashtype);
  553. void monster_fire_railgun (edict_t *self, vec3_t start, vec3_t aimdir, int damage, int kick, int flashtype);
  554. void monster_fire_bfg (edict_t *self, vec3_t start, vec3_t aimdir, int damage, int speed, int kick, float damage_radius, int flashtype);
  555. void M_droptofloor (edict_t *ent);
  556. void monster_think (edict_t *self);
  557. void walkmonster_start (edict_t *self);
  558. void swimmonster_start (edict_t *self);
  559. void flymonster_start (edict_t *self);
  560. void AttackFinished (edict_t *self, float time);
  561. void monster_death_use (edict_t *self);
  562. void M_CatagorizePosition (edict_t *ent);
  563. qboolean M_CheckAttack (edict_t *self);
  564. void M_FlyCheck (edict_t *self);
  565. void M_CheckGround (edict_t *ent);
  566. //
  567. // g_misc.c
  568. //
  569. void ThrowHead (edict_t *self, char *gibname, int damage, int type);
  570. void ThrowClientHead (edict_t *self, int damage);
  571. void ThrowGib (edict_t *self, char *gibname, int damage, int type);
  572. void BecomeExplosion1(edict_t *self);
  573. //
  574. // g_ai.c
  575. //
  576. void AI_SetSightClient (void);
  577. void ai_stand (edict_t *self, float dist);
  578. void ai_move (edict_t *self, float dist);
  579. void ai_walk (edict_t *self, float dist);
  580. void ai_turn (edict_t *self, float dist);
  581. void ai_run (edict_t *self, float dist);
  582. void ai_charge (edict_t *self, float dist);
  583. int range (edict_t *self, edict_t *other);
  584. void FoundTarget (edict_t *self);
  585. qboolean infront (edict_t *self, edict_t *other);
  586. qboolean visible (edict_t *self, edict_t *other);
  587. qboolean FacingIdeal(edict_t *self);
  588. //
  589. // g_weapon.c
  590. //
  591. void ThrowDebris (edict_t *self, char *modelname, float speed, vec3_t origin);
  592. qboolean fire_hit (edict_t *self, vec3_t aim, int damage, int kick);
  593. void fire_bullet (edict_t *self, vec3_t start, vec3_t aimdir, int damage, int kick, int hspread, int vspread, int mod);
  594. void fire_shotgun (edict_t *self, vec3_t start, vec3_t aimdir, int damage, int kick, int hspread, int vspread, int count, int mod);
  595. void fire_blaster (edict_t *self, vec3_t start, vec3_t aimdir, int damage, int speed, int effect, qboolean hyper);
  596. void fire_grenade (edict_t *self, vec3_t start, vec3_t aimdir, int damage, int speed, float timer, float damage_radius);
  597. void fire_grenade2 (edict_t *self, vec3_t start, vec3_t aimdir, int damage, int speed, float timer, float damage_radius, qboolean held);
  598. void fire_rocket (edict_t *self, vec3_t start, vec3_t dir, int damage, int speed, float damage_radius, int radius_damage);
  599. void fire_rail (edict_t *self, vec3_t start, vec3_t aimdir, int damage, int kick);
  600. void fire_bfg (edict_t *self, vec3_t start, vec3_t dir, int damage, int speed, float damage_radius);
  601. //
  602. // g_ptrail.c
  603. //
  604. void PlayerTrail_Init (void);
  605. void PlayerTrail_Add (vec3_t spot);
  606. void PlayerTrail_New (vec3_t spot);
  607. edict_t *PlayerTrail_PickFirst (edict_t *self);
  608. edict_t *PlayerTrail_PickNext (edict_t *self);
  609. edict_t *PlayerTrail_LastSpot (void);
  610. //
  611. // g_client.c
  612. //
  613. void respawn (edict_t *ent);
  614. void BeginIntermission (edict_t *targ);
  615. void PutClientInServer (edict_t *ent);
  616. void InitClientPersistant (gclient_t *client);
  617. void InitClientResp (gclient_t *client);
  618. void InitBodyQue (void);
  619. void ClientBeginServerFrame (edict_t *ent);
  620. //
  621. // g_player.c
  622. //
  623. void player_pain (edict_t *self, edict_t *other, float kick, int damage);
  624. void player_die (edict_t *self, edict_t *inflictor, edict_t *attacker, int damage, vec3_t point);
  625. //
  626. // g_svcmds.c
  627. //
  628. void ServerCommand (void);
  629. qboolean SV_FilterPacket (char *from);
  630. //
  631. // p_view.c
  632. //
  633. void ClientEndServerFrame (edict_t *ent);
  634. //
  635. // p_hud.c
  636. //
  637. void MoveClientToIntermission (edict_t *client);
  638. void G_SetStats (edict_t *ent);
  639. void G_SetSpectatorStats (edict_t *ent);
  640. void G_CheckChaseStats (edict_t *ent);
  641. void ValidateSelectedItem (edict_t *ent);
  642. void DeathmatchScoreboardMessage (edict_t *client, edict_t *killer);
  643. //
  644. // g_pweapon.c
  645. //
  646. void PlayerNoise(edict_t *who, vec3_t where, int type);
  647. //
  648. // m_move.c
  649. //
  650. qboolean M_CheckBottom (edict_t *ent);
  651. qboolean M_walkmove (edict_t *ent, float yaw, float dist);
  652. void M_MoveToGoal (edict_t *ent, float dist);
  653. void M_ChangeYaw (edict_t *ent);
  654. //
  655. // g_phys.c
  656. //
  657. void G_RunEntity (edict_t *ent);
  658. //
  659. // g_main.c
  660. //
  661. void SaveClientData (void);
  662. void FetchClientEntData (edict_t *ent);
  663. //
  664. // g_chase.c
  665. //
  666. void UpdateChaseCam(edict_t *ent);
  667. void ChaseNext(edict_t *ent);
  668. void ChasePrev(edict_t *ent);
  669. void GetChaseTarget(edict_t *ent);
  670. //============================================================================
  671. // client_t->anim_priority
  672. #define ANIM_BASIC 0 // stand / run
  673. #define ANIM_WAVE 1
  674. #define ANIM_JUMP 2
  675. #define ANIM_PAIN 3
  676. #define ANIM_ATTACK 4
  677. #define ANIM_DEATH 5
  678. #define ANIM_REVERSE 6
  679. // client data that stays across multiple level loads
  680. typedef struct
  681. {
  682. char userinfo[MAX_INFO_STRING];
  683. char netname[16];
  684. int hand;
  685. qboolean connected; // a loadgame will leave valid entities that
  686. // just don't have a connection yet
  687. // values saved and restored from edicts when changing levels
  688. int health;
  689. int max_health;
  690. int savedFlags;
  691. int selected_item;
  692. int inventory[MAX_ITEMS];
  693. // ammo capacities
  694. int max_bullets;
  695. int max_shells;
  696. int max_rockets;
  697. int max_grenades;
  698. int max_cells;
  699. int max_slugs;
  700. gitem_t *weapon;
  701. gitem_t *lastweapon;
  702. int power_cubes; // used for tracking the cubes in coop games
  703. int score; // for calculating total unit score in coop games
  704. int game_helpchanged;
  705. int helpchanged;
  706. qboolean spectator; // client is a spectator
  707. } client_persistant_t;
  708. // client data that stays across deathmatch respawns
  709. typedef struct
  710. {
  711. client_persistant_t coop_respawn; // what to set client->pers to on a respawn
  712. int enterframe; // level.framenum the client entered the game
  713. int score; // frags, etc
  714. vec3_t cmd_angles; // angles sent over in the last command
  715. qboolean spectator; // client is a spectator
  716. } client_respawn_t;
  717. // this structure is cleared on each PutClientInServer(),
  718. // except for 'client->pers'
  719. struct gclient_s
  720. {
  721. // known to server
  722. player_state_t ps; // communicated by server to clients
  723. int ping;
  724. // private to game
  725. client_persistant_t pers;
  726. client_respawn_t resp;
  727. pmove_state_t old_pmove; // for detecting out-of-pmove changes
  728. qboolean showscores; // set layout stat
  729. qboolean showinventory; // set layout stat
  730. qboolean showhelp;
  731. qboolean showhelpicon;
  732. int ammo_index;
  733. int buttons;
  734. int oldbuttons;
  735. int latched_buttons;
  736. qboolean weapon_thunk;
  737. gitem_t *newweapon;
  738. // sum up damage over an entire frame, so
  739. // shotgun blasts give a single big kick
  740. int damage_armor; // damage absorbed by armor
  741. int damage_parmor; // damage absorbed by power armor
  742. int damage_blood; // damage taken out of health
  743. int damage_knockback; // impact damage
  744. vec3_t damage_from; // origin for vector calculation
  745. float killer_yaw; // when dead, look at killer
  746. weaponstate_t weaponstate;
  747. vec3_t kick_angles; // weapon kicks
  748. vec3_t kick_origin;
  749. float v_dmg_roll, v_dmg_pitch, v_dmg_time; // damage kicks
  750. float fall_time, fall_value; // for view drop on fall
  751. float damage_alpha;
  752. float bonus_alpha;
  753. vec3_t damage_blend;
  754. vec3_t v_angle; // aiming direction
  755. float bobtime; // so off-ground doesn't change it
  756. vec3_t oldviewangles;
  757. vec3_t oldvelocity;
  758. float next_drown_time;
  759. int old_waterlevel;
  760. int breather_sound;
  761. int machinegun_shots; // for weapon raising
  762. // animation vars
  763. int anim_end;
  764. int anim_priority;
  765. qboolean anim_duck;
  766. qboolean anim_run;
  767. // powerup timers
  768. float quad_framenum;
  769. float invincible_framenum;
  770. float breather_framenum;
  771. float enviro_framenum;
  772. qboolean grenade_blew_up;
  773. float grenade_time;
  774. int silencer_shots;
  775. int weapon_sound;
  776. float pickup_msg_time;
  777. float flood_locktill; // locked from talking
  778. float flood_when[10]; // when messages were said
  779. int flood_whenhead; // head pointer for when said
  780. float respawn_time; // can respawn when time > this
  781. edict_t *chase_target; // player we are chasing
  782. qboolean update_chase; // need to update chase info?
  783. };
  784. struct edict_s
  785. {
  786. entity_state_t s;
  787. struct gclient_s *client; // NULL if not a player
  788. // the server expects the first part
  789. // of gclient_s to be a player_state_t
  790. // but the rest of it is opaque
  791. qboolean inuse;
  792. int linkcount;
  793. // FIXME: move these fields to a server private sv_entity_t
  794. link_t area; // linked to a division node or leaf
  795. int num_clusters; // if -1, use headnode instead
  796. int clusternums[MAX_ENT_CLUSTERS];
  797. int headnode; // unused if num_clusters != -1
  798. int areanum, areanum2;
  799. //================================
  800. int svflags;
  801. vec3_t mins, maxs;
  802. vec3_t absmin, absmax, size;
  803. solid_t solid;
  804. int clipmask;
  805. edict_t *owner;
  806. // DO NOT MODIFY ANYTHING ABOVE THIS, THE SERVER
  807. // EXPECTS THE FIELDS IN THAT ORDER!
  808. //================================
  809. int movetype;
  810. int flags;
  811. char *model;
  812. float freetime; // sv.time when the object was freed
  813. //
  814. // only used locally in game, not by server
  815. //
  816. char *message;
  817. char *classname;
  818. int spawnflags;
  819. float timestamp;
  820. float angle; // set in qe3, -1 = up, -2 = down
  821. char *target;
  822. char *targetname;
  823. char *killtarget;
  824. char *team;
  825. char *pathtarget;
  826. char *deathtarget;
  827. char *combattarget;
  828. edict_t *target_ent;
  829. float speed, accel, decel;
  830. vec3_t movedir;
  831. vec3_t pos1, pos2;
  832. vec3_t velocity;
  833. vec3_t avelocity;
  834. int mass;
  835. float air_finished;
  836. float gravity; // per entity gravity multiplier (1.0 is normal)
  837. // use for lowgrav artifact, flares
  838. edict_t *goalentity;
  839. edict_t *movetarget;
  840. float yaw_speed;
  841. float ideal_yaw;
  842. float nextthink;
  843. void (*prethink) (edict_t *ent);
  844. void (*think)(edict_t *self);
  845. void (*blocked)(edict_t *self, edict_t *other); //move to moveinfo?
  846. void (*touch)(edict_t *self, edict_t *other, cplane_t *plane, csurface_t *surf);
  847. void (*use)(edict_t *self, edict_t *other, edict_t *activator);
  848. void (*pain)(edict_t *self, edict_t *other, float kick, int damage);
  849. void (*die)(edict_t *self, edict_t *inflictor, edict_t *attacker, int damage, vec3_t point);
  850. float touch_debounce_time; // are all these legit? do we need more/less of them?
  851. float pain_debounce_time;
  852. float damage_debounce_time;
  853. float fly_sound_debounce_time; //move to clientinfo
  854. float last_move_time;
  855. int health;
  856. int max_health;
  857. int gib_health;
  858. int deadflag;
  859. qboolean show_hostile;
  860. float powerarmor_time;
  861. char *map; // target_changelevel
  862. int viewheight; // height above origin where eyesight is determined
  863. int takedamage;
  864. int dmg;
  865. int radius_dmg;
  866. float dmg_radius;
  867. int sounds; //make this a spawntemp var?
  868. int count;
  869. edict_t *chain;
  870. edict_t *enemy;
  871. edict_t *oldenemy;
  872. edict_t *activator;
  873. edict_t *groundentity;
  874. int groundentity_linkcount;
  875. edict_t *teamchain;
  876. edict_t *teammaster;
  877. edict_t *mynoise; // can go in client only
  878. edict_t *mynoise2;
  879. int noise_index;
  880. int noise_index2;
  881. float volume;
  882. float attenuation;
  883. // timing variables
  884. float wait;
  885. float delay; // before firing targets
  886. float random;
  887. float teleport_time;
  888. int watertype;
  889. int waterlevel;
  890. vec3_t move_origin;
  891. vec3_t move_angles;
  892. // move this to clientinfo?
  893. int light_level;
  894. int style; // also used as areaportal number
  895. gitem_t *item; // for bonus items
  896. // common data blocks
  897. moveinfo_t moveinfo;
  898. monsterinfo_t monsterinfo;
  899. };