Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

128 lines
4.5 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: TF's custom C_PlayerResource
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef C_TF_PLAYERRESOURCE_H
  8. #define C_TF_PLAYERRESOURCE_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "tf_shareddefs.h"
  13. #include "c_playerresource.h"
  14. #include "tf_player_shared.h"
  15. class C_TF_PlayerResource : public C_PlayerResource
  16. {
  17. DECLARE_CLASS( C_TF_PlayerResource, C_PlayerResource );
  18. public:
  19. DECLARE_CLIENTCLASS();
  20. C_TF_PlayerResource();
  21. virtual ~C_TF_PlayerResource();
  22. virtual int GetTeam( int index ) OVERRIDE;
  23. int GetTotalScore( int iIndex ) { return GetArrayValue( iIndex, m_iTotalScore, 0 ); }
  24. int GetMaxHealth( int iIndex ) { return GetArrayValue( iIndex, m_iMaxHealth, TF_HEALTH_UNDEFINED ); }
  25. int GetMaxHealthForBuffing( int iIndex ) { return GetArrayValue( iIndex, m_iMaxBuffedHealth, TF_HEALTH_UNDEFINED ); }
  26. int GetPlayerClass( int iIndex ) { return GetArrayValue( iIndex, m_iPlayerClass, TF_CLASS_UNDEFINED ); }
  27. int GetActiveDominations( int iIndex ) { return GetArrayValue( iIndex, m_iActiveDominations, 0 ); }
  28. float GetNextRespawnTime( int iIndex ) { return (IsConnected(iIndex) ? m_flNextRespawnTime[iIndex] : 0); }
  29. int GetChargeLevel( int iIndex ) { return GetArrayValue( iIndex, m_iChargeLevel, 0 ); }
  30. int GetDamage( unsigned int nIndex );
  31. int GetDamageAssist( unsigned int nIndex );
  32. int GetDamageBoss( unsigned int nIndex );
  33. int GetHealing( unsigned int nIndex );
  34. int GetHealingAssist( unsigned int nIndex );
  35. int GetDamageBlocked( unsigned int nIndex );
  36. int GetCurrencyCollected( unsigned int nIndex );
  37. int GetBonusPoints( unsigned int nIndex );
  38. int GetPlayerLevel( unsigned int nIndex ) { return GetArrayValue( nIndex, m_iPlayerLevel, 0 ); }
  39. int GetStreak( unsigned int nIndex, CTFPlayerShared::ETFStreak streak_type );
  40. int GetNumRespecCredits( uint32 unIndex );
  41. int GetNumBuybackCredits( uint32 unIndex );
  42. void UpdatePlayerScoreStats( void );
  43. void ResetPlayerScoreStats( int playerIndex = -1 );
  44. bool IsArenaSpectator( int iIndex )
  45. {
  46. if ( !IsConnected( iIndex ) )
  47. {
  48. return false;
  49. }
  50. return m_bArenaSpectator[iIndex];
  51. }
  52. int GetCountForPlayerClass( int iTeam, int iClass, bool bExcludeLocalPlayer = false );
  53. int GetNumPlayersForTeam( int iTeam, bool bAliveOnly );
  54. bool HasPremadeParties(){ return ( ( m_iPartyLeaderRedTeamIndex > 0 ) && ( m_iPartyLeaderBlueTeamIndex > 0 ) ); }
  55. int GetPartyLeaderRedTeamIndex(){ return m_iPartyLeaderRedTeamIndex; }
  56. int GetPartyLeaderBlueTeamIndex(){ return m_iPartyLeaderBlueTeamIndex; }
  57. int GetEventTeamStatus() { return m_iEventTeamStatus; }
  58. int GetPlayerClassWhenKilled( int iIndex ) { return GetArrayValue( iIndex, m_iPlayerClassWhenKilled, TF_CLASS_UNDEFINED ); }
  59. MM_PlayerConnectionState_t GetPlayerConnectionState( int iIndex ) const;
  60. protected:
  61. int GetArrayValue( int iIndex, int *pArray, int defaultVal );
  62. int m_iTotalScore[MAX_PLAYERS+1];
  63. int m_iMaxHealth[MAX_PLAYERS+1];
  64. // !! This is actually m_iMaxHealthForBuffing, but we can't fix it now because of demos :-/
  65. int m_iMaxBuffedHealth[MAX_PLAYERS+1];
  66. int m_iPlayerClass[MAX_PLAYERS+1];
  67. bool m_bArenaSpectator[MAX_PLAYERS+1];
  68. int m_iActiveDominations[MAX_PLAYERS+1];
  69. // These variables are only networked in tournament mode
  70. float m_flNextRespawnTime[MAX_PLAYERS+1];
  71. int m_iChargeLevel[MAX_PLAYERS+1];
  72. private:
  73. int m_iDamage[MAX_PLAYERS+1];
  74. int m_iDamageAssist[MAX_PLAYERS+1];
  75. int m_iDamageBoss[MAX_PLAYERS+1];
  76. int m_iHealing[MAX_PLAYERS+1];
  77. int m_iHealingAssist[MAX_PLAYERS+1];
  78. int m_iDamageBlocked[MAX_PLAYERS+1];
  79. int m_iCurrencyCollected[MAX_PLAYERS+1];
  80. int m_iBonusPoints[MAX_PLAYERS+1];
  81. int m_iPlayerLevel[MAX_PLAYERS+1];
  82. // Pseudo multidimensional array [MAX_PLAYERS + 1][CTFPlayerShared::kTFStreak_COUNT]
  83. int m_iStreaks[(MAX_PLAYERS+1) * CTFPlayerShared::kTFStreak_COUNT];
  84. int m_iUpgradeRefundCredits[MAX_PLAYERS + 1];
  85. int m_iBuybackCredits[MAX_PLAYERS + 1];
  86. int m_iPartyLeaderBlueTeamIndex;
  87. int m_iPartyLeaderRedTeamIndex;
  88. int m_iEventTeamStatus;
  89. int m_iPlayerClassWhenKilled[MAX_PLAYERS+1];
  90. MM_PlayerConnectionState_t m_iConnectionState[MAX_PLAYERS+1];
  91. struct PlayerScoreboardStats_t
  92. {
  93. int m_iPrevDamage;
  94. int m_iPrevDamageAssist;
  95. int m_iPrevDamageBoss;
  96. int m_iPrevHealing;
  97. int m_iPrevHealingAssist;
  98. int m_iPrevDamageBlocked;
  99. int m_iPrevCurrencyCollected;
  100. int m_iPrevBonusPoints;
  101. };
  102. PlayerScoreboardStats_t m_aPlayerScoreStats[MAX_PLAYERS+1];
  103. };
  104. extern C_TF_PlayerResource *g_TF_PR;
  105. #endif // C_TF_PLAYERRESOURCE_H