/***
*
*	Copyright (c) 1996-2002, Valve LLC. All rights reserved.
*	
*	This product contains software technology licensed from Id 
*	Software, Inc. ("Id Technology").  Id Technology (c) 1996 Id Software, Inc. 
*	All Rights Reserved.
*
*   Use, distribution, and modification of this source code and/or resulting
*   object code is restricted to non-commercial enhancements to products from
*   Valve LLC.  All other use, distribution, or modification is prohibited
*   without written permission from Valve LLC.
*
****/
#ifndef PLAYER_H
#define PLAYER_H
#define TURBO_PL_MULTIPLIER 1.25
#define	CLASS_CHANGE_DELAY	2.0
// Edited by Pcjoe
//#define	TEAM_CHANGE_DELAY	2.0
#define	TEAM_CHANGE_DELAY	10.0
#define MAXPL 999999999

#include "pm_materials.h"
// Added by Pcjoe
#include "magicattack.h"
#include "explodingattack.h"
#include "playermelee.h"
#include "swoop.h"
#include "chargedturbo.h"
#include "classes.h"

// IAN:: moved this here so Ginyu.cpp could know about it
#define ASCEND_KI_COST					100			//cost of ascending
// IAN::

/* modified by harSens
#define PLAYER_FATAL_FALL_SPEED		1024// approx 60 feet
#define PLAYER_MAX_SAFE_FALL_SPEED	580// approx 20 feet
#define DAMAGE_FOR_FALL_SPEED		(float) 100 / ( PLAYER_FATAL_FALL_SPEED - PLAYER_MAX_SAFE_FALL_SPEED )// damage per unit per second.
#define PLAYER_MIN_BOUNCE_SPEED		200
#define PLAYER_FALL_PUNCH_THRESHHOLD (float)350 // won't punch player's screen/make scrape noise unless player falling at least this fast.
*/
#define PLAYER_FATAL_FALL_SPEED		3000// approx 60 feet
#define PLAYER_MAX_SAFE_FALL_SPEED	2000// approx 20 feet
#define DAMAGE_FOR_FALL_SPEED		(float) 100 / ( PLAYER_FATAL_FALL_SPEED - PLAYER_MAX_SAFE_FALL_SPEED )// damage per unit per second.
#define PLAYER_MIN_BOUNCE_SPEED		200
#define PLAYER_FALL_PUNCH_THRESHHOLD (float)350 // won't punch player's screen/make scrape noise unless player falling at least this fast.

//added by harSens
#define PLAYER_BLOCKANGLE 75
#define BLOCKSTRUGGLE_POWER	4

#define CHANGEPL_RATIO 0.75


//
// Player PHYSICS FLAGS bits
//
#define		PFLAG_ONLADDER		( 1<<0 )
#define		PFLAG_ONSWING		( 1<<0 )
#define		PFLAG_ONTRAIN		( 1<<1 )
#define		PFLAG_ONBARNACLE	( 1<<2 )
/* disabled by harSens
#define		PFLAG_DUCKING		( 1<<3 )		// In the process of ducking, but totally squatted yet
*/
#define		PFLAG_USING			( 1<<4 )		// Using a continuous entity
#define		PFLAG_OBSERVER		( 1<<5 )		// player is locked in stationary cam mode. Spectators can move, observers can't.

//
// generic player
//
//-----------------------------------------------------
//This is Half-Life player entity
//-----------------------------------------------------
#define CSUITPLAYLIST	4		// max of 4 suit sentences queued up at any time

#define SUIT_GROUP			TRUE
#define	SUIT_SENTENCE		FALSE

#define	SUIT_REPEAT_OK		0
#define SUIT_NEXT_IN_30SEC	30
#define SUIT_NEXT_IN_1MIN	60
#define SUIT_NEXT_IN_5MIN	300
#define SUIT_NEXT_IN_10MIN	600
#define SUIT_NEXT_IN_30MIN	1800
#define SUIT_NEXT_IN_1HOUR	3600

#define CSUITNOREPEAT		32

/* removed by harSens
#define	SOUND_FLASHLIGHT_ON		"items/flashlight1.wav"
#define	SOUND_FLASHLIGHT_OFF	"items/flashlight1.wav"
*/
#define PLDROP_HEALTH					 5

#define TEAM_NAME_LENGTH	16

