
/***
*
*	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.
*
****/
//			
//  hud.h
//
// class CHud declaration
//
// CHud handles the message, calculation, and drawing the HUD
//

//added by harSens
#ifndef HUD_H
#define HUD_H

#pragma warning (disable:4786)
#pragma warning (disable:4530)

#include <list>
#include <vector>
#include <map>
#include <string>
#include <sstream>

#define RGB_YELLOWISH 0x00FFA000 //255,160,0
#define RGB_REDISH 0x00FF1010 //255,160,0
#define RGB_GREENISH 0x0000A000 //0,160,0

//added by harSens
#define RGB_BLUEISH  0x000000A0 // 0,0,160
#define RGB_WHITEISH 0x00FFFFFF // 255,255,255

#include "wrect.h"
#include "cl_dll.h"
/* modified by harSens
#include "ammo.h"
*/
#include "attack.h"

//added by harSens, used for mp3player
#include "../fmod/inc/fmod.h"
#include "../fmod/inc/fmod_errors.h"
#include "fmodwrapper.h"
#include "fxsystem.h"

// Added by Pcjoe
#include "transformfx.h"
#include "studio.h"
#include "studio_util.h"
#include "r_efx.h"
#include "3dhud.h"
#include "Vrml.h"
#include "custommodel.h"

#define DHN_DRAWZERO 1
#define DHN_2DIGITS  2
#define DHN_3DIGITS  4
//added by harSens
#define DHN_KI		 8   //supports up to 9 digits
#define MIN_ALPHA	 100	
// Added by Pcjoe
#define MAX_DUST_GROUP	10
#define MAX_DUST		100
#define MAX_RIPPLES		10
#define MAX_ROCKS		50
#define MAX_AURA		100

// Added by Pcjoe, iterate through STL containers
#ifndef ForEachIn
#define ForEachIn( a, b ) for( a = b.begin(); a != b.end(); a++ )
#endif

// added by ian
//
// local information about buddies for drawing diamonds/target color/scouter
struct buddy_info_s
{
	int buddy_index;
	int buddy_team;
	int powerlevel;
	short playerclass;
};

typedef struct buddy_info_s buddy_info_t;

#define MAX_DISCS 255
#define		HUDELEM_ACTIVE	1

//added by harSens
struct ltstr
{
	int operator()(const char *s1,const char *s2) const
	{
		return strcmp(s1,s2)<0;
	}
};

typedef struct {
	int x, y;
} POSITION;

enum 
{ 
	MAX_PLAYERS = 64,
	MAX_TEAMS = 64,
	MAX_TEAM_NAME = 16,
};

// Pcjoe: Characters
enum
{	CLASS_BUU=1, 
	CLASS_GOKU,
	CLASS_GOHAN,
	CLASS_KRILLIN,
	CLASS_FRIEZA,
	CLASS_PICCOLO,
	CLASS_TRUNKS,
	CLASS_VEGETA,
	CLASS_CELL,
	CLASS_GINYU,
	CLASS_A18,
	CLASS_LASTCLASS=13,
};

typedef struct {
	unsigned char r,g,b,a;
} RGBA;
//Start of edit/add by Pcjoe
struct group_particle
{	vec3_t origin;
	vec3_t direction;
	vec3_t endpos;
	vec3_t vecRotation;	// Only used for 3d rocks
	bool m_blLiving;		// Only used when particle is generated too close to the wall
	bool m_blCollision;
};

struct parGroup
{	int r;
	int g;
	int b;
	int m_iSize;
	int m_iFrame;
	int m_iSprite;
	float m_flLife;
	float m_flSpeed;
	// ONLY used by rocks
	bool m_blAddDyingLife;
	int m_iBounce;

	group_particle dust[MAX_DUST];
	group_particle ripple[1];
	group_particle rock[1];
};

struct aura_particle
{
	vec3_t	vecParticleOrigin;
	vec3_t	vecDirection;
	float	m_flLife;
	float	m_flSpeed;
	int		m_flSize;
	int		m_iFrame;
	int r;
	int g;
	int b;
};

struct particletime
{	float m_flSubTime;		// Used to take life away from particles
	float m_flSizeTime;		// Time used to add size to the particles
	float m_flRingTime;		// Time used to let out "waves" on time
	float m_flRingTime2;	// Just incase the user needs another ring time
	int m_iCurrentRing;		// Current wave that is going to be let out
	float m_flCurrentFrame;	// Timed used for Frames
};

struct powerupfx
{	bool enabled;
	int r;
	int g;
	int b;
	float m_flDyingTime;

	parGroup dustgroup[MAX_DUST_GROUP];
	parGroup ripplegroup[MAX_RIPPLES];
	parGroup rockgroup[MAX_ROCKS];
	aura_particle aura[MAX_AURA];

	particletime ParDustTime;
	particletime ParRippleTime;
	particletime ParRockTime;
	particletime ParAuraTime;

	// Light
	dlight_t *dl;
	bool m_bRadiusPulsate;

	//Added by Rick
	int m_iEntIndex;
	powerupfx *next;
	powerupfx(int EntIndex);
};

struct dust_particle
{	vec3_t vecOrigin;
	vec3_t vecDirection;
	bool m_blLiving;
	bool m_blCollision;
	int m_flAlpha;
	int m_iSize;
	int m_iSprite;
	float m_flLife;
	float m_flSpeed;
};

struct melee_hud_s
{
	int		iType;
	int		iID;
	int		iBlockStatus;
	int		iDirection;
	int		x;
	int		y;
	float	flStartTime;
	float	flEndTime;
	bool	blFinished;
};

typedef enum
{	MELEETXT_HIT=0,
	MELEETXT_HITS,
	MELEETXT_COMBO,
	MELEETXT_DAMAGE,
	MELEETXT_SWORDKILL,
	MELEETXT_CRITICAL,
	MELEETXT_PERDAMAGE,
	MELEETXT_LOWKI,
	MELEETXT_LOWHP,
	MELEETXT_DEEPSHIT,
	MELEETXT_DODGED,
	MELEETXT_BLOCKBREAK,
	MELEETXT_WINNER,
	MELEETXT_LOOSER,
	MELEETXT_TIE,
	MELEETXT_HEADON,
	MELEETXT_KNOCKBACK,
	MELEETXT_PREPUNCH
}MELEETXT;

struct interpol_gait_s
{	int iIndex;
	int iSequence;
	int iPrevSequence;
	int iRealGait;
	int iRealGaitPrev;
	float flPrevAnimTime;
	float flPrevMaxSpeed;

	// Lower Body
	float pos[MAXSTUDIOBONES][3];
	vec4_t q[MAXSTUDIOBONES];
	float posprev[MAXSTUDIOBONES][3];
	vec4_t qprev[MAXSTUDIOBONES];

	// Upper Body
	bool blStartRecUpper;
	float upperposprev[MAXSTUDIOBONES][3];
	vec4_t upperqprev[MAXSTUDIOBONES];

	// Player model
	model_s *pModel;

	bool blRendered;
	//added by harSens
	bool blActive;
};

typedef struct
{	int iType;
	int iSSize;
	int iESize;
	int iSAlpha;
	int iEAlpha;
	int r;
	int g;
	int b;
	int iFrame;
	float flFrameTime;
	float flSTime;
	float flETime;
	bool bl3d;
	HSPRITE hsprSprite;

	vec3_t vecOrigin;
}melee_shock_t;
//end of edit/add by Pcjoe
/*
struct trail_points
{	vec3_t point;
	trail_points *next;
};
*/
// Pcjoe: Model manip data
struct model_manip_s
{
	int iFlags;
	int iPlayerIndex;	// Ent Index
	int iOtherIndex;
	int iDistance;		// Distance apart in connecting manips
	int iAISeqPlayer;	// After Images
	int iAISeqOther;
	int	iBodyPlayer;	// Sub Bodies
	int iBodyOther;
	int	iBodyPlayerSeq;
	int iBodyOtherSeq;
	float flAITimePlayer;	// After Image times
	float flAITimeOther;
	float playerpos[128][3]; // Bone origins
	float otherpos[128][3];
	bool blPlayedAIPlayer;	// If after image is enabled
	bool blPlayedAIOther;
	bool blCanUsePlayerPos;	// Can use bone origins
	bool blCanUseOtherPos;
	bool blLockGait;		// Lock Gait
	bool blAttached;
	bool blFixedAngles;		// Fixed model angles
	bool blFixedViewAngles;	// Fixed view angles
	bool blTeleportPlayer;	// Teleport player
	bool blTeleportOther;
	vec3_t vecTele;
	vec3_t vecAngles;
	vec3_t vecViewAngles;
	vec3_t vecViewOriginPlayer;
	vec3_t vecViewOriginOther;
	vec3_t vecDir;
	vec3_t vecOldOrigin;
	float flLastTime;
	dlight_t *dl;
	// Used to reset interpolation
	int iBody;	
};

enum beam_detail{LOW_DETAIL = 1, MEDIUM_DETAIL = 2, HIGH_DETAIL = 3};

struct footskid
{
	bool active;
	vec3_t footskid_start_left;
	vec3_t footskid_start_right;	
	vec3_t footskid_end_left;
	vec3_t footskid_end_right;
	vec3_t right;
};

struct ball
{
	int ent;
	int bsent;
	bool bs;
	bool ps;
	footskid *skid;
	std::list<model_manip_s>::iterator bones;
	short sprite;
	float width;
	int frame;
};

struct beam
{
	int ent;
	int bsent;
	bool bs;
	bool ps;
	footskid *skid;
	std::list<model_manip_s>::iterator bones;
	short flarea;
	short flareb;
	int flareframe[9];
	float width;	
};

struct beam2
{
	short flarea;
	short flareb;
};

struct beam_state
{
	int ent;
	int flareframe[9];
	float width;
	beam2 head;
};

struct sbc_trail
{
	int startent;
	int attachment;
	vec3_t startpos;
	vec3_t orbitpos;
	vec3_t pos;
	float angle;

	beam head;
	short trail;	
	float width;
	int trailframe;	

	beam orbithead;
	short orbittrail;
	float orbitwidth;
	int orbittrailframe;

	sbc_trail(){}
	// Copy Constructor
    sbc_trail(const sbc_trail &copy);

	std::list <vec3_t> points;
	std::list <vec3_t> mainpoints;
};

struct ent_ent_trail
{	
	beam head;
	short starta;
	short startb;	
	std::list <vec3_t> points;
	int startent;	
	int attachment;	
	short trail;	
	float width;
	int startframe[4];
	int trailframe;
	float traillength;
	beam_detail detail;
	ent_ent_trail(){}
	// Copy Constructor
    ent_ent_trail(const ent_ent_trail &copy);	
};

struct flare
{	beam head;
	int maxlength;
	short trail;	
	float width;
	std::list <vec3_t> points;
	flare(){}
	~flare();
	// Copy Constructor
    flare(const flare &copy);	

	int trailframe;
	float traillength;
};

struct flare2
{
	int maxlength;
	float maxwidth;
	short trail;
	beam2 head;
};

struct flare_state
{
	flare2 flar;
	beam_state head;
	std::list <vec3_t> points;
	float width;
	int trailframe;
	float traillength;
};

struct explosion
{	vec3_t pos;
	float radius;
	// added by Pcjoe
	int maxradius;
	bool expand;
	bool explode;
	int m_iFrame;
	float m_flFrameTime;
	int iIndex;	// Index of Explosion(if its attached to an entity)
	int iType;	// Type of explosion - Blob or Shield
	int iAlpha;	// Alpha setting of the Blob/Shield
	float flFlashTime;	// Time the shield flashes

