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.

1841 lines
60 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // The copyright to the contents herein is the property of Valve, L.L.C.
  4. // The contents may be used and/or copied only with the written permission of
  5. // Valve, L.L.C., or in accordance with the terms and conditions stipulated in
  6. // the agreement/contract under which the contents have been supplied.
  7. //
  8. // Purpose: The TF Game rules object
  9. //
  10. // $Workfile: $
  11. // $Date: $
  12. // $NoKeywords: $
  13. //=============================================================================
  14. #ifndef TF_GAMERULES_H
  15. #define TF_GAMERULES_H
  16. #ifdef _WIN32
  17. #pragma once
  18. #endif
  19. #include "teamplayroundbased_gamerules.h"
  20. #include "convar.h"
  21. #include "gamevars_shared.h"
  22. #include "GameEventListener.h"
  23. #include "tf_gamestats_shared.h"
  24. #include "tf_match_description.h"
  25. #ifdef CLIENT_DLL
  26. #include "c_tf_player.h"
  27. #else
  28. #include "tf_player.h"
  29. #endif
  30. #ifdef CLIENT_DLL
  31. #define CTFGameRules C_TFGameRules
  32. #define CTFGameRulesProxy C_TFGameRulesProxy
  33. #define CBonusRoundLogic C_BonusRoundLogic
  34. #else
  35. extern CUtlString s_strNextMvMPopFile;
  36. extern BOOL no_cease_fire_text;
  37. extern BOOL cease_fire;
  38. class CHealthKit;
  39. class CTrainingModeLogic;
  40. class CTFHolidayEntity;
  41. class CTFNavArea;
  42. class CTFBot;
  43. class CTFBotRoster;
  44. class CMedievalLogic;
  45. class CCPTimerLogic;
  46. class CPopulationManager;
  47. class CCompetitiveLogic;
  48. #endif
  49. class CBonusRoundLogic;
  50. class CTeamTrainWatcher;
  51. class CPhysicsProp;
  52. class CObjectSentrygun;
  53. class CGhost;
  54. class CUpgrades;
  55. extern ConVar tf_spec_xray;
  56. extern ConVar tf_avoidteammates;
  57. extern ConVar tf_avoidteammates_pushaway;
  58. extern ConVar mp_tournament_blueteamname;
  59. extern ConVar mp_tournament_redteamname;
  60. extern ConVar tf_arena_force_class;
  61. extern ConVar tf_arena_change_limit;
  62. extern ConVar tf_ctf_bonus_time;
  63. extern ConVar tf_mvm_respec_enabled;
  64. extern ConVar tf_spawn_glows_duration;
  65. #ifdef TF_RAID_MODE
  66. class CRaidLogic;
  67. class CBossBattleLogic;
  68. extern ConVar tf_gamemode_raid;
  69. extern ConVar tf_gamemode_creep_wave;
  70. extern ConVar tf_gamemode_boss_battle;
  71. #endif // TF_RAID_MODE
  72. class CMannVsMachineLogic;
  73. class CMannVsMachineUpgrades;
  74. //extern ConVar tf_populator_health_multiplier;
  75. //extern ConVar tf_populator_damage_multiplier;
  76. const int kMVM_DefendersTeamSize = 6;
  77. const int kLadder_TeamSize_6v6 = 6;
  78. const int kLadder_TeamSize_9v9 = 9;
  79. const int kLadder_TeamSize_12v12 = 12;
  80. //#define TF_MVM_FCVAR_CHEAT 0 /* Cheats enabled */
  81. #define TF_MVM_FCVAR_CHEAT FCVAR_CHEAT /* Cheats disabled */
  82. extern bool TF_IsHolidayActive( /*EHoliday*/ int eHoliday );
  83. //=============================================================================
  84. // HPE_BEGIN
  85. // [msmith] Used for the client to tell the server that we're whatching a movie or not
  86. // and weather or not we're ready to transition to the next map.
  87. //=============================================================================
  88. // Training mode cvars
  89. extern ConVar tf_training_client_message;
  90. enum {
  91. TRAINING_CLIENT_MESSAGE_NONE = 0,
  92. TRAINING_CLIENT_MESSAGE_WATCHING_INTRO_MOVIE,
  93. TRAINING_CLIENT_MESSAGE_IN_SUMMARY_SCREEN,
  94. TRAINING_CLIENT_MESSAGE_NEXT_MAP,
  95. TRAINING_CLIENT_MESSAGE_REPLAY,
  96. TRAINING_CLIENT_MESSAGE_MAX,
  97. };
  98. // How many achievements we show in the summary screen.
  99. #define MAX_SHOWN_ACHIEVEMENTS 6
  100. //=============================================================================
  101. // HPE_END
  102. //=============================================================================
  103. extern Vector g_TFClassViewVectors[];
  104. #define NO_CLASS_LIMIT -1
  105. enum {
  106. STOPWATCH_CAPTURE_TIME_NOT_SET = 0,
  107. STOPWATCH_RUNNING,
  108. STOPWATCH_OVERTIME,
  109. };
  110. class CTFGameRulesProxy : public CTeamplayRoundBasedRulesProxy, public CGameEventListener
  111. {
  112. public:
  113. DECLARE_CLASS( CTFGameRulesProxy, CTeamplayRoundBasedRulesProxy );
  114. DECLARE_NETWORKCLASS();
  115. #ifdef GAME_DLL
  116. DECLARE_DATADESC();
  117. CTFGameRulesProxy();
  118. void InputSetRedTeamRespawnWaveTime( inputdata_t &inputdata );
  119. void InputSetBlueTeamRespawnWaveTime( inputdata_t &inputdata );
  120. void InputAddRedTeamRespawnWaveTime( inputdata_t &inputdata );
  121. void InputAddBlueTeamRespawnWaveTime( inputdata_t &inputdata );
  122. void InputSetRedTeamGoalString( inputdata_t &inputdata );
  123. void InputSetBlueTeamGoalString( inputdata_t &inputdata );
  124. void InputSetRedTeamRole( inputdata_t &inputdata );
  125. void InputSetBlueTeamRole( inputdata_t &inputdata );
  126. void InputSetRequiredObserverTarget( inputdata_t &inputdata );
  127. void InputAddRedTeamScore( inputdata_t &inputdata );
  128. void InputAddBlueTeamScore( inputdata_t &inputdata );
  129. void InputSetRedKothClockActive( inputdata_t &inputdata );
  130. void InputSetBlueKothClockActive( inputdata_t &inputdata );
  131. void InputSetCTFCaptureBonusTime( inputdata_t &inputdata );
  132. void InputPlayVORed( inputdata_t &inputdata );
  133. void InputPlayVOBlue( inputdata_t &inputdata );
  134. void InputPlayVO( inputdata_t &inputdata );
  135. void InputHandleMapEvent( inputdata_t &inputdata );
  136. void InputSetCustomUpgradesFile( inputdata_t &inputdata );
  137. void InputSetRoundRespawnFreezeEnabled( inputdata_t &inputdata );
  138. void InputSetMapForcedTruceDuringBossFight( inputdata_t &inputdata );
  139. void TeamPlayerCountChanged( CTFTeam *pTeam );
  140. void PowerupTeamImbalance( int nTeam );
  141. void StateEnterRoundRunning( void );
  142. void StateEnterBetweenRounds( void );
  143. void StateEnterPreRound( void );
  144. void StateExitPreRound( void );
  145. void MatchSummaryStart( void );
  146. void TruceStart( void );
  147. void TruceEnd( void );
  148. COutputEvent m_OnWonByTeam1;
  149. COutputEvent m_OnWonByTeam2;
  150. COutputInt m_Team1PlayersChanged;
  151. COutputInt m_Team2PlayersChanged;
  152. COutputEvent m_OnPowerupImbalanceTeam1;
  153. COutputEvent m_OnPowerupImbalanceTeam2;
  154. COutputEvent m_OnPowerupImbalanceMeasuresOver;
  155. COutputEvent m_OnStateEnterRoundRunning;
  156. COutputEvent m_OnStateEnterBetweenRounds;
  157. COutputEvent m_OnStateEnterPreRound;
  158. COutputEvent m_OnStateExitPreRound;
  159. COutputEvent m_OnMatchSummaryStart;
  160. COutputEvent m_OnTruceStart;
  161. COutputEvent m_OnTruceEnd;
  162. virtual void Activate();
  163. private:
  164. //=============================================================================
  165. // HPE_BEGIN:
  166. // [msmith] hud type so the game type and hud type can be separate. Used for
  167. // training missions.
  168. //=============================================================================
  169. int m_nHudType;
  170. //=============================================================================
  171. // HPE_END
  172. //=============================================================================
  173. bool m_bOvertimeAllowedForCTF;
  174. #endif
  175. public: // IGameEventListener Interface
  176. virtual void FireGameEvent( IGameEvent * event );
  177. };
  178. class CTFRadiusDamageInfo
  179. {
  180. DECLARE_CLASS_NOBASE( CTFRadiusDamageInfo );
  181. public:
  182. CTFRadiusDamageInfo( CTakeDamageInfo *pInfo, const Vector &vecSrcIn, float flRadiusIn, CBaseEntity *pIgnore = NULL, float flRJRadiusIn = 0, float flForceScaleIn = 1.0f )
  183. {
  184. dmgInfo = pInfo;
  185. vecSrc = vecSrcIn;
  186. flRadius = flRadiusIn;
  187. pEntityIgnore = pIgnore;
  188. flRJRadius = flRJRadiusIn;
  189. flFalloff = 0;
  190. m_flForceScale = flForceScaleIn;
  191. m_pEntityTarget = NULL;
  192. CalculateFalloff();
  193. }
  194. void CalculateFalloff( void );
  195. int ApplyToEntity( CBaseEntity *pEntity );
  196. public:
  197. // Fill these in & call RadiusDamage()
  198. CTakeDamageInfo *dmgInfo;
  199. Vector vecSrc;
  200. float flRadius;
  201. CBaseEntity *pEntityIgnore;
  202. float flRJRadius; // Radius to use to calculate RJ, to maintain RJs when damage/radius changes on a RL
  203. float m_flForceScale;
  204. CBaseEntity *m_pEntityTarget; // Target being direct hit if any
  205. private:
  206. // These are used during the application of the RadiusDamage
  207. float flFalloff;
  208. };
  209. struct PlayerRoundScore_t
  210. {
  211. int iPlayerIndex; // player index
  212. int iRoundScore; // how many points scored this round
  213. int iTotalScore; // total points scored across all rounds
  214. };
  215. struct PlayerArenaRoundScore_t
  216. {
  217. int iPlayerIndex; // player index
  218. int iTotalDamage; // damage done this round
  219. int iTotalHealing; // healing done this round
  220. int iTimeAlive; // time alive (in seconds)
  221. int iKillingBlows; // killing blows this round
  222. int iScore;
  223. };
  224. #ifdef CLIENT_DLL
  225. const char *GetMapType( const char *mapName );
  226. const char *GetMapDisplayName( const char *mapName );
  227. #else
  228. class CKothLogic;
  229. #endif
  230. // Used to sort the players in the list by their bonus score
  231. typedef CTFPlayer *BONUSPLAYERPTR;
  232. class CBonusPlayerListLess
  233. {
  234. public:
  235. bool Less( const BONUSPLAYERPTR &src1, const BONUSPLAYERPTR &src2, void *pCtx )
  236. {
  237. if ( src1->m_Shared.GetItemFindBonus() > src2->m_Shared.GetItemFindBonus() )
  238. return true;
  239. return false;
  240. }
  241. };
  242. #define MAX_TEAMGOAL_STRING 256
  243. #define MAX_TEAMNAME_STRING 6
  244. class CTFGameRules : public CTeamplayRoundBasedRules
  245. {
  246. public:
  247. DECLARE_CLASS( CTFGameRules, CTeamplayRoundBasedRules );
  248. CTFGameRules();
  249. virtual void LevelInitPostEntity( void );
  250. virtual float GetRespawnTimeScalar( int iTeam );
  251. virtual float GetRespawnWaveMaxLength( int iTeam, bool bScaleWithNumPlayers = true );
  252. // Damage Queries.
  253. virtual bool Damage_IsTimeBased( int iDmgType ); // Damage types that are time-based.
  254. virtual bool Damage_ShowOnHUD( int iDmgType ); // Damage types that have client HUD art.
  255. virtual bool Damage_ShouldNotBleed( int iDmgType ); // Damage types that don't make the player bleed.
  256. // TEMP:
  257. virtual int Damage_GetTimeBased( void );
  258. virtual int Damage_GetShowOnHud( void );
  259. virtual int Damage_GetShouldNotBleed( void );
  260. int GetFarthestOwnedControlPoint( int iTeam, bool bWithSpawnpoints );
  261. virtual bool TeamMayCapturePoint( int iTeam, int iPointIndex );
  262. virtual bool PlayerMayCapturePoint( CBasePlayer *pPlayer, int iPointIndex, char *pszReason = NULL, int iMaxReasonLength = 0 );
  263. virtual bool PlayerMayBlockPoint( CBasePlayer *pPlayer, int iPointIndex, char *pszReason = NULL, int iMaxReasonLength = 0 );
  264. static int CalcPlayerScore( RoundStats_t *pRoundStats, CTFPlayer *pPlayer );
  265. static int CalcPlayerSupportScore( RoundStats_t *pRoundStats, int iPlayerIdx );
  266. bool IsBirthday( void ) const;
  267. bool IsBirthdayOrPyroVision( void ) const;
  268. virtual bool IsHolidayActive( /*EHoliday*/ int eHoliday ) const;
  269. virtual const unsigned char *GetEncryptionKey( void ) { return GetTFEncryptionKey(); }
  270. int GetClassLimit( int iClass );
  271. bool CanPlayerChooseClass( CBasePlayer *pPlayer, int iClass );
  272. virtual bool ShouldBalanceTeams( void );
  273. virtual int GetBonusRoundTime( bool bGameOver = false ) OVERRIDE;
  274. #ifdef GAME_DLL
  275. public:
  276. virtual void Precache( void );
  277. // Override this to prevent removal of game specific entities that need to persist
  278. virtual bool RoundCleanupShouldIgnore( CBaseEntity *pEnt );
  279. virtual bool ShouldCreateEntity( const char *pszClassName );
  280. virtual void CleanUpMap( void );
  281. virtual void FrameUpdatePostEntityThink();
  282. virtual void RespawnPlayers( bool bForceRespawn, bool bTeam = false, int iTeam = TEAM_UNASSIGNED ) OVERRIDE;
  283. // Called when a new round is being initialized
  284. virtual void SetupOnRoundStart( void );
  285. // Called when a new round is off and running
  286. virtual void SetupOnRoundRunning( void );
  287. // Called before a new round is started (so the previous round can end)
  288. virtual void PreviousRoundEnd( void );
  289. // Send the team scores down to the client
  290. virtual void SendTeamScoresEvent( void ) { return; }
  291. // Send the end of round info displayed in the win panel
  292. virtual void SendWinPanelInfo( bool bGameOver ) OVERRIDE;
  293. void SendArenaWinPanelInfo( void );
  294. void SendPVEWinPanelInfo( void );
  295. // Setup spawn points for the current round before it starts
  296. virtual void SetupSpawnPointsForRound( void );
  297. // Called when a round has entered stalemate mode (timer has run out)
  298. virtual void SetupOnStalemateStart( void );
  299. virtual void SetupOnStalemateEnd( void );
  300. virtual void RecalculateControlPointState( void );
  301. void TeamPlayerCountChanged( CTFTeam *pTeam );
  302. void PowerupTeamImbalance( int nTeam );
  303. int GetAssignedHumanTeam( void );
  304. virtual void HandleSwitchTeams( void );
  305. virtual void HandleScrambleTeams( void );
  306. bool CanChangeClassInStalemate( void );
  307. bool CanChangeTeam( int iCurrentTeam ) const;
  308. virtual void SetRoundOverlayDetails( void );
  309. virtual void ShowRoundInfoPanel( CTFPlayer *pPlayer = NULL ); // NULL pPlayer means show the panel to everyone
  310. virtual bool TimerMayExpire( void );
  311. virtual void Activate();
  312. virtual bool AllowDamage( CBaseEntity *pVictim, const CTakeDamageInfo &info );
  313. void SetTeamGoalString( int iTeam, const char *pszGoal );
  314. //=============================================================================
  315. // HPE_BEGIN:
  316. // [msmith] Added a HUD type separate from the game mode so we can do different
  317. // HUDs for the same mode. This is used in training maps.
  318. //=============================================================================
  319. void SetHUDType( int nHudType );
  320. //=============================================================================
  321. // HPE_END
  322. //=============================================================================
  323. // Speaking, vcds, voice commands.
  324. virtual void InitCustomResponseRulesDicts();
  325. virtual void ShutdownCustomResponseRulesDicts();
  326. virtual bool HasPassedMinRespawnTime( CBasePlayer *pPlayer );
  327. virtual bool ShouldRespawnQuickly( CBasePlayer *pPlayer );
  328. bool ShouldScorePerRound( void );
  329. virtual bool IsValveMap( void );
  330. virtual void PlayTrainCaptureAlert( CTeamControlPoint *pPoint, bool bFinalPointInMap );
  331. void SetRequiredObserverTarget( CBaseEntity *pEnt ){ m_hRequiredObserverTarget = pEnt; }
  332. void SetObjectiveObserverTarget( CBaseEntity *pEnt ) { m_hObjectiveObserverTarget = pEnt; }
  333. EHANDLE GetRequiredObserverTarget( void ){ return m_hRequiredObserverTarget.Get(); }
  334. EHANDLE GetObjectiveObserverTarget( void ){ return m_hObjectiveObserverTarget.Get(); }
  335. virtual void GetTaggedConVarList( KeyValues *pCvarTagList );
  336. virtual bool PointsMayBeCaptured( void );
  337. virtual bool PointsMayAlwaysBeBlocked(){ return ( GetGameType() == TF_GAMETYPE_ESCORT ); }
  338. virtual void PlaySpecialCapSounds( int iCappingTeam, CTeamControlPoint *pPoint );
  339. virtual CTacticalMissionManager *TacticalMissionManagerFactory( void );
  340. virtual bool ShouldSwitchTeams( void );
  341. virtual bool ShouldScrambleTeams( void );
  342. virtual void ClientCommandKeyValues( edict_t *pEntity, KeyValues *pKeyValues );
  343. bool CanBotChangeClass( CBasePlayer* pPlayer );
  344. bool CanBotChooseClass( CBasePlayer *pPlayer, int iClass );
  345. void SetCTFCaptureBonusTime( float flTime ){ m_flCTFCaptureBonusTime = flTime; }
  346. float GetCTFCaptureBonusTime( void )
  347. {
  348. float flRetVal = tf_ctf_bonus_time.GetFloat();
  349. if ( m_flCTFCaptureBonusTime >= 0.0f )
  350. {
  351. flRetVal = m_flCTFCaptureBonusTime;
  352. }
  353. return flRetVal;
  354. }
  355. // populate vector with set of control points the player needs to capture
  356. virtual void CollectCapturePoints( CBasePlayer *player, CUtlVector< CTeamControlPoint * > *captureVector ) const;
  357. // populate vector with set of control points the player needs to defend from capture
  358. virtual void CollectDefendPoints( CBasePlayer *player, CUtlVector< CTeamControlPoint * > *defendVector ) const;
  359. CObjectSentrygun *FindSentryGunWithMostKills( int team = TEAM_ANY ) const;
  360. // Client connection/disconnection
  361. virtual bool ClientConnected( edict_t *pEntity, const char *pszName, const char *pszAddress, char *reject, int maxrejectlen );
  362. virtual bool ShouldSkipAutoScramble( void )
  363. {
  364. return IsPVEModeActive();
  365. }
  366. bool ShouldMakeChristmasAmmoPack( void );
  367. void UpdatePeriodicEvent( CTFPlayer *pPlayer, eEconPeriodicScoreEvents eEvent, uint32 nCount );
  368. void HandleMapEvent( inputdata_t &inputdata );
  369. void SetCustomUpgradesFile( inputdata_t &inputdata );
  370. virtual bool ShouldWaitToStartRecording( void );
  371. void SetGravityMultiplier( float flValue ){ m_flGravityMultiplier.Set( flValue ); }
  372. bool CanFlagBeCaptured( CBaseEntity *pOther );
  373. bool PowerupModeFlagStandoffActive( void );
  374. void TeleportPlayersToTargetEntities( int iTeam, const char *pszEntTargetName, CUtlVector< CTFPlayer * > *pTeleportedPlayers );
  375. virtual void LoadMapCycleFileIntoVector ( const char *pszMapCycleFile, CUtlVector<char *> &mapList ) OVERRIDE;
  376. void OnWorkshopMapUpdated( PublishedFileId_t nWorkshopID );
  377. void RecalculateTruce( void );
  378. void SetMapForcedTruceDuringBossFight( bool bState ){ m_bMapForcedTruceDuringBossFight = bState; }
  379. bool IsMapForcedTruceDuringBossFight( void ){ return m_bMapForcedTruceDuringBossFight; }
  380. protected:
  381. virtual void LoadMapCycleFile( void ) OVERRIDE;
  382. void TrackWorkshopMapsInMapCycle( void );
  383. virtual const char* GetStalemateSong( int nTeam ) OVERRIDE;
  384. virtual const char* WinSongName( int nTeam ) OVERRIDE;
  385. virtual const char* LoseSongName( int nTeam ) OVERRIDE;
  386. virtual void InitTeams( void );
  387. virtual void RoundRespawn( void );
  388. virtual void RespawnTeam( int iTeam );
  389. virtual void InternalHandleTeamWin( int iWinningTeam );
  390. static int PlayerRoundScoreSortFunc( const PlayerRoundScore_t *pRoundScore1, const PlayerRoundScore_t *pRoundScore2 );
  391. static int PlayerArenaRoundScoreSortFunc( const PlayerArenaRoundScore_t *pRoundScore1, const PlayerArenaRoundScore_t *pRoundScore2 );
  392. virtual void FillOutTeamplayRoundWinEvent( IGameEvent *event );
  393. virtual bool CanChangelevelBecauseOfTimeLimit( void );
  394. virtual bool CanGoToStalemate( void );
  395. virtual void RestoreActiveTimer( void );
  396. void BroadcastDrawLine( CTFPlayer *pTFPlayer, KeyValues *pKeyValues );
  397. #endif // GAME_DLL
  398. public:
  399. // Bonus round handling
  400. #ifdef GAME_DLL
  401. virtual bool ShouldGoToBonusRound( void );
  402. virtual void SetupOnBonusStart( void );
  403. virtual void SetupOnBonusEnd( void );
  404. virtual void BonusStateThink( void );
  405. void BonusStateAbort( void );
  406. void SetBonusItem( itemid_t iItemID );
  407. // Between rounds handling
  408. virtual void BetweenRounds_Start( void );
  409. virtual void BetweenRounds_End( void );
  410. virtual void BetweenRounds_Think( void );
  411. virtual void PreRound_Start( void ) OVERRIDE;
  412. virtual void PreRound_End( void ) OVERRIDE;
  413. #endif
  414. public:
  415. // Return the value of this player towards capturing a point
  416. virtual int GetCaptureValueForPlayer( CBasePlayer *pPlayer );
  417. // Collision and Damage rules.
  418. virtual bool ShouldCollide( int collisionGroup0, int collisionGroup1 );
  419. int GetTimeLeft( void );
  420. // Get the view vectors for this mod.
  421. virtual const CViewVectors *GetViewVectors() const;
  422. virtual void FireGameEvent( IGameEvent *event );
  423. virtual const char *GetGameTypeName( void );
  424. virtual int GetGameType( void ){ return m_nGameType; }
  425. virtual void ClientSpawned( edict_t * pPlayer );
  426. virtual void OnFileReceived( const char * fileName, unsigned int transferID );
  427. virtual bool FlagsMayBeCapped( void );
  428. void RunPlayerConditionThink ( void );
  429. const char *GetTeamGoalString( int iTeam );
  430. int GetStopWatchState( void ) { return m_nStopWatchState; }
  431. // Game Modes
  432. virtual bool IsInArenaMode( void ) const OVERRIDE;
  433. virtual bool IsInKothMode( void ) const OVERRIDE { return m_bPlayingKoth; }
  434. bool IsInMedievalMode( void ) const { return m_bPlayingMedieval; }
  435. bool IsHolidayMap( int nHoliday ) const { return m_nMapHolidayType == nHoliday; }
  436. #ifdef TF_RAID_MODE
  437. bool IsRaidMode( void ) const;
  438. bool IsBossBattleMode( void ) const;
  439. #endif // TF_RAID_MODE
  440. #ifdef TF_CREEP_MODE
  441. bool IsCreepWaveMode( void ) const;
  442. #endif
  443. bool IsMannVsMachineMode( void ) const { return m_bPlayingMannVsMachine; }
  444. void SetMannVsMachineAlarmStatus( bool bStatus ){ m_bMannVsMachineAlarmStatus.Set( bStatus ); }
  445. bool GetMannVsMachineAlarmStatus( void ){ return m_bMannVsMachineAlarmStatus; }
  446. bool IsQuickBuildTime( void );
  447. bool GameModeUsesUpgrades( void );
  448. bool GameModeUsesCurrency( void ) { return IsMannVsMachineMode() || IsBountyMode(); }
  449. bool GameModeUsesMiniBosses( void ) { return IsMannVsMachineMode() || IsBountyMode(); }
  450. bool IsPasstimeMode() const { return m_nGameType == TF_GAMETYPE_PASSTIME; }
  451. #ifdef STAGING_ONLY
  452. bool GameModeUsesExperience( void ) { return IsBountyMode(); }
  453. #endif // STAGING_ONLY
  454. bool IsMannVsMachineRespecEnabled( void ) { return IsMannVsMachineMode() && tf_mvm_respec_enabled.GetBool(); }
  455. bool CanPlayerUseRespec( CTFPlayer *pTFPlayer );
  456. bool IsPowerupMode( void ) { return m_bPowerupMode; }
  457. void SetPowerupMode( bool bValue );
  458. #ifdef GAME_DLL
  459. // Managed competitive matches should go through the End/StopCompetitiveMatch path
  460. void EndManagedMvMMatch( bool bKickPlayersToParties );
  461. #endif
  462. // Competitive games
  463. bool IsCompetitiveMode( void ) const; // means we're using competitive/casual matchmaking
  464. bool IsMatchTypeCasual( void ) const;
  465. bool IsMatchTypeCompetitive( void ) const;
  466. // Are we showing the match-start-countdown doors right now
  467. bool BInMatchStartCountdown() const;
  468. #ifdef GAME_DLL
  469. void SyncMatchSettings();
  470. // ! Check return
  471. bool StartManagedMatch();
  472. void SetCompetitiveMode( bool bValue );
  473. #endif
  474. void StartCompetitiveMatch( void );
  475. void StopCompetitiveMatch( CMsgGC_Match_Result_Status nCode );
  476. void EndCompetitiveMatch( void );
  477. void ManageCompetitiveMode( void );
  478. bool ReportMatchResultsToGC( CMsgGC_Match_Result_Status nCode );
  479. bool MatchmakingShouldUseStopwatchMode();
  480. EMatchGroup GetCurrentMatchGroup() const;
  481. bool IsManagedMatchEnded() const;
  482. bool UsePlayerReadyStatusMode( void );
  483. bool PlayerReadyStatus_HaveMinPlayersToEnable( void );
  484. #ifdef GAME_DLL
  485. bool PlayerReadyStatus_ArePlayersOnTeamReady( int iTeam );
  486. bool PlayerReadyStatus_ShouldStartCountdown( void );
  487. void PlayerReadyStatus_ResetState( void );
  488. void PlayerReadyStatus_UpdatePlayerState( CTFPlayer *pTFPlayer, bool bState );
  489. #endif // GAME_DLL
  490. bool IsDefaultGameMode( void ); // The absence of arena, mvm, tournament mode, etc
  491. // Upgrades
  492. int GetCostForUpgrade( CMannVsMachineUpgrades *pUpgrade, int iItemSlot, int nClass, CTFPlayer *pPurchaser = NULL );
  493. bool CanUpgradeWithAttrib( CTFPlayer *pPlayer, int iWeaponSlot, attrib_definition_index_t iAttribIndex, CMannVsMachineUpgrades *pUpgrade );
  494. int GetUpgradeTier( int iUpgrade );
  495. bool IsUpgradeTierEnabled( CTFPlayer *pTFPlayer, int iItemSlot, int iUpgrade );
  496. bool IsPVEModeActive( void ) const; // return true if we are playing a PvE mode
  497. bool IsPVEModeControlled( CBaseEntity *who ) const; // return true for PvE opponents (ie: enemy bot team)
  498. const char* GetCustomUpgradesFile() { return m_pszCustomUpgradesFile.Get(); }
  499. //=============================================================================
  500. // HPE_BEGIN:
  501. // [msmith] Training Status. And HUD type.
  502. //=============================================================================
  503. bool IsInTraining( void ){ return m_bIsInTraining; }
  504. bool AllowTrainingAchievements() { return m_bAllowTrainingAchievements; }
  505. void SetAllowTrainingAchievements( bool bAllow) { m_bAllowTrainingAchievements = bAllow; }
  506. bool IsWaitingForTrainingContinue() { return m_bIsWaitingForTrainingContinue; }
  507. void SetIsWaitingForTrainingContinue( bool bWaiting ) { m_bIsWaitingForTrainingContinue = bWaiting; }
  508. int GetHUDType( void ){ return m_nHudType; }
  509. //=============================================================================
  510. // HPE_END
  511. //=============================================================================
  512. bool IsTrainingHUDVisible( void ) { return IsInTraining() && m_bIsTrainingHUDVisible; }
  513. void SetTrainingHUDVisible( bool bVisible ) { m_bIsTrainingHUDVisible.Set( bVisible ); }
  514. virtual bool IsInItemTestingMode( void ) { return m_bIsInItemTestingMode; }
  515. void SetInItemTestingMode( bool bInTesting ) { m_bIsInItemTestingMode.Set( bInTesting ); }
  516. int ItemTesting_GetBotAnim( void ) { return m_iItemTesting_BotAnim; }
  517. float ItemTesting_GetBotAnimSpeed( void );
  518. bool ItemTesting_GetBotForceFire( void ) { return m_bItemTesting_BotForceFire; }
  519. bool ItemTesting_GetBotTurntable( void ) { return m_bItemTesting_BotTurntable; }
  520. bool ItemTesting_GetBotViewScan( void ) { return m_bItemTesting_BotViewScan; }
  521. void ItemTesting_SetupFromKV( KeyValues *pKV );
  522. bool IsPlayingHybrid_CTF_CP( void ) const { return m_bPlayingHybrid_CTF_CP; }
  523. bool IsPlayingSpecialDeliveryMode( void ) const { return m_bPlayingSpecialDeliveryMode; }
  524. bool IsPlayingRobotDestructionMode( void ) const { return m_bPlayingRobotDestructionMode; }
  525. virtual bool AllowThirdPersonCamera( void ) { return ( IsInMedievalMode() || ShowMatchSummary() ); }
  526. // Bonus rounds
  527. CBonusRoundLogic *GetBonusLogic( void ) { return m_hBonusLogic.Get(); }
  528. void BuildBonusPlayerList( void );
  529. CTeamRoundTimer *GetRedKothRoundTimer( void ) { return m_hRedKothTimer.Get(); }
  530. CTeamRoundTimer *GetBlueKothRoundTimer( void ) { return m_hBlueKothTimer.Get(); }
  531. int GetStatsMinimumPlayers( void );
  532. int GetStatsMinimumPlayedTime( void );
  533. // BountyMode
  534. #ifdef STAGING_ONLY
  535. bool IsBountyMode( void ) { return m_bBountyModeEnabled && !IsMannVsMachineMode() && !IsInTraining(); }
  536. #else
  537. bool IsBountyMode( void ) { return false; }
  538. #endif
  539. float GetGravityMultiplier( void ){ return m_flGravityMultiplier; }
  540. virtual bool IsConnectedUserInfoChangeAllowed( CBasePlayer *pPlayer );
  541. void SetPlayersInHell( bool bState ){ m_bHelltowerPlayersInHell.Set( bState ); } // used for Halloween 2013 state of the game (players in the underworld fighting)
  542. bool ArePlayersInHell( void ) const { return m_bHelltowerPlayersInHell; }
  543. void SpawnPlayerInHell( CTFPlayer *pPlayer, const char *pszSpawnPointName );
  544. // Halloween 2013
  545. void PlayHelltowerAnnouncerVO( int iRedLine, int iBlueLine );
  546. void SetUsingSpells( bool bState )
  547. {
  548. m_bIsUsingSpells.Set( bState );
  549. }
  550. bool IsUsingSpells( void ) const;
  551. bool IsUsingGrapplingHook( void ) const;
  552. bool IsTruceActive( void ) const;
  553. bool MapHasMatchSummaryStage( void ){ return m_bMapHasMatchSummaryStage; }
  554. bool PlayersAreOnMatchSummaryStage( void ){ return m_bPlayersAreOnMatchSummaryStage; }
  555. bool ShowMatchSummary( void ){ return m_bShowMatchSummary; }
  556. bool HaveStopWatchWinner( void ) { return m_bStopWatchWinner; }
  557. int GetGameTeamForGCTeam( TF_GC_TEAM nGCTeam );
  558. TF_GC_TEAM GetGCTeamForGameTeam( int nGameTeam );
  559. enum ENextMapVotingState
  560. {
  561. NEXT_MAP_VOTE_STATE_NONE,
  562. NEXT_MAP_VOTE_STATE_WAITING_FOR_USERS_TO_VOTE,
  563. NEXT_MAP_VOTE_STATE_MAP_CHOSEN_PAUSE,
  564. };
  565. enum EUserNextMapVote
  566. {
  567. USER_NEXT_MAP_VOTE_MAP_0 = 0,
  568. USER_NEXT_MAP_VOTE_MAP_1,
  569. USER_NEXT_MAP_VOTE_MAP_2,
  570. USER_NEXT_MAP_VOTE_UNDECIDED,
  571. NUM_VOTE_STATES
  572. };
  573. EUserNextMapVote GetWinningVote( int (&nVotes)[ EUserNextMapVote::NUM_VOTE_STATES ] ) const;
  574. EUserNextMapVote PlayerNextMapVoteState( int nIndex ) const { return m_ePlayerWantsRematch.Get( nIndex ); }
  575. ENextMapVotingState GetCurrentNextMapVotingState() const { return m_eRematchState; }
  576. MapDefIndex_t GetNextMapVoteOption( int nIndex ) const { return m_nNextMapVoteOptions.Get( nIndex ); }
  577. #ifdef GAME_DLL
  578. void UpdateNextMapVoteOptionsFromLobby();
  579. void KickPlayersNewMatchIDRequestFailed();
  580. void CheckAndSetPartyLeader( CTFPlayer *pTFPlayer, int iTeam );
  581. #endif // GAME_DLL
  582. #ifdef STAGING_ONLY
  583. #ifdef GAME_DLL
  584. void SetBountyMode( bool bValue );
  585. #endif // GAME_DLL
  586. #endif // STAGING_ONLY
  587. #ifdef CLIENT_DLL
  588. DECLARE_CLIENTCLASS_NOBASE(); // This makes data tables able to access our private vars.
  589. virtual ~CTFGameRules();
  590. virtual void OnDataChanged( DataUpdateType_t updateType );
  591. virtual void HandleOvertimeBegin();
  592. bool ShouldShowTeamGoal( void );
  593. const char *GetVideoFileForMap( bool bWithExtension = true );
  594. const char *FormatVideoName( const char *videoName, bool bWithExtension = true );
  595. void SetUpVisionFilterKeyValues( void );
  596. bool UseSillyGibs( void );
  597. virtual bool AllowMapParticleEffect( const char *pszParticleEffect );
  598. virtual bool AllowWeatherParticles( void );
  599. virtual bool AllowMapVisionFilterShaders( void );
  600. virtual const char* TranslateEffectForVisionFilter( const char *pchEffectType, const char *pchEffectName );
  601. virtual void ModifySentChat( char *pBuf, int iBufSize );
  602. virtual void GetTeamGlowColor( int nTeam, float &r, float &g, float &b );
  603. virtual bool ShouldConfirmOnDisconnect();
  604. bool ShouldShowPreRoundDoors() const;
  605. bool RecievedBaseline() const { return m_bRecievedBaseline; }
  606. #else
  607. DECLARE_SERVERCLASS_NOBASE(); // This makes data tables able to access our private vars.
  608. virtual ~CTFGameRules();
  609. virtual void LevelShutdown();
  610. virtual bool ClientCommand( CBaseEntity *pEdict, const CCommand &args );
  611. virtual void Think();
  612. void PeriodicHalloweenUpdate();
  613. virtual bool SwitchToNextBestWeapon( CBaseCombatCharacter *pPlayer, CBaseCombatWeapon *pCurrentWeapon );
  614. bool CheckWinLimit( bool bAllowEnd = true, int nAddValueWhenChecking = 0 ) OVERRIDE;
  615. bool SetCtfWinningTeam();
  616. bool SetPasstimeWinningTeam();
  617. bool CheckCapsPerRound();
  618. virtual void CheckRespawnWaves();
  619. virtual void PlayWinSong( int team ) OVERRIDE;
  620. //=============================================================================
  621. // HPE_BEGIN:
  622. // [msmith] Used in training to load the next training map in sequence.
  623. //=============================================================================
  624. void LoadNextTrainingMap();
  625. //=============================================================================
  626. // HPE_END
  627. //=============================================================================
  628. virtual void SetWinningTeam( int team, int iWinReason, bool bForceMapReset = true, bool bSwitchTeams = false, bool bDontAddScore = false, bool bFinal = false ) OVERRIDE;
  629. virtual void SetStalemate( int iReason, bool bForceMapReset = true, bool bSwitchTeams = false );
  630. void CheckTauntAchievement( CTFPlayer *pAchiever, int nGibs, int *pTauntCamAchievements );
  631. virtual bool FPlayerCanTakeDamage( CBasePlayer *pPlayer, CBaseEntity *pAttacker, const CTakeDamageInfo &info );
  632. // Spawing rules.
  633. CBaseEntity *GetPlayerSpawnSpot( CBasePlayer *pPlayer );
  634. bool IsSpawnPointValid( CBaseEntity *pSpot, CBasePlayer *pPlayer, bool bIgnorePlayers, PlayerTeamSpawnMode_t nSpawndMode = PlayerTeamSpawnMode_Normal );
  635. virtual int ItemShouldRespawn( CItem *pItem );
  636. virtual float FlItemRespawnTime( CItem *pItem );
  637. virtual Vector VecItemRespawnSpot( CItem *pItem );
  638. virtual QAngle VecItemRespawnAngles( CItem *pItem );
  639. virtual const char *GetChatFormat( bool bTeamOnly, CBasePlayer *pPlayer );
  640. void ClientSettingsChanged( CBasePlayer *pPlayer );
  641. void ChangePlayerName( CTFPlayer *pPlayer, const char *pszNewName );
  642. virtual VoiceCommandMenuItem_t *VoiceCommand( CBaseMultiplayerPlayer *pPlayer, int iMenu, int iItem );
  643. float GetPreMatchEndTime() const; // Returns the time at which the prematch will be over.
  644. void GoToIntermission( void );
  645. virtual int GetAutoAimMode() { return AUTOAIM_NONE; }
  646. void SetSetup( bool bSetup );
  647. void ManageStopwatchTimer( bool bInSetup );
  648. virtual void HandleTeamScoreModify( int iTeam, int iScore);
  649. bool CanHaveAmmo( CBaseCombatCharacter *pPlayer, int iAmmoIndex );
  650. virtual const char *GetGameDescription( void ){ return "Team Fortress"; }
  651. virtual void Status( void (*print) (PRINTF_FORMAT_STRING const char *fmt, ...) );
  652. // Sets up g_pPlayerResource.
  653. virtual void CreateStandardEntities();
  654. virtual void PlayerKilled( CBasePlayer *pVictim, const CTakeDamageInfo &info );
  655. virtual void PlayerKilledCheckAchievements( CTFPlayer *pAttacker, CTFPlayer *pVictim );
  656. virtual void DeathNotice( CBasePlayer *pVictim, const CTakeDamageInfo &info );
  657. virtual void DeathNotice( CBasePlayer *pVictim, const CTakeDamageInfo &info, const char* eventName );
  658. virtual CBasePlayer *GetDeathScorer( CBaseEntity *pKiller, CBaseEntity *pInflictor, CBaseEntity *pVictim );
  659. void CalcDominationAndRevenge( CTFPlayer *pAttacker, CBaseEntity *pWeapon, CTFPlayer *pVictim, bool bIsAssist, int *piDeathFlags );
  660. const char *GetKillingWeaponName( const CTakeDamageInfo &info, CTFPlayer *pVictim, int *iWeaponID );
  661. CBasePlayer *GetAssister( CBasePlayer *pVictim, CBasePlayer *pScorer, CBaseEntity *pInflictor );
  662. CTFPlayer *GetRecentDamager( CTFPlayer *pVictim, int iDamager, float flMaxElapsed );
  663. virtual void ClientDisconnected( edict_t *pClient );
  664. virtual void RadiusDamage( const CTakeDamageInfo &info, const Vector &vecSrc, float flRadius, int iClassIgnore, CBaseEntity *pEntityIgnore );
  665. void RadiusDamage( CTFRadiusDamageInfo &info );
  666. bool ApplyOnDamageModifyRules( CTakeDamageInfo &info, CBaseEntity *pVictimBaseEntity, bool bAllowDamage );
  667. struct DamageModifyExtras_t
  668. {
  669. bool bIgniting;
  670. bool bSelfBlastDmg;
  671. bool bSendPreFeignDamage;
  672. bool bPlayDamageReductionSound;
  673. };
  674. float ApplyOnDamageAliveModifyRules( const CTakeDamageInfo &info, CBaseEntity *pVictimBaseEntity, DamageModifyExtras_t& outParams );
  675. virtual float FlPlayerFallDamage( CBasePlayer *pPlayer );
  676. virtual bool FlPlayerFallDeathDoesScreenFade( CBasePlayer *pl ) { return false; }
  677. virtual bool UseSuicidePenalty() { return false; }
  678. int GetPreviousRoundWinners( void ) { return m_iPreviousRoundWinners; }
  679. void SendHudNotification( IRecipientFilter &filter, HudNotification_t iType, bool bForceShow = false );
  680. void SendHudNotification( IRecipientFilter &filter, const char *pszText, const char *pszIcon, int iTeam = TEAM_UNASSIGNED );
  681. void StopWatchModeThink( void );
  682. virtual void RestartTournament( void );
  683. bool TFVoiceManager( CBasePlayer *pListener, CBasePlayer *pTalker );
  684. void OnNavMeshLoad( void );
  685. void OnDispenserBuilt( CBaseEntity *dispenser );
  686. void OnDispenserDestroyed( CBaseEntity *dispenser );
  687. void OnPlayerSpawned( CTFPlayer *pPlayer );
  688. void OnCoachJoining( uint32 unCoachAccountID, uint32 unStudentAccountID );
  689. void OnRemoveCoach( uint32 unCoachAccountID );
  690. //Arena
  691. void AddPlayerToQueue( CTFPlayer *pPlayer );
  692. void AddPlayerToQueueHead( CTFPlayer *pPlayer );
  693. void RemovePlayerFromQueue( CTFPlayer *pPlayer );
  694. virtual bool BHavePlayers( void ) OVERRIDE;
  695. void Arena_RunTeamLogic( void );
  696. void Arena_ResetLosersScore( bool bResetAll );
  697. void Arena_PrepareNewPlayerQueue( bool bResetAll );
  698. int Arena_PlayersNeededForMatch( void );
  699. void Arena_CleanupPlayerQueue( void );
  700. void Arena_ClientDisconnect( const char *playername );
  701. void Arena_SendPlayerNotifications( void );
  702. void Arena_NotifyTeamSizeChange( void );
  703. float GetRoundStart( void ) { return m_flRoundStartTime; }
  704. // Voting
  705. void ManageServerSideVoteCreation( void );
  706. #ifdef TF_RAID_MODE
  707. // Raid game mode
  708. CRaidLogic *GetRaidLogic( void ) const { return m_hRaidLogic.Get(); }
  709. #endif // TF_RAID_MODE
  710. // Currency awarding
  711. int CalculateCurrencyAmount_CustomPack( int nAmount ); // If we should drop a custom currency pack, and how much money to put in - 0 means don't drop
  712. int CalculateCurrencyAmount_ByType( CurrencyRewards_t nType ); // How much to give players for specific items and events, i.e. cash collection bonus, small packs
  713. int DistributeCurrencyAmount( int nAmount, CTFPlayer *pTFPlayer = NULL, bool bShared = true, bool bCountAsDropped = false, bool bIsBonus = false ); // Distributes nAmount to a specific player or team
  714. virtual bool StopWatchShouldBeTimedWin( void ) OVERRIDE;
  715. public:
  716. void SetPlayerNextMapVote( int nIndex, EUserNextMapVote eState ) { m_ePlayerWantsRematch.Set( nIndex, eState ); }
  717. CTrainingModeLogic *GetTrainingModeLogic() { return m_hTrainingModeLogic; }
  718. CTFHolidayEntity *GetHolidayLogic() const { return m_hHolidayLogic; }
  719. void HandleCTFCaptureBonus( int nTeam );
  720. bool TournamentModeCanEndWithTimelimit( void ){ return ( GetStopWatchTimer() == NULL ); }
  721. CTeamRoundTimer *GetKothTeamTimer( int iTeam )
  722. {
  723. if ( IsInKothMode() == false )
  724. return NULL;
  725. if ( iTeam == TF_TEAM_RED )
  726. {
  727. return m_hRedKothTimer.Get();
  728. }
  729. else if ( iTeam == TF_TEAM_BLUE )
  730. {
  731. return m_hBlueKothTimer.Get();
  732. }
  733. return NULL;
  734. }
  735. void SetKothTeamTimer( int iTeam, CTeamRoundTimer *pTimer )
  736. {
  737. if ( iTeam == TF_TEAM_RED )
  738. {
  739. m_hRedKothTimer.Set( pTimer );
  740. }
  741. else if ( iTeam == TF_TEAM_BLUE )
  742. {
  743. m_hBlueKothTimer.Set( pTimer );
  744. }
  745. }
  746. void SetOvertimeAllowedForCTF( bool bAllowed ){ m_bOvertimeAllowedForCTF = bAllowed; }
  747. bool GetOvertimeAllowedForCTF( void ){ return m_bOvertimeAllowedForCTF; }
  748. const CUtlVector< CHandle< CBaseEntity > > &GetHealthEntityVector( void ); // return vector of health entities
  749. const CUtlVector< CHandle< CBaseEntity > > &GetAmmoEntityVector( void ); // return vector of ammo entities
  750. CHandle< CTeamTrainWatcher > GetPayloadToPush( int pushingTeam ) const; // return the train watcher for the Payload cart the given team needs to push to win, or NULL if none currently exists
  751. CHandle< CTeamTrainWatcher > GetPayloadToBlock( int blockingTeam ) const; // return the train watcher for the Payload cart the given team needs to block from advancing, or NULL if none currently exists
  752. virtual void ProcessVerboseLogOutput( void );
  753. void PushAllPlayersAway( const Vector& vFromThisPoint, float flRange, float flForce, int nTeam, CUtlVector< CTFPlayer* > *pPushedPlayers = NULL );
  754. bool ShouldDropSpellPickup();
  755. void DropSpellPickup( const Vector& vPosition, int nTier = 0 ) const;
  756. bool ShouldDropBonusDuck( void );
  757. bool ShouldDropBonusDuckFromPlayer( CTFPlayer *pScorer, CTFPlayer *pVictim );
  758. void DropBonusDuck( const Vector& vPosition, CTFPlayer *pScorer = NULL, CTFPlayer *pAssistor = NULL, CTFPlayer *pVictim = NULL, bool bCrit = false, bool bObjective = false ) const;
  759. void DropHalloweenSoulPackToTeam( int nAmount, const Vector& vecPosition, int nTeamNumber, int nSourceTeam );
  760. void DropHalloweenSoulPack( int nAmount, const Vector& vecSource, CBaseEntity *pTarget, int nSourceTeam );
  761. #ifdef STAGING_ONLY
  762. void MatchSummaryTest( void );
  763. #endif // STAGING_ONLY
  764. void MatchSummaryStart( void );
  765. void MatchSummaryEnd( void );
  766. int GetTeamAssignmentOverride( CTFPlayer *pTFPlayer, int iDesiredTeam, bool bAutoBalance = false );
  767. private:
  768. void ChooseNextMapVoteOptions();
  769. int DefaultFOV( void ) { return 75; }
  770. int GetDuckSkinForClass( int nTeam, int nClass ) const;
  771. void MatchSummaryTeleport();
  772. void StopWatchShouldBeTimedWin_Calculate( void );
  773. #endif // GAME_DLL
  774. private:
  775. void ComputeHealthAndAmmoVectors( void ); // compute internal vectors of health and ammo locations
  776. bool m_areHealthAndAmmoVectorsReady;
  777. #ifdef GAME_DLL
  778. void CheckHelltowerCartAchievement( int iTeam );
  779. Vector2D m_vecPlayerPositions[MAX_PLAYERS];
  780. CUtlVector<CHandle<CHealthKit> > m_hDisabledHealthKits;
  781. char m_szMostRecentCappers[MAX_PLAYERS+1]; // list of players who made most recent capture. Stored as string so it can be passed in events.
  782. int m_iNumCaps[TF_TEAM_COUNT]; // # of captures ever by each team during a round
  783. int SetCurrentRoundStateBitString();
  784. void SetMiniRoundBitMask( int iMask );
  785. int m_iPrevRoundState; // bit string representing the state of the points at the start of the previous miniround
  786. int m_iCurrentRoundState;
  787. int m_iCurrentMiniRoundMask;
  788. CHandle<CTeamRoundTimer> m_hStopWatchTimer;
  789. CTeamRoundTimer* GetStopWatchTimer( void ) { return (CTeamRoundTimer*)m_hStopWatchTimer.Get(); }
  790. EHANDLE m_hRequiredObserverTarget;
  791. EHANDLE m_hObjectiveObserverTarget;
  792. CHandle<CTFGameRulesProxy> m_hGamerulesProxy;
  793. //Arena
  794. bool IsFirstBloodAllowed( void );
  795. EHANDLE m_hArenaEntity;
  796. CUtlVector<CHandle<CTFPlayer> > m_hArenaPlayerQueue;
  797. int m_iPreviousTeamSize;
  798. bool m_bArenaFirstBlood;
  799. float m_flSendNotificationTime;
  800. // Tournament
  801. CHandle< CCompetitiveLogic > m_hCompetitiveLogicEntity;
  802. CHandle<CTrainingModeLogic> m_hTrainingModeLogic;
  803. CHandle<CTFHolidayEntity> m_hHolidayLogic;
  804. bool m_bOvertimeAllowedForCTF;
  805. // for bot rosters
  806. CHandle<CTFBotRoster> m_hBlueBotRoster;
  807. CHandle<CTFBotRoster> m_hRedBotRoster;
  808. // coaching
  809. typedef CUtlMap<uint32, uint32> tCoachToStudentMap;
  810. tCoachToStudentMap m_mapCoachToStudentMap;
  811. // Automatic vote called near the end of a map
  812. bool m_bVoteCalled;
  813. bool m_bServerVoteOnReset;
  814. float m_flVoteCheckThrottle;
  815. CUtlVector< CHandle< CCPTimerLogic > > m_CPTimerEnts;
  816. float m_flCapInProgressBuffer;
  817. float m_flMatchSummaryTeleportTime;
  818. #ifdef TF_RAID_MODE
  819. CHandle< CRaidLogic > m_hRaidLogic;
  820. CHandle< CBossBattleLogic > m_hBossBattleLogic;
  821. #endif // TF_RAID_MODE
  822. int m_nCurrencyAccumulator;
  823. int m_iCurrencyPool;
  824. float m_flCheckPlayersConnectingTime;
  825. CountdownTimer m_helltowerTimer; // used for Halloween 2013 Announcer VO in plr_hightower_event
  826. CountdownTimer m_doomsdaySetupTimer; // used for Halloween 2014 Announcer Setup VO in sd_doomsday_event
  827. CountdownTimer m_doomsdayTicketsTimer; // Used on sd_doomsday_event to nag players about picking up the tickets
  828. float m_flNextStrangeEventProcessTime;
  829. bool m_bMapForcedTruceDuringBossFight;
  830. float m_flNextHalloweenGiftUpdateTime;
  831. #else
  832. KeyValues *m_pkvVisionFilterTranslations;
  833. KeyValues *m_pkvVisionFilterShadersMapWhitelist;
  834. bool m_bSillyGibs;
  835. #endif
  836. CNetworkVar( ETFGameType, m_nGameType ); // Type of game this map is (CTF, CP)
  837. CNetworkVar( int, m_nStopWatchState );
  838. CNetworkString( m_pszTeamGoalStringRed, MAX_TEAMGOAL_STRING );
  839. CNetworkString( m_pszTeamGoalStringBlue, MAX_TEAMGOAL_STRING );
  840. CNetworkVar( float, m_flCapturePointEnableTime );
  841. CNetworkVar( int, m_iGlobalAttributeCacheVersion );
  842. //=============================================================================
  843. // HPE_BEGIN:
  844. // [msmith] Training and HUD status.
  845. //=============================================================================
  846. CNetworkVar( int, m_nHudType ); // Used by map authors to override the default HUD clients are showing
  847. CNetworkVar( bool, m_bIsInTraining );
  848. CNetworkVar( bool, m_bAllowTrainingAchievements );
  849. CNetworkVar( bool, m_bIsWaitingForTrainingContinue );
  850. //=============================================================================
  851. // HPE_END
  852. //=============================================================================
  853. CNetworkVar( bool, m_bIsTrainingHUDVisible );
  854. CNetworkVar( bool, m_bIsInItemTestingMode );
  855. int m_iItemTesting_BotAnim;
  856. float m_flItemTesting_BotAnimSpeed;
  857. bool m_bItemTesting_BotForceFire;
  858. bool m_bItemTesting_BotTurntable;
  859. bool m_bItemTesting_BotViewScan;
  860. CNetworkVar( CHandle<CBonusRoundLogic>, m_hBonusLogic );
  861. CNetworkVar( bool, m_bPlayingKoth );
  862. CNetworkVar( bool, m_bPowerupMode );
  863. CNetworkVar( bool, m_bPlayingRobotDestructionMode );
  864. CNetworkVar( bool, m_bPlayingMedieval );
  865. CNetworkVar( bool, m_bPlayingHybrid_CTF_CP );
  866. CNetworkVar( bool, m_bPlayingSpecialDeliveryMode );
  867. CNetworkVar( bool, m_bPlayingMannVsMachine );
  868. CNetworkVar( bool, m_bMannVsMachineAlarmStatus );
  869. CNetworkVar( bool, m_bHaveMinPlayersToEnableReady );
  870. CNetworkVar( bool, m_bBountyModeEnabled );
  871. CNetworkVar( bool, m_bCompetitiveMode );
  872. CNetworkVar( float, m_flGravityMultiplier );
  873. CNetworkVar( int, m_nMatchGroupType );
  874. CNetworkVar( bool, m_bMatchEnded );
  875. // This is used to check if players are in hell. The name doesn't make sense because we thought this would only be used for Halloween 2013
  876. // cannot change the name because it's network var which will break demo
  877. CNetworkVar( bool, m_bHelltowerPlayersInHell );
  878. CNetworkVar( bool, m_bIsUsingSpells );
  879. CNetworkVar( bool, m_bTruceActive );
  880. CNetworkVar( bool, m_bTeamsSwitched );
  881. #ifdef GAME_DLL
  882. float m_flNextFlagAlarm;
  883. float m_flNextFlagAlert;
  884. float m_flSafeToLeaveTimer;
  885. CBaseEntity *m_pUpgrades;
  886. #endif
  887. CNetworkVar( CHandle<CTeamRoundTimer>, m_hRedKothTimer );
  888. CNetworkVar( CHandle<CTeamRoundTimer>, m_hBlueKothTimer );
  889. CNetworkVar( int, m_nMapHolidayType ); // Used by map authors to indicate this is a holiday map
  890. CNetworkString( m_pszCustomUpgradesFile, MAX_PATH );
  891. CNetworkVar( bool, m_bShowMatchSummary );
  892. CNetworkVar( bool, m_bMapHasMatchSummaryStage );
  893. CNetworkVar( bool, m_bPlayersAreOnMatchSummaryStage );
  894. CNetworkVar( bool, m_bStopWatchWinner );
  895. // This is called m_ePlayerWantsRematch because we initially had rematches, but now we
  896. // let players vote on the next map instead. Can't rename this variable, so we're just
  897. // going to use with the wrong name
  898. CNetworkArray( EUserNextMapVote, m_ePlayerWantsRematch, MAX_PLAYERS + 1 );
  899. CNetworkVar( ENextMapVotingState, m_eRematchState );
  900. CNetworkArray( MapDefIndex_t, m_nNextMapVoteOptions, 3 );
  901. float m_flCTFCaptureBonusTime;
  902. public:
  903. bool m_bControlSpawnsPerTeam[ MAX_TEAMS ][ MAX_CONTROL_POINTS ];
  904. int m_iPreviousRoundWinners;
  905. float GetCapturePointTime( void ) { return m_flCapturePointEnableTime; }
  906. virtual bool ShouldDrawHeadLabels()
  907. {
  908. if ( IsInTournamentMode() )
  909. return false;
  910. return BaseClass::ShouldDrawHeadLabels();
  911. }
  912. enum HalloweenScenarioType
  913. {
  914. HALLOWEEN_SCENARIO_NONE = 0,
  915. HALLOWEEN_SCENARIO_MANN_MANOR,
  916. HALLOWEEN_SCENARIO_VIADUCT,
  917. HALLOWEEN_SCENARIO_LAKESIDE,
  918. HALLOWEEN_SCENARIO_HIGHTOWER,
  919. HALLOWEEN_SCENARIO_DOOMSDAY,
  920. };
  921. HalloweenScenarioType GetHalloweenScenario( void ) const;
  922. bool IsHalloweenScenario( HalloweenScenarioType scenario ) const;
  923. bool CanInitiateDuels( void );
  924. #ifdef GAME_DLL
  925. // Used on sd_doomsday_event to nag players about picking up the tickets
  926. void StartDoomsdayTicketsTimer( void ) { m_doomsdayTicketsTimer.Start( RandomInt( 30, 60 ) ); }
  927. void StopDoomsdayTicketsTimer( void ) { m_doomsdayTicketsTimer.Invalidate(); }
  928. bool DoomsdayTicketTimerElapsed( void ) const { return m_doomsdayTicketsTimer.HasStarted() && m_doomsdayTicketsTimer.IsElapsed(); }
  929. int GetBossCount() const { return m_activeBosses.Count(); }
  930. CBaseCombatCharacter *GetActiveBoss( int iBoss = 0 )
  931. {
  932. if ( iBoss < 0 || iBoss >= m_activeBosses.Count() )
  933. return NULL;
  934. return m_activeBosses[iBoss];
  935. }
  936. void AddActiveBoss( CBaseCombatCharacter *boss )
  937. {
  938. // don't add the same boss
  939. if ( m_activeBosses.Find( boss ) != m_activeBosses.InvalidIndex() )
  940. return;
  941. m_activeBosses.AddToTail( boss );
  942. }
  943. void RemoveActiveBoss( CBaseCombatCharacter *boss )
  944. {
  945. m_activeBosses.FindAndRemove( boss );
  946. }
  947. CBaseEntity *GetIT( void ) const // who is the boss chasing
  948. {
  949. return m_itHandle;
  950. }
  951. void SetIT( CBaseEntity *who );
  952. void SetBirthdayPlayer( CBaseEntity *pEntity );
  953. void SetHalloweenEffectStatus( int effect, float duration ) // Update the current Halloween effect on the HUD
  954. {
  955. m_nHalloweenEffect = effect;
  956. m_fHalloweenEffectStartTime = gpGlobals->curtime;
  957. m_fHalloweenEffectDuration = duration;
  958. }
  959. // remove all projectiles in the world
  960. void RemoveAllProjectiles();
  961. // remove all buildings in the world
  962. void RemoveAllBuildings( bool bExplodeBuildings = false );
  963. // remove all sentry's ammo
  964. void RemoveAllSentriesAmmo();
  965. // remove all projectiles and objects
  966. void RemoveAllProjectilesAndBuildings( bool bExplodeBuildings = false );
  967. #endif // GAME_DLL
  968. void ClearHalloweenEffectStatus( void ) // Clear the current Halloween effect and hide the HUD display
  969. {
  970. m_nHalloweenEffect = -1;
  971. m_fHalloweenEffectStartTime = -1.0f;
  972. m_fHalloweenEffectDuration = -1.0f;
  973. }
  974. bool IsIT( CBaseEntity *who ) const
  975. {
  976. return ( who && who == m_itHandle.Get() );
  977. }
  978. CBaseEntity *GetBirthdayPlayer( void ) const
  979. {
  980. return m_hBirthdayPlayer.Get();
  981. }
  982. bool IsHalloweenEffectStatusActive( void ) const
  983. {
  984. return m_nHalloweenEffect >= 0;
  985. }
  986. int GetHalloweenEffectStatus( void ) const
  987. {
  988. return m_nHalloweenEffect;
  989. }
  990. float GetHalloweenEffectTimeLeft( void ) const
  991. {
  992. float expireTime = m_fHalloweenEffectStartTime + m_fHalloweenEffectDuration;
  993. return expireTime - gpGlobals->curtime;
  994. }
  995. float GetHalloweenEffectDuration( void ) const
  996. {
  997. return m_fHalloweenEffectDuration;
  998. }
  999. int GetGlobalAttributeCacheVersion( void ) const
  1000. {
  1001. return m_iGlobalAttributeCacheVersion;
  1002. }
  1003. void FlushAllAttributeCaches( void )
  1004. {
  1005. m_iGlobalAttributeCacheVersion++;
  1006. }
  1007. private:
  1008. #ifdef CLIENT_DLL
  1009. bool m_bRecievedBaseline;
  1010. #endif
  1011. CountdownTimer m_botCountTimer;
  1012. CUtlVector< CHandle< CBaseEntity > > m_ammoVector; // vector of active ammo entities
  1013. bool m_isAmmoVectorReady; // for lazy evaluation
  1014. CUtlVector< CHandle< CBaseEntity > > m_healthVector; // vector of active health entities
  1015. bool m_isHealthVectorReady; // for lazy evaluation
  1016. bool m_bUseMatchHUD;
  1017. bool m_bUsePreRoundDoors;
  1018. #ifdef GAME_DLL
  1019. mutable CHandle< CTeamTrainWatcher > m_redPayloadToPush;
  1020. mutable CHandle< CTeamTrainWatcher > m_bluePayloadToPush;
  1021. mutable CHandle< CTeamTrainWatcher > m_redPayloadToBlock;
  1022. mutable CHandle< CTeamTrainWatcher > m_bluePayloadToBlock;
  1023. bool m_hasSpawnedToy;
  1024. void SpawnHalloweenBoss( void );
  1025. CountdownTimer m_halloweenBossTimer;
  1026. CUtlVector< CHandle< CBaseCombatCharacter > > m_activeBosses;
  1027. bool m_bHasSpawnedSoccerBall[TF_TEAM_COUNT];
  1028. CountdownTimer m_ghostTimer;
  1029. void SpawnZombieMob( void );
  1030. CountdownTimer m_zombieMobTimer;
  1031. int m_zombiesLeftToSpawn;
  1032. Vector m_zombieSpawnSpot;
  1033. public:
  1034. void BeginHaunting( int nDesiredCount, float flMinDuration, float flMaxDuration );
  1035. void StartHalloweenBossTimer( float flTime, float flVariation = 0.f )
  1036. {
  1037. m_halloweenBossTimer.Start( RandomFloat( flTime - flVariation, flTime + flVariation ) );
  1038. }
  1039. // Recent player stuff
  1040. void PlayerHistory_AddPlayer( CTFPlayer *pTFPlayer );
  1041. PlayerHistoryInfo_t *PlayerHistory_GetPlayerInfo( CTFPlayer *pTFPlayer );
  1042. int PlayerHistory_GetTimeSinceLastSeen( CTFPlayer *pTFPlayer );
  1043. CUtlVector< Vector > *GetHalloweenSpawnLocations() { return &m_halloweenGiftSpawnLocations; }
  1044. bool BAttemptMapVoteRollingMatch();
  1045. bool BIsManagedMatchEndImminent( void );
  1046. private:
  1047. CUtlVector< CHandle< CGhost > > m_ghostVector;
  1048. CUtlVector< PlayerHistoryInfo_t > m_vecPlayerHistory;
  1049. struct TeleportLocation_t
  1050. {
  1051. Vector m_vecPosition;
  1052. QAngle m_qAngles;
  1053. };
  1054. CUtlMap< string_t, CUtlVector< TeleportLocation_t >* > m_mapTeleportLocations;
  1055. // Keep track of kills made with powerups
  1056. int m_nPowerupKillsRedTeam;
  1057. int m_nPowerupKillsBlueTeam;
  1058. float m_flTimeToRunImbalanceMeasures;
  1059. float m_flTimeToStopImbalanceMeasures;
  1060. bool m_bPowerupImbalanceMeasuresRunning;
  1061. bool m_bMapCycleNeedsUpdate;
  1062. CUtlVector< Vector > m_halloweenGiftSpawnLocations; // vector of valid gift spawn locations from the map
  1063. float m_flCompModeRespawnPlayersAtMatchStart;
  1064. #endif // GAME_DLL
  1065. // LEGACY BOSS CODE. Keeping this to not break demo
  1066. CNetworkVar( int, m_nBossHealth );
  1067. CNetworkVar( int, m_nMaxBossHealth );
  1068. CNetworkVar( float, m_fBossNormalizedTravelDistance );
  1069. CNetworkHandle( CBaseEntity, m_itHandle ); // entindex of current IT entity (0 = no it)
  1070. CNetworkHandle( CBaseEntity, m_hBirthdayPlayer ); // entindex of current birthday player (0 = none)
  1071. CNetworkVar( int, m_nHalloweenEffect );
  1072. CNetworkVar( float, m_fHalloweenEffectStartTime );
  1073. CNetworkVar( float, m_fHalloweenEffectDuration );
  1074. CNetworkVar( HalloweenScenarioType, m_halloweenScenario );
  1075. // MvM Helpers
  1076. #ifdef GAME_DLL
  1077. public:
  1078. void SetNextMvMPopfile ( const char * next );
  1079. const char * GetNextMvMPopfile ();
  1080. virtual void BalanceTeams( bool bRequireSwitcheesToBeDead );
  1081. #endif
  1082. };
  1083. //-----------------------------------------------------------------------------
  1084. // Gets us at the team fortress game rules
  1085. //-----------------------------------------------------------------------------
  1086. inline CTFGameRules* TFGameRules()
  1087. {
  1088. return static_cast<CTFGameRules*>(g_pGameRules);
  1089. }
  1090. inline float CTFGameRules::ItemTesting_GetBotAnimSpeed( void )
  1091. {
  1092. static const ConVar *pHostTimescale = NULL;
  1093. if ( !pHostTimescale )
  1094. {
  1095. pHostTimescale = cvar->FindVar( "host_timescale" );
  1096. }
  1097. if ( pHostTimescale )
  1098. return (m_flItemTesting_BotAnimSpeed * pHostTimescale->GetFloat());
  1099. return m_flItemTesting_BotAnimSpeed;
  1100. }
  1101. #ifdef TF_RAID_MODE
  1102. inline bool CTFGameRules::IsRaidMode( void ) const
  1103. {
  1104. #ifdef GAME_DLL
  1105. return m_hRaidLogic != NULL;
  1106. #else
  1107. return tf_gamemode_raid.GetBool();
  1108. #endif
  1109. }
  1110. inline bool CTFGameRules::IsBossBattleMode( void ) const
  1111. {
  1112. return tf_gamemode_boss_battle.GetBool();
  1113. }
  1114. #endif // TF_RAID_MODE
  1115. #ifdef TF_CREEP_MODE
  1116. inline bool CTFGameRules::IsCreepWaveMode( void ) const
  1117. {
  1118. return tf_gamemode_creep_wave.GetBool();
  1119. }
  1120. #endif
  1121. inline bool CTFGameRules::IsHalloweenScenario( HalloweenScenarioType scenario ) const
  1122. {
  1123. return m_halloweenScenario == scenario;
  1124. }
  1125. #ifdef GAME_DLL
  1126. bool EntityPlacementTest( CBaseEntity *pMainEnt, const Vector &vOrigin, Vector &outPos, bool bDropToGround );
  1127. //-----------------------------------------------------------------------------
  1128. // Purpose:
  1129. //-----------------------------------------------------------------------------
  1130. class CArenaLogic : public CPointEntity
  1131. {
  1132. DECLARE_CLASS( CArenaLogic, CPointEntity );
  1133. public:
  1134. DECLARE_DATADESC();
  1135. virtual int UpdateTransmitState()
  1136. {
  1137. return SetTransmitState( FL_EDICT_ALWAYS );
  1138. }
  1139. virtual void ArenaLogicThink( void );
  1140. virtual void Spawn( void );
  1141. COutputEvent m_OnArenaRoundStart;
  1142. float m_flTimeToEnableCapPoint;
  1143. COutputEvent m_OnCapEnabled;
  1144. bool m_bFiredOutput;
  1145. };
  1146. //-----------------------------------------------------------------------------
  1147. // Purpose:
  1148. //-----------------------------------------------------------------------------
  1149. class CCompetitiveLogic : public CPointEntity
  1150. {
  1151. DECLARE_CLASS( CCompetitiveLogic, CPointEntity );
  1152. public:
  1153. DECLARE_DATADESC();
  1154. void OnSpawnRoomDoorsShouldLock( void );
  1155. void OnSpawnRoomDoorsShouldUnlock( void );
  1156. COutputEvent m_OnSpawnRoomDoorsShouldLock;
  1157. COutputEvent m_OnSpawnRoomDoorsShouldUnlock;
  1158. };
  1159. //-----------------------------------------------------------------------------
  1160. // Purpose:
  1161. //-----------------------------------------------------------------------------
  1162. class CLogicMannPower : public CPointEntity
  1163. {
  1164. DECLARE_CLASS( CLogicMannPower, CPointEntity );
  1165. public:
  1166. DECLARE_DATADESC();
  1167. };
  1168. //-----------------------------------------------------------------------------
  1169. // Purpose: New training stuff
  1170. //-----------------------------------------------------------------------------
  1171. class CTrainingModeLogic : public CPointEntity
  1172. {
  1173. DECLARE_CLASS( CTrainingModeLogic, CPointEntity );
  1174. public:
  1175. DECLARE_DATADESC();
  1176. void SetupOnRoundStart( void );
  1177. void SetTrainingMsg( const char *msg );
  1178. void SetTrainingObjective( const char *msg );
  1179. void OnPlayerSpawned( CTFPlayer *pPlayer );
  1180. void OnPlayerDied( CTFPlayer *pPlayer, CBaseEntity *pKiller );
  1181. void OnBotDied( CTFPlayer *pPlayer, CBaseEntity *pKiller );
  1182. void OnPlayerSwitchedWeapons( CTFPlayer *pPlayer );
  1183. void OnPlayerWantsToContinue();
  1184. void OnPlayerBuiltBuilding( CTFPlayer *pPlayer, CBaseObject *pBaseObject );
  1185. void OnPlayerUpgradedBuilding( CTFPlayer *pPlayer, CBaseObject *pBaseObject );
  1186. void OnPlayerDetonateBuilding( CTFPlayer *pPlayer, CBaseObject *pBaseObject );
  1187. void UpdateHUDObjective();
  1188. const char* GetNextMap();
  1189. const char* GetTrainingEndText();
  1190. int GetDesiredClass() const;
  1191. // Inputs
  1192. void InputForcePlayerSpawnAsClassOutput( inputdata_t &inputdata );
  1193. void InputKickAllBots( inputdata_t &inputdata );
  1194. void InputShowTrainingMsg( inputdata_t &inputdata );
  1195. void InputShowTrainingObjective( inputdata_t &inputdata );
  1196. void InputShowTrainingHUD( inputdata_t &inputdata );
  1197. void InputHideTrainingHUD( inputdata_t &inputdata );
  1198. void InputEndTraining( inputdata_t &inputdata );
  1199. void InputPlaySoundOnPlayer( inputdata_t &inputdata );
  1200. void InputWaitForTimerOrKeypress( inputdata_t &inputdata );
  1201. void InputSetNextMap( inputdata_t &inputdata );
  1202. void InputForcePlayerSwapToWeapon( inputdata_t &inputdata );
  1203. protected:
  1204. enum
  1205. {
  1206. kMaxLengthObjectiveText = 128,
  1207. };
  1208. // outputs based on the class the player spawned as
  1209. COutputEvent m_outputOnPlayerSpawnAsScout;
  1210. COutputEvent m_outputOnPlayerSpawnAsSniper;
  1211. COutputEvent m_outputOnPlayerSpawnAsSoldier;
  1212. COutputEvent m_outputOnPlayerSpawnAsDemoman;
  1213. COutputEvent m_outputOnPlayerSpawnAsMedic;
  1214. COutputEvent m_outputOnPlayerSpawnAsHeavy;
  1215. COutputEvent m_outputOnPlayerSpawnAsPyro;
  1216. COutputEvent m_outputOnPlayerSpawnAsSpy;
  1217. COutputEvent m_outputOnPlayerSpawnAsEngineer;
  1218. // outputs based on the weapon the player swapped to
  1219. COutputEvent m_outputOnPlayerSwappedToWeaponSlotPrimary;
  1220. COutputEvent m_outputOnPlayerSwappedToWeaponSlotSecondary;
  1221. COutputEvent m_outputOnPlayerSwappedToWeaponSlotMelee;
  1222. COutputEvent m_outputOnPlayerSwappedToWeaponSlotBuilding;
  1223. COutputEvent m_outputOnPlayerSwappedToWeaponSlotPDA;
  1224. // outputs based on if the player built inside a suggested area
  1225. COutputEvent m_outputOnPlayerBuiltOutsideSuggestedArea;
  1226. // player detonated their own building
  1227. COutputEvent m_outputOnPlayerDetonateBuilding;
  1228. // other outputs
  1229. COutputEvent m_outputOnPlayerDied;
  1230. COutputEvent m_outputOnBotDied;
  1231. CHandle<CBaseEntity> m_waitingForKeypressTimer;
  1232. string_t m_nextMapName;
  1233. char m_objText[kMaxLengthObjectiveText];
  1234. string_t m_endTrainingText;
  1235. };
  1236. class CMultipleEscort : public CPointEntity
  1237. {
  1238. DECLARE_CLASS( CMultipleEscort, CPointEntity );
  1239. public:
  1240. virtual int UpdateTransmitState()
  1241. {
  1242. return SetTransmitState( FL_EDICT_ALWAYS );
  1243. }
  1244. };
  1245. class CMedievalLogic : public CPointEntity
  1246. {
  1247. DECLARE_CLASS( CMedievalLogic, CPointEntity );
  1248. public:
  1249. virtual int UpdateTransmitState()
  1250. {
  1251. return SetTransmitState( FL_EDICT_ALWAYS );
  1252. }
  1253. };
  1254. class CHybridMap_CTF_CP : public CPointEntity
  1255. {
  1256. DECLARE_CLASS( CHybridMap_CTF_CP, CPointEntity );
  1257. public:
  1258. virtual int UpdateTransmitState()
  1259. {
  1260. return SetTransmitState( FL_EDICT_ALWAYS );
  1261. }
  1262. };
  1263. class CTFHolidayEntity : public CPointEntity, public CGameEventListener
  1264. {
  1265. DECLARE_CLASS( CTFHolidayEntity, CPointEntity );
  1266. public:
  1267. DECLARE_DATADESC();
  1268. CTFHolidayEntity()
  1269. {
  1270. m_nHolidayType = kHoliday_None;
  1271. m_nTauntInHell = 0;
  1272. m_nAllowHaunting = 0;
  1273. ListenForGameEvent( "player_turned_to_ghost" );
  1274. ListenForGameEvent( "player_disconnect" );
  1275. ListenForGameEvent( "player_team" );
  1276. }
  1277. ~CTFHolidayEntity()
  1278. {
  1279. }
  1280. virtual int UpdateTransmitState()
  1281. {
  1282. return SetTransmitState( FL_EDICT_ALWAYS );
  1283. }
  1284. int GetHolidayType( void ){ return m_nHolidayType; }
  1285. bool ShouldTauntInHell( void ){ return ( m_nTauntInHell > 0 ); }
  1286. bool ShouldAllowHaunting( void ){ return ( m_nAllowHaunting > 0 ); }
  1287. void InputHalloweenSetUsingSpells( inputdata_t &inputdata );
  1288. void InputHalloweenTeleportToHell( inputdata_t &inputdata );
  1289. virtual void FireGameEvent( IGameEvent *event );
  1290. void ResetWinner() { m_nWinningTeam = TF_TEAM_COUNT; }
  1291. int GetWinningTeam() const { return m_nWinningTeam; }
  1292. private:
  1293. void HalloweenTeleportToHellDanceThink( void );
  1294. void Teleport();
  1295. CUtlVector< CHandle<CTFPlayer> > m_vecDancers;
  1296. int m_nWinningTeam;
  1297. int m_nHolidayType;
  1298. int m_nTauntInHell;
  1299. int m_nAllowHaunting;
  1300. };
  1301. class CKothLogic : public CPointEntity
  1302. {
  1303. DECLARE_CLASS( CKothLogic, CPointEntity );
  1304. public:
  1305. DECLARE_DATADESC();
  1306. CKothLogic()
  1307. {
  1308. m_nTimerInitialLength = 180; // seconds
  1309. m_nTimeToUnlockPoint = 30; // seconds
  1310. m_hRedTimer = NULL;
  1311. m_hBlueTimer = NULL;
  1312. }
  1313. virtual int UpdateTransmitState()
  1314. {
  1315. return SetTransmitState( FL_EDICT_ALWAYS );
  1316. }
  1317. int GetInitialTimerLength( void ){ return m_nTimerInitialLength; }
  1318. int GetTimerToUnlockPoint( void ){ return m_nTimeToUnlockPoint; }
  1319. void InputRoundSpawn( inputdata_t &inputdata );
  1320. void InputRoundActivate( inputdata_t &inputdata );
  1321. void InputSetRedTimer( inputdata_t &inputdata );
  1322. void InputSetBlueTimer( inputdata_t &inputdata );
  1323. void InputAddRedTimer( inputdata_t &inputdata );
  1324. void InputAddBlueTimer( inputdata_t &inputdata );
  1325. private:
  1326. int m_nTimerInitialLength;
  1327. int m_nTimeToUnlockPoint;
  1328. CHandle< CTeamRoundTimer > m_hRedTimer;
  1329. CHandle< CTeamRoundTimer > m_hBlueTimer;
  1330. };
  1331. #define CP_TIMER_THINK "CCPTimerLogicThink"
  1332. class CCPTimerLogic : public CPointEntity
  1333. {
  1334. DECLARE_CLASS( CCPTimerLogic, CPointEntity );
  1335. public:
  1336. DECLARE_DATADESC();
  1337. CCPTimerLogic()
  1338. {
  1339. m_nTimerLength = 60; // seconds
  1340. m_iszControlPointName = NULL_STRING;
  1341. m_hControlPoint = NULL;
  1342. m_bFire15SecRemain = m_bFire10SecRemain = m_bFire5SecRemain = true;
  1343. SetContextThink( &CCPTimerLogic::Think, gpGlobals->curtime + 0.15, CP_TIMER_THINK );
  1344. }
  1345. virtual int UpdateTransmitState()
  1346. {
  1347. return SetTransmitState( FL_EDICT_ALWAYS );
  1348. }
  1349. void InputRoundSpawn( inputdata_t &inputdata );
  1350. void Think( void );
  1351. bool TimerMayExpire( void );
  1352. private:
  1353. int m_nTimerLength;
  1354. string_t m_iszControlPointName;
  1355. CHandle<CTeamControlPoint> m_hControlPoint;
  1356. CountdownTimer m_pointTimer;
  1357. bool m_bFire15SecRemain;
  1358. bool m_bFire10SecRemain;
  1359. bool m_bFire5SecRemain;
  1360. COutputEvent m_onCountdownStart;
  1361. COutputEvent m_onCountdown15SecRemain;
  1362. COutputEvent m_onCountdown10SecRemain;
  1363. COutputEvent m_onCountdown5SecRemain;
  1364. COutputEvent m_onCountdownEnd;
  1365. };
  1366. #endif
  1367. class CBonusRoundLogic : public CBaseEntity
  1368. {
  1369. DECLARE_CLASS( CBonusRoundLogic, CBaseEntity );
  1370. public:
  1371. DECLARE_NETWORKCLASS();
  1372. #ifdef GAME_DLL
  1373. bool InitBonusRound( void );
  1374. void SetBonusItem( itemid_t iItemID );
  1375. virtual int UpdateTransmitState()
  1376. {
  1377. return SetTransmitState( FL_EDICT_ALWAYS );
  1378. }
  1379. #endif
  1380. void BuildBonusPlayerList( void );
  1381. int GetNumBonusPlayers( void ) { return m_aBonusPlayerList.Count(); }
  1382. CTFPlayer *GetBonusPlayer( int i ) { Assert ( i < m_aBonusPlayerList.Count() ); return m_aBonusPlayerList[i]; }
  1383. CTFPlayer *GetBonusWinner( void ) { return m_hBonusWinner.Get(); }
  1384. void SetBonusStateAborted( bool bAborted ) { m_bAbortedBonusRound = bAborted; }
  1385. bool BonusStateAborted( void ) { return m_bAbortedBonusRound; }
  1386. int GetPlayerBonusRoll( int iPlayer ) { return (iPlayer < m_aBonusPlayerRoll.Count()) ? m_aBonusPlayerRoll[iPlayer] : 0; }
  1387. CEconItemView *GetBonusItem( void ) { return &m_Item; }
  1388. private:
  1389. CUtlSortVector< BONUSPLAYERPTR, CBonusPlayerListLess > m_aBonusPlayerList;
  1390. CUtlVector<int> m_aBonusPlayerRoll;
  1391. CNetworkVar( CHandle<CTFPlayer>, m_hBonusWinner );
  1392. CNetworkVar( bool, m_bAbortedBonusRound );
  1393. itemid_t m_iBonusItemID;
  1394. CNetworkVarEmbedded( CEconItemView, m_Item );
  1395. };
  1396. #ifdef GAME_DLL
  1397. class CSingleUserReliableRecipientFilter : public CRecipientFilter
  1398. {
  1399. public:
  1400. CSingleUserReliableRecipientFilter( CBasePlayer *player )
  1401. {
  1402. AddRecipient( player );
  1403. MakeReliable();
  1404. }
  1405. };
  1406. #endif
  1407. #endif // TF_GAMERULES_H