summaryrefslogtreecommitdiff
path: root/game/client/tf/c_tf_playerresource.h
blob: 423bc27279bcf63c799c7a85a57351ec1c3496d5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: TF's custom C_PlayerResource
//
// $NoKeywords: $
//=============================================================================//

#ifndef C_TF_PLAYERRESOURCE_H
#define C_TF_PLAYERRESOURCE_H
#ifdef _WIN32
#pragma once
#endif

#include "tf_shareddefs.h"
#include "c_playerresource.h"
#include "tf_player_shared.h"

class C_TF_PlayerResource : public C_PlayerResource
{
	DECLARE_CLASS( C_TF_PlayerResource, C_PlayerResource );
public:
	DECLARE_CLIENTCLASS();

	C_TF_PlayerResource();
	virtual ~C_TF_PlayerResource();

	virtual int	GetTeam( int index ) OVERRIDE;

	int	GetTotalScore( int iIndex ) { return GetArrayValue( iIndex, m_iTotalScore, 0 ); }
	int GetMaxHealth( int iIndex )   { return GetArrayValue( iIndex, m_iMaxHealth, TF_HEALTH_UNDEFINED ); }
	int GetMaxHealthForBuffing( int iIndex )   { return GetArrayValue( iIndex, m_iMaxBuffedHealth, TF_HEALTH_UNDEFINED ); }
	int GetPlayerClass( int iIndex ) { return GetArrayValue( iIndex, m_iPlayerClass, TF_CLASS_UNDEFINED ); }
	int	GetActiveDominations( int iIndex ) { return GetArrayValue( iIndex, m_iActiveDominations, 0 ); }
	float GetNextRespawnTime( int iIndex ) { return (IsConnected(iIndex) ? m_flNextRespawnTime[iIndex] : 0); }
	int GetChargeLevel( int iIndex ) { return GetArrayValue( iIndex, m_iChargeLevel, 0 ); }
	int GetDamage( unsigned int nIndex );
	int GetDamageAssist( unsigned int nIndex );
	int GetDamageBoss( unsigned int nIndex );
	int GetHealing( unsigned int nIndex );
	int GetHealingAssist( unsigned int nIndex );
	int GetDamageBlocked( unsigned int nIndex );
	int GetCurrencyCollected( unsigned int nIndex );
	int GetBonusPoints( unsigned int nIndex );
	int	GetPlayerLevel( unsigned int nIndex ) { return GetArrayValue( nIndex, m_iPlayerLevel, 0 ); }
	int GetStreak( unsigned int nIndex, CTFPlayerShared::ETFStreak streak_type );
	int GetNumRespecCredits( uint32 unIndex );
	int GetNumBuybackCredits( uint32 unIndex );

	void UpdatePlayerScoreStats( void );
	void ResetPlayerScoreStats( int playerIndex = -1 );

	bool IsArenaSpectator( int iIndex ) 
	{
		if ( !IsConnected( iIndex ) )
		{
			return false;
		}
		return m_bArenaSpectator[iIndex];
	}

	int GetCountForPlayerClass( int iTeam, int iClass, bool bExcludeLocalPlayer = false );

	int GetNumPlayersForTeam( int iTeam, bool bAliveOnly );

	bool HasPremadeParties(){ return ( ( m_iPartyLeaderRedTeamIndex > 0 ) && ( m_iPartyLeaderBlueTeamIndex > 0 ) ); }
	int GetPartyLeaderRedTeamIndex(){ return m_iPartyLeaderRedTeamIndex; }
	int GetPartyLeaderBlueTeamIndex(){ return m_iPartyLeaderBlueTeamIndex; }
	int GetEventTeamStatus() { return m_iEventTeamStatus; }

	int GetPlayerClassWhenKilled( int iIndex ) { return GetArrayValue( iIndex, m_iPlayerClassWhenKilled, TF_CLASS_UNDEFINED ); }

	MM_PlayerConnectionState_t GetPlayerConnectionState( int iIndex ) const;
	
protected:
	int GetArrayValue( int iIndex, int *pArray, int defaultVal );

	int		m_iTotalScore[MAX_PLAYERS+1];
	int		m_iMaxHealth[MAX_PLAYERS+1];
	// !! This is actually m_iMaxHealthForBuffing, but we can't fix it now because of demos :-/
	int		m_iMaxBuffedHealth[MAX_PLAYERS+1];
	int		m_iPlayerClass[MAX_PLAYERS+1];
	bool	m_bArenaSpectator[MAX_PLAYERS+1];
	int		m_iActiveDominations[MAX_PLAYERS+1];

	// These variables are only networked in tournament mode
	float	m_flNextRespawnTime[MAX_PLAYERS+1];
	int		m_iChargeLevel[MAX_PLAYERS+1];

private:
	int		m_iDamage[MAX_PLAYERS+1];
	int		m_iDamageAssist[MAX_PLAYERS+1];
	int		m_iDamageBoss[MAX_PLAYERS+1];
	int		m_iHealing[MAX_PLAYERS+1];
	int		m_iHealingAssist[MAX_PLAYERS+1];
	int		m_iDamageBlocked[MAX_PLAYERS+1];
	int		m_iCurrencyCollected[MAX_PLAYERS+1];
	int		m_iBonusPoints[MAX_PLAYERS+1];
	int		m_iPlayerLevel[MAX_PLAYERS+1];
	// Pseudo multidimensional array [MAX_PLAYERS + 1][CTFPlayerShared::kTFStreak_COUNT]
	int		m_iStreaks[(MAX_PLAYERS+1) * CTFPlayerShared::kTFStreak_COUNT];
	int		m_iUpgradeRefundCredits[MAX_PLAYERS + 1];
	int		m_iBuybackCredits[MAX_PLAYERS + 1];

	int		m_iPartyLeaderBlueTeamIndex;
	int		m_iPartyLeaderRedTeamIndex;
	int		m_iEventTeamStatus;

	int		m_iPlayerClassWhenKilled[MAX_PLAYERS+1];
	MM_PlayerConnectionState_t	m_iConnectionState[MAX_PLAYERS+1];

	struct PlayerScoreboardStats_t
	{
		int	m_iPrevDamage;
		int	m_iPrevDamageAssist;
		int	m_iPrevDamageBoss;
		int	m_iPrevHealing;
		int	m_iPrevHealingAssist;
		int m_iPrevDamageBlocked;
		int	m_iPrevCurrencyCollected;
		int	m_iPrevBonusPoints;
	};

	PlayerScoreboardStats_t m_aPlayerScoreStats[MAX_PLAYERS+1];
};

extern C_TF_PlayerResource *g_TF_PR;

#endif // C_TF_PLAYERRESOURCE_H