	HSPRITE sprite;
	vec3_t rotation;
	explosion *next;
};

//end harSens add

// Pcjoe: Flags for model manip
#define MANIP_FLAG_CONNECT		 (1<<1)
#define MANIP_FLAG_ANGLE_FIX	 (1<<2)
#define MANIP_FLAG_ANGLE_FIX_ENT (1<<3)
#define MANIP_FLAG_GRAB			 (1<<4)
#define MANIP_FLAG_MSTRUGGLE	 (1<<5)
#define MANIP_FLAG_SWITCH		 (1<<6)
#define MANIP_FLAG_AURABEND		 (1<<7)
#define MANIP_FLAG_RECPOS		 (1<<8)
#define MANIP_FLAG_BLURSEQ		 (1<<9)

typedef enum
{	SWOOP_UP=0,
	SWOOP_DOWN,
	SWOOP_LEFT,
	SWOOP_RIGHT,
	SWOOP_FRONT,
	SWOOP_BACK,
} SWOOP_DIRECTION;

// Pcjoe: Mouse capture class (capture mouse clicks)
class CMouseCapture
{
public:
	// Constructor
	CMouseCapture()
	{	// Reset
		for(int i = 0; i < 5; i++)
			m_bMouseStatus[i] = false;
	}

	// Update status
	void updateStatus( int iButton, bool bDown )
	{	if(iButton>5)
			iButton = 5;
		else if(iButton < 0)
			iButton = 0;
		m_bMouseStatus[iButton] = bDown;
	}

	// Get Status
	bool getStatus( int iButton )
	{	if(iButton>5)
			iButton = 5;
		else if(iButton < 0)
			iButton = 0;
		return m_bMouseStatus[iButton];
	}

private:
	bool	m_bMouseStatus[5];
};

// end of add by Pcjoe

typedef struct cvar_s cvar_t;


#define HUD_ACTIVE	1
#define HUD_INTERMISSION 2

#define MAX_PLAYER_NAME_LENGTH		32

#define	MAX_MOTD_LENGTH				1536

//
//-----------------------------------------------------
//
class CHudBase
{
public:
	POSITION  m_pos;
	int   m_type;
	int	  m_iFlags; // active, moving, 
	virtual		~CHudBase() {}
	virtual int Init( void ) {return 0;}
	virtual int VidInit( void ) {return 0;}
	virtual int Draw(float flTime) {return 0;}
	virtual void Think(void) {return;}
	virtual void Reset(void) {return;}
	virtual void InitHUDData( void ) {}		// called every time a server is connected to
	virtual void InitHUDMap( void ) {}		// Added by Pcjoe, called every level change
};

struct HUDLIST {
	CHudBase	*p;
	HUDLIST		*pNext;
};



//
//-----------------------------------------------------
//
#include "..\game_shared\voice_status.h"
#include "hud_spectator.h"


//
//-----------------------------------------------------
//
class CHudAttack: public CHudBase
{
public:
	/**
	* Inits attacks
	* @return int: always 1
	*/
	int Init( void );

	/**
	* Initializes sprites
	* @return int: always 1
	*/
	int VidInit( void );

	/**
	* Draws the attack select sprites
	* @param float flTime: the current time
	* @return int: always 1
	*/
	int Draw(float flTime);

	/**
	* Think function: selects the right weapon
	*/
	void Think(void);

	/**
	* Resets the attack selection
	*/
	void Reset(void);

	/**
	* Draws the weapon list
	* @param float flTime: the current time
	* @return int: always 1
	*/
	int DrawWList(float flTime);

	/**
	* handles speed current weapon messages from the server
	* @param const char *pszName: name of the message
	* @param int iSize: size of the message
	* @param void *pbuf: message buffer
	* @return int: always 1
	*/
	int MsgFunc_CurWeapon(const char *pszName, int iSize, void *pbuf);

	/**
	* handles weapon list messages from the server
	* @param const char *pszName: name of the message
	* @param int iSize: size of the message
	* @param void *pbuf: message buffer
	* @return int: always 1
	*/	
	int MsgFunc_WeaponList(const char *pszName, int iSize, void *pbuf);

	/**
	* handles update weapon messages from the server
	* @param const char *pszName: name of the message
	* @param int iSize: size of the message
	* @param void *pbuf: message buffer
	* @return int: always 1
	*/	
	int MsgFunc_WeapUpdate( const char *pszName, int iSize, void *pbuf );

	/**
	* handles hide weapon messages from the server
	* @param const char *pszName: name of the message
	* @param int iSize: size of the message
	* @param void *pbuf: message buffer
	* @return int: always 1
	*/		
	int MsgFunc_HideWeapon( const char *pszName, int iSize, void *pbuf );
	
	/**
	* Handles slot selects
	* @param int iSlot: the slot the user selected
	*/
	void SlotInput( int iSlot );

	/**
	* Handles slot 1 command
	*/
	void _cdecl UserCmd_Slot1( void );

	
	/**
	* Handles slot 2 command
	*/	
	void _cdecl UserCmd_Slot2( void );

	
	/**
	* Handles slot 3 command
	*/
	void _cdecl UserCmd_Slot3( void );

	
	/**
	* Handles slot 4 command
	*/
	void _cdecl UserCmd_Slot4( void );

	
	/**
	* Handles slot 5 command
	*/
	void _cdecl UserCmd_Slot5( void );

	
	/**
	* Handles slot 6 command
	*/
	void _cdecl UserCmd_Slot6( void );

	
	/**
	* Handles slot 7 command
	*/
	void _cdecl UserCmd_Slot7( void );

	
	/**
	* Handles slot 8 command
	*/
	void _cdecl UserCmd_Slot8( void );

	
	/**
	* Handles slot 9 command
	*/
	void _cdecl UserCmd_Slot9( void );

	
	/**
	* Handles slot 10 command
	*/	
	void _cdecl UserCmd_Slot10( void );

	/**
	* Handles next weapon command
	*/	
	void _cdecl UserCmd_NextWeapon( void );
	void _cdecl UserCmd_PrevWeapon( void );
	void _cdecl UserCmd_Close( void );
private:
	WEAPON *m_pWeapon;			//current weapon
	
	int m_iActiveWeaponFrame;	//current frame
	float m_flLastWeaponDraw;	//last time we drew the weapon sprite
	int m_fSecondAnimLoop;		//are we running the ani for the 2nd time already?
};
/* removed by harSens
class CHudAmmo: public CHudBase
{
public:
	int Init( void );
	int VidInit( void );
	int Draw(float flTime);
	void Think(void);
	void Reset(void);
	int DrawWList(float flTime);
	int MsgFunc_CurWeapon(const char *pszName, int iSize, void *pbuf);
	int MsgFunc_WeaponList(const char *pszName, int iSize, void *pbuf);
	int MsgFunc_AmmoX(const char *pszName, int iSize, void *pbuf);
	int MsgFunc_AmmoPickup( const char *pszName, int iSize, void *pbuf );
	int MsgFunc_WeapPickup( const char *pszName, int iSize, void *pbuf );
	int MsgFunc_ItemPickup( const char *pszName, int iSize, void *pbuf );
	int MsgFunc_HideWeapon( const char *pszName, int iSize, void *pbuf );

	void SlotInput( int iSlot );
	void _cdecl UserCmd_Slot1( void );
	void _cdecl UserCmd_Slot2( void );
	void _cdecl UserCmd_Slot3( void );
	void _cdecl UserCmd_Slot4( void );
	void _cdecl UserCmd_Slot5( void );
	void _cdecl UserCmd_Slot6( void );
	void _cdecl UserCmd_Slot7( void );
	void _cdecl UserCmd_Slot8( void );
	void _cdecl UserCmd_Slot9( void );
	void _cdecl UserCmd_Slot10( void );
	void _cdecl UserCmd_Close( void );
	void _cdecl UserCmd_NextWeapon( void );
	void _cdecl UserCmd_PrevWeapon( void );

private:
	float m_fFade;
	RGBA  m_rgba;
	WEAPON *m_pWeapon;
	int	m_HUD_bucket0;
	int m_HUD_selection;

};
*/
//
//-----------------------------------------------------
//

/* disabled by harSens
class CHudAmmoSecondary: public CHudBase
{
public:
	int Init( void );
	int VidInit( void );
	void Reset( void );
	int Draw(float flTime);

	int MsgFunc_SecAmmoVal( const char *pszName, int iSize, void *pbuf );
	int MsgFunc_SecAmmoIcon( const char *pszName, int iSize, void *pbuf );

private:
	enum {
		MAX_SEC_AMMO_VALUES = 4
	};

	int m_HUD_ammoicon; // sprite indices
	int m_iAmmoAmounts[MAX_SEC_AMMO_VALUES];
	float m_fFade;
};
*/

#include "health.h"
#include "buddyinfo.h"


#define FADE_TIME 100


//
//-----------------------------------------------------
//
/* removed by harSens
class CHudGeiger: public CHudBase
{
public:
	int Init( void );
	int VidInit( void );
	int Draw(float flTime);
	int MsgFunc_Geiger(const char *pszName, int iSize, void *pbuf);
	
private:
	int m_iGeigerRange;

};
*/

//
//-----------------------------------------------------
//
class CHudTrain: public CHudBase
{
public:
	int Init( void );
	int VidInit( void );
	int Draw(float flTime);
	int MsgFunc_Train(const char *pszName, int iSize, void *pbuf);

private:
	HSPRITE m_hSprite;
	int m_iPos;

};

//
//-----------------------------------------------------
//
// REMOVED: Vgui has replaced this.
//
/*
class CHudMOTD : public CHudBase
{
public:
	int Init( void );
	int VidInit( void );
	int Draw( float flTime );
	void Reset( void );

	int MsgFunc_MOTD( const char *pszName, int iSize, void *pbuf );

protected:
	static int MOTD_DISPLAY_TIME;
	char m_szMOTD[ MAX_MOTD_LENGTH ];
	float m_flActiveRemaining;
	int m_iLines;
};
*/

//
//-----------------------------------------------------
//
/* removed by harSens
class CHudStatusBar : public CHudBase
{
public:
	int Init( void );
	int VidInit( void );
	int Draw( float flTime );
	void Reset( void );
	void ParseStatusString( int line_num );

	int MsgFunc_StatusText( const char *pszName, int iSize, void *pbuf );
	int MsgFunc_StatusValue( const char *pszName, int iSize, void *pbuf );

protected:
	enum { 
		MAX_STATUSTEXT_LENGTH = 128,
		MAX_STATUSBAR_VALUES = 8,
		MAX_STATUSBAR_LINES = 2,
	};

	char m_szStatusText[MAX_STATUSBAR_LINES][MAX_STATUSTEXT_LENGTH];  // a text string describing how the status bar is to be drawn
	char m_szStatusBar[MAX_STATUSBAR_LINES][MAX_STATUSTEXT_LENGTH];	// the constructed bar that is drawn
	int m_iStatusValues[MAX_STATUSBAR_VALUES];  // an array of values for use in the status bar

	int m_bReparseString; // set to TRUE whenever the m_szStatusBar needs to be recalculated

	// an array of colors...one color for each line
	float *m_pflNameColors[MAX_STATUSBAR_LINES];
};
*/
//
//-----------------------------------------------------
//
// REMOVED: Vgui has replaced this.
//
/*
class CHudScoreboard: public CHudBase
{
public:
	int Init( void );
	void InitHUDData( void );
	int VidInit( void );
	int Draw( float flTime );
	int DrawPlayers( int xoffset, float listslot, int nameoffset = 0, char *team = NULL ); // returns the ypos where it finishes drawing
	void UserCmd_ShowScores( void );
	void UserCmd_HideScores( void );
	int MsgFunc_ScoreInfo( const char *pszName, int iSize, void *pbuf );
	int MsgFunc_TeamInfo( const char *pszName, int iSize, void *pbuf );
	int MsgFunc_TeamScore( const char *pszName, int iSize, void *pbuf );
	void DeathMsg( int killer, int victim );

	int m_iNumTeams;

	int m_iLastKilledBy;
	int m_fLastKillTime;
	int m_iPlayerNum;
	int m_iShowscoresHeld;

	void GetAllPlayersInfo( void );
private:
	struct cvar_s *cl_showpacketloss;

};
*/

