#include "../qcommon/q_shared.h"
#include "bg_public.h"

#define NO_SUBAMMO	-1

weapondefs_t	WPN_Defs[] = 
{
	// NONE
	{
		WP_NONE,
		WEAPON_MELEE,
		WPNPOS_MELEE,
		1.0,			// OBLIGATION, else, death freezes
		NO_SUBAMMO,		// AmmoClip
		AMMO_INFINITE,	// MaxAmmo
		0,0,0,
		{ false, 0, 0 },	// FOV
		0,0					// NextAttack 
	},

	//=====================
	// MELEE WEAPONS
	//=====================

	// Gauntlet
	{
		WP_GAUNTLET,
		WEAPON_MELEE,
		WPNPOS_MELEE,
		1.025,			// Speed modifier
		NO_SUBAMMO,		// AmmoClip
		AMMO_INFINITE,	// MaxAmmo
		0,0,0,
		{ false, 80, 129 },	// FOV
		0, 0.4				// NextAttack 
	},

//
//=====================
// PRIMARY WEAPONS
//=====================
//  

	/*
	-----------------------
	Automatic Weapons
	-----------------------
	*/
	{
		//------- UZI -------
		WP_PRI_UZI,		
		WEAPON_AUTO,
		WPNPOS_PRIMARY,

		0.95,			// Speed modifier
		25, 120,		// Ammo
		300, 1.15, 675, // Spread control

		{ true, 85, 100 },	// FOV

		1.35,
		0.070
	},
	{
		//------- AK47 -------
		WP_PRI_AK47,	
		WEAPON_AUTO,
		WPNPOS_PRIMARY,

		0.87,			// Speed modifier

		30,	 100,		// Ammo		
		150, 1.20, 500,	// Spread control

		{ true, 70, 200 },	// FOV SETTINGS

		1,				// ReloadTime
		0.105			// NextAttack 
	},
	{
		//------- M4 -------
		WP_PRI_M4,
		WEAPON_AUTO,
		WPNPOS_PRIMARY,

		0.83,			// Speed modifier
		30,	100,		// Ammo
		150, 1.20, 375,	// Max Accuracy

		{ true, 75, 150 },	// FOV

		2,				// ReloadTime
		0.0925			// NextAttack 
		
	},
	{
		//------- MP5 -------
		WP_PRI_MP5,
		WEAPON_AUTO,
		WPNPOS_PRIMARY,

		0.90,			// Speed modifier
		25,	75,			// Ammo
		250, 1, 250,	// Max Accuracy

		{ true, 87, 225 },	// FOV

		1.75,				// ReloadTime
		0.125				// NextAttack 
		
	},

	/*
	-----------------------
	SHOTGUNS
	-----------------------
	*/
	{
		WP_PRI_SHOTGUN,
		WEAPON_SEMIAUTO,
		WPNPOS_PRIMARY,

		0.85,			// Speed modifier
		5, 20,			// Ammo	
		500, 1.5, 500,	// Spread control	

		{ false, 0, 129 },	// FOV

		1,				// ReloadTime
		0.80				// NextAttack 
	},
	{
		WP_PRI_LEVER,
		WEAPON_SEMIAUTO,
		WPNPOS_PRIMARY,

		0.88,			// Speed modifier
		3, 27,			// Ammo
		550, 1, 550,	// Spread control

		{ true, 75, 250 },	// FOV

		1,				// ReloadTime
		1.3				// NextAttack 
	},
	{
		WP_PRI_SUPERSHOTGUN,
		WEAPON_SEMIAUTO,
		WPNPOS_PRIMARY,

		0.80,			// Speed modifier
		NO_SUBAMMO,	16,	// Ammo
		1150, 1.1, 1150,// Accuracy Max

		{ false, 0, 129 },	// FOV

		1,				// ReloadTime
		2.5				// NextAttack 
	},
	{
		WP_PRI_AUTOSHOTGUN,
		WEAPON_AUTO,
		WPNPOS_PRIMARY,

		0.85,			// Speed modifier
		8, 24,			// Ammo
		500, 1.5, 500,			

		{ false, 0, 129 },	// FOV

		1,				// ReloadTime
		0.5				// NextAttack 
	},

//----------------

	{
		WP_ROCKET_LAUNCHER,
		WEAPON_SEMIAUTO,
		WPNPOS_PRIMARY,

		0.65,			// Speed modifier
		-1,				// AmmoClip
		5,				// MaxAmmo

		0,0,0,

		{ false, 80, 129 },	// FOV

		0,			// ReloadTime
		3.0				// NextAttack 
	},
	{
		WP_PRI_LOUDSNIPER,
		WEAPON_SEMIAUTO,
		WPNPOS_PRIMARY,
		
		0.80,			// Speed modifier
		5, 15,			// Ammo
		50, 2, 150,

		{ true, 60, 450 },	// FOV

		1,				// ReloadTime
		1.5				// NextAttack 
	},

		{
		WP_MACHINEGUN,
		WEAPON_SEMIAUTO,
		WPNPOS_SECONDARY,

		0.975,			// Speed modifier
		13,	65,			// Ammo
		150, 1.3, 200,	

		{ true, 0, 0 },	// FOV

		1.25,			// ReloadTime
		0.075			// NextAttack 
	},

//
//=====================
// OPTIONNAL EQUIPMENT
//=====================
//  
	{
		//------- Frag. Grenade -------
		WP_GRENADE_LAUNCHER,
		WEAPON_SEMIAUTO,
		WPNPOS_EQUIPMENT,

		0.80,			// Speed modifier
		NO_SUBAMMO,	3,	// Ammo
		0,	0,	0,		// It's a projectile!

		{ false, 0, 0 },	// FOV

		0, 0.8				// NextAttack 
	},

	{
		WP_EQUIP_APMINE,
		WEAPON_SEMIAUTO,
		WPNPOS_EQUIPMENT,
		
		1.0,
		NO_SUBAMMO,	2,	// Ammo
		0, 0, 0,		// It's a projectile!

		{ false, 0, 129 },	// FOV

		1, 1 // NextAttack 
	},
};

int	bg_rox = ARRAY_LEN( WPN_Defs );

/*
==============
WPN_FindWeaponDefinition
==============
*/
weapondefs_t *WPN_FindWeaponDefinition( int weapon ) {
	int		i;

	for ( i = 0 ; i < bg_rox ; i++ ) {
		if ( WPN_Defs[i].iWeaponID == weapon ) {
			return &WPN_Defs[i];
		}
	}
	return NULL;
}

/*
==============
WPN_GetDefaultWeaponClip
Returns the ammoclip necessary
==============
*/
int	WPN_GetDefaultWeaponClip (int weapon)
{
	weapondefs_t	*WPN;
	WPN = WPN_FindWeaponDefinition(weapon);

	return WPN->iAmmoClip;
}
