Quake-2

Quake 2 GPL Source Release
Log | Files | Refs

g_local.h (28552B)


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