struct extra_player_info_t 
{
	short frags;
	short deaths;
	//added by harSens
	short dragonballs_gathered;
	int powerlevel;

	short playerclass;
	short teamnumber;
	char teamname[MAX_TEAM_NAME];

	//added by DragonDude
	short scoreboardclass;	//index in the scoreboardclassname array
};

struct team_info_t 
{
	char name[MAX_TEAM_NAME];
	short frags;
	short deaths;
	//added by harSens
	short dragonballs_gathered;
	short ping;
	short packetloss;
	short ownteam;
	short players;
	int already_drawn;
	int scores_overriden;
	int teamnumber;
};

extern hud_player_info_t	g_PlayerInfoList[MAX_PLAYERS+1];	   // player info from the engine
extern extra_player_info_t  g_PlayerExtraInfo[MAX_PLAYERS+1];   // additional player info sent directly to the client dll
extern team_info_t			g_TeamInfo[MAX_TEAMS+1];
extern int					g_IsSpectator[MAX_PLAYERS+1];


//
//-----------------------------------------------------
//
class CHudDeathNotice : public CHudBase
{
public:
	int Init( void );
	void InitHUDData( void );
	/* removed by harSens
	int VidInit( void );
	*/
	int Draw( float flTime );
	int MsgFunc_DeathMsg( const char *pszName, int iSize, void *pbuf );

private:
	/* removed by harSens
	int m_HUD_d_skull;  // sprite index of skull icon
	*/
};

//
//-----------------------------------------------------
//
class CHudMenu : public CHudBase
{
public:
	int Init( void );
	void InitHUDData( void );
	int VidInit( void );
	void Reset( void );
	int Draw( float flTime );
	int MsgFunc_ShowMenu( const char *pszName, int iSize, void *pbuf );

	void SelectMenuItem( int menu_item );

	int m_fMenuDisplayed;
	int m_bitsValidSlots;
	float m_flShutoffTime;
	int m_fWaitingForMore;
};

//
//-----------------------------------------------------
//
class CHudSayText : public CHudBase
{
public:
	int Init( void );
	void InitHUDData( void );
	int VidInit( void );
	int Draw( float flTime );
	int MsgFunc_SayText( const char *pszName, int iSize, void *pbuf );
	void SayTextPrint( const char *pszBuf, int iBufSize, int clientIndex = -1 );
	void EnsureTextFitsInOneLineAndWrapIfHaveTo( int line );
friend class CHudSpectator;

private:

	struct cvar_s *	m_HUD_saytext;
	struct cvar_s *	m_HUD_saytext_time;
};

//
//-----------------------------------------------------
//
/* removed by harSens
class CHudBattery: public CHudBase
{
public:
	int Init( void );
	int VidInit( void );
	int Draw(float flTime);
	int MsgFunc_Battery(const char *pszName,  int iSize, void *pbuf );
	
private:
	HSPRITE m_hSprite1;
	HSPRITE m_hSprite2;
	wrect_t *m_prc1;
	wrect_t *m_prc2;
	int	  m_iBat;	
	float m_fFade;
	int	  m_iHeight;		// width of the battery innards
};
*/

//
//-----------------------------------------------------
//
/* removed by harSens
class CHudFlashlight: public CHudBase
{
public:
	int Init( void );
	int VidInit( void );
	int Draw(float flTime);
	void Reset( void );
	int MsgFunc_Flashlight(const char *pszName,  int iSize, void *pbuf );
	int MsgFunc_FlashBat(const char *pszName,  int iSize, void *pbuf );
	
private:
	HSPRITE m_hSprite1;
	HSPRITE m_hSprite2;
	HSPRITE m_hBeam;
	wrect_t *m_prc1;
	wrect_t *m_prc2;
	wrect_t *m_prcBeam;
	float m_flBat;	
	int	  m_iBat;	
	int	  m_fOn;
	float m_fFade;
	int	  m_iWidth;		// width of the battery innards
};
*/

//
//-----------------------------------------------------
//
const int maxHUDMessages = 16;
struct message_parms_t
{
	client_textmessage_t	*pMessage;
	float	time;
	int x, y;
	int	totalWidth, totalHeight;
	int width;
	int lines;
	int lineLength;
	int length;
	int r, g, b;
	int text;
	int fadeBlend;
	float charTime;
	float fadeTime;
};

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

class CHudTextMessage: public CHudBase
{
public:
	int Init( void );
	static char *LocaliseTextString( const char *msg, char *dst_buffer, int buffer_size );
	static char *BufferedLocaliseTextString( const char *msg );
	char *LookupString( const char *msg_name, int *msg_dest = NULL );
	int MsgFunc_TextMsg(const char *pszName, int iSize, void *pbuf);
};

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

class CHudMessage: public CHudBase
{
public:
	int Init( void );
	int VidInit( void );
	int Draw(float flTime);
	int MsgFunc_HudText(const char *pszName, int iSize, void *pbuf);
	/* disabled by harSens
	int MsgFunc_GameTitle(const char *pszName, int iSize, void *pbuf);
	*/

	float FadeBlend( float fadein, float fadeout, float hold, float localTime );
	int	XPosition( float x, int width, int lineWidth );
	int YPosition( float y, int height );

	void MessageAdd( const char *pName, float time );
	void MessageAdd(client_textmessage_t * newMessage );
	void MessageDrawScan( client_textmessage_t *pMessage, float time );
	void MessageScanStart( void );
	void MessageScanNextChar( void );
	void Reset( void );

private:
	client_textmessage_t		*m_pMessages[maxHUDMessages];
	float						m_startTime[maxHUDMessages];
	message_parms_t				m_parms;
	float						m_gameTitleTime;
	client_textmessage_t		*m_pGameTitle;

	int m_HUD_title_life;
	int m_HUD_title_half;
};

//
//-----------------------------------------------------
//
#define MAX_SPRITE_NAME_LENGTH	24

class CHudStatusIcons: public CHudBase
{
public:
	int Init( void );
	int VidInit( void );
	void Reset( void );
	int Draw(float flTime);
	int MsgFunc_StatusIcon(const char *pszName, int iSize, void *pbuf);

	enum { 
		MAX_ICONSPRITENAME_LENGTH = MAX_SPRITE_NAME_LENGTH,
		MAX_ICONSPRITES = 4,
	};

	
	//had to make these public so CHud could access them (to enable concussion icon)
	//could use a friend declaration instead...
	void EnableIcon( char *pszIconName, unsigned char red, unsigned char green, unsigned char blue );
	void DisableIcon( char *pszIconName );

private:

	typedef struct
	{
		char szSpriteName[MAX_ICONSPRITENAME_LENGTH];
		HSPRITE spr;
		wrect_t rc;
		unsigned char r, g, b;
	} icon_sprite_t;

	icon_sprite_t m_IconList[MAX_ICONSPRITES];

};
/**
* speed changer
* @version 18-4-2001
* @author Herwin 'harSens' van Welbergen
*/
class CHudSpeed: public CHudBase 
{ 
public: 
	/**
	* initializes 
	* @return int: always 1
	*/
	int Init( void ); 
	
	/**
	* handles speed messages from the server
	* @param const char *pszName: name of the message
	* @param int iSize: size of the message
	* @param void *pbuf: message buffer
	*/
	// Removed by Pcjoe
//	int MsgFunc_Speed(const char *pszName, int iSize, void *pbuf); 
	
	/**
	* Pcjoe: Think function
	*/
	void Think( void );
private:
	// Edited by Pcjoe
//	void SetSpeed( int speed ); 
	void SetSpeed( void ); 

	// Pcjoe: Current speed
	int m_iSpeed;
}; 

class CHudWorld: public CHudBase 
{
public:	
	/**
	 * init
	 */
	int Init(void);

	// Removed by Pcjoe
	/**
	 * reset
	 */
//	void Reset();

	/**
	 * Pcjoe: Set Texture Mode
	 */
	void SetTextureMode( void );


	/**
	 * Pcjoe: Map Reset
	 */
	void InitHUDMap( void );

	/**
	 * set world textures
	 * @param flTime time
	 */
	int Draw(float flTime);
private:
	int m_fTexturesSet;
	// added by Pcjoe
	float m_flLastSetting;
	
};

/**
* bounding box drawer
* @version 11-9-2001
* @author Herwin 'harSens' van Welbergen
*/
class CHudBoundingBox: public CHudBase 
{ 
public: 
	/**
	* initializes 
	* @return int: always 1
	*/
	int Init( void ); 
	
	/**
	* handles speed bounding box msg's from the server
	* @param const char *pszName: name of the message
	* @param int iSize: size of the message
	* @param void *pbuf: message buffer
	*/
	int MsgFunc_BoundingBox(const char *pszName, int iSize, void *pbuf); 
}; 


/**
* Explosion maker
* @version 14-8-2001
* @author Herwin 'harSens' van Welbergen
*/
class CHudExplosion: public CHudBase 
{ 
public: 
	/**
	* initializes 
	* @return int: always 1
	*/
	int Init( void ); 

	/**
	 * removes all explosions
	 */
	void Reset();
	
	/**
	* handles explosion messages from the server
	* @param const char *pszName: name of the message
	* @param int iSize: size of the message
	* @param void *pbuf: message buffer
	*/
	int MsgFunc_Explosion(const char *pszName, int iSize, void *pbuf); 

	/**
	* loads explosion sprite
	* @return int: always 1
	*/
	int VidInit( void );

	/**
	* Think function, shrinks explosions
	*/
	void Think( void );
private:
	void AddExplosion(vec3_t org, int radius, HSPRITE sprite);
	// added by Pcjoe
	void AnimateExplosion(explosion *pCurrent, float flTime);

	explosion* RemoveExplosion(explosion *exp);
	float m_flLastResize;
	HSPRITE m_hsprExplosionBlue,m_hsprExplosionGreen,m_hsprExplosionOrange,
		m_hsprExplosionPurple,m_hsprExplosionYellow,m_hsprExplosionRed,m_hsprExplosionWhite;
}; 

/**
 * Manages particle systems
 */
class CHudFXManager: public CHudBase
{
public:
	/**
	 * initializes 
	 * @return int: always 1
	 */
	int Init( void ); 	

	/**
	 * precaches all needed sprites
	 * @return int: always 1
	 */
	int VidInit(void);

	/**
	 * Resets the system
	 */
	void InitHUDMap(void);

	/**
	 * Think function
	 */
	void Think(void);

	/**
	 * draw all fx.
	 * assumes v_right,v_up and v_forward are set correctly
	 */
	void Draw();

	/**
	 * Add a fx system
	 * @param *s the system to add
	 */
	void addSystem(FXSystem* s);

	/**
	 * adds a fx system
	 * @param const char *pszName: name of the message
	 * @param int iSize: size of the message
	 * @param void *pbuf: message buffer
	 */
	int MsgFunc_AddEffect(const char *pszName, int iSize, void *pbuf);