/* modified by harSens
typedef enum
{
	PLAYER_IDLE,
	PLAYER_WALK,
	PLAYER_JUMP,
	PLAYER_SUPERJUMP,
	PLAYER_DIE,
	PLAYER_ATTACK1,
}PLAYER_ANIM;
*/
typedef enum
{
	PLAYER_NULL = 0,	
	PLAYER_JUMP,
	PLAYER_SUPERJUMP,
	PLAYER_BACKFLIP,
	PLAYER_DIE,
	PLAYER_ATTACK1,
	PLAYER_ATTACK2,
	PLAYER_SWATAWAY_LEFT,
	PLAYER_SWATAWAY_RIGHT,
	PLAYER_SWATAWAY_FORWARD,
	PLAYER_WRAP
} PLAYER_ANIM;

//added by harSens
typedef enum
{	ANIM_NONE = 0,
	ANIM_REF,
	ANIM_FLY
} ANIM_FLAGS;

// added by Pcjoe
typedef enum
{ 
	TRANS_NONE,
	TRANS_SHORT,
	TRANS_NORM,
	TRANS_LONG
} TRANS_STATUS;

// added by Pcjoe
enum meleefx
{	MELEE_SIMPLE=1,
	MELEE_PREPUNCH,
	MELEE_ENDSHOCKWAVE,
};

enum BuddyMood
{
	buddyMimic,
	buddyAttack,
	buddyDefend
};

// added by Rick
struct old_position_s
{
	Vector Pos;
	float flCreateTime;
};

#define MAX_ID_RANGE 2048
#define SBAR_STRING_SIZE 128

enum sbar_data
{
	SBAR_ID_TARGETNAME = 1,
	SBAR_ID_TARGETHEALTH,
	SBAR_ID_TARGETARMOR,
	SBAR_END,
};
#define CHAT_INTERVAL 1.0f
#define TRANSFORM_TIME 10

// Added by Rick
#define MAX_OLD_POSITIONS			5
#define MAX_OLD_POSITION_LIFE_TIME	15.0
#define MIN_NEW_POSITION_DIST		200.0
// end add by Rick

//added by harSens
class CPowerStruggle;
// added by Rick
class CBuddy;

class CBasePlayer : public CBaseMonster
{
public:
	int					random_seed;    // See that is shared between client & server for shared weapons code

	int					m_iPlayerSound;// the index of the sound list slot reserved for this player
	int					m_iTargetVolume;// ideal sound volume. 
	int					m_iWeaponVolume;// how loud the player's weapon is right now.
	int					m_iExtraSoundTypes;// additional classification for this weapon's sound
	int					m_iWeaponFlash;// brightness of the weapon flash
	float				m_flStopExtraSoundTime;
	
	/* removed by harSens
	float				m_flFlashLightTime;	// Time until next battery draw/Recharge
	int					m_iFlashBattery;		// Flashlight Battery Draw
	*/

	int					m_afButtonLast;
	int					m_afButtonPressed;
	int					m_afButtonReleased;
	
	edict_t			   *m_pentSndLast;			// last sound entity to modify player room type
	float				m_flSndRoomtype;		// last roomtype set by sound entity
	float				m_flSndRange;			// dist from player to sound entity

	float				m_flFallVelocity;
	
	int					m_rgItems[MAX_ITEMS];
	int					m_fKnownItem;		// True when a new item needs to be added
	int					m_fNewAmmo;			// True when a new item has been added

	unsigned int		m_afPhysicsFlags;	// physics flags - set when 'normal' physics should be revisited or overriden
	float				m_fNextSuicideTime; // the time after which the player can next use the suicide command

