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