	/**
	 * removes a fx system
	 * @param const char *pszName: name of the message
	 * @param int iSize: size of the message
	 * @param void *pbuf: message buffer
	 */
	int MsgFunc_RemEffect(const char *pszName, int iSize, void *pbuf);

	/**
	 * removes a fx system
	 * @param const char *pszName: name of the message
	 * @param int iSize: size of the message
	 * @param void *pbuf: message buffer
	 */
	int MsgFunc_UpdEffect(const char *pszName, int iSize, void *pbuf);
private:
	std::vector<FXSystem*>systems;
	float m_flLastTime;
	void RemoveSystem(int type, int id);
//public:
	//precached sprites
	HSPRITE m_hsprSBCharge,m_hsprDust,m_hsprFlameThrower,m_hsprBodySplash;	
};

/**
* camera view changer
* @version 20-6-2001
* @author Herwin 'harSens' van Welbergen
*/
class CHudCamera: public CHudBase 
{ 
public:
	/**
	* initializes 
	* @return int: always 1
	*/
	int Init( void ); 

	/**
	 * Pcjoe: Resets Camera View
	 */
	void Reset(void);

	/**
	 * Pcjoe: Think function
	 */
	void Think(void);

	/**
	* handles camera view changing messages from the server
	* @param const char *pszName: name of the message
	* @param int iSize: size of the message
	* @param void *pbuf: message buffer
	*/
	int MsgFunc_ChangeView(const char *pszName, int iSize, void *pbuf); 

	
	///toggles the view if the changeview button is pressed
	void _cdecl UserCmd_ToggleView( void );

	///resets the view
	void _cdecl UserCmd_ResetView( void );

	// added by Pcjoe
	bool m_blForceThird;
private:
	int m_fForceView;
}; 

/**
* Shows the credits
* @version 31-8-2001
* @author Herwin 'harSens' van Welbergen
*/
class CHudCredits: public CHudBase 
{ 
public:
	/**
	* initializes 
	* @return int: always 1
	*/
	int Init( void ); 

	/**
	 * resets credits
	 */
	void Reset(void);

	///draws credits
	int Draw(float flTime);

	///Shows credits if button for that is pressed
	void _cdecl UserCmd_ShowCredits( void );

private:
	int m_fShowing;//are the credits already shown?
	int m_iCreditNr;//number of showing credit
	int m_iLastCredit;//nr of the last credit
	float m_flLastScroll;
	float m_flYOffset;
	char m_pLeftCredits[255][255];
	char m_pRightCredits[255][255];
}; 

/**
* Charge bar drawer
* @version 12-7-2001
* @author Herwin 'harSens' van Welbergen
*/
class CHudCharge: public CHudBase 
{ 
public:
	/**
	* initializes 
	* @return int: always 1
	*/
	int Init( void ); 
	
	/**
	* resets chargebar
	*/
	void Reset(void);

	/**
	* loads sprites
	* @return int: always 1
	*/
	int VidInit( void );

	/**
	* draws chargebar
	* @param float time: the time
	* @return int: always 1
	*/
	int Draw(float flTime);

	/**
	* changes the fill value
	* @param const char *pszName: name of the message
	* @param int iSize: size of the message
	* @param void *pbuf: message buffer
	*/
	int MsgFunc_Charge(const char *pszName, int iSize, void *pbuf);
private:
	float m_flFill;
	int m_HUD_chargebar;
	int m_HUD_chargeline;
	int m_HUD_chargering;
	int m_fChargeRing;
};

/**
* Power Struggle drawing
* @version 28-8-2001
* @author Herwin 'harSens' van Welbergen
*/
class CHudPowerStruggle: public CHudBase 
{ 
public:
	/**
	* initializes 
	* @return int: always 1
	*/
	int Init( void ); 

	/**
	 * removes ps bar
	 */
	void Reset(void);
	
	/**
	* loads sprites
	* @return int: always 1
	*/
	int VidInit( void );

	/**
	* draws chargebar
	* @param float time: the time
	* @return int: always 1
	*/
	int Draw(float flTime);	

	/**
	* changes the 
	* @param const char *pszName: name of the message
	* @param int iSize: size of the message
	* @param void *pbuf: message buffer
	*/
	int MsgFunc_PowerStrug(const char *pszName, int iSize, void *pbuf);
private:
	int m_fPowerStruggle;
	float m_flPowerRatio;
	int m_HUD_powerstrugglebar;
	int m_HUD_powerstruggleline;
	int m_HUD_powerstrugglering;
	int m_fOverPowering;
	int m_fOverPowered;
};

/**
* Mp3 Player
* @version 25-8-2001
* @author Herwin 'harSens' van Welbergen
*/
class CHudMp3Player: public CHudBase
{	
public:
	/**
	* initializes 
	* @return int: always 1
	*/
	int Init( void );
	
	/**
	* think function, used to change tracks
	*/
	void Think( void );

	/**
	* deinitializes
	*/
	void DeInit();
	
	///plays current song
	void Play();

	///pauses playing
	void Pause();

	///stop playing
	void Stop();

	///select next song
	void Next();

	///select previous song
	void Previous();

	///selects playing mode
	void Mode();
	
	enum status{MP3_NONE = 0,MP3_STOP = 1, MP3_PLAY=2, MP3_PAUSE=3}m_eStatus;
	enum mode{MP3MODE_NONE = 0,MP3MODE_NORMAL =1 ,MP3MODE_SHUFFLE=2}m_eMode;
	int m_iError;	
private:
	void InitFmod();
	int m_iChannel;
	int m_iSecs;
	int m_iMins;
	int m_fInit;
	std::vector <std::string> m_pFixedPlaylist;
	std::vector <std::string> m_pPlaylist;
	std::vector <std::string>::iterator m_pCurrentSong;
	FSOUND_STREAM *m_pStream;	
	// Moved by Pcjoe, Fmod wrapper made global for fx script system
//	FMODWrapper m_FMODWrapper;
	void Shuffle();
	void Normal();
	void LoadStatus();
	void SaveStatus();

	// added by Pcjoe
	std::string GetSongName();
};


/**
* Powerlevel indicator
* @version 30-7-2001
* @author Herwin 'harSens' van Welbergen
*/
class CHudPowerLevel: public CHudBase
{
public:
	/**
	* Inits powerlevel
	* @return int: always 1 (?)
	*/
	int Init( void );

	/**
	* Updates the powerlevel
	* @param const char *pszName: message name
	* @param int iSize: message size
	* @param void *pbuf: buffer with message info
	* @return int:always 1
	*/ 
	int MsgFunc_PowerLevel(const char *pszName, int iSize, void *pbuf);

	int m_iPowerLevel;
private:	
};

/**
* Ki indicator
* @version 12-5-2001
* @author Herwin 'harSens' van Welbergen
*/
class CHudKi: public CHudBase
{
public:
	/**
	* Inits ki
	* @return int: always 1 (?)
	*/
	int Init( void );

	/**
	* Load some sprites,etc
	* @return int: always 1 (?)
	*/
	int VidInit(void);
	
	/**
	* Drawing code
	* @param float flTime: time (?)
	* @return int: 1 if succeeded 0 if not
	*/
	int Draw(float flTime);
	
	/**
	* Updates the ki
	* @param const char *pszName: message name
	* @param int iSize: message size
	* @param void *pbuf: buffer with message info
	* @return int:always 1
	*/ 
	//int MsgFunc_Ki(const char *pszName, int iSize, void *pbuf);
	
private:
	//int m_iKi;
	int m_HUD_mainbar;
	int m_HUD_kiline;
	int m_HUD_kifront;
};

/**
* Stamina indicator
* @version 12-11-2006
* @author Herwin 'harSens' van Welbergen
*/
class CHudStamina: public CHudBase
{
public:
	/**
	* Inits ki
	* @return int: always 1 (?)
	*/
	int Init( void );

	/**
	* Load some sprites,etc
	* @return int: always 1 (?)
	*/
	int VidInit(void);
	
	/**
	* Drawing code
	* @param float flTime: time (?)
	* @return int: 1 if succeeded 0 if not
	*/
	int Draw(float flTime);
	
	/**
	* Updates the ki
	* @param const char *pszName: message name
	* @param int iSize: message size
	* @param void *pbuf: buffer with message info
	* @return int:always 1
	*/ 
	int MsgFunc_Stamina(const char *pszName, int iSize, void *pbuf);
	
private:
	int m_iStamina;
	int m_HUD_mainbar;
	int m_HUD_staminaline;
	int m_HUD_staminafront;
};

/**
* Sensubean hud gfx
* @version 22-9-2001
* @author Herwin 'harSens' van Welbergen
*/
class CHudSensuBean: public CHudBase 
{ 
public: 
	/**
	* initializes 
	* @return int: always 1
	*/
	int Init( void ); 
	
	/**
	* handles senzubean messages from the server
	* @param const char *pszName: name of the message
	* @param int iSize: size of the message
	* @param void *pbuf: message buffer
	*/
	int MsgFunc_SensuBean(const char *pszName, int iSize, void *pbuf); 

	/**
	* loads sprites
	* @return int: always 1
	*/
	int VidInit( void );

	/**
	* Draw function
	* @param float time: time since last level restart
	*/
	int Draw(float flTime);

	int m_iWidth;
private:
	int m_iSensuBeans;
	int m_HUD_beanbar;	
};

/**
 * Attack trails
 * @version 22-10-2001
 * @author Herwin 'harSens' van Welbergen
 */
class CHudTrail: public CHudBase
{
public:
	/**
	* Inits trails
	* @return int: always 1 (?)
	*/
	int Init( void );

	/**
	 * loads sprites
	 * @return always 1 (?)
	 */
	int VidInit();

	/**
	 * Removes all trails
	 */
	void InitHUDMap(void);

	/**
	* Drawing code
	* @param float flTime: time (?)
	* @return int: 1 if succeeded 0 if not
	*/
	int Draw(float flTime);

	/**
	* Starts a Point Ent trail
	* @param const char *pszName: message name
	* @param int iSize: message size
	* @param void *pbuf: buffer with message info
	* @return int:always 1
	*/ 
	int MsgFunc_SBCTrail(const char *pszName, int iSize, void *pbuf);

	/**
	* Starts a Point Ent trail
	* @param const char *pszName: message name
	* @param int iSize: message size
	* @param void *pbuf: buffer with message info
	* @return int:always 1
	*/ 
	int MsgFunc_EETrail(const char *pszName, int iSize, void *pbuf);

	/**
	* Starts a Flare
	* @param const char *pszName: message name
	* @param int iSize: message size
	* @param void *pbuf: buffer with message info
	* @return int:always 1
	*/ 	
	int MsgFunc_Flare(const char *pszName,  int iSize, void *pbuf );

	/**
	* Starts a Ball
	* @param const char *pszName: message name
	* @param int iSize: message size
	* @param void *pbuf: buffer with message info
	* @return int:always 1
	*/ 	
	int MsgFunc_Ball(const char *pszName,  int iSize, void *pbuf );
	
	/**
	* Removes the point ent trail
	* @param const char *pszName: message name
	* @param int iSize: message size
	* @param void *pbuf: buffer with message info
	* @return int:always 1
	*/ 
	int MsgFunc_KillTrail( const char *pszName, int iSize, void *pbuf );

	/**
	* Changes the ent-ent trail into a point-ent trail
	* @param const char *pszName: message name
	* @param int iSize: message size
	* @param void *pbuf: buffer with message info
	* @return int:always 1
	*/
	int MsgFunc_DetachTrail( const char *pszName, int iSize, void *pbuf );

