g_local.h 28 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115
  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 *needpass;
  423. extern cvar_t *g_select_empty;
  424. extern cvar_t *dedicated;
  425. extern cvar_t *filterban;
  426. extern cvar_t *sv_gravity;
  427. extern cvar_t *sv_maxvelocity;
  428. extern cvar_t *gun_x, *gun_y, *gun_z;
  429. extern cvar_t *sv_rollspeed;
  430. extern cvar_t *sv_rollangle;
  431. extern cvar_t *run_pitch;
  432. extern cvar_t *run_roll;
  433. extern cvar_t *bob_up;
  434. extern cvar_t *bob_pitch;
  435. extern cvar_t *bob_roll;
  436. extern cvar_t *sv_cheats;
  437. extern cvar_t *maxclients;
  438. extern cvar_t *maxspectators;
  439. extern cvar_t *flood_msgs;
  440. extern cvar_t *flood_persecond;
  441. extern cvar_t *flood_waitdelay;
  442. extern cvar_t *sv_maplist;
  443. #define world (&g_edicts[0])
  444. // item spawnflags
  445. #define ITEM_TRIGGER_SPAWN 0x00000001
  446. #define ITEM_NO_TOUCH 0x00000002
  447. // 6 bits reserved for editor flags
  448. // 8 bits used as power cube id bits for coop games
  449. #define DROPPED_ITEM 0x00010000
  450. #define DROPPED_PLAYER_ITEM 0x00020000
  451. #define ITEM_TARGETS_USED 0x00040000
  452. //
  453. // fields are needed for spawning from the entity string
  454. // and saving / loading games
  455. //
  456. #define FFL_SPAWNTEMP 1
  457. #define FFL_NOSPAWN 2
  458. typedef enum {
  459. F_INT,
  460. F_FLOAT,
  461. F_LSTRING, // string on disk, pointer in memory, TAG_LEVEL
  462. F_GSTRING, // string on disk, pointer in memory, TAG_GAME
  463. F_VECTOR,
  464. F_ANGLEHACK,
  465. F_EDICT, // index on disk, pointer in memory
  466. F_ITEM, // index on disk, pointer in memory
  467. F_CLIENT, // index on disk, pointer in memory
  468. F_FUNCTION,
  469. F_MMOVE,
  470. F_IGNORE
  471. } fieldtype_t;
  472. typedef struct
  473. {
  474. char *name;
  475. int ofs;
  476. fieldtype_t type;
  477. int flags;
  478. } field_t;
  479. extern field_t fields[];
  480. extern gitem_t itemlist[];
  481. //
  482. // g_cmds.c
  483. //
  484. void Cmd_Help_f (edict_t *ent);
  485. void Cmd_Score_f (edict_t *ent);
  486. //
  487. // g_items.c
  488. //
  489. void PrecacheItem (gitem_t *it);
  490. void InitItems (void);
  491. void SetItemNames (void);
  492. gitem_t *FindItem (char *pickup_name);
  493. gitem_t *FindItemByClassname (char *classname);
  494. #define ITEM_INDEX(x) ((x)-itemlist)
  495. edict_t *Drop_Item (edict_t *ent, gitem_t *item);
  496. void SetRespawn (edict_t *ent, float delay);
  497. void ChangeWeapon (edict_t *ent);
  498. void SpawnItem (edict_t *ent, gitem_t *item);
  499. void Think_Weapon (edict_t *ent);
  500. int ArmorIndex (edict_t *ent);
  501. int PowerArmorType (edict_t *ent);
  502. gitem_t *GetItemByIndex (int index);
  503. qboolean Add_Ammo (edict_t *ent, gitem_t *item, int count);
  504. void Touch_Item (edict_t *ent, edict_t *other, cplane_t *plane, csurface_t *surf);
  505. //
  506. // g_utils.c
  507. //
  508. qboolean KillBox (edict_t *ent);
  509. void G_ProjectSource (vec3_t point, vec3_t distance, vec3_t forward, vec3_t right, vec3_t result);
  510. edict_t *G_Find (edict_t *from, int fieldofs, char *match);
  511. edict_t *findradius (edict_t *from, vec3_t org, float rad);
  512. edict_t *G_PickTarget (char *targetname);
  513. void G_UseTargets (edict_t *ent, edict_t *activator);
  514. void G_SetMovedir (vec3_t angles, vec3_t movedir);
  515. void G_InitEdict (edict_t *e);
  516. edict_t *G_Spawn (void);
  517. void G_FreeEdict (edict_t *e);
  518. void G_TouchTriggers (edict_t *ent);
  519. void G_TouchSolids (edict_t *ent);
  520. char *G_CopyString (char *in);
  521. float *tv (float x, float y, float z);
  522. char *vtos (vec3_t v);
  523. float vectoyaw (vec3_t vec);
  524. void vectoangles (vec3_t vec, vec3_t angles);
  525. //
  526. // g_combat.c
  527. //
  528. qboolean OnSameTeam (edict_t *ent1, edict_t *ent2);
  529. qboolean CanDamage (edict_t *targ, edict_t *inflictor);
  530. 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);
  531. void T_RadiusDamage (edict_t *inflictor, edict_t *attacker, float damage, edict_t *ignore, float radius, int mod);
  532. // damage flags
  533. #define DAMAGE_RADIUS 0x00000001 // damage was indirect
  534. #define DAMAGE_NO_ARMOR 0x00000002 // armour does not protect from this damage
  535. #define DAMAGE_ENERGY 0x00000004 // damage is from an energy based weapon
  536. #define DAMAGE_NO_KNOCKBACK 0x00000008 // do not affect velocity, just view angles
  537. #define DAMAGE_BULLET 0x00000010 // damage is from a bullet (used for ricochets)
  538. #define DAMAGE_NO_PROTECTION 0x00000020 // armor, shields, invulnerability, and godmode have no effect
  539. #define DEFAULT_BULLET_HSPREAD 300
  540. #define DEFAULT_BULLET_VSPREAD 500
  541. #define DEFAULT_SHOTGUN_HSPREAD 1000
  542. #define DEFAULT_SHOTGUN_VSPREAD 500
  543. #define DEFAULT_DEATHMATCH_SHOTGUN_COUNT 12
  544. #define DEFAULT_SHOTGUN_COUNT 12
  545. #define DEFAULT_SSHOTGUN_COUNT 20
  546. //
  547. // g_monster.c
  548. //
  549. void monster_fire_bullet (edict_t *self, vec3_t start, vec3_t dir, int damage, int kick, int hspread, int vspread, int flashtype);
  550. 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);
  551. void monster_fire_blaster (edict_t *self, vec3_t start, vec3_t dir, int damage, int speed, int flashtype, int effect);
  552. void monster_fire_grenade (edict_t *self, vec3_t start, vec3_t aimdir, int damage, int speed, int flashtype);
  553. void monster_fire_rocket (edict_t *self, vec3_t start, vec3_t dir, int damage, int speed, int flashtype);
  554. void monster_fire_railgun (edict_t *self, vec3_t start, vec3_t aimdir, int damage, int kick, int flashtype);
  555. void monster_fire_bfg (edict_t *self, vec3_t start, vec3_t aimdir, int damage, int speed, int kick, float damage_radius, int flashtype);
  556. void M_droptofloor (edict_t *ent);
  557. void monster_think (edict_t *self);
  558. void walkmonster_start (edict_t *self);
  559. void swimmonster_start (edict_t *self);
  560. void flymonster_start (edict_t *self);
  561. void AttackFinished (edict_t *self, float time);
  562. void monster_death_use (edict_t *self);
  563. void M_CatagorizePosition (edict_t *ent);
  564. qboolean M_CheckAttack (edict_t *self);
  565. void M_FlyCheck (edict_t *self);
  566. void M_CheckGround (edict_t *ent);
  567. //
  568. // g_misc.c
  569. //
  570. void ThrowHead (edict_t *self, char *gibname, int damage, int type);
  571. void ThrowClientHead (edict_t *self, int damage);
  572. void ThrowGib (edict_t *self, char *gibname, int damage, int type);
  573. void BecomeExplosion1(edict_t *self);
  574. //
  575. // g_ai.c
  576. //
  577. void AI_SetSightClient (void);
  578. void ai_stand (edict_t *self, float dist);
  579. void ai_move (edict_t *self, float dist);
  580. void ai_walk (edict_t *self, float dist);
  581. void ai_turn (edict_t *self, float dist);
  582. void ai_run (edict_t *self, float dist);
  583. void ai_charge (edict_t *self, float dist);
  584. int range (edict_t *self, edict_t *other);
  585. void FoundTarget (edict_t *self);
  586. qboolean infront (edict_t *self, edict_t *other);
  587. qboolean visible (edict_t *self, edict_t *other);
  588. qboolean FacingIdeal(edict_t *self);
  589. //
  590. // g_weapon.c
  591. //
  592. void ThrowDebris (edict_t *self, char *modelname, float speed, vec3_t origin);
  593. qboolean fire_hit (edict_t *self, vec3_t aim, int damage, int kick);
  594. void fire_bullet (edict_t *self, vec3_t start, vec3_t aimdir, int damage, int kick, int hspread, int vspread, int mod);
  595. void fire_shotgun (edict_t *self, vec3_t start, vec3_t aimdir, int damage, int kick, int hspread, int vspread, int count, int mod);
  596. void fire_blaster (edict_t *self, vec3_t start, vec3_t aimdir, int damage, int speed, int effect, qboolean hyper);
  597. void fire_grenade (edict_t *self, vec3_t start, vec3_t aimdir, int damage, int speed, float timer, float damage_radius);
  598. void fire_grenade2 (edict_t *self, vec3_t start, vec3_t aimdir, int damage, int speed, float timer, float damage_radius, qboolean held);
  599. void fire_rocket (edict_t *self, vec3_t start, vec3_t dir, int damage, int speed, float damage_radius, int radius_damage);
  600. void fire_rail (edict_t *self, vec3_t start, vec3_t aimdir, int damage, int kick);
  601. void fire_bfg (edict_t *self, vec3_t start, vec3_t dir, int damage, int speed, float damage_radius);
  602. //
  603. // g_ptrail.c
  604. //
  605. void PlayerTrail_Init (void);
  606. void PlayerTrail_Add (vec3_t spot);
  607. void PlayerTrail_New (vec3_t spot);
  608. edict_t *PlayerTrail_PickFirst (edict_t *self);
  609. edict_t *PlayerTrail_PickNext (edict_t *self);
  610. edict_t *PlayerTrail_LastSpot (void);
  611. //
  612. // g_client.c
  613. //
  614. void respawn (edict_t *ent);
  615. void BeginIntermission (edict_t *targ);
  616. void PutClientInServer (edict_t *ent);
  617. void InitClientPersistant (gclient_t *client);
  618. void InitClientResp (gclient_t *client);
  619. void InitBodyQue (void);
  620. void ClientBeginServerFrame (edict_t *ent);
  621. //
  622. // g_player.c
  623. //
  624. void player_pain (edict_t *self, edict_t *other, float kick, int damage);
  625. void player_die (edict_t *self, edict_t *inflictor, edict_t *attacker, int damage, vec3_t point);
  626. //
  627. // g_svcmds.c
  628. //
  629. void ServerCommand (void);
  630. qboolean SV_FilterPacket (char *from);
  631. //
  632. // p_view.c
  633. //
  634. void ClientEndServerFrame (edict_t *ent);
  635. //
  636. // p_hud.c
  637. //
  638. void MoveClientToIntermission (edict_t *client);
  639. void G_SetStats (edict_t *ent);
  640. void G_SetSpectatorStats (edict_t *ent);
  641. void G_CheckChaseStats (edict_t *ent);
  642. void ValidateSelectedItem (edict_t *ent);
  643. void DeathmatchScoreboardMessage (edict_t *client, edict_t *killer);
  644. //
  645. // g_pweapon.c
  646. //
  647. void PlayerNoise(edict_t *who, vec3_t where, int type);
  648. //
  649. // m_move.c
  650. //
  651. qboolean M_CheckBottom (edict_t *ent);
  652. qboolean M_walkmove (edict_t *ent, float yaw, float dist);
  653. void M_MoveToGoal (edict_t *ent, float dist);
  654. void M_ChangeYaw (edict_t *ent);
  655. //
  656. // g_phys.c
  657. //
  658. void G_RunEntity (edict_t *ent);
  659. //
  660. // g_main.c
  661. //
  662. void SaveClientData (void);
  663. void FetchClientEntData (edict_t *ent);
  664. //
  665. // g_chase.c
  666. //
  667. void UpdateChaseCam(edict_t *ent);
  668. void ChaseNext(edict_t *ent);
  669. void ChasePrev(edict_t *ent);
  670. void GetChaseTarget(edict_t *ent);
  671. //============================================================================
  672. // client_t->anim_priority
  673. #define ANIM_BASIC 0 // stand / run
  674. #define ANIM_WAVE 1
  675. #define ANIM_JUMP 2
  676. #define ANIM_PAIN 3
  677. #define ANIM_ATTACK 4
  678. #define ANIM_DEATH 5
  679. #define ANIM_REVERSE 6
  680. // client data that stays across multiple level loads
  681. typedef struct
  682. {
  683. char userinfo[MAX_INFO_STRING];
  684. char netname[16];
  685. int hand;
  686. qboolean connected; // a loadgame will leave valid entities that
  687. // just don't have a connection yet
  688. // values saved and restored from edicts when changing levels
  689. int health;
  690. int max_health;
  691. int savedFlags;
  692. int selected_item;
  693. int inventory[MAX_ITEMS];
  694. // ammo capacities
  695. int max_bullets;
  696. int max_shells;
  697. int max_rockets;
  698. int max_grenades;
  699. int max_cells;
  700. int max_slugs;
  701. gitem_t *weapon;
  702. gitem_t *lastweapon;
  703. int power_cubes; // used for tracking the cubes in coop games
  704. int score; // for calculating total unit score in coop games
  705. int game_helpchanged;
  706. int helpchanged;
  707. qboolean spectator; // client is a spectator
  708. } client_persistant_t;
  709. // client data that stays across deathmatch respawns
  710. typedef struct
  711. {
  712. client_persistant_t coop_respawn; // what to set client->pers to on a respawn
  713. int enterframe; // level.framenum the client entered the game
  714. int score; // frags, etc
  715. vec3_t cmd_angles; // angles sent over in the last command
  716. qboolean spectator; // client is a spectator
  717. } client_respawn_t;
  718. // this structure is cleared on each PutClientInServer(),
  719. // except for 'client->pers'
  720. struct gclient_s
  721. {
  722. // known to server
  723. player_state_t ps; // communicated by server to clients
  724. int ping;
  725. // private to game
  726. client_persistant_t pers;
  727. client_respawn_t resp;
  728. pmove_state_t old_pmove; // for detecting out-of-pmove changes
  729. qboolean showscores; // set layout stat
  730. qboolean showinventory; // set layout stat
  731. qboolean showhelp;
  732. qboolean showhelpicon;
  733. int ammo_index;
  734. int buttons;
  735. int oldbuttons;
  736. int latched_buttons;
  737. qboolean weapon_thunk;
  738. gitem_t *newweapon;
  739. // sum up damage over an entire frame, so
  740. // shotgun blasts give a single big kick
  741. int damage_armor; // damage absorbed by armor
  742. int damage_parmor; // damage absorbed by power armor
  743. int damage_blood; // damage taken out of health
  744. int damage_knockback; // impact damage
  745. vec3_t damage_from; // origin for vector calculation
  746. float killer_yaw; // when dead, look at killer
  747. weaponstate_t weaponstate;
  748. vec3_t kick_angles; // weapon kicks
  749. vec3_t kick_origin;
  750. float v_dmg_roll, v_dmg_pitch, v_dmg_time; // damage kicks
  751. float fall_time, fall_value; // for view drop on fall
  752. float damage_alpha;
  753. float bonus_alpha;
  754. vec3_t damage_blend;
  755. vec3_t v_angle; // aiming direction
  756. float bobtime; // so off-ground doesn't change it
  757. vec3_t oldviewangles;
  758. vec3_t oldvelocity;
  759. float next_drown_time;
  760. int old_waterlevel;
  761. int breather_sound;
  762. int machinegun_shots; // for weapon raising
  763. // animation vars
  764. int anim_end;
  765. int anim_priority;
  766. qboolean anim_duck;
  767. qboolean anim_run;
  768. // powerup timers
  769. float quad_framenum;
  770. float invincible_framenum;
  771. float breather_framenum;
  772. float enviro_framenum;
  773. qboolean grenade_blew_up;
  774. float grenade_time;
  775. int silencer_shots;
  776. int weapon_sound;
  777. float pickup_msg_time;
  778. float flood_locktill; // locked from talking
  779. float flood_when[10]; // when messages were said
  780. int flood_whenhead; // head pointer for when said
  781. float respawn_time; // can respawn when time > this
  782. edict_t *chase_target; // player we are chasing
  783. qboolean update_chase; // need to update chase info?
  784. };
  785. struct edict_s
  786. {
  787. entity_state_t s;
  788. struct gclient_s *client; // NULL if not a player
  789. // the server expects the first part
  790. // of gclient_s to be a player_state_t
  791. // but the rest of it is opaque
  792. qboolean inuse;
  793. int linkcount;
  794. // FIXME: move these fields to a server private sv_entity_t
  795. link_t area; // linked to a division node or leaf
  796. int num_clusters; // if -1, use headnode instead
  797. int clusternums[MAX_ENT_CLUSTERS];
  798. int headnode; // unused if num_clusters != -1
  799. int areanum, areanum2;
  800. //================================
  801. int svflags;
  802. vec3_t mins, maxs;
  803. vec3_t absmin, absmax, size;
  804. solid_t solid;
  805. int clipmask;
  806. edict_t *owner;
  807. // DO NOT MODIFY ANYTHING ABOVE THIS, THE SERVER
  808. // EXPECTS THE FIELDS IN THAT ORDER!
  809. //================================
  810. int movetype;
  811. int flags;
  812. char *model;
  813. float freetime; // sv.time when the object was freed
  814. //
  815. // only used locally in game, not by server
  816. //
  817. char *message;
  818. char *classname;
  819. int spawnflags;
  820. float timestamp;
  821. float angle; // set in qe3, -1 = up, -2 = down
  822. char *target;
  823. char *targetname;
  824. char *killtarget;
  825. char *team;
  826. char *pathtarget;
  827. char *deathtarget;
  828. char *combattarget;
  829. edict_t *target_ent;
  830. float speed, accel, decel;
  831. vec3_t movedir;
  832. vec3_t pos1, pos2;
  833. vec3_t velocity;
  834. vec3_t avelocity;
  835. int mass;
  836. float air_finished;
  837. float gravity; // per entity gravity multiplier (1.0 is normal)
  838. // use for lowgrav artifact, flares
  839. edict_t *goalentity;
  840. edict_t *movetarget;
  841. float yaw_speed;
  842. float ideal_yaw;
  843. float nextthink;
  844. void (*prethink) (edict_t *ent);
  845. void (*think)(edict_t *self);
  846. void (*blocked)(edict_t *self, edict_t *other); //move to moveinfo?
  847. void (*touch)(edict_t *self, edict_t *other, cplane_t *plane, csurface_t *surf);
  848. void (*use)(edict_t *self, edict_t *other, edict_t *activator);
  849. void (*pain)(edict_t *self, edict_t *other, float kick, int damage);
  850. void (*die)(edict_t *self, edict_t *inflictor, edict_t *attacker, int damage, vec3_t point);
  851. float touch_debounce_time; // are all these legit? do we need more/less of them?
  852. float pain_debounce_time;
  853. float damage_debounce_time;
  854. float fly_sound_debounce_time; //move to clientinfo
  855. float last_move_time;
  856. int health;
  857. int max_health;
  858. int gib_health;
  859. int deadflag;
  860. qboolean show_hostile;
  861. float powerarmor_time;
  862. char *map; // target_changelevel
  863. int viewheight; // height above origin where eyesight is determined
  864. int takedamage;
  865. int dmg;
  866. int radius_dmg;
  867. float dmg_radius;
  868. int sounds; //make this a spawntemp var?
  869. int count;
  870. edict_t *chain;
  871. edict_t *enemy;
  872. edict_t *oldenemy;
  873. edict_t *activator;
  874. edict_t *groundentity;
  875. int groundentity_linkcount;
  876. edict_t *teamchain;
  877. edict_t *teammaster;
  878. edict_t *mynoise; // can go in client only
  879. edict_t *mynoise2;
  880. int noise_index;
  881. int noise_index2;
  882. float volume;
  883. float attenuation;
  884. // timing variables
  885. float wait;
  886. float delay; // before firing targets
  887. float random;
  888. float teleport_time;
  889. int watertype;
  890. int waterlevel;
  891. vec3_t move_origin;
  892. vec3_t move_angles;
  893. // move this to clientinfo?
  894. int light_level;
  895. int style; // also used as areaportal number
  896. gitem_t *item; // for bonus items
  897. // common data blocks
  898. moveinfo_t moveinfo;
  899. monsterinfo_t monsterinfo;
  900. };