	//added by harSens
	BOOL				m_fAimAnimation;		//play aim ani?
	BOOL				m_fBurning;				//burned by burning attack?
	CBasePlayer			*m_pBurner;				//burner
	float				m_flKiUpdate;			//time of last ki update
	float				m_flBlindedTime;		//time when blinded
	BOOL				m_fFlying;				//set when flying
	BOOL				m_fTurbo;				//set when in turbo mode
	BOOL				m_fObserverFlag;		//set when in observer mode
	//BOOL				m_fRandomClass;			//set when player is a random class
	BOOL				m_fBlock;				//set when the player is in blocking mode
	BOOL				m_fPowerUp;				//set when the player is in powerup mode
	BOOL				m_fExhausted;			//set when out of stamina
	float				m_flExhaustedTime;		//set at start of exhaust
	BOOL				m_fCharging;			//set when the player is charging a wave attack
	BOOL				m_fCharging2;			//set when the player is using the secondary charge of an attack
	BOOL				m_fControl;				//set when guiding a magicattack
	BOOL				m_fHoldDisc;			//set when the player holds a disk
	BOOL				m_fBlinded;				//set when the player is blinded by a solarflare
	BOOL				m_fWishing;				//set when the player made a wish
	BOOL				m_fInvulnerable;		//set when invulnerable
	BOOL				m_fSpawnInvulnerable;	//set when spawned
	BOOL				m_fPowerStruggling;		//set when the player is power struggling
	BOOL				m_fBlockStruggling;		//set when the player is struggling with an attack
	BOOL				m_fBlockStruggleAttacker; //set when the player is on the attacking end of a bs
	BOOL				m_fStrangled;			//strangled by buu's bodypart
	BOOL				m_fBecomeCandy;			//becoming a candy
	BOOL				m_fChargeNamekSB;		//charging a namek-style sb (OMG this is ugly)
	CPowerStruggle		*m_pPowerStruggle;		//the powerstruggle your participating in
	float				m_flPowerLevelMultiplier;//pl multiplier
	// Added by Pcjoe
	BOOL				m_fInitHUDMap;			// Reset hud info on level change
	BOOL				m_fAddWepAfterTrans;	//set when the player is controlling a beam + transforming
	BOOL				m_fMelee;				// Melee in General
	CPlayerMelee		m_Melee;				// Player Melee
	CSwoop				m_Swoop;				// Swoop
	CChargedTurbo		m_ChargedTurbo;			// Charged Turbo

	// General Stuff
	int					m_iTransformStatus;		// Transform status
	int					m_iNextSubModel;		// Sub model index
	int					m_iBody;				// Sub model, set here just in case we need to reset pev->body
	float				m_flIdleTime;			// how long the person was in "idle" for, to enable deep idle
	float				m_flBlobTime[2];		// The time the blobs were fired off
	float				m_flSubModelDelay;		// The delay between sub model changes
	float				m_flLastTeleport;		// Last Teleport
	char				m_szCurrentModel[256];	// Current model we have set (for the client)
	char				m_szCustomModel[256];	// Custom Model
	BOOL				m_fSword;				// Do we have the sword out?
	Vector				m_vecBlob[2];			// The Last positions where ki blast exploded
	// Used for Gohans shield only
	BOOL				m_fShield;				// If shield is active or not
	float				m_flDragonBallPickup;	// Dragonball pickup time
	// added by Rick
	float				m_flDragonballDrop;		// Dragonball drop time
	BOOL				m_fInJump;				// In Jump ( Used for Walljump )
	BOOL				m_fWallJump;			// Currently wall jumping
	// Transform Status
	enum { TRANS_NEVER, TRANS_FIRST, TRANS_FIRST_DONE} m_eTransStatus;
	// Auth status
	BOOL				m_fAuthed;				// Currently authorized
	float				m_flAuthTimer;			// Time at our first auth attempt - only allow so long for the id to pend

	// end of add by Pcjoe

	// Added by Rick
	int					m_iChargePercent;		// Percent that this player charged
	old_position_s		m_OldPositions[MAX_OLD_POSITIONS]; // Contains previous locations of this player
	float				m_flOldPosUpdateDelay;
	EHANDLE				m_pSPSpawnPoint; // Last SP spawnpoint entity 'used'
	// end of add by Rick