	/**
	* Power struggle
	* @param const char *pszName: message name
	* @param int iSize: message size
	* @param void *pbuf: buffer with message info
	* @return int:always 1
	*/
	int MsgFunc_PowStrug(const char *pszName,  int iSize, void *pbuf );

	/**
	 * Adds a ball
	 * @param iEnt the entity
	 * @param iSprite the ball sprite
	 * @param iWidth the width
	 */
	void AddBall(int iEnt,int iSprite,int iWidth);
	
	/**
	* Adds a point to a point ent trail
	* @param int iStartEnt: start entity
	* @param int iEndEnt: end entity
	* @param int iStartAttachement: starting attachment
	* @param int iFlareA: flare sprite a
	* @param int iFlareB: flare sprite b
	* @param int iBeam: beam sprite
	* @param int iSize: size of the trail
	* @param int iOrbitFlareA: orbit flare sprite a
	* @param int iOrbitFlareB: orbit flare sprite b
	* @param int iOrbitBeam: orbit beam sprite
	* @param int iOrbitSize: size of orbitting trail
	*/ 	
	void AddSBCTrail(int iStartEnt,int iEndEnt,int iStartAttachment,int iFlareA,int iFlareB,int iBeam,int iSize,int iOrbitFlareA,int iOrbitFlareB,int iOrbitBeam,int iOrbitSize);

	/**
	* Adds a point to a point ent trail
	* @param int startent: start entity
	* @param int endent: end entity
	* @param int attachment: start attachment
	* @param int sidestart: start sprite (side)
	* @param int sideflare: flare sprite (side)	
	* @param int frontstart: start sprite (front)
	* @param int frontflare: flare sprite (front)
	* @param int beam: beam sprite
	* @param int width: width of trail
	* @param int detail: detail level
	* @param vec3_t vecOrigin: origin
	*/ 	
	void AddEntEntTrail(int startent, int endent, int attachment, int sidestart, int sideflare, int frontstart, int frontflare, int trail, int width, int detail, vec3_t vecOrigin);
	
	/**
	* Connect the beam to the player it's struggling with
	* @param const char *pszName: message name
	* @param int iSize: message size
	* @param void *pbuf: buffer with message info
	* @return int:always 1
	*/
	int MsgFunc_BlockStrug(const char *pszName,  int iSize, void *pbuf );

	/**
	 * Removes an ent-ent trail
	 * @param int target: the target to remove
	 */
	void RemoveEETrail(int target);

	/**
	 * Removes a sbs trail
	 * @param int target: the target to remove
	 */
	void RemoveSBCTrail(int target);

	/**
	 * Removes a ball
	 * @param int target: the target to remove
	 */
	void RemoveBall(int target);

	/**
	 * Removes a flare
	 * @param int target: the target to remove
	 */
	void RemoveFlare(int target);

	/**
	 * draw the trails
	 */
	void DrawTrails();

	/**
	 * Finds a point ent trail
	 * @param int target: target entity to search for
	 * @return int: the trail nr, -1 for not found
	 */
	std::list<ent_ent_trail>::iterator FindEntEntTrail(int target);

	/**
	 * Limits the trails length
	 * @param trail_points *points: points
	 * @param int length: length to limit to
	 * @param vec3_t vecOrigin: current beam position
	 */
	float LimitTrailLength(std::list <vec3_t> &points, float length, vec3_t vecOrigin);

	int GetBeamQuality();

private:
	/**
	 * set blockstruggle info on beam
	 * @param head beam to set blockstruggle info on
	 * @param player player entity nr
	 */
	void SetBlockStruggle(beam &head, int player);

	/**
	 * draws the footskids
	 * @param skid the footskid
	 */
	void DrawFootskids(footskid skid);

	/**
	 * Adds a flare
	 * @param int iEnt: start ent
	 * @param int iFlareA: flare a sprite
	 * @param int iFlareB: flare b sprite
	 * @param int iBeam: the beam sprite
	 * @param ini iLength: max length of the flare
	 * @param int iWidth: flare width*5
	 * @param vec3_t vecStart: start pos
	 */
	void AddFlare(int iEnt, int iFlareA, int iFlareB, int iBeam, int iLength, int iWidth, vec3_t vecStart);

	/**
	 * Finds a point ent trail
	 * @param int target: target entity to search for
	 * @return int: the trail nr, -1 for not found
	 */
	std::list<sbc_trail>::iterator FindSBCTrail(int target);


	/**
	 * Finds a flare
	 * @param int target: target entity to search for
	 * @return int: the trail nr, -1 for not found
	 */
	std::list<flare>::iterator FindFlare(int target);

	

	/**
	 * Finds a ball
	 * @param int target: target entity to search for
	 * @return the iterator to the ball
	 */
	std::list<ball>::iterator FindBall(int target);

	

	/**
	 * Adds a point to the trail
	 * @param vec3_t point: point to add
	 * @param trail_point point: trailpoint to add the new point to
	 * @return trail_points *: the new trail
	 */ 
	//trail_points * AddPoint( vec3_t point, trail_points *startpoint);

	/**
	 * Gets the distance between the last point in the trail, and some random point
	 * @param vec3_t point: point to get the distance from
	 * @param trail_point point: trailpoint of the trail
	 * @return float: the length between the last 2 points
	 */	
	//float GetDistance(vec3_t point, list <vec3_t> startpoint);	

	/**
	 * Gets the next trail frame
	 * @param int trail: trail sprite
	 * @param int oldframe: last frame
	 */
	int getTrailFrame(int trail, int oldframe);

	/**
	 * Sets the right frame for a beamstart
	 * @param ent_ent_trail trTrail: the entent trail to set the start for
	 */
	void AnimateStart(ent_ent_trail &trTrail);

	/**
	 * Set the right frame for a ball
	 * @param b the ball
	 */
	void AnimateBall(ball &b);

	/**
	 * Sets the right frame for the head sprites
	 * @param beam head: the head to set the frame for
	 */	
	void AnimateFlare(beam &head);

	std::vector<footskid> m_footskids;
	std::list<ball>m_balls;

	float m_flLastDraw;
	float m_flPreviousDraw;
	HSPRITE m_hsprFootskid;
};


/**
* Scouter
* @version 29-11-2001
* @author Herwin 'harSens' van Welbergen
*/
class CHudScouter: public CHudBase
{
public:
	/**
	* Inits scouter
	* @return int: always 1 (?)
	*/
	int Init( void );

	/**
	* Drawing code
	* @param float flTime: time (?)
	* @return int: 1 if succeeded 0 if not
	*/
	int Draw(float flTime);

	/**
	 * Resets scouter
	 */
	void Reset();

	/**
	* loads sprites
	* @return int: always 1
	*/
	int VidInit( void );

	///enables/disables scouter
	void _cdecl UserCmd_ToggleScouter( void );

	void _cdecl UserCmd_ShowMemLeaks( void );

	/**
	* sends the entity nr for the dragonballs
	* @param const char *pszName: message name
	* @param int iSize: message size
	* @param void *pbuf: buffer with message info
	* @return int:always 1
	*/ 
	int MsgFunc_DBEnt( const char *pszName, int iSize, void *pbuf );
	
private:
	/**
	* Draws the radar
	* @param float flTime: time passed since last draw
	*/	
	void DrawRadar(float flTime, int x, int y);

	/**
	* draws the stats of the player the crosshair hit
	* @param int index: the index of the player hit
	*/
	void DrawPlayerStats();

	/**
	* Drawing dragonradar
	* @param float flTime: time (?)
	* @return int: 1 if succeeded 0 if not
	*/
	int DrawDragonRadar(float flTime, int iMidX, int iMidY, int iRadius);

	/**
	* Drawing dragonradar
	* @param float flTime: time (?)
	* @return int: 1 if succeeded 0 if not
	*/
	int DrawPlayerRadar(float flTime, int iMidX, int iMidY, int iRadius);

	int DrawBuddyRadar(float flTime, int iMidX, int iMidY, int iRadius);
	
	/**
	* calculates the position of the client to draw on the radar
	* @param int iClientindex: client index
	* @param int iMidX: x coordinate of the center of the radar
	* @param int iMidY: y coordinate of the center of the radar
	* @param int iRadius: radar radius
	* @param Vector2D vecPos: vecPos to return the position in
	* @returns bool true if on radar
	*/
	bool CalculateRadarPos(int iClientindex, int iMidX, int iMidY, int iRadius, Vector2D &vecPos);

	/**
	 * Draws a dot on the radar
	 * @param Vector2D pos: position of the dot
	 * @param int sprite: dot sprite
	 * @param color: dot color
	 */
	void DrawDot(Vector2D pos, int sprite, int color);

	// Added by Pcjoe
	/**
	* Does time difference for all of the particle systems, used to add velocity equally
	* @param float flTime: The time
	*/
	void SetTimeDifference( float flTime )
	{	m_flTimeDifference = flTime - m_flDrawTime;
	}

	/**
	* Resets draw time for time difference
	* @param float flTime: The time
	*/
	void ResetTimeDifference( float flTime)
	{	m_flDrawTime = flTime;
	}
	int m_HUD_scoutermetalmode[3];
	int m_HUD_scoutermetal;
	int m_HUD_radarglass;
	int m_HUD_scouterglass;
	int m_iRadarFrame;
	int m_HUD_radardot[7];
	int m_HUD_class[10];
	int m_HUD_dragonballdot;
	int m_HUD_radarcenter;
	float m_flLastDraw;
	float m_flLastDotDraw[MAX_PLAYERS + 1];
	int m_fDrawPlayerDot[MAX_PLAYERS + 1];
	int m_iDragonBallEnt[7];
	int m_iStatsEnt;
	bool m_bIsBuddy;
	float m_flLastStats;
	int m_fScouter;
	float m_flPlayerStatsTime;
	// Added by Pcjoe
	float m_flTimeDifference;
	float m_flDrawTime;
	
};

/**
* Custom crosshair
* @version 31-1-2002
* @author Herwin 'harSens' van Welbergen
*/
class CHudCrosshair: public CHudBase 
{ 
public: 
	/**
	* initializes 
	* @return int: always 1
	*/
	int Init( void ); 
	
	/**
	 * vidinit
	 */
	int VidInit();

	/**
	 * Resets crosshair
	 */
	void Reset();
	
	/**
	* Draw function
	* @param float time: time since last draw
	*/
	int Draw(float flTime);

	/**
	 * Draw rectangles around beam
	 */
	void DrawFollowRectangle();

	int m_iAimedAtPlayer;
	bool m_bAimedAtBuddy;

	/**
	* Pcjoe: Get Crosshair Pos
	* @param vec3_t &screen: Location of crosshair
	* @param cl_entity_t *player: Local Player
	* @return int: Index of the entity we hit in the traceline
	*/
	int GetCrosshairPos( vec3_t &screen, cl_entity_t *player );
	int m_fRotate;
	float m_flRotateTime;
	int m_fLock;
	vec3_t m_vecOldPos;
	int m_iBeamEnt;
	//crosshair screen pos
	int m_iX;	
	int m_iY;	
private:
	HSPRITE m_sprBeamBox;	
};

/**
* Power up fx creator
* @version 04-03-2002
* @author Herwin 'harSens' van Welbergen
* @author Joseph 'Pcjoe' Florencio
*/
class CHudPowerup: public CHudBase 
{ 
public: 
	/**
	* initializes 
	* @return int: always 1
	*/
	int Init( void ); 

	/**
	* Removes all powerup fx
	*/
	void InitHUDMap(void);
	
	/**
	* handles explosion messages from the server
	* @param const char *pszName: name of the message
	* @param int iSize: size of the message
	* @param void *pbuf: message buffer
	*/
	int MsgFunc_Powerup(const char *pszName, int iSize, void *pbuf);

