g_local.h 29 KB

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