	CBasePlayer			*m_pCandyVictim;		//victim of the candy attack
	// Added by Rick
	CBuddy				*m_pBuddyCandyVictim;	//buddy victim of the candy attack
	// end of add by Rick
	float				m_flCandyCounter;		//time to release the victim yet?
	int					m_iBlockPoints;			//the number of block points
	float				m_flNextBlockStruggle;
	int					m_iWishes;				//#wishes done by player
	float				m_flInvulnerableTime;	//time till invulnerable time is over
	int					m_iClientSpeed;			//What the client thinks the player's max speed is 
	int					m_iClientStamina;		//What the client thinks the stamina is
	int					m_iStamina;				//The stamina
	int					m_iPowerLevel;			//The powerlevel for the character
	int					m_iMaxPowerLevel;		//The max powerlevel for the character
	int					m_iMaxSpeed;			//max speed for the character
	int					m_iClientPowerLevel;	//What the client thinks is the powerlevel
	float				m_flSlowDown;			//Slowdown compared to normal speed. needed for block, charge, powerup, etc
	short				m_sModelIndexTurbo;		//the turbo aura
	int					m_iSensuBeans;			//the nr of senzubeans the player has
	int					m_iDragonball;			//the nr of the dragonball the player is holding (0 for none)
	CBaseClass			*m_pClass; 				//class of the player
	CBaseClass			*m_pNextClass;			//The next class of the player
	CAura				*m_pAura;				//the aura for this player	
	BOOL				m_fAscending;			//player is transforming
	float				m_flAscendTime;			//time at wich transformation is complete
	PLAYER_ANIM			m_eAnimationTrigger;	//trigger for triggered animations
	ANIM_FLAGS			m_eAnimationFlags;		//flags for the animation
	CExplodingAttack	*m_pBlockStruggler;		//the attack to blockstruggle agains
	int					m_fSwat;				//swatting an attack
	EHANDLE				m_hSpectatorTarget;		//observer to follow
	float				m_flNextSpectatorInput;	//time when the observer can input again
	BOOL				m_fSelfKill;
	float				m_flLastClassChange;	//last class change time
	float				m_flLastTeamChange;		//last team change
	Vector				m_vecLastAngles;		//last angles

	// ADDED BY IAN
	CBuddy			    *m_hBuddy;				//if we can have a buddy, you'll find him/herS here
	bool				m_bHadBuddy;
	BuddyMood			m_eBuddyMood;
	// ADDED BY IAN
	
	//Added by DragonDude
	float				m_flSenzuPercent;		//percent until next senzu bean is awarded to this player

	int					IsSpectator() { return pev->iuser1; };

	/**
	 * Starts spectator mode
	 */
	void StartSpectator( Vector vecPosition, Vector vecViewAngle );
	
	/**
	 * Stops observer mode
	 */
	void StopSpectator( void );

	/**
	 * Handles buttons pressed in observer mode	 
	 */
	void Spectator_HandleButtons();

	/**
	 * Finds the next player (in spectator mode)
	 * @param bReverse: search backward
	 */
	void Spectator_FindNextPlayer( bool bReverse );

	/**
	 * Set the observer mode
	 * @param mode: new observermode
	 */
	void Spectator_SetMode( int iMode );

	/**
	 * Increase the pl of a player, keeping it below MAXPL
	 * @param int increase: amount to add
	 */
	void IncreasePL(int increase);

	/**
	 * Sets the pl of the player, keeping it below MAXPL
	 * @param int pl: new pl
	 */
	void SetPowerLevel(int pl);

	/**
	 * Checks if a certain amount of stamina is available
	 * @param int amount: amount of stamina to use
	 * @return BOOL: enough stamina
	 */	
	BOOL HasStamina(int amount);

	/**
	 * Checks if a certain amount of ki is available
	 * @param int amount: amount of ki to use
	 * @return BOOL: enough ki
	 */	
	BOOL HasKi(int amount);
	
	/**
	 * Use an amount of ki, keeping ki-efficiency into consideration
	 * @param int amount: amount of ki to use
	 * @return BOOL: enough ki to use?
	 */
	BOOL UseKi(int amount);

	/**
	 * Use an amount of stamina, keeping stamina-efficiency into consideration
	 * @param int amount: amount of stamina to use
	 * @return BOOL: enough stamina to use?
	 */	
	BOOL UseStamina(int amount);

	/**
	 * Get the maximum PL potential of this player
	 * @return the potential pl
	 */
	int GetPotentialPL();
	
	/**
	* waits to become candy
	* @param CBasePlayer *m_pAttacker: the one who attacked you
	*/
	void WaitToBecomeCandy(CBasePlayer *m_pAttacker);

	/**
	* release a player from becoming candy
	*/
	void ReleaseCandy();

	/**
	* become a candy
	* @param const char *candy: the sort of candy to become
	* @param CBaseEntity *attacker: the one turning you into candy
	*/
	BOOL BecomeCandy(const char *candy, CBaseEntity *attacker);

