#include "extdll.h"
#include "util.h"
#include "cbase.h"
#include "monsters.h"
#include "weapons.h"
#include "nodes.h"
#include "effects.h"
#include "aura.h"
#include "classes.h"
#include "magicattack.h"
#include "explodingattack.h"
#include "player.h"
#include "gamerules.h"
#include "chargedattack.h"
#include "melee.h"

extern int gmsgMeleeFX;
extern cvar_t meleeallowed;

/**
* Sword Melee attack system
* @version 24-6-2001
* @author Joseph 'Pcjoe' Florencio
*/
class CSword:public CMelee
{	
public:
	/**
	* Init function
	*/
	void Spawn( void );

	/**
	* Precaches sprites and sounds
	*/
	void Precache( void );

	/**
	* Get melee slot
	* return int: the slot, is 1 for melee
	*/
	int iItemSlot( void ) { return 1; }

	/**
	* Get melee item info
	* @param ItemInfo *p: The ItemInfo gets stored here
	* @return int: Always returns 1 (why???)
	*/
	int GetItemInfo(ItemInfo *p);

	/**
	* Holsters Sword
	*/
	void Holster(int skiplocal);

	/**
	* Deploys the melee attack
	*/
	BOOL Deploy();

};

LINK_ENTITY_TO_CLASS( weapon_sword, CSword );

void CSword::Spawn( void )
{	CMelee::Spawn();
	m_iId = WEAPON_SWORD;

	FallInit();// get ready to fall down.
}

void CSword::Precache( void )
{	// Precache all melee sounds
	CMelee::Precache();
	// Precache sword sounds
	PRECACHE_SOUND("weapons/swordhit.wav");
}

int CSword::GetItemInfo(ItemInfo *p)
{	p->pszName = STRING(pev->classname);
	p->pszAmmo1 = "ki";	//no ki required
	p->iMaxAmmo1 = -1;	//max ammo is weapon independent
	p->pszAmmo2 = NULL;
	p->iMaxAmmo2 = -1;
	p->iMaxClip = WEAPON_NOCLIP;
	p->iSlot = 0;
	p->iPosition = 1;
	p->iId = m_iId = WEAPON_SWORD;
	p->iWeight = SWORD_WEIGHT;
	p->iFlags = 0;
	return 1;
}

BOOL CSword::Deploy( void )
{	return DefaultDeploy( "sword" );
}

void CSword::Holster(int skiplocal=0)
{	CMelee::Holster(0);
}
