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.

183 lines
5.7 KiB

  1. //====== Copyright � 1996-2005, Valve Corporation, All rights reserved. =======
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. #ifndef TEAM_CONTROL_POINT_H
  7. #define TEAM_CONTROL_POINT_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "basemultiplayerplayer.h"
  12. // Spawnflags
  13. #define SF_CAP_POINT_HIDEFLAG (1<<0)
  14. #define SF_CAP_POINT_HIDE_MODEL (1<<1)
  15. #define SF_CAP_POINT_HIDE_SHADOW (1<<2)
  16. #define SF_CAP_POINT_NO_CAP_SOUNDS (1<<3)
  17. #define SF_CAP_POINT_NO_ANNOUNCER (1<<4)
  18. //-----------------------------------------------------------------------------
  19. // Purpose:
  20. //-----------------------------------------------------------------------------
  21. class CTeamControlPoint : public CBaseAnimating
  22. {
  23. DECLARE_CLASS( CTeamControlPoint, CBaseAnimating );
  24. public:
  25. DECLARE_DATADESC();
  26. CTeamControlPoint();
  27. // Derived, game-specific control points must override these functions
  28. public:
  29. // Used to find game specific entities
  30. virtual const char *GetControlPointMasterName( void ) { return "team_control_point_master"; }
  31. public:
  32. virtual void Spawn( void );
  33. virtual bool KeyValue( const char *szKeyName, const char *szValue );
  34. virtual void Precache( void );
  35. virtual int DrawDebugTextOverlays( void );
  36. //Inputs
  37. inline void Enable( inputdata_t &input ) { SetActive( false ); }
  38. inline void Disable( inputdata_t &input ) { SetActive( true ); }
  39. void InputReset( inputdata_t &input );
  40. void InputSetOwner( inputdata_t &input );
  41. void InputShowModel( inputdata_t &input );
  42. void InputHideModel( inputdata_t &input );
  43. void InputRoundActivate( inputdata_t &inputdata );
  44. // Owner handling
  45. void ForceOwner( int iTeam ); // used when selecting a specific round to play
  46. void SetOwner( int iCapTeam, bool bMakeSound = true, int iNumCappers = 0, int *iCappingPlayers = NULL );
  47. int GetOwner( void ) const;
  48. int GetDefaultOwner( void ) const;
  49. bool RandomOwnerOnRestart( void ){ return m_bRandomOwnerOnRestart; }
  50. void SetActive( bool active );
  51. inline bool IsActive( void ) { return m_bActive; }
  52. void AnimThink( void );
  53. bool PointIsVisible( void ) { return !( FBitSet( m_spawnflags, SF_CAP_POINT_HIDEFLAG ) ); }
  54. inline const char *GetName( void ) { return STRING(m_iszPrintName); }
  55. int GetCPGroup( void );
  56. int GetPointIndex( void ) { return m_iPointIndex; }
  57. void SetPointIndex( int index ) { m_iPointIndex = index; }
  58. int GetWarnOnCap( void ) { return m_iWarnOnCap; }
  59. string_t GetWarnSound( void ) { return m_iszWarnSound; }
  60. int GetTeamIcon( int iTeam );
  61. int GetCurrentHudIconIndex( void );
  62. int GetHudIconIndexForTeam( int iGameTeam );
  63. int GetHudOverlayIndexForTeam( int iGameTeam );
  64. int GetPreviousPointForTeam( int iGameTeam, int iPrevPoint );
  65. void SetCappersRequiredForTeam( int iGameTeam, int iCappers );
  66. void CaptureBlocked( CBaseMultiplayerPlayer *pPlayer );
  67. int PointValue( void );
  68. float LastContestedAt( void );
  69. void SetLastContestedAt( float flTime );
  70. void UpdateCapPercentage( void );
  71. // The specified player took part in capping this point.
  72. virtual void PlayerCapped( CBaseMultiplayerPlayer *pPlayer );
  73. // The specified player blocked the enemy team from capping this point.
  74. virtual void PlayerBlocked( CBaseMultiplayerPlayer *pPlayer );
  75. void CaptureEnd( void );
  76. void CaptureStart( int iCapTeam, int iNumCappingPlayers, int *pCappingPlayers );
  77. void CaptureInterrupted( bool bBlocked );
  78. virtual void StopLoopingSounds( void );
  79. private:
  80. void SendCapString( int iCapTeam, int iNumCappingPlayers, int *pCappingPlayers );
  81. void InternalSetOwner( int iCapTeam, bool bMakeSound = true, int iNumCappers = 0, int *iCappingPlayers = NULL );
  82. float GetTeamCapPercentage( int iTeam );
  83. void HandleScoring( int iTeam );
  84. int m_iTeam;
  85. int m_iDefaultOwner; // Team that initially owns the cap point
  86. int m_iIndex; // The index of this point in the controlpointArray
  87. int m_iWarnOnCap; // Warn the team that owns the control point when the opposing team starts to capture it.
  88. string_t m_iszPrintName;
  89. string_t m_iszWarnSound; // Sound played if the team needs to be warned about this point being captured
  90. bool m_bRandomOwnerOnRestart; // Do we want to randomize the owner after a restart?
  91. // We store a copy of this data for each team, +1 for the un-owned state.
  92. struct perteamdata_t
  93. {
  94. perteamdata_t()
  95. {
  96. iszCapSound = NULL_STRING;
  97. iszModel = NULL_STRING;
  98. iModelBodygroup = -1;
  99. iIcon = 0;
  100. iszIcon = NULL_STRING;
  101. iOverlay = 0;
  102. iszOverlay = NULL_STRING;
  103. iPlayersRequired = 0;
  104. iTimedPoints = 0;
  105. for ( int i = 0; i < MAX_PREVIOUS_POINTS; i++ )
  106. {
  107. iszPreviousPoint[i] = NULL_STRING;
  108. }
  109. iTeamPoseParam = 0;
  110. }
  111. string_t iszCapSound;
  112. string_t iszModel;
  113. int iModelBodygroup;
  114. int iTeamPoseParam;
  115. int iIcon;
  116. string_t iszIcon;
  117. int iOverlay;
  118. string_t iszOverlay;
  119. int iPlayersRequired;
  120. int iTimedPoints;
  121. string_t iszPreviousPoint[MAX_PREVIOUS_POINTS];
  122. };
  123. CUtlVector<perteamdata_t> m_TeamData;
  124. COutputEvent m_OnCapReset;
  125. COutputEvent m_OnCapTeam1;
  126. COutputEvent m_OnCapTeam2;
  127. COutputEvent m_OnOwnerChangedToTeam1;
  128. COutputEvent m_OnOwnerChangedToTeam2;
  129. COutputEvent m_OnRoundStartOwnedByTeam1;
  130. COutputEvent m_OnRoundStartOwnedByTeam2;
  131. int m_bPointVisible; //should this capture point be visible on the hud?
  132. int m_iPointIndex; //the mapper set index value of this control point
  133. int m_iCPGroup; //the group that this control point belongs to
  134. bool m_bActive; //
  135. string_t m_iszName; //Name used in cap messages
  136. bool m_bStartDisabled;
  137. float m_flLastContestedAt;
  138. CSoundPatch *m_pCaptureInProgressSound;
  139. string_t m_iszCaptureStartSound;
  140. string_t m_iszCaptureEndSound;
  141. string_t m_iszCaptureInProgress;
  142. string_t m_iszCaptureInterrupted;
  143. };
  144. #endif // TEAM_CONTROL_POINT_H