	/**
	* makes a candy from the victim
	* @param const char *candy: the sort of candy to become
	*/
	BOOL MakeCandy(const char *candy);

	/**
	* Pcjoe: Remove Special Modes
	*/
	void RemoveSpecialModes( void );
	
	/**
	* Pcjoe: Can play forward walk/run animation
	*/
	BOOL CanPlayForwardWalk( void );

	/**
	* Plays the full body animation
	* @return int: true:playing full body animation
	*/
	int PlayFullBodyAnimation(void);

	/**
	 * checks for animation triggers to remove	
	 */
	void RemoveAnimationTriggers();

	/**
	* Gets the upper body animation
	* @param int &iFrame: the frame for the upper body ani
	* @return int: the upper body animation
	*/
	int GetUpperBodyAnimation(int &iFrame);

	/**
	* Gets the lower body animation
	* @return int: the lower body animation
	*/
	int GetLowerBodyAnimation(void);

	/**
	* Sets the animation
	*/
	void PlayAnimation(void);

	/**
	* teleports
	*/
	void Teleport( void );

	/**
	* starts turbo mode
	*/
	void StartTurbo ( void );

	/**
	* stop turbo mode
	*/
	void StopTurbo ( void );

	/**
	* start fly mode
	*/
	void StartFly(void);

	/**
	* stop fly mode
	*/
	void StopFly(void);

	/**
	* Changes the class of the player
	* @param const char *pClassName: the name of the class to change in
	* @return bool:class exists
	*/
	BOOL ChangeClass(const char *pClassName);

	/**
	* start blockmode
	*/
	void StartBlock();

	/**
	* stop blockmode
	*/
	void StopBlock();

	/**
	* starts powerup
	*/
	void StartPowerUp();

	/**
	* stops powerup
	*/
	void StopPowerUp();

	/**
	* gets maximum speed for this class including turbo
	* @return int: the maximum speed
	*/
	int GetMaxSpeed( void );

	/**
	* gets the powerlevel, corrected for turbo
	* @return int: the powerlevel
	*/
	int GetPowerLevel(void);
	
	/**
	* Starts observing mode
	*/
	void StartObserving ( void );
	
	/**
	* Stops observing mode
	*/
	void StopObserving ( void );

	/**
	* Sets max health to hud
	* @param int health: max health 
	*/
	void SetMaxHealth(int health);

	/**
	* Sets max ki to hud
	* @param int ki: max ki
	*/
	void SetMaxPowerLevel(int powerlevel);

	/**
	* gives you beans
	* @param int nr_of_beans: nr of beans to get
	* @return BOOL: accepted some of the beans?
	*/
	BOOL GiveBean(int nr_of_beans);

	/**
	* use a bean
	* @return BOOL: possible to take a bean?
	*/
	BOOL TakeBean();

	/**
	* increase PL,ki,health, by killing someone
	* @param CBasePlayer *pVictim: the one killed
	* @param int damage: damage done to victim
	*/
	void IncreaseStrength(CBasePlayer *pVictim, int damage);

	// Added by Rick : Buddy version of IncreaseStrength
	/**
	* increase PL,ki,health, by killing someone
	* @param CBasePlayer *pVictim: the one killed
	* @param int damage: damage done to victim
	*/
	void IncreaseStrength(CBuddy *pVictim, int damage);
	// End add by Rick

	/**
	* start ascending 
	*/
	void StartAscend();

	/**
	* stops ascending 
	*/
	void StopAscending();

	/**
	* Ascend into his next class
	*/
	void Ascend();

	/**
	* Edited by Pcjoe
	* Descend to the previous class
	* @param bool blRemoveWeapons: Should remove + add weapons along with the descending
	*/
	void Descend( bool blRemoveWeapons );

	/**
	 * Emits a class specific sound using CHAN_VOICE
	 * @param 
	 */
	void EmitClassSound(const char *sound);

	/**
	* removes all attacks from a player
	*/
	void RemoveAllWeapons(BOOL removesuit);

	/**
	* Gets the powerratio for the player
	* @returns float: the power ratio
	*/
	float GetPowerRatio( void );
	//end harSens add

	// added by Pcjoe

	/*
	* TransformFX
	*/
	void TransformFX( float flTime );

	// --- Aura
	/**
	* Pcjoe: Get Aura Direction
	*/
	int GetAuraDirection( void );
	