	/**
	* handles explosion messages from the server
	* @param const char *pszName: name of the message
	* @param int iSize: size of the message
	* @param void *pbuf: message buffer
	* @return int: always 1
	*/
	int MsgFunc_StopPowerup(const char *pszName, int iSize, void *pbuf); 

	/**
	* loads explosion sprite
	* @return int: always 1
	*/
	int VidInit( void );
	
	/**
	* Think func
	*/
	void Think( void );

private:

	/**
	* Does a traceline Directly down to the floor.
	* @param vec3_t Origin: The origin of the particle that you want to be traced
	* @param bool &water: If the trace landed ontop of water
	* @param int direction: Trace Down(0), trace up(1)
	* @return vec3_t: The position after the traceline
	*/
	vec3_t ParticleTrace(vec3_t Origin, bool &blwater, int direction);
	
	/**
	* Sets up Collision detection
	* @param particle &pParticle: The particle pointer
		Thats modified for collision detection
	* @param int collisionsize: How far close to the particles end point can it spawn?
		Example - If a particle generates 1 foot away from the wall, it wont generate
		(if the collisionsize is large enough)
	*/
	void ParticleCollisionSetup( group_particle &p, int iCollisionsize);

	/**
	* When particle amount is modified by the cvar,
	* this is used so we wont have particles drawing in unknown places
	* @param int &iMaxParticles: Maximum amount of particles per ring
	* @param int iLastMaxParticles: What was the max amount of particles before we messed with it?
	* @param int ifxtype: What shall we reset? 1 == Dust
	*/
	void ResetParticles(int &iMaxParticles, int iLastMaxParticles, int ifxtype);

	/**
	* Add size to a particle
	* @param float flTime: Hud time
	* @param int index: Index of player
	* @param float &flSizeTime: The particles time to make sure we don't add size too fast
	* @param float flTimeInc: In how many seconds shall we add more size
	* @param float flSizeIncrease: Increment we should increase size by
	* @param parGroup &group: used to change the size of the particle
	* @param int iMaxGroup: How many particles do we have to a group
	*/
	void AddSize(float flTime, powerupfx *pFXEntry, float &flSizeTime, float flTimeInc, float flSizeIncrease, parGroup &group, int iMaxGroup);

	/**
	* Subrtracts Life from  particle
	* @param float flTime: Hud time value
	* @param float flSubTime: How often shall we take away life
	* @param float flParticleTime: The time that works with flTime for the particles(to see when to draw and when not to)
	* @param parGroup &group[MAX_PARTICLE_GROUP]: The particles life(only part we use in this function
	* @param float flAddTime: Whens the next time we should take life away
	* @param int MaxParticleGroup: How many particles are in the group
	*/
	void SubLife(float flTime, float flSubLife, float &flParticleTime, parGroup group[MAX_DUST_GROUP], float flAddTime, int MaxParticleGroup);

	/**
	* Does time difference for all of the particle systems, used to add velocity equally
	* @param float flTime: The time
	*/
	void SetTimeDifference( float flTime )
	{	m_flTimeDifference = flTime - m_flDrawTime;
	}

	/**
	* Resets draw time for time difference
	* @param float flTime: The time
	*/
	void ResetTimeDifference( float flTime)
	{	m_flDrawTime = flTime;
	}

	// Dust Particle System
	void CreateDustGroupParticle( powerupfx *pFXEntry, int group );
	void CreateDustParticle( powerupfx *pFXEntry, int particle, int group, vec3_t origin );
	void ParticleDustThink( float flTime );

	// Ripple Particle System
	void CreateRippleGroupParticle(powerupfx *pFXEntry, int group);
	void CreateRippleParticle(powerupfx *pFXEntry, int particle, int group, vec3_t origin);
	void ParticleRippleThink(float flTime);

	// Rock Particle System
	void CreateRockGroupParticle( powerupfx *pFXEntry, int group );
	void CreateRockParticle( powerupfx *pFXEntry, int particle, int group, vec3_t origin );
	void ParticleRockThink( float flTime );


	// Aura Particle System
	void CreateAuraParticle( powerupfx *pFXEntry, int particle );
	void ParticleAuraThink( float flTime );
	
	// Varibles
	// Time used to add velocity
	float m_flDrawTime;
	float m_flTimeDifference;
}; 

/**
* Transformation indicator
* @version 10-3-2001
* @author Herwin 'harSens' van Welbergen
*/
class CHudTransform: public CHudBase
{
public:
	/**
	* Inits transformation
	* @return int: always 1 (?)
	*/
	int Init( void );

	/**
	* Load some sprites,etc
	* @return int: always 1 (?)
	*/
	int VidInit(void);
	
	/**
	* Drawing code
	* @param float flTime: time (?)
	* @return int: 1 if succeeded 0 if not
	*/
	int Draw(float flTime);
	
	/**
	* Gets transforming message from the client
	* @param const char *pszName: message name
	* @param int iSize: message size
	* @param void *pbuf: buffer with message info
	* @return int:always 1
	*/ 
	int MsgFunc_Transform( const char *pszName, int iSize, void *pbuf );
	int m_iWidth;
private:
	int m_iMaxTransform;
	int m_iTransformation;
	int m_HUD_transformline;
	int m_HUD_cffront;
	int m_HUD_mainbar;
};

/**
* Transformation indicator
* @version 10-3-2001
* @author Herwin 'harSens' van Welbergen
*/
class CHudFog: public CHudBase
{
public:
	/**
	* Inits fog
	* @return int: always 1 (?)
	*/
	int Init( void );

	/**
	* Drawing code
	* @param float flTime: time (?)
	* @return int: 1 if succeeded 0 if not
	*/
	int Draw(float flTime);
	
	/**
	* Gets transforming message from the client
	* @param const char *pszName: message name
	* @param int iSize: message size
	* @param void *pbuf: buffer with message info
	* @return int:always 1
	*/ 
	int MsgFunc_Fog( const char *pszName, int iSize, void *pbuf );
};

/**
* 
* @version 17-7-2003
* @author Herwin 'harSens' van Welbergen
*/
class CHudFlare: public CHudBase
{
public:
	/**
	* Inits flare
	* @return int: always 1 (?)
	*/
	int Init( void );
private:
	std::map <const char *,flare,ltstr> flares;
};

/**
* Transformation FX
* @version 19-6-2002
* @author Joseph 'Pcjoe' Florencio
*/
class CHudTransformFX: public CHudBase
{
public:
	/**
	* Inits transformation
	* @return int: always 1 (?)
	*/
	int Init( void );

	/**
	* Load some sprites,etc
	* @return int: always 1 (?)
	*/
	int VidInit(void);
	
	/**
	* Removes all powerup fx
	*/
	void ResetInit(void);
	
	/**
	* Drawing code
	* @param float flTime: time (?)
	* @return int: 1 if succeeded 0 if not
	*/
	int Draw(float flTime);

	/**
	* Called when a server is connected to
	*/
	void InitHUDData( void ) { ResetInit(); }
	
	/**
	* Gets transforming message from the client
	* @param const char *pszName: message name
	* @param int iSize: message size
	* @param void *pbuf: buffer with message info
	* @return int:always 1
	*/ 
	int MsgFunc_TransformFX( const char *pszName, int iSize, void *pbuf );
	/**
	* Gets message to stop transforming from the client
	* @param const char *pszName: message name
	* @param int iSize: message size
	* @param void *pbuf: buffer with message info
	* @return int:always 1
	*/ 
	int MsgFunc_StopTransFX(const char *pszName, int iSize, void *pbuf);
	// Draws the different types of trans FX
	CParticleFx Partsys;

private:

	/**
	* Does time difference for all of the particle systems, used to add velocity equally
	* @param float flTime: The time
	*/
	void SetTimeDifference( float flTime )
	{	m_flTimeDifference = flTime - m_flDrawTime;
	}

	/**
	* Resets draw time for time difference
	* @param float flTime: The time
	*/
	void ResetTimeDifference( float flTime)
	{	m_flDrawTime = flTime;
	}

	// Find Events/Transforms
	trans_event *FindEvent( int iFlag );
	trans_event *FindPrevEvent( trans_event *pEvent, trans_event *pStart );
	trans_event_manager *FindPrevTrans( int iIndex );
	trans_event_manager *FindTrans( int iIndex );
	// Delete Events
	trans_event *CHudTransformFX::DeleteEvent( trans_event *pEvent, trans_event_manager *pManager );

	// Control Events
	
	void AddEvents( trans_event_manager *pTransFx );

	void AddEvent( trans_event_manager *pTransFx, int iFlag, float flTimeStart, float flDurration );

	// Handle transforms
	trans_event_manager *DeleteTransFx( trans_event_manager *pTransFx );

	void AddTransform( int iIndex, int iCharacter, float flAcendTime );

	// Transformations for everyone
	void GokuTrans( trans_event_manager *pTransFx );

	void VegetaTrans( trans_event_manager *pTransFx );

	void GohanTrans( trans_event_manager *pTransFx );

	void TrunksTrans( trans_event_manager *pTransFx );

	void CellTrans( trans_event_manager *pTransFx );

	void FriezaTrans( trans_event_manager *pTransFx );
	
	void BuuTrans( trans_event_manager *pTransFx );

	void KrillinTrans ( trans_event_manager *pTransFx );

	void PiccoloTrans( trans_event_manager *pTransFx );

	void PerfectTransform( trans_event_manager *pTransFx );

	// flTime copied to the class
	float m_flTime;

	float m_flDrawTime;
	float m_flTimeDifference;
	// If we paused the mp3 within the tranny FX
	bool m_blMp3Pause;
};

/**
* Melee Shockwaves
* @version 18-7-2002
* @author Joseph Florencio
*/
class CHudMeleeFX: public CHudBase
{
public:
	/**
	* Inits powerlevel
	* @return int: always 1 (?)
	*/
	int Init( void );

	/**
	* Load some sprites,etc
	* @return int: always 1 (?)
	*/
	int VidInit(void);

	/**
	* Removes all powerup fx
	*/
	void InitHUDMap(void);
	
	/**
	* Receives the type of FX that is going to be displayed
	* @param const char *pszName: message name
	* @param int iSize: message size
	* @param void *pbuf: buffer with message info
	* @return int:always 1
	*/ 
	int MsgFunc_MeleeFX(const char *pszName, int iSize, void *pbuf);

	/**
	* Client afterfx
	* @param const char *pszName: message name
	* @param int iSize: message size
	* @param void *pbuf: buffer with message info
	* @return int:always 1
	*/ 
	int MsgFunc_AfterFX(const char *pszName, int iSize, void *pbuf);

	/*
	* Create after fx
	* @param float flFadeSpeed: Speed of fade
	* @param vec3_t vecOrigin: Origin of this after fx
	* @param vec3_t vecAngles: Angles of after fx
	* @param cl_entity_t *pEnt: Entity we're modeling the after fx over
	*/
	void CreateAfterfx( float flFadeSpeed, vec3_t vecOrigin, vec3_t vecAngles, cl_entity_t *pEnt );

	/*
	* Set Bodypart ( only while in melee )
	* @param int iIndex: Player Index
	* @param int iBody: Body Part index
	*/
	void SetBodypart( int iIndex, int iBody );

	/*
	* Create shockwave FX
	* @param int iType: Type of melee shockwave
	* @param vec3_t vecOrigin: Spawn origin
	*/
	std::list<melee_shock_t>::iterator CreateShockwave( int iType, vec3_t vecOrigin );

