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.

161 lines
4.8 KiB

  1. //====== Copyright � 1996-2005, Valve Corporation, All rights reserved. =======
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. #ifndef TRIGGER_AREA_CAPTURE_H
  7. #define TRIGGER_AREA_CAPTURE_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "basemultiplayerplayer.h"
  12. #include "triggers.h"
  13. #include "team_control_point.h"
  14. #define AREA_ATTEND_TIME 0.7f
  15. #define AREA_THINK_TIME 0.1f
  16. #define CAPTURE_NORMAL 0
  17. #define CAPTURE_CATCHUP_ALIVEPLAYERS 1
  18. #define MAX_CLIENT_AREAS 128
  19. #define MAX_AREA_CAPPERS 9
  20. //-----------------------------------------------------------------------------
  21. // Purpose: An area entity that players must remain in in order to active another entity
  22. // Triggers are fired on start of capture, on end of capture and on broken capture
  23. // Can either be capped by both teams at once, or just by one
  24. // Time to capture and number of people required to capture are both passed by the mapper
  25. //-----------------------------------------------------------------------------
  26. class CTriggerAreaCapture : public CBaseTrigger
  27. {
  28. DECLARE_CLASS( CTriggerAreaCapture, CBaseTrigger );
  29. public:
  30. CTriggerAreaCapture();
  31. // Derived, game-specific area triggers must override these functions
  32. public:
  33. // Display a hint about capturing zones to the player
  34. virtual void DisplayCapHintTo( CBaseMultiplayerPlayer *pPlayer ) { return; }
  35. // A team has finished capturing the zone.
  36. virtual void OnEndCapture( int iTeam ) { return; }
  37. public:
  38. virtual void Spawn( void );
  39. virtual void Precache( void );
  40. virtual bool KeyValue( const char *szKeyName, const char *szValue );
  41. void SetAreaIndex( int index );
  42. bool IsActive( void );
  43. bool CheckIfDeathCausesBlock( CBaseMultiplayerPlayer *pVictim, CBaseMultiplayerPlayer *pKiller );
  44. void UpdateNumPlayers( void );
  45. void UpdateOwningTeam( void );
  46. void UpdateCappingTeam( int iTeam );
  47. void UpdateTeamInZone( void );
  48. void UpdateBlocked( void );
  49. void ForceOwner( int team ); // by the control_point_round to force an owner of this point (so we can play a specific round)
  50. bool TeamCanCap( int iTeam ){ return m_TeamData[iTeam].bCanCap; }
  51. CHandle<CTeamControlPoint> GetControlPoint( void ){ return m_hPoint; }
  52. int GetOwningTeam( void ) { return m_nOwningTeam; }
  53. bool IsBlocked( void ) { return m_bBlocked; }
  54. private:
  55. void StartTouch(CBaseEntity *pOther);
  56. void EXPORT AreaTouch( CBaseEntity *pOther );
  57. void EndTouch(CBaseEntity *pOther);
  58. void CaptureThink( void );
  59. void StartCapture( int team, int capmode );
  60. void EndCapture( int team );
  61. void BreakCapture( bool bNotEnoughPlayers );
  62. void IncrementCapAttemptNumber( void );
  63. void SwitchCapture( int team );
  64. void SendNumPlayers( void );
  65. void SetOwner( int team ); //sets the owner of this point - useful for resetting all to -1
  66. void InputRoundSpawn( inputdata_t &inputdata );
  67. void InputCaptureCurrentCP( inputdata_t &inputdata );
  68. void InputSetTeamCanCap( inputdata_t &inputdata );
  69. void InputSetControlPoint( inputdata_t &inputdata );
  70. void SetCapTimeRemaining( float flTime );
  71. void HandleRespawnTimeAdjustments( int oldTeam, int newTeam );
  72. void GetNumCappingPlayers( int team, int &numcappers, int *cappingplayers );
  73. private:
  74. int m_iCapMode; //which capture mode we're in
  75. bool m_bCapturing;
  76. int m_nCapturingTeam; //the team that is capturing this point
  77. int m_nOwningTeam; //the team that has captured this point
  78. int m_nTeamInZone; //if there's one team in the zone, this is it.
  79. float m_flCapTime; //the total time it takes to capture the area, in seconds
  80. float m_fTimeRemaining; //the time left in the capture
  81. float m_flLastReductionTime;
  82. bool m_bBlocked;
  83. struct perteamdata_t
  84. {
  85. perteamdata_t()
  86. {
  87. iNumRequiredToCap = 0;
  88. iNumTouching = 0;
  89. iBlockedTouching = 0;
  90. bCanCap = false;
  91. iSpawnAdjust = 0;
  92. }
  93. int iNumRequiredToCap;
  94. int iNumTouching;
  95. int iBlockedTouching; // Number of capping players on the cap while it's being blocked
  96. bool bCanCap;
  97. int iSpawnAdjust;
  98. };
  99. CUtlVector<perteamdata_t> m_TeamData;
  100. struct blockers_t
  101. {
  102. CHandle<CBaseMultiplayerPlayer> hPlayer;
  103. int iCapAttemptNumber;
  104. };
  105. CUtlVector<blockers_t> m_Blockers;
  106. bool m_bActive;
  107. COutputEvent m_OnStartTeam1;
  108. COutputEvent m_OnStartTeam2;
  109. COutputEvent m_OnBreakTeam1;
  110. COutputEvent m_OnBreakTeam2;
  111. COutputEvent m_OnCapTeam1;
  112. COutputEvent m_OnCapTeam2;
  113. COutputEvent m_StartOutput;
  114. COutputEvent m_BreakOutput;
  115. COutputEvent m_CapOutput;
  116. COutputInt m_OnNumCappersChanged;
  117. int m_iAreaIndex; //index of this area among all other areas
  118. CHandle<CTeamControlPoint> m_hPoint; //the capture point that we are linked to!
  119. bool m_bRequiresObject;
  120. string_t m_iszCapPointName; //name of the cap point that we're linked to
  121. int m_iCapAttemptNumber; // number used to keep track of discrete cap attempts, for block tracking
  122. DECLARE_DATADESC();
  123. };
  124. #endif // TRIGGER_AREA_CAPTURE_H