	// --- Melee

	/*
	* Can Melee
	* @param CBasePlayer *pOther: Player we are attacking
	*/
	BOOL CanMelee( CBasePlayer *pOther );

	// Added by Rick: Buddy version
	/*
	* Can Melee
	* @param CBuddy *pOther: Buddy we are attacking
	*/
	BOOL CanMelee( CBuddy *pOther );

	/**
	* Pcjoe: Swoop
	*/
	void Swoop( void );
	
	/**
	* Pcjoe: End Swoop
	*/
	void StopSwoop( void );

	/*
	* Pcjoe: Check Wall Jump
	*/
	void CheckWallJump( void );
	
	/*
	* Pcjoe: Get wall jump anim
	* @param char *pPrefix: String placed before direction
	* @param Vector vecNormal: Normal of the surface we're jumping off of
	* @param char *pReturn: Animation name
	*/
	void GetWallJumpAnim( char *pPrefix, Vector vecNormal, char *pReturn );

	/*
	* Pcjoe: Get wall jump anim
	* @param char *pAnim: name of wallgrab anim, giving back walljump
	* @param char *pReturn: Animation name
	*/
	void GetWallJumpAnim( char *pAnim, char *pReturn );

	/*
	* Enable Wall Jump
	*/
	void EnableWallJump( vec3_t vecNormal );

	/*
	* Disable Wall Jump
	*/
	void DisableWallJump( void );

	/*
	* Remove Wall Jump ( Disable without intentions of jumping off the wall )
	*/
	void RemoveWallJump( void );

	/*
	* Reset Walljump varibles
	*/
	void ResetWallJumpVars( void );

	// Sub model control
	/*
	* Pcjoe: Set sub model
	* @param float flTime: When should we set this sub-model?
	* @param int iSubModel: What sub-model are we changing to?
	*/
	void SetBodyPart( float flTime, int iSubModel );

	/*
	* Pcjoe: Check on sub model status
	*/
	void CheckSubModelStatus( void );

	/*
	* Pcjoe: Add client afterfx
	*/
	void AddClientAfterFX( void );

	/*
	* Pcjoe: Force Correct Models
	*/
	void ForceCorrectModels( void );

	//end Pcjoe add

	/*
	* Rick: Draws the chrage bar
	* @param int iChargePercent: The charge percent
	*/
	void DrawChargeBar(int iChargePercent);

	/*
	* Rick: Stores locations where this player moved in the pas
	*/
	void UpdateOldPositions(void);

	/*
	* DragonDude: whenever a player is killed, determine a percent to add to their senzu bean counter,
	*			  and add it to both the killer and the victim
	*/
	void UpdateSenzuStats(CBasePlayer* pKiller);

// these are time-sensitive things that we keep track of
	float				m_flTimeStepSound;	// when the last stepping sound was made
	float				m_flTimeWeaponIdle; // when to play another weapon idle animation.
	float				m_flSwimTime;		// how long player has been underwater
//	float				m_flDuckTime;		// how long we've been ducking
	float				m_flWallJumpTime;	// how long until next walljump

	float				m_flSuitUpdate;					// when to play next suit update
	int					m_rgSuitPlayList[CSUITPLAYLIST];// next sentencenum to play for suit update
	int					m_iSuitPlayNext;				// next sentence slot for queue storage;
	int					m_rgiSuitNoRepeat[CSUITNOREPEAT];		// suit sentence no repeat list
	float				m_rgflSuitNoRepeatTime[CSUITNOREPEAT];	// how long to wait before allowing repeat
	int					m_lastDamageAmount;		// Last damage taken
	float				m_tbdPrev;				// Time-based damage timer

	/*disabled by harSens
	float				m_flgeigerRange;		// range to nearest radiation source
	float				m_flgeigerDelay;		// delay per update of range msg to client
	int					m_igeigerRangePrev;
	*/
	int					m_iStepLeft;			// alternate left/right foot stepping sound
	char				m_szTextureName[CBTEXTURENAMEMAX];	// current texture name we're standing on
	char				m_chTextureType;		// current texture type

	int					m_idrowndmg;			// track drowning damage taken
	int					m_idrownrestored;		// track drowning damage restored