	/*
	* Create shockwave on bone
	* @param int iType: type of shockwave effect
	* @param int idx: Index of player emitting shockwave
	* @param char *pBone: Bone we're emitting the FX from
	*/
	void CreateShockwaveBone( int iType, int idx, char *pBone );

	/*
	* Render Shockwaves
	*/
	void RenderShockwaves( void );

private:
	/*
	* Get Life
	* @param std::list<melee_shock_t>::iterator iter: STL iterator
	* @return float: 0-1 percent life
	*/
	float GetLife( std::list<melee_shock_t>::iterator shock );

	/*
	* Get Size
	* @param std::list<melee_shock_t>::iterator iter: STL iterator
	* @return float: Current size
	*/
	float GetSize( std::list<melee_shock_t>::iterator shock );

	/*
	* Get Alpha
	* @param std::list<melee_shock_t>::iterator iter: STL iterator
	* @return float: Current alpha transparency
	*/
	float GetAlpha( std::list<melee_shock_t>::iterator shock );

	/*
	* Animate
	* @param std::list<melee_shock_t>::iterator iter: STL iterator
	*/
	void Animate( std::list<melee_shock_t>::iterator shock );


	std::list <melee_shock_t> m_Meleefx;
};

/**
* Blob GFX
* @version 9-5-2002
* @author Joseph 'Pcjoe' Florencio
*/
class CHudBlob: public CHudBase
{
public:
	/**
	* Inits transformation
	* @return int: always 1 (?)
	*/
	int Init( void );

	/**
	* Load some sprites,etc
	* @return int: always 1 (?)
	*/
	int VidInit(void);

	/**
	* resets GFX
	*/
	void Reset( void );
	
	/**
	* Think code
	*/
	void Think( void );
	
	/**
	* Gets transforming message from the client
	* @param const char *pszName: message name
	* @param int iSize: message size
	* @param void *pbuf: buffer with message info
	* @return int:always 1
	*/ 
	int MsgFunc_BlobStart( const char *pszName, int iSize, void *pbuf );
	int MsgFunc_BlobUpdate( const char *pszName, int iSize, void *pbuf );
	int MsgFunc_BlobKill( const char *pszName, int iSize, void *pbuf );

private:

	void AddExplosion( int iSize, int iIndex, int iType, vec3_t vecOrigin, HSPRITE sprite );
	void AnimateSprite( explosion *pBlob, float flTime );
	void UpdateExplosion( int iSize, int iIndex );
	explosion *RemoveBlob( explosion *pExp );
	explosion *FindExplosion( int iIndex );
	float m_flUpdateTime;
	HSPRITE m_hsprBlobWhite;
	HSPRITE m_hsprBlobYellow;
};

/**
* Manipulation of bones
* @version 5-3-03
* @author Joseph 'Pcjoe' Florencio
*/
class CHudManipModel: public CHudBase 
{ 
public: 
	/**
	* Init
	* @return int: always 1 (?)
	*/
	int Init( void );

	/**
	* Load some sprites,etc
	* @return int: always 1 (?)
	*/
	int VidInit(void);

	/**
	* resets GFX
	*/
	void InitHUDMap( void );
	
	/**
	* Think code
	*/
	void Think( void );

	/*
	* Can Record Pos
	* @param int flags: Flags of current model_manip_s
	* @return bool: If we should record the bone positions
	*/
	bool RecordPos( int flags );
	

	/**
	* Gets info from server
	* @param const char *pszName: message name
	* @param int iSize: message size
	* @param void *pbuf: buffer with message info
	* @return int:always 1
	*/ 
	int MsgFunc_ManipModel( const char *pszName, int iSize, void *pbuf );

	/*
	* Remove all effects from entity
	* @param int iIndex: ent index
	*/
	void RemoveAll( int iIndex );

	/*
	* Remove single effect from entity
	* @param int iIndex: ent index
	* @param int iFlag: Flag we are removing
	*/
	void RemoveEffect( int iIndex, int iFlag );

	/*
	* Find by iPlayerIndex
	* @param int iIndex: Index we are trying to find
	* @param model_manip_s *pStart: Starting point of search
	*/
	/*modified by harSens
	std::list<model_manip_s>::iterator FindByPlayerIndex( int iIndex);
	std::list<model_manip_s>::iterator FindByPlayerIndex( std::list<model_manip_s>::iterator pStart, int iIndex);
	*/
	model_manip_s* FindByPlayerIndex( int iIndex);
	model_manip_s* FindByPlayerIndex( std::list<model_manip_s>::iterator pStart, int iIndex);

	/*
	* Find by iOtherIndex
	* @param int iIndex: Index we are trying to find
	*/
	/*modified by harSens
	std::list<model_manip_s>::iterator FindByOtherIndex( int iIndex  );
	std::list<model_manip_s>::iterator FindByOtherIndex( std::list<model_manip_s>::iterator, int iIndex);
	*/
	model_manip_s *FindByOtherIndex( int iIndex  );
	model_manip_s *FindByOtherIndex( std::list<model_manip_s>::iterator, int iIndex);

	/*
	* Remove link
	* @return model_manip_s: next link
	*/
	std::list<model_manip_s>::iterator Remove( std::list<model_manip_s>::iterator pManip );
	
	/**
	 * added by harSens
	 */
	void Remove( model_manip_s *pManip );

	/*
	* Find by iOtherIndex and iPlayerIndex
	* @param int iIndex: Index we are trying to find
	*/
	/*modified by harSens
	std::list<model_manip_s>::iterator FindByPlayerAndOtherIndex( int iIndex );
	std::list<model_manip_s>::iterator FindByPlayerAndOtherIndex( std::list<model_manip_s>::iterator pStart, int iIndex );
	*/
	model_manip_s* FindByPlayerAndOtherIndex( int iIndex );
	model_manip_s* FindByPlayerAndOtherIndex( std::list<model_manip_s>::iterator pStart, int iIndex );

	/*
	* Add rec bone to list
	*/
	std::list<model_manip_s>::iterator AddRecordBone( int iIndex );

	/*
	* Add motion blur to list
	*/
	std::list<model_manip_s>::iterator AddMotionBlur( int iIndex, int iSeq );

	std::list <model_manip_s> m_pModelManip;

private:

	/*
	* Add entity to the real list
	* @param model_manip_s *pModelManip: Entity we are adding
	*/
	std::list<model_manip_s>::iterator AddEntity( model_manip_s pModelManip );

	/*
	* Add to list
	* @param int iFlag: flags
	* @param int iIndex: entindex we are applying the effect to
	*/
	void AddEntity( int iFlag, int iIndex );

	/*
	* Add to list
	* @param int iFlag: flags
	* @param int iPlayerIndex: "Main" player index
	* @param int iOtherIndex: "Other" player index
	*/
	void AddEntity( int iFlag, int iPlayerIndex, int iOtherIndex );

	/*
	* Add to list
	* @param int iFlag: flags
	* @param int iPlayerIndex: "Main" player index
	* @param int iOtherIndex: "Other" player index
	*/
	void AddEntity( int iFlag, int iPlayerIndex, int iOtherIndex, int iDistance );

	/*
	* Add to list
	* @param int iFlag: flags
	* @param int iPlayerIndex: player index
	* @param vec3_t vecAngles: Angles we are setting for the player
	*/
	void AddEntity( int iFlag, int iPlayerIndex, vec3_t vecAngles );

	/*
	* Re-fix melee struggle angles
	* @param int iPlayerIndex: player index
	* @param vec3_t vecAngles: Angles we are setting for the player
	*/
	void FixMstruggleAngles( int iPlayerIndex, vec3_t vecAngles );

	/*
	* Switch rolls
	*/
	void Switch( int iIndex );
};

/**
* Melee Attacking/Defending Hud
* @version 7-14-03
* @author Joseph 'Pcjoe' Florencio
*/
class CHudMelee: public CHudBase
{
public:
	/**
	* Inits transformation
	* @return int: always 1 (?)
	*/
	int Init( void );

	/**
	* Load some sprites,etc
	* @return int: always 1 (?)
	*/
	int VidInit(void);

	/**
	* resets GFX
	*/
	void Reset(void);
	
	/**
	* Drawing code
	* @param float flTime: time (?)
	* @return int: 1 if succeeded 0 if not
	*/
	int Draw(float flTime);
	
	/**
	* Gets transforming message from the client
	* @param const char *pszName: message name
	* @param int iSize: message size
	* @param void *pbuf: buffer with message info
	* @return int:always 1
	*/ 
	int MsgFunc_MeleeAtkHud( const char *pszName, int iSize, void *pbuf );

private:

	/*
	* Get Sprite Height
	* @param char szTexture[]: Texture
	*/
	int GetSpriteHeight( char szTexture[] );

	/*
	* Get Sprite Width
	* @param char szTexture[]: Texture
	*/
	int GetSpriteWidth( char szTexture[] );

	/*
	* Get Sprite Height
	* @param int iSprite: Index to a texture
	*/
	int GetSpriteHeight( int iSprite );

	/*
	* Get Sprite Width
	* @param int iSprite: Index to a texture
	*/
	int GetSpriteWidth( int iSprite );

	/*
	* Enables hud drawing
	* @param int type: type of hud we're actiavting( arrow, blocking, combo )
	* @return bool: returns false if we shouldn't add this element
	*/
	bool ActivateHud( int type );

	/*
	* Add element
	* @param int type: Type of element ( arrow, blocking, combo )
	* @param int direction: Direction 
	*/
	void AddElement( int type, int direction );

	/*
	* Get current hud elem
	* @returnstd::list<meleetext_hud_t>::iterator: last member of "m_pMeleeHud" linked list
	*/
	std::list<melee_hud_s>::iterator GetHudElem( void );

	/*
	* Get Combo Time
	*/
	float GetCmbTime( std::list<melee_hud_s>::iterator hudelem );

	/*
	* Get Block Sprite
	* @param std::list<melee_hud_s>::iterator meleehud: Melee hud element
	* @param int &iSprite: Sprite we're setting
	* @param wrect_t &rect: Sprite rect
	*/
	void GetBlockSprite( std::list<melee_hud_s>::iterator MeleeHud, int &iSprite, wrect_t &rect );

	/*
	* Get Crossfade Sprite
	* @param std::list<melee_hud_s>::iterator meleehud: Melee hud element
	* @param int &iSprite: sprite we're setting ( 0 if no crossfade )
	* @param wrect &rect: Sprite rect
	* @return float: Crossfade percent
	*/
	float CrossFade( std::list<melee_hud_s>::iterator MeleeHud, int &iSprite, wrect_t &rect );

	/*
	* Remove all
	*/
	void RemoveAll( void );

	int		m_iType;
	int		m_iFlashNum;
	bool	m_blEnabled;
	std::list <melee_hud_s> m_MeleeHud;

	// Predict varibles
	float	m_flWeakRange;
	float	m_flMedRange;
	float	m_flStrongRange;
	float	m_flStunTime;

	// Sprites
	int	m_HUD_chargebar;
	int	m_HUD_chargeline;
	int	m_HUD_greenbar;		// colored bars
	int	m_HUD_bluebar;
	int	m_HUD_redbar;
	int	m_HUD_greybar;
	int	m_HUD_Arrows;	// arrow directions
	int	m_HUD_Blocks;	// blocking directions
	int	m_HUD_UBlocks;	// "random" blocking directions
};

/**
* Melee Hud Text Printouts
* @version 2-18-04
* @author Joseph 'Pcjoe' Florencio
*/
class CHudMeleeText: public CHudBase
{
public:
	/**
	* Inits transformation
	* @return int: always 1 (?)
	*/
	int Init( void );

	/**
	* resets GFX
	*/
	void Reset(void);
	
