Counter Strike : Global Offensive Source Code
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.

137 lines
4.2 KiB

  1. //========= Copyright � 1996-2005, Valve LLC, All rights reserved. ============
  2. //
  3. //=============================================================================
  4. #ifndef BASEMULTIPLAYERPLAYER_H
  5. #define BASEMULTIPLAYERPLAYER_H
  6. #pragma once
  7. #include "ai_speech.h"
  8. class CBasePlayer;
  9. enum SpeechPriorityType
  10. {
  11. SPEECH_PRIORITY_LOW,
  12. SPEECH_PRIORITY_NORMAL,
  13. SPEECH_PRIORITY_MANUAL,
  14. SPEECH_PRIORITY_UNINTERRUPTABLE,
  15. };
  16. //-----------------------------------------------------------------------------
  17. // Purpose:
  18. //-----------------------------------------------------------------------------
  19. class CBaseMultiplayerPlayer : public CAI_ExpresserHost<CBasePlayer>
  20. {
  21. DECLARE_CLASS( CBaseMultiplayerPlayer, CAI_ExpresserHost<CBasePlayer> );
  22. DECLARE_ENT_SCRIPTDESC();
  23. public:
  24. CBaseMultiplayerPlayer();
  25. ~CBaseMultiplayerPlayer();
  26. virtual void Spawn( void );
  27. virtual void PostConstructor( const char *szClassname );
  28. virtual void ModifyOrAppendCriteria( AI_CriteriaSet& criteriaSet );
  29. virtual bool SpeakIfAllowed( AIConcept_t concept, SpeechPriorityType priority, const char *modifiers = NULL, char *pszOutResponseChosen = NULL, size_t bufsize = 0, IRecipientFilter *filter = NULL );
  30. void SpeakConcept( AI_Response &outresponse, int iConcept );
  31. virtual bool SpeakConceptIfAllowed( int iConcept, const char *modifiers = NULL, char *pszOutResponseChosen = NULL, size_t bufsize = 0, IRecipientFilter *filter = NULL );
  32. virtual bool CanHearAndReadChatFrom( CBasePlayer *pPlayer );
  33. virtual bool CanSpeak( void ) { return true; }
  34. virtual void Precache( void )
  35. {
  36. #if !defined( DOTA_DLL ) && !defined( PORTAL2 )
  37. PrecacheParticleSystem( "achieved" );
  38. #endif
  39. BaseClass::Precache();
  40. }
  41. virtual bool ClientCommand( const CCommand &args );
  42. virtual bool CanSpeakVoiceCommand( void ) { return true; }
  43. virtual bool ShouldShowVoiceSubtitleToEnemy( void );
  44. virtual void NoteSpokeVoiceCommand( const char *pszScenePlayed ) {}
  45. virtual void OnAchievementEarned( int iAchievement ) {}
  46. enum ChatIgnore
  47. {
  48. CHAT_IGNORE_NONE = 0,
  49. CHAT_IGNORE_BROADCAST,
  50. CHAT_IGNORE_BROADCAST_AND_TEAM,
  51. CHAT_IGNORE_EVERYTHING,
  52. };
  53. int m_iIgnoreGlobalChat;
  54. //---------------------------------
  55. // Speech support
  56. virtual CAI_Expresser *GetExpresser() { return m_pExpresser; }
  57. virtual CMultiplayer_Expresser *GetMultiplayerExpresser() { return m_pExpresser; }
  58. void SetLastForcedChangeTeamTimeToNow( void ) { m_flLastForcedChangeTeamTime = gpGlobals->curtime; }
  59. float GetLastForcedChangeTeamTime( void ) { return m_flLastForcedChangeTeamTime; }
  60. void SetTeamBalanceScore( int iScore ) { m_iBalanceScore = iScore; }
  61. int GetTeamBalanceScore( void ) { return m_iBalanceScore; }
  62. virtual int CalculateTeamBalanceScore( void );
  63. virtual void AwardAchievement( int iAchievement, int iCount = 1 );
  64. int GetPerLifeCounterKV( const char *name );
  65. void SetPerLifeCounterKV( const char *name, int value );
  66. void ResetPerLifeCounters( void );
  67. KeyValues *GetPerLifeCounterKeys( void ) { return m_pAchievementKV; }
  68. void EscortScoringThink( void );
  69. void StartScoringEscortPoints( float flRate );
  70. void StopScoringEscortPoints( void );
  71. float m_flAreaCaptureScoreAccumulator;
  72. float m_flCapPointScoreRate;
  73. float GetConnectionTime( void ) { return m_flConnectionTime; }
  74. #if !defined(NO_STEAM)
  75. //----------------------------
  76. // Steam handling
  77. bool GetSteamID( CSteamID *pID ) const;
  78. uint64 GetSteamIDAsUInt64( void ) const;
  79. #endif
  80. protected:
  81. virtual CAI_Expresser *CreateExpresser( void );
  82. int m_iCurrentConcept;
  83. private:
  84. //---------------------------------
  85. CMultiplayer_Expresser *m_pExpresser;
  86. float m_flConnectionTime;
  87. float m_flLastForcedChangeTeamTime;
  88. int m_iBalanceScore; // a score used to determine which players are switched to balance the teams
  89. KeyValues *m_pAchievementKV;
  90. };
  91. //-----------------------------------------------------------------------------
  92. // Inline methods
  93. //-----------------------------------------------------------------------------
  94. inline CBaseMultiplayerPlayer *ToBaseMultiplayerPlayer( CBaseEntity *pEntity )
  95. {
  96. if ( !pEntity || !pEntity->IsPlayer() )
  97. return NULL;
  98. #if _DEBUG
  99. return dynamic_cast<CBaseMultiplayerPlayer *>( pEntity );
  100. #else
  101. return static_cast<CBaseMultiplayerPlayer *>( pEntity );
  102. #endif
  103. }
  104. #endif // BASEMULTIPLAYERPLAYER_H