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.

174 lines
5.4 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. // tf_raid_logic.h
  3. // Raid game mode singleton manager
  4. // Michael Booth, November 2009
  5. #ifndef TF_RAID_LOGIC_H
  6. #define TF_RAID_LOGIC_H
  7. #ifdef TF_RAID_MODE
  8. #include "tf_gamerules.h"
  9. #include "player_vs_environment/tf_population_manager.h"
  10. class CBaseDoor;
  11. //-----------------------------------------------------------------------
  12. class CRaidLogic : public CPointEntity, public CGameEventListener
  13. {
  14. DECLARE_CLASS( CRaidLogic, CPointEntity );
  15. public:
  16. DECLARE_DATADESC();
  17. CRaidLogic();
  18. virtual ~CRaidLogic();
  19. virtual void Spawn( void );
  20. void Reset( void );
  21. void Update( void );
  22. virtual void FireGameEvent( IGameEvent *event );
  23. void DrawDebugDisplay( float deltaT );
  24. CTeamControlPoint *GetContestedPoint( void ) const; // return the next control point that can be captured
  25. bool IsWaitingForRaidersToLeaveSafeRoom( void ) const; // returns true if all raiders have not yet left the spawn room for the first time
  26. bool IsMobSpawning( void ) const; // return true if a mob is trying to spawn right now
  27. bool IsSentryGunArea( CTFNavArea *area ) const; // return true if this area should contain an enemy sentry gun
  28. int GetWandererCount( void ) const; // how many wanderers exist at the moment?
  29. CTFPlayer *GetFarthestAlongRaider( void ) const; // return raider who is farthest through the map
  30. float GetMaximumRaiderIncursionDistance( void ) const; // return incursion distance of farthest along raider
  31. float GetIncursionDistanceAtEnd( void ) const; // return maximum incursion distance at end of route
  32. CTFNavArea *GetEscapeRouteStart( void ) const;
  33. CTFNavArea *GetEscapeRouteEnd( void ) const;
  34. CTFNavArea *FindSniperSpawn( void );
  35. CTFNavArea *FindSentryArea( void );
  36. CTFNavArea *FindSpawnAreaAhead( void );
  37. CTFNavArea *FindSpawnAreaBehind( void );
  38. CTFNavArea *SelectRaidSentryArea( void ) const; // choose unpopulated sentry area nearest the invaders
  39. CTFPlayer *SelectRaiderToAttack( void ); // pick a member of the raiding (blue) team for a red defender to attack
  40. virtual int UpdateTransmitState()
  41. {
  42. return SetTransmitState( FL_EDICT_ALWAYS );
  43. }
  44. CBaseEntity *GetRescueRespawn( void ) const; // return entity positioned within next valid rescue closet area for to respawn players in
  45. private:
  46. bool LoadPopulationFromFile( void );
  47. int m_priorRaiderAliveCount;
  48. int m_wandererCount;
  49. int m_engineerCount;
  50. int m_demomanCount;
  51. int m_heavyCount;
  52. int m_soldierCount;
  53. int m_pyroCount;
  54. int m_spyCount;
  55. int m_sniperCount;
  56. int m_squadCount;
  57. void OnRoundStart( void );
  58. bool Unspawn( CTFPlayer *who );
  59. void CullObsoleteEnemies( float minIncursion, float maxIncursion );
  60. // void SpawnMobs( CUtlVector< CTFNavArea * > *spawnAreaVector );
  61. CountdownTimer m_mobSpawnTimer;
  62. CountdownTimer m_mobLifetimeTimer;
  63. CTFNavArea *m_mobArea;
  64. int m_mobCountRemaining;
  65. int m_mobClass;
  66. // void SpawnEngineers( void );
  67. CountdownTimer m_engineerSpawnTimer;
  68. // void SpawnSpecials( CUtlVector< CTFNavArea * > *spawnAheadVector, CUtlVector< CTFNavArea * > *spawnAnywhereVector );
  69. CountdownTimer m_specialSpawnTimer;
  70. CTFNavArea *SelectMobSpawn( CUtlVector< CTFNavArea * > *spawnAreaVector, RelativePositionType where );
  71. // bool SpawnSquad( CTFNavArea *spawnArea );
  72. void StartMobTimer( float duration );
  73. bool m_isWaitingForRaidersToLeaveSpawnRoom;
  74. bool m_wasCapturingPoint;
  75. bool m_didFailLastTime;
  76. CHandle< CTFPlayer > m_farthestAlongRaider; // raider with highest incursion distance
  77. float m_incursionDistanceAtEnd;
  78. void BuildEscapeRoute( void );
  79. CUtlVector< CTFNavArea * > m_escapeRouteVector; // a vector of areas in order along the escape route
  80. CTFNavArea *m_farthestAlongEscapeRouteArea;
  81. CTFNavArea *FindEarliestVisibleEscapeRouteAreaNearTeam( CTFNavArea *viewArea ) const; // given a viewing area, return the earliest escape route area near the team that is visible
  82. CUtlVector< CTFNavArea * > m_sniperSpotVector; // a vector of good sniping areas
  83. CUtlVector< CTFNavArea * > m_sentrySpotVector; // a vector of good sentry areas
  84. CUtlVector< CTFNavArea * > m_actualSentrySpotVector; // a vector of areas to actually place sentry guns
  85. CUtlVector< CTFNavArea * > m_rescueClosetVector; // a vector of areas to respawn raiders
  86. CUtlVector< CTFNavArea * > m_miniBossHomeVector;
  87. int m_miniBossIndex;
  88. CUtlVector< CBaseDoor * > m_gateVector; // vector of gates that open when point is captured
  89. };
  90. inline bool CRaidLogic::IsSentryGunArea( CTFNavArea *area ) const
  91. {
  92. return m_actualSentrySpotVector.HasElement( area );
  93. }
  94. inline int CRaidLogic::GetWandererCount( void ) const
  95. {
  96. return m_wandererCount;
  97. }
  98. inline CTFNavArea *CRaidLogic::GetEscapeRouteStart( void ) const
  99. {
  100. return m_escapeRouteVector.Count() ? m_escapeRouteVector[0] : NULL;
  101. }
  102. inline CTFNavArea *CRaidLogic::GetEscapeRouteEnd( void ) const
  103. {
  104. return m_escapeRouteVector.Count() ? m_escapeRouteVector[ m_escapeRouteVector.Count()-1 ] : NULL;
  105. }
  106. inline CTFPlayer *CRaidLogic::GetFarthestAlongRaider( void ) const
  107. {
  108. return m_farthestAlongRaider;
  109. }
  110. inline bool CRaidLogic::IsWaitingForRaidersToLeaveSafeRoom( void ) const
  111. {
  112. return m_isWaitingForRaidersToLeaveSpawnRoom;
  113. }
  114. inline bool CRaidLogic::IsMobSpawning( void ) const
  115. {
  116. return m_mobLifetimeTimer.HasStarted() && !m_mobLifetimeTimer.IsElapsed();
  117. }
  118. inline float CRaidLogic::GetIncursionDistanceAtEnd( void ) const
  119. {
  120. return m_incursionDistanceAtEnd;
  121. }
  122. extern CRaidLogic *g_pRaidLogic;
  123. #endif // TF_RAID_MODE
  124. #endif // TF_RAID_LOGIC_H