	/**
	* Drawing code
	* @param float flTime: time (?)
	* @return int: 1 if succeeded 0 if not
	*/
	int Draw(float flTime);
	
	/**
	* Gets transforming message from the client
	* @param const char *pszName: message name
	* @param int iSize: message size
	* @param void *pbuf: buffer with message info
	* @return int:always 1
	*/ 
	int MsgFunc_MeleeTxtHud( const char *pszName, int iSize, void *pbuf );

private:

	/*
	* Add Element
	* @param int iType: Type of element we're adding
	* @param int iNum: Number associated with the type (if any)
	*/
	void AddElement( int iType, int iNum );
};

/**
* 3D Hud Manager
* @version 12-26-03
* @author Joseph 'Pcjoe' Florencio
*/
class CHud3D: public CHudBase
{
public:
	/**
	* Init
	* @return int: always 1 (?)
	*/
	int Init( void );

	/**
	* Load some sprites,etc
	* @return int: always 1 (?)
	*/
	int VidInit(void);
	/**
	* resets GFX
	*/
	void Reset(void);
	
	/**
	* Drawing code
	* @param float flTime: time (?)
	* @return int: 1 if succeeded 0 if not
	*/
	int Draw(float flTime);

	C3DHud *m_p3DHud;
};

//Added by Rick
class CBotVGUI : public CHudBase
{
public:
	virtual int Init(void);
	virtual int VidInit( void ) {return 1;}
	int MsgFunc_BotVGUI( const char *pszName, int iSize, void *pbuf );
	virtual ~CBotVGUI(void);

	struct bot_perso_list_s
	{
		char *szBotPersoName;
		bot_perso_list_s *next;

		bot_perso_list_s(char *szName) : szBotPersoName(szName), next(NULL) {};
	};

	bot_perso_list_s *m_pBotPersonalityNames;
	bot_perso_list_s *m_pLastPersoNameEntry;
};

/**
* FX Script
* @version: 12-26-2004
* @author Joseph 'Pcjoe' Florencio
*/
class CFXScript: public CHudBase
{
public:
	/*
	* Init
	*/
	int Init( void );

	/*
	* Precache
	*/
	int VidInit(void);

	/*
	* Resets GFX
	*/
	void Reset(void);
	
	/**
	* Think
	*/
	void Think( void );
};

/**
* Custom Model
* @version: 8-26-05
* @author Joseph 'Pcjoe' Florencio
*/
class CCustomModelManager: public CHudBase 
{ 
public:
	/**
	* initializes 
	* @return int: always 1
	*/
	int Init( void ); 

	/**
	* Precaches
	* @return int: always 1
	*/
	int VidInit( void );

	/**
	* Player using Custom Model
	* @param int iIndex: Index of player we're checking
	* @returns bool: if using custom model
	*/
	bool usingCustomModelPlayer( int iIndex );

	/**
	* Get Custom Model for player
	* @param int iIndex: Index of player we're getting the custom model for
	* @return model_s *: Model
	*/
	model_s *getCustomModelPlayer( int iIndex );

	/**
	* Get Custom Model count for class
	* @param int iClass: Class we're checking
	* @return int: Count of custom models for this class
	*/
	int getCustomModelNum( int iClass );

	/**
	* Get custom model for class
	* @param int iClass: Class we're getting custom model from
	* @param int iNum: Index of the custom model we're getting
	* @return CCustomModel*: Custom Model
	*/
	CCustomModel *getCustomModel( int iClass, int iNum );

	/**
	* Get custom model for class
	* @param int iClass: Class we're getting custom model from
	* @param std::string strModel: Name of custom model directory
	* @return CCustomModel*: Custom Model
	*/
	CCustomModel *getCustomModel( int iClass, std::string strModel );

	/**
	* Updates on custom model status
	* @param const char *pszName: name of the message
	* @param int iSize: size of the message
	* @param void *pbuf: message buffer
	*/
	int MsgFunc_CustomModel(const char *pszName, int iSize, void *pbuf);

private:
	std::string m_CustomList[MAX_PLAYERS];
	std::vector<CCustomModel>	m_CustomModels[CLASS_LASTCLASS];
};


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



class CHud
{
private:
	HUDLIST						*m_pHudList;
	HSPRITE						m_hsprLogo;
	int							m_iLogo;
	client_sprite_t				*m_pSpriteList;
	int							m_iSpriteCount;
	int							m_iSpriteCountAllRes;
	float						m_flMouseSensitivity;
	int							m_iConcussionEffect; 

public:

	HSPRITE						m_hsprCursor;
	float m_flTime;	   // the current client time
	float m_fOldTime;  // the time at which the HUD was last redrawn
	double m_flTimeDelta; // the difference between flTime and fOldTime
	Vector	m_vecOrigin;
	Vector	m_vecAngles;
	int		m_iKeyBits;
	int		m_iHideHUDDisplay;
	int		m_iFOV;
	int		m_Teamplay;
	int		m_iRes;
	cvar_t  *m_pCvarStealMouse;
	cvar_t	*m_pCvarDraw;

	//added by harSens
	int		m_iCharacterLimit;
	
	int m_iFontHeight;
	/**
	* Gets the number of digits for a certain number
	* @param int number: the number to calculate the #digits for
	* @return int: the number of digits
	*/
	int Digits(int number);
	int DrawHudNumber(int x, int y, int iFlags, int iNumber, int r, int g, int b );
	int DrawHudString(int x, int y, int iMaxX, char *szString, int r, int g, int b );
	int DrawHudStringReverse( int xpos, int ypos, int iMinX, char *szString, int r, int g, int b );
	int DrawHudNumberString( int xpos, int ypos, int iMinX, int iNumber, int r, int g, int b );
	int GetNumWidth(int iNumber, int iFlags);

private:
	// the memory for these arrays are allocated in the first call to CHud::VidInit(), when the hud.txt and associated sprites are loaded.
	// freed in ~CHud()
	HSPRITE *m_rghSprites;	/*[HUD_SPRITE_COUNT]*/			// the sprites loaded from hud.txt
	wrect_t *m_rgrcRects;	/*[HUD_SPRITE_COUNT]*/
	char *m_rgszSpriteNames; /*[HUD_SPRITE_COUNT][MAX_SPRITE_NAME_LENGTH]*/

	struct cvar_s *default_fov;
public:
	HSPRITE GetSprite( int index ) 
	{
		return (index < 0) ? 0 : m_rghSprites[index];
	}

	wrect_t& GetSpriteRect( int index )
	{
		return m_rgrcRects[index];
	}

	
	int GetSpriteIndex( const char *SpriteName );	// gets a sprite index, for use in the m_rghSprites[] array

	/* modified by harSens
	CHudAmmo		m_Ammo;
	*/
	CHudAttack		m_Attack;
	CHudHealth		m_Health;
	CHudSpectator	m_Spectator;
	
	CHudBuddy       m_BuddyInfo;
	/* removed by harSens
	CHudGeiger		m_Geiger;
	CHudBattery		m_Battery;
	*/
	CHudTrain		m_Train;
	/* removed by harSens
  	CHudFlashlight	m_Flash;
	*/
	CHudMessage		m_Message;
	/* removed by harSens
	CHudStatusBar   m_StatusBar;
	*/
	CHudDeathNotice m_DeathNotice;
	CHudSayText		m_SayText;
	CHudMenu		m_Menu;
	/* disabled by harSens
	CHudAmmoSecondary	m_AmmoSecondary;
	*/
	CHudTextMessage m_TextMessage;
	CHudStatusIcons m_StatusIcons;
	
	//credits player by harSens
	CHudCredits m_Credits;
	//particle system manager by harSens
	CHudFXManager m_FXManager;
	//speed changer by harSens
	CHudSpeed m_Speed;
	//world 16-bit texture loader by harSens
	CHudWorld m_World;
	//bounding box drawer by harSens
	CHudBoundingBox m_BoundingBox;
	//camera changer by harSens
	CHudCamera m_Camera;
	//magic charger by harSens
	CHudCharge m_Charge;
	//powerlevel bar by harSens
	CHudPowerLevel m_PowerLevel;
	//ki bar by harSens
	CHudKi m_Ki;
	//stamina bar by harSens
	CHudStamina m_Stamina;
	//explosion trigger by harSens
	CHudExplosion m_Explosion;
	//mp3player by harSens
	CHudMp3Player m_Mp3Player;
	//powerstruggle hud gfx by harSens
	CHudPowerStruggle m_PowerStruggle;
	//sensubean gfx by harSens	
	CHudSensuBean m_SensuBean;
	//attack trails by harSens
	CHudTrail m_Trail;
	//scouter by harSens
	CHudScouter m_Scouter;
	//custom crosshair by harSens
	CHudCrosshair m_Crosshair;
	//powerupfx by harSens
	CHudPowerup m_Powerup;
	//transform bar by harSens
	CHudTransform m_Transform;
	//fog by harSens
	CHudFog m_Fog;
	//flare by harSens
	CHudFlare m_Flare;
	//transformFX by Pcjoe
	CHudTransformFX m_TransformFX;
	//melee fx by Pcjoe
	CHudMeleeFX m_MeleeFX;
	// blob fx by Pcjoe
	CHudBlob m_Blob;
	// bone manipulation by Pcjoe
	CHudManipModel m_ManipModel;
	// adv melee hud effects
	CHudMelee m_MeleeHud;
	// adv melee hud text printouts
	CHudMeleeText m_MeleeHudText;
	// 3d hud by Pcjoe
	CHud3D m_3dhud;
	// Bot VGUI by Rick
	CBotVGUI m_BotVGUI;
	// fx script by Pcjoe
	CFXScript m_FXScript;
	// custom models by pcjoe
	CCustomModelManager m_CustomModel;

	void Init( void );
	void VidInit( void );
	void Think(void);
	int Redraw( float flTime, int intermission );
	int UpdateClientData( client_data_t *cdata, float time );

	CHud() : m_iSpriteCount(0), m_pHudList(NULL) {}  
	~CHud();			// destructor, frees allocated memory

	// user messages
	int _cdecl MsgFunc_Damage(const char *pszName, int iSize, void *pbuf );
	int _cdecl MsgFunc_GameMode(const char *pszName, int iSize, void *pbuf );
	int _cdecl MsgFunc_Logo(const char *pszName,  int iSize, void *pbuf);
	int _cdecl MsgFunc_ResetHUD(const char *pszName,  int iSize, void *pbuf);
	void _cdecl MsgFunc_InitHUD( const char *pszName, int iSize, void *pbuf );
	void _cdecl MsgFunc_InitHUDMap( const char *pszName, int iSize, void *pbuf );	// Added by Pcjoe
	void _cdecl MsgFunc_ViewMode( const char *pszName, int iSize, void *pbuf );
	int _cdecl MsgFunc_SetFOV(const char *pszName,  int iSize, void *pbuf);
	int  _cdecl MsgFunc_Concuss( const char *pszName, int iSize, void *pbuf );

	// Screen information
	SCREENINFO	m_scrinfo;

	int	m_iWeaponBits;
	int	m_fPlayerDead;
	int m_iIntermission;

	// sprite indexes
	int m_HUD_number_0;

	// added by harSens
	int m_HUD_comma;

	void AddHudElem(CHudBase *p);

	float GetSensitivity();

};

class TeamFortressViewport;

extern CHud gHUD;
extern TeamFortressViewport *gViewPort;

extern int g_iPlayerClass;
extern int g_iTeamNumber;
extern int g_iUser1;
extern int g_iUser2;
extern int g_iUser3;
//added by harSens
extern float g_fUser4;
#endif