	int					m_bitsHUDDamage;		// Damage bits for the current fame. These get sent to 
												// the hude via the DAMAGE message
	BOOL				m_fInitHUD;				// True when deferred HUD restart msg needs to be sent
	BOOL				m_fGameHUDInitialized;
	int					m_iTrain;				// Train control position
	BOOL				m_fWeapon;				// Set this to FALSE to force a reset of the current weapon HUD info

	EHANDLE				m_pTank;				// the tank which the player is currently controlling,  NULL if no tank
	float				m_fDeadTime;			// the time at which the player died  (used in PlayerDeathThink())

	BOOL			m_fNoPlayerSound;	// a debugging feature. Player makes no sound if this is true. 
	BOOL			m_fLongJump; // does this player have the longjump module?

	float       m_tSneaking;
	int			m_iUpdateTime;		// stores the number of frame ticks before sending HUD update messages
	int			m_iClientHealth;	// the health currently known by the client.  If this changes, send a new
	int			m_iClientBattery;	// the Battery currently known by the client.  If this changes, send a new
	int			m_iHideHUD;		// the players hud weapon info is to be hidden
	int			m_iClientHideHUD;
	int			m_iFOV;			// field of view
	int			m_iClientFOV;	// client's known FOV
	// usable player items 
	CBasePlayerItem	*m_rgpPlayerItems[MAX_ITEM_TYPES];
	CBasePlayerItem *m_pActiveItem;
	CBasePlayerItem *m_pClientActiveItem;  // client version of the active item
	CBasePlayerItem *m_pLastItem;
	// shared ammo slots
	/* disabled by harSens
	int	m_rgAmmo[MAX_AMMO_SLOTS];
	int	m_rgAmmoLast[MAX_AMMO_SLOTS];
	*/

	Vector				m_vecAutoAim;
	BOOL				m_fOnTarget;
	int					m_iDeaths;
	float				m_iRespawnFrames;	// used in PlayerDeathThink() to make sure players can always respawn

	int m_lastx, m_lasty;  // These are the previous update's crosshair angles, DON"T SAVE/RESTORE

	int m_nCustomSprayFrames;// Custom clan logo frames for this player
	float	m_flNextDecalTime;// next time this player can spray a decal

	char m_szTeamName[TEAM_NAME_LENGTH];

