#ifndef	AI_WEAPONS_H
#define	AI_WEAPONS_H

//////////////////////////////////////////////////////////////////////////////////
//	generalized functions for attacking monsters
//////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////
//	defines
////////////////////////////////////////////////////////////////////////////////

#define	WEAPON_PROJECTILE	0x00000001
#define	WEAPON_TRACE		0x00000002
#define	WEAPON_BULLET		0x00000004
#define	WEAPON_EXPLOSIVE	0x00000008	//	smart monsters will try for splash damage

////////////////////////////////////////////////////////////////////////////////
//	typedefs
////////////////////////////////////////////////////////////////////////////////

typedef struct
{
	// first seven fields must be the same
	char    *name;
	void    (*use)(struct userInventory_s *ptr, userEntity_t *user);
	void	*(*command)(struct userInventory_s *ptr, char *commandStr, void *data);
	void   *precache;
	void   *dummy3;
	void   *dummy4;

	ammo_t  *ammo;

	int		base_damage;
	int		rnd_damage;
	int		distance;

	float	spread_x;
	float	spread_z;
	float	speed;
	
	Vector	ofs;

	unsigned	long	flags;
} ai_weapon_t;

////////////////////////////////////////////////////////////////////////////////
//	prototypes
////////////////////////////////////////////////////////////////////////////////

void			ai_lead_target (userEntity_t *targ, Vector org, float speed, Vector &predicted_org);

void			ai_fire_bullet (userEntity_t *self, userEntity_t *target, ai_weapon_t *weapon);

int				ai_check_projectile_attack (userEntity_t *self, userEntity_t *target, ai_weapon_t *weapon, float min_dist);
userEntity_t	*ai_fire_projectile (userEntity_t *self, userEntity_t *target, ai_weapon_t *weapon, char *model, touch_t touch, unsigned long fx);

userEntity_t	*ai_trace_attack ( userEntity_t *self, ai_weapon_t *weapon);

////////////////////////////////////////////////////////////////////////////////
//	monster weapons
////////////////////////////////////////////////////////////////////////////////

void			psiblast_fire (userInventory_s *ptr, userEntity_t *self);
void			melee_punch (userInventory_s *ptr, userEntity_t *self);
void			melee_swing (userInventory_s *ptr, userEntity_t *self);
void			chaingun_fire (userInventory_s *ptr, userEntity_t *self);
void			boargun_fire (userInventory_s *ptr, userEntity_t *self);
void			dart_fire (userInventory_s *ptr, userEntity_t *self);
void			dart_strafe_fire (userInventory_s *ptr, userEntity_t *self);
void			poison_bite_mild (userInventory_s *ptr, userEntity_t *self);
void			poison_bubble (userInventory_s *ptr, userEntity_t *self);
void			rocket_attack (userInventory_s *ptr, userEntity_t *self);
void			magic_arrow_attack (userInventory_s *ptr, userEntity_t *self);
void			laser_fire (userInventory_s *ptr, userEntity_t *self);
void			sludge_attack (userInventory_s *ptr, userEntity_t *self);
void			wack_back (userInventory_s *ptr, userEntity_t *self);
void			wack_left (userInventory_s *ptr, userEntity_t *self);
void			wack_right (userInventory_s *ptr, userEntity_t *self);

void			ai_fire_curWeapon (userEntity_t *self, Vector org, Vector end, float spread_x, float spread_z);
userInventory_t	*ai_weapon_create (char	*weapon_name, weaponUse_t use_func, weaponCommand_t command_func);
void			*ai_weapon_command (struct userInventory_s *ptr, char *commandStr, void *data);

void			ai_init_weapons (void);
userInventory_t	*ai_init_weapon (userEntity_t *self, float base_damage, float rnd_damage,
						float spread_x, float spread_z, float speed, float dist, Vector ofs, 
						char *name, weaponUse_t use_func, unsigned long flags);

#endif