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.

147 lines
3.4 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. // tf_bot_manager.h
  3. // Team Fortress NextBotManager
  4. // Tom Bui, May 2010
  5. #ifndef TF_BOT_MANAGER_H
  6. #define TF_BOT_MANAGER_H
  7. #include "NextBotManager.h"
  8. #include "tf_team.h"
  9. class CTFBot;
  10. class CTFPlayer;
  11. class CTFBotSquad;
  12. class CStuckBotEvent;
  13. //----------------------------------------------------------------------------------------------
  14. // For parsing and displaying stuck events from server logs.
  15. class CStuckBot
  16. {
  17. public:
  18. CStuckBot( int id, const char *name )
  19. {
  20. m_id = id;
  21. Q_strncpy( m_name, name, 256 );
  22. }
  23. bool IsMatch( int id, const char *name )
  24. {
  25. return ( id == m_id && FStrEq( name, m_name ) );
  26. }
  27. char m_name[256];
  28. int m_id;
  29. CUtlVector< CStuckBotEvent * > m_stuckEventVector;
  30. };
  31. //----------------------------------------------------------------------------------------------
  32. // For parsing and displaying stuck events from server logs.
  33. class CStuckBotEvent
  34. {
  35. public:
  36. Vector m_stuckSpot;
  37. float m_stuckDuration;
  38. Vector m_goalSpot;
  39. bool m_isGoalValid;
  40. void Draw( float deltaT = 0.1f )
  41. {
  42. NDebugOverlay::Cross3D( m_stuckSpot, 5.0f, 255, 255, 0, true, deltaT );
  43. if ( m_isGoalValid )
  44. {
  45. if ( m_stuckDuration > 6.0f )
  46. {
  47. NDebugOverlay::HorzArrow( m_stuckSpot, m_goalSpot, 2.0f, 255, 0, 0, 255, true, deltaT );
  48. }
  49. else if ( m_stuckDuration > 3.0f )
  50. {
  51. NDebugOverlay::HorzArrow( m_stuckSpot, m_goalSpot, 2.0f, 255, 255, 0, 255, true, deltaT );
  52. }
  53. else
  54. {
  55. NDebugOverlay::HorzArrow( m_stuckSpot, m_goalSpot, 2.0f, 0, 255, 0, 255, true, deltaT );
  56. }
  57. }
  58. }
  59. };
  60. //----------------------------------------------------------------------------------------------
  61. class CTFBotManager : public NextBotManager
  62. {
  63. public:
  64. CTFBotManager();
  65. virtual ~CTFBotManager();
  66. virtual void Update();
  67. void LevelShutdown();
  68. virtual void OnMapLoaded( void ); // when the server has changed maps
  69. virtual void OnRoundRestart( void ); // when the scenario restarts
  70. bool IsAllBotTeam( int iTeam );
  71. bool IsInOfflinePractice() const;
  72. bool IsMeleeOnly() const;
  73. CTFBot* GetAvailableBotFromPool();
  74. void OnForceAddedBots( int iNumAdded );
  75. void OnForceKickedBots( int iNumKicked );
  76. void ClearStuckBotData();
  77. CStuckBot *FindOrCreateStuckBot( int id, const char *playerClass ); // for parsing and debugging stuck bot server logs
  78. void DrawStuckBotData( float deltaT = 0.1f );
  79. #ifdef TF_CREEP_MODE
  80. void OnCreepKilled( CTFPlayer *killer );
  81. #endif
  82. bool RemoveBotFromTeamAndKick( int nTeam );
  83. protected:
  84. void MaintainBotQuota();
  85. void SetIsInOfflinePractice( bool bIsInOfflinePractice );
  86. void RevertOfflinePracticeConvars();
  87. float m_flNextPeriodicThink;
  88. #ifdef TF_CREEP_MODE
  89. void UpdateCreepWaves();
  90. CountdownTimer m_creepWaveTimer;
  91. void SpawnCreep( int team, CTFBotSquad *squad );
  92. void SpawnCreepWave( int team );
  93. int m_creepExperience[ TF_TEAM_COUNT ];
  94. #endif
  95. void UpdateMedievalBossScenario();
  96. bool m_isMedeivalBossScenarioSetup;
  97. void SetupMedievalBossScenario();
  98. CUtlVector< CBaseEntity * > m_archerSpawnVector;
  99. struct ArcherAssignmentInfo
  100. {
  101. CHandle< CBaseCombatCharacter > m_archer;
  102. CHandle< CBaseEntity > m_mark;
  103. };
  104. CUtlVector< ArcherAssignmentInfo > m_archerMarkVector;
  105. CountdownTimer m_archerTimer;
  106. CUtlVector< CStuckBot * > m_stuckBotVector;
  107. CountdownTimer m_stuckDisplayTimer;
  108. };
  109. // singleton accessor
  110. CTFBotManager &TheTFBots( void );
  111. #endif // TF_BOT_MANAGER_H