	virtual void Spawn( void );
	void Pain( void );

//	virtual void Think( void );
	virtual void Jump( void );
	/* disabled by harSens
	virtual void Duck( void );
	*/
	virtual void PreThink( void );
	virtual void PostThink( void );
	virtual Vector GetGunPosition( void );
	virtual int TakeHealth( float flHealth, int bitsDamageType );
	virtual void TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType);
	virtual int TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType);
	virtual void	Killed( entvars_t *pevAttacker, int iGib );
	virtual Vector BodyTarget( const Vector &posSrc ) { return Center( ) + pev->view_ofs * RANDOM_FLOAT( 0.5, 1.1 ); };		// position to shoot at
	virtual void StartSneaking( void ) { m_tSneaking = gpGlobals->time - 1; }
	virtual void StopSneaking( void ) { m_tSneaking = gpGlobals->time + 30; }
	virtual BOOL IsSneaking( void ) { return m_tSneaking <= gpGlobals->time; }
	virtual BOOL IsAlive( void ) { return (pev->deadflag == DEAD_NO) && pev->health > 0; }
	virtual BOOL ShouldFadeOnDeath( void ) { return FALSE; }
	virtual	BOOL IsPlayer( void ) { return TRUE; }			// Spectators should return FALSE for this, they aren't "players" as far as game logic is concerned

	virtual BOOL IsNetClient( void ) { return TRUE; }		// Bots should return FALSE for this, they can't receive NET messages
															// Spectators should return TRUE for this
	virtual const char *TeamID( void );

	virtual int		Save( CSave &save );
	virtual int		Restore( CRestore &restore );
	void RenewItems(void);
	void PackDeadPlayerItems( void );
	void RemoveAllItems( BOOL removeSuit );
	BOOL SwitchWeapon( CBasePlayerItem *pWeapon );

	// JOHN:  sends custom messages if player HUD data has changed  (eg health, ammo)
	virtual void UpdateClientData( void );
	
	static	TYPEDESCRIPTION m_playerSaveData[];

	// Player is moved across the transition by other means
	virtual int		ObjectCaps( void ) { return CBaseMonster :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION; }
	virtual void	Precache( void );
	BOOL			IsOnLadder( void );

	/* removed by harSens
	BOOL			FlashlightIsOn( void );
	void			FlashlightTurnOn( void );
	void			FlashlightTurnOff( void );
	*/
	
	void UpdatePlayerSound ( void );
	void DeathSound ( void );

	int Classify ( void );
	void SetAnimation( PLAYER_ANIM playerAnim );
	//added by harSens
	/**
	 * Removes an animation trigger.
	 * stops the animation when the trigger matches.
	 * @param PLAYER_ANIM playerAnim: animation to stop
	 */
	void StopAniTrigger( PLAYER_ANIM playerAnim );

	void SetWeaponAnimType( const char *szExtention );
	char m_szAnimExtention[32];

	// custom player functions
	virtual void ImpulseCommands( void );
	void CheatImpulseCommands( int iImpulse );

	void StartDeathCam( void );
	void StartObserver( Vector vecPosition, Vector vecViewAngle );

	void AddPoints( int score, BOOL bAllowNegativeScore );
	void AddPointsToTeam( int score, BOOL bAllowNegativeScore );
	BOOL AddPlayerItem( CBasePlayerItem *pItem );
	BOOL RemovePlayerItem( CBasePlayerItem *pItem );
	void DropPlayerItem ( char *pszItemName );
	BOOL HasPlayerItem( CBasePlayerItem *pCheckItem );
	BOOL HasNamedPlayerItem( const char *pszItemName );
	BOOL HasWeapons( void );// do I have ANY weapons?
	void SelectPrevItem( int iItem );
	void SelectNextItem( int iItem );
	void SelectLastItem(void);
	void SelectItem(const char *pstr);
	void ItemPreFrame( void );
	void ItemPostFrame( void );
	void GiveNamedItem( const char *szName );
	void EnableControl(BOOL fControl);

	/*disabled by harSens
	int  GiveAmmo( int iAmount, char *szName, int iMax );
	void SendAmmoUpdate(void);
	*/

	void WaterMove( void );
	void EXPORT PlayerDeathThink( void );
	void PlayerUse( void );

	void CheckSuitUpdate();
	void SetSuitUpdate(char *name, int fgroup, int iNoRepeat);
	/* disabled by harSens
	void UpdateGeigerCounter( void );
	*/
	void CheckTimeBasedDamage( void );

	BOOL FBecomeProne ( void );
	void BarnacleVictimBitten ( entvars_t *pevBarnacle );
	void BarnacleVictimReleased ( void );
	static int GetAmmoIndex(const char *psz);
	/*disabled by harSens
	int AmmoInventory( int iAmmoIndex );
	*/
	int Illumination( void );

	/* disabled by harSens
	void ResetAutoaim( void );
	Vector GetAutoaimVector( float flDelta  );
	Vector AutoaimDeflection( Vector &vecSrc, float flDist, float flDelta  );
	*/
	void ForceClientDllUpdate( void );  // Forces all client .dll specific data to be resent to client.

	void DeathMessage( entvars_t *pevKiller );

	void SetCustomDecalFrames( int nFrames );
	int GetCustomDecalFrames( void );

	/*disabled by harSens
	void CBasePlayer::TabulateAmmo( void );
	*/

	float m_flStartCharge;
	float m_flAmmoStartCharge;
	float m_flPlayAftershock;
	float m_flNextAmmoBurn;// while charging, when to absorb another unit of player's ammo?
	
	//Player ID
	/*
	void InitStatusBar( void );
	void UpdateStatusBar( void );
	int m_izSBarState[ SBAR_END ];
	float m_flNextSBarUpdateTime;
	float m_flStatusBarDisappearDelay;
	char m_SbarString0[ SBAR_STRING_SIZE ];
	char m_SbarString1[ SBAR_STRING_SIZE ];
	*/
	float m_flNextChatTime;
	
};

#define AUTOAIM_2DEGREES  0.0348994967025
#define AUTOAIM_5DEGREES  0.08715574274766
#define AUTOAIM_8DEGREES  0.1391731009601
#define AUTOAIM_10DEGREES 0.1736481776669


extern int	gmsgHudText;
extern BOOL gInitHUD;

#endif // PLAYER_H

