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.

1606 lines
58 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: The TF Game rules object
  4. //
  5. // $Workfile: $
  6. // $Date: $
  7. // $NoKeywords: $
  8. //=============================================================================//
  9. #ifndef CS_GAMERULES_H
  10. #define CS_GAMERULES_H
  11. #ifdef _WIN32
  12. #pragma once
  13. #endif
  14. #include "teamplay_gamerules.h"
  15. #include "convar.h"
  16. #include "cs_shareddefs.h"
  17. #include "cs_weapon_parse.h"
  18. #include "gamevars_shared.h"
  19. #include "bot/bot_constants.h"
  20. #include "../../../common/input_device.h"
  21. #include "cstrike15_gcconstants.h"
  22. #include "cstrike15_gcmessages.pb.h"
  23. #include "usermessages.h"
  24. #if defined( GAME_DLL )
  25. #include "maprules.h"
  26. #endif
  27. //#define DEBUG_QUESTS_IN_CLIENT
  28. #ifdef CLIENT_DLL
  29. #include "networkstringtable_clientdll.h"
  30. class C_CSPlayer;
  31. #define CCSPlayer C_CSPlayer
  32. #else
  33. #include "funfactmgr_cs.h"
  34. class CCSPlayer;
  35. #endif
  36. #define WINNER_NONE 0
  37. #define WINNER_DRAW 1
  38. #define WINNER_TER TEAM_TERRORIST
  39. #define WINNER_CT TEAM_CT
  40. #define CUSTOM_BOT_DIFFICULTY_NOBOTS 0
  41. #define CUSTOM_BOT_DIFFICULTY_DUMB 1
  42. #define CUSTOM_BOT_DIFFICULTY_EASY 2
  43. #define CUSTOM_BOT_DIFFICULTY_MEDIUM 3
  44. #define CUSTOM_BOT_DIFFICULTY_HARD 4
  45. #define CUSTOM_BOT_DIFFICULTY_EXPERT 5
  46. #define CUSTOM_BOT_MIN_DIFFICULTY_FOR_AWARDS_PROGRESS CUSTOM_BOT_DIFFICULTY_EASY
  47. #define MAX_WEAPON_NAME_POPUP_RANGE 128.0
  48. #define MAX_GIFT_GIVERS_FEATURED_COUNT 4
  49. #define MAX_TOURNAMENT_ACTIVE_CASTER_COUNT 4
  50. class CCSBot;
  51. class CHostage;
  52. class CCSWeaponInfo;
  53. struct quest_data_t;
  54. extern ConVar mp_startmoney;
  55. extern ConVar mp_maxmoney;
  56. extern ConVar mp_afterroundmoney;
  57. extern ConVar mp_playercashawards;
  58. extern ConVar mp_teamcashawards;
  59. extern ConVar mp_tkpunish;
  60. extern ConVar mp_c4timer;
  61. extern ConVar mp_buytime;
  62. extern ConVar mp_freezetime;
  63. extern ConVar mp_playerid;
  64. extern ConVar mp_defuser_allocation;
  65. extern ConVar mp_death_drop_gun;
  66. extern ConVar mp_death_drop_grenade;
  67. extern ConVar mp_death_drop_defuser;
  68. extern ConVar ammo_grenade_limit_total;
  69. extern ConVar sv_competitive_official_5v5;
  70. namespace DefuserAllocation
  71. {
  72. enum Type
  73. {
  74. None = 0,
  75. Random = 1,
  76. All = 2,
  77. };
  78. };
  79. namespace TeamCashAward
  80. {
  81. enum Type
  82. {
  83. NONE = 0,
  84. TERRORIST_WIN_BOMB,
  85. ELIMINATION_HOSTAGE_MAP_T,
  86. ELIMINATION_HOSTAGE_MAP_CT,
  87. ELIMINATION_BOMB_MAP,
  88. WIN_BY_TIME_RUNNING_OUT_HOSTAGE,
  89. WIN_BY_TIME_RUNNING_OUT_BOMB,
  90. WIN_BY_DEFUSING_BOMB,
  91. WIN_BY_HOSTAGE_RESCUE,
  92. LOSER_BONUS,
  93. LOSER_BONUS_CONSECUTIVE_ROUNDS,
  94. RESCUED_HOSTAGE,
  95. HOSTAGE_ALIVE,
  96. PLANTED_BOMB_BUT_DEFUSED,
  97. HOSTAGE_INTERACTION,
  98. LOSER_ZERO,
  99. SURVIVE_GUARDIAN_WAVE,
  100. CUSTOM_AWARD,
  101. };
  102. };
  103. namespace RoundResult
  104. {
  105. enum Reason
  106. {
  107. UNDEFINED = 0,
  108. CT_WIN_ELIMINATION,
  109. CT_WIN_RESCUE,
  110. CT_WIN_DEFUSE,
  111. CT_WIN_TIME,
  112. T_WIN_ELIMINATION,
  113. T_WIN_BOMB,
  114. T_WIN_TIME,
  115. COUNT,
  116. UNKNOWN
  117. };
  118. };
  119. namespace PlayerCashAward
  120. {
  121. enum Type
  122. {
  123. NONE = 0,
  124. KILL_TEAMMATE,
  125. KILLED_ENEMY,
  126. BOMB_PLANTED,
  127. BOMB_DEFUSED,
  128. RESCUED_HOSTAGE,
  129. INTERACT_WITH_HOSTAGE,
  130. DAMAGE_HOSTAGE,
  131. KILL_HOSTAGE,
  132. RESPAWN,
  133. GET_KILLED,
  134. };
  135. };
  136. namespace AutobalanceStatus
  137. {
  138. enum Type
  139. {
  140. NONE = 0,
  141. NEXT_ROUND,
  142. THIS_ROUND
  143. };
  144. };
  145. //--------------------------------------------------------------------------------------------------------------
  146. struct GGWeaponAliasName
  147. {
  148. CSWeaponID id;
  149. const char *aliasName;
  150. };
  151. #define GGLIST_PISTOLS_TOTAL 9
  152. #define GGLIST_RIFLES_TOTAL 7
  153. #define GGLIST_MGS_TOTAL 2
  154. #define GGLIST_SGS_TOTAL 4
  155. #define GGLIST_SMGS_TOTAL 6
  156. #define GGLIST_SNIPERS_TOTAL 3
  157. #define GGLIST_PISTOLS_START 0
  158. #define GGLIST_PISTOLS_LAST (GGLIST_PISTOLS_START+GGLIST_PISTOLS_TOTAL-1)
  159. #define GGLIST_RIFLES_START GGLIST_PISTOLS_LAST+1
  160. #define GGLIST_RIFLES_LAST (GGLIST_RIFLES_START+GGLIST_RIFLES_TOTAL-1)
  161. #define GGLIST_MGS_START GGLIST_RIFLES_LAST+1
  162. #define GGLIST_MGS_LAST (GGLIST_MGS_START+GGLIST_MGS_TOTAL-1)
  163. #define GGLIST_SGS_START GGLIST_MGS_LAST+1
  164. #define GGLIST_SGS_LAST (GGLIST_SGS_START+GGLIST_SGS_TOTAL-1)
  165. #define GGLIST_SMGS_START GGLIST_SGS_LAST+1
  166. #define GGLIST_SMGS_LAST (GGLIST_SMGS_START+GGLIST_SMGS_TOTAL-1)
  167. #define GGLIST_SNIPERS_START GGLIST_SMGS_LAST+1
  168. #define GGLIST_SNIPERS_LAST (GGLIST_SNIPERS_START+GGLIST_SNIPERS_TOTAL-1)
  169. //--------------------------------------------------------------------------------------------------------------
  170. // NOTE: Array must be NULL-terminated
  171. static GGWeaponAliasName ggWeaponAliasNameList[] =
  172. {
  173. //pistols
  174. { WEAPON_DEAGLE, "deagle" },
  175. { WEAPON_DEAGLE, "revolver" },
  176. { WEAPON_ELITE, "elite" },
  177. { WEAPON_FIVESEVEN, "fiveseven" },
  178. { WEAPON_GLOCK, "glock" },
  179. { WEAPON_TEC9, "tec9" },
  180. { WEAPON_HKP2000, "hkp2000" },
  181. { WEAPON_HKP2000, "usp_silencer" },
  182. { WEAPON_P250, "p250" },
  183. //rifles
  184. { WEAPON_AK47, "ak47" },
  185. { WEAPON_AUG, "aug" },
  186. { WEAPON_FAMAS, "famas" },
  187. { WEAPON_GALILAR, "galilar" },
  188. { WEAPON_M4A1, "m4a1" },
  189. { WEAPON_M4A1, "m4a1_silencer" },
  190. { WEAPON_SG556, "sg556" },
  191. //mgs
  192. { WEAPON_M249, "m249" },
  193. { WEAPON_NEGEV, "negev" },
  194. //shotguns
  195. { WEAPON_XM1014, "xm1014" },
  196. { WEAPON_MAG7, "mag7" },
  197. { WEAPON_SAWEDOFF, "sawedoff" },
  198. { WEAPON_NOVA, "nova" },
  199. //smgs
  200. { WEAPON_MAC10, "mac10" },
  201. { WEAPON_P90, "p90" },
  202. { WEAPON_UMP45, "ump45" },
  203. { WEAPON_BIZON, "bizon" },
  204. { WEAPON_MP7, "mp7" },
  205. { WEAPON_MP9, "mp9" },
  206. //snipers
  207. // { WEAPON_SSG08, "ssg08" },
  208. { WEAPON_SCAR20, "scar20" },
  209. { WEAPON_G3SG1, "g3sg1" },
  210. { WEAPON_AWP, "awp" },
  211. { WEAPON_NONE, "" }
  212. };
  213. class CEconItemPreviewDataBlock; // forward declare item data
  214. class CCSUsrMsg_PlayerDecalDigitalSignature; // forward declare proto message
  215. #ifndef CLIENT_DLL
  216. extern ConVar mp_autoteambalance;
  217. #endif // !CLIENT_DLL
  218. #ifdef CLIENT_DLL
  219. #define CCSGameRules C_CSGameRules
  220. #define CCSGameRulesProxy C_CSGameRulesProxy
  221. #endif
  222. #if !defined( CLIENT_DLL )
  223. // forward declare GC message
  224. class CMsgGCCStrike15_v2_MatchmakingServerRoundStats;
  225. class CMsgGCCStrike15_v2_MatchmakingGC2ServerReserve;
  226. int ScramblePlayersSort( CCSPlayer* const *p1, CCSPlayer* const *p2 );
  227. class CCSMatch
  228. {
  229. public:
  230. CCSMatch();
  231. void Reset( void );
  232. void SetPhase( GamePhase phase );
  233. GamePhase GetPhase( void ) const { return m_phase; }
  234. //These functions add to both the score and the number of rounds
  235. void AddTerroristWins( int numWins );
  236. void AddCTWins( int numWins);
  237. void IncrementRound( int nNumRounds );
  238. //These functions only adjust the score (without adding to the number of rounds played)
  239. void AddTerroristBonusPoints( int numWins );
  240. void AddCTBonusPoints( int numWins);
  241. int GetTerroristScore( void ) const { return m_terroristScoreTotal; }
  242. int GetCTScore( void ) const { return m_ctScoreTotal; }
  243. int GetTeamScore( int nTeam ) const { switch( nTeam ) { case TEAM_TERRORIST: return GetTerroristScore(); case TEAM_CT: return GetCTScore(); default: Assert( !"unexpected value for nTeam" ); return 0; } }
  244. int GetRoundsPlayed( void ) const { return m_actualRoundsPlayed; }
  245. //Since the teams change in halftime modes and we want to retain their scores, we swap the scores
  246. //between halves.
  247. void SwapTeamScores( void );
  248. int GetWinningTeam( void );
  249. //These are the internal functions that actually mess with the scores, adjusting the appropriate phase-specific scores as well.
  250. void AddTerroristScore( int score );
  251. void AddCTScore( int score );
  252. void GoToOvertime( int numOvertimesToAdd );
  253. private:
  254. //This is called anytime the match-internal scores are updated to reflect the changes in the team object (so the scores can be replicated)
  255. void UpdateTeamScores( void );
  256. // Called when we wish to change the full all-talk rules, based on entering a specific phase of the match
  257. void EnableFullAlltalk( bool bEnable );
  258. //This is the number of rounds that have been played, regardless of the actual score of the match (e.g. Demolition mode can give bonus points)
  259. short m_actualRoundsPlayed;
  260. // This is the index of the overtime that is being played, 0 when game has no overtime or is still in regulation time, 1 for first overtime, 2 for second, etc.
  261. short m_nOvertimePlaying;
  262. short m_ctScoreFirstHalf;
  263. short m_ctScoreSecondHalf;
  264. short m_ctScoreOvertime;
  265. short m_ctScoreTotal;
  266. short m_terroristScoreFirstHalf;
  267. short m_terroristScoreSecondHalf;
  268. short m_terroristScoreOvertime;
  269. short m_terroristScoreTotal;
  270. GamePhase m_phase;
  271. };
  272. class SpawnPoint : public CServerOnlyPointEntity
  273. {
  274. DECLARE_CLASS( SpawnPoint, CServerOnlyPointEntity );
  275. DECLARE_DATADESC();
  276. public:
  277. SpawnPoint();
  278. void Spawn( void );
  279. bool IsEnabled() { return m_bEnabled; }
  280. void InputSetEnabled( inputdata_t &inputdata );
  281. void InputSetDisabled( inputdata_t &inputdata );
  282. void InputToggleEnabled( inputdata_t &inputdata );
  283. void SetSpawnEnabled( bool bEnabled );
  284. int m_iPriority;
  285. bool m_bEnabled;
  286. int m_nType;
  287. enum Type
  288. {
  289. Default = 0,
  290. Deathmatch = 1,
  291. ArmsRace = 2,
  292. };
  293. };
  294. class SpawnPointCoopEnemy : public SpawnPoint
  295. {
  296. DECLARE_CLASS( SpawnPointCoopEnemy, SpawnPoint );
  297. DECLARE_DATADESC();
  298. public:
  299. SpawnPointCoopEnemy();
  300. void Spawn( void );
  301. void Precache( void );
  302. const char *GetWeaponsToGive( void ) { return STRING( m_szWeaponsToGive ); }
  303. const char *GetPlayerModelToUse( void ) { return STRING( m_szPlayerModelToUse ); }
  304. int GetArmorToSpawnWith( void ) { return m_nArmorToSpawnWith; }
  305. bool ShouldStartAsleep( void ) { return m_bStartAsleep; }
  306. int GetBotDifficulty( void ) { return m_nBotDifficulty; }
  307. bool IsBotAgressive( void ) { return m_bIsAgressive; }
  308. CNavArea *FindNearestArea( void );
  309. float HideRadius() const { return m_flHideRadius; }
  310. void HideRadius(bool val) { m_flHideRadius = val; }
  311. enum BotDefaultBehavior_t
  312. {
  313. DEFEND_AREA = 0,
  314. HUNT,
  315. CHARGE_ENEMY,
  316. DEFEND_INVESTIGATE,
  317. };
  318. BotDefaultBehavior_t GetDefaultBehavior() const { return m_nDefaultBehavior; }
  319. void SetDefaultBehavior( BotDefaultBehavior_t val ) { m_nDefaultBehavior = val; }
  320. protected:
  321. string_t m_szWeaponsToGive;
  322. string_t m_szPlayerModelToUse;
  323. int m_nArmorToSpawnWith;
  324. BotDefaultBehavior_t m_nDefaultBehavior;
  325. int m_nBotDifficulty;
  326. bool m_bIsAgressive;
  327. bool m_bStartAsleep;
  328. float m_flHideRadius;
  329. CNavArea *m_pMyArea;
  330. };
  331. #endif //!CLIENT_DLL
  332. class CCSGameRulesProxy : public CGameRulesProxy
  333. {
  334. public:
  335. DECLARE_CLASS( CCSGameRulesProxy, CGameRulesProxy );
  336. DECLARE_NETWORKCLASS();
  337. };
  338. class CCSGameRules : public CTeamplayRules
  339. {
  340. public:
  341. DECLARE_CLASS( CCSGameRules, CTeamplayRules );
  342. // Stuff that is shared between client and server.
  343. bool IsFreezePeriod();
  344. bool IsWarmupPeriod() const;
  345. float GetWarmupPeriodEndTime() const;
  346. bool IsWarmupPeriodPaused();
  347. void SetWarmupPeriodStartTime( float fl ) { m_fWarmupPeriodStart = fl; }
  348. float GetWarmupPeriodStartTime( void ) { return m_fWarmupPeriodStart; }
  349. bool AllowTaunts( void );
  350. bool IsTimeOutActive() const { return ( IsTerroristTimeOutActive() || IsCTTimeOutActive() ); }
  351. bool IsTerroristTimeOutActive() const { return m_bTerroristTimeOutActive; }
  352. bool IsCTTimeOutActive() const { return m_bCTTimeOutActive; }
  353. void StartTerroristTimeOut( void );
  354. void StartCTTimeOut( void );
  355. void EndTerroristTimeOut( void );
  356. void EndCTTimeOut( void );
  357. float GetCTTimeOutRemaining() const { return m_flCTTimeOutRemaining; }
  358. float GetTerroristTimeOutRemaining() const { return m_flTerroristTimeOutRemaining; }
  359. int GetCTTimeOuts( ) const { return m_nCTTimeOuts; }
  360. int GetTerroristTimeOuts( ) const { return m_nTerroristTimeOuts; }
  361. #ifdef CLIENT_DLL
  362. virtual bool AllowThirdPersonCamera();
  363. bool IsGoodDownTime( void ); // this returns true when its a good time to do things like garbage collection
  364. bool IsLoadoutAllowed( void );
  365. void MarkClientStopRecordAtRoundEnd( bool bStop );
  366. #endif
  367. #ifndef CLIENT_DLL
  368. void StartWarmup( void );
  369. void EndWarmup( void );
  370. virtual bool IsTeamChangeSilent( CBasePlayer *pPlayer, int iTeamNum, bool bAutoTeam, bool bSilent ) { return bSilent || m_bForceTeamChangeSilent; }
  371. void CheckForGiftsLeaderboardUpdate();
  372. #endif
  373. bool IsConnectedUserInfoChangeAllowed( CBasePlayer *pPlayer );
  374. virtual bool ShouldCollide( int collisionGroup0, int collisionGroup1 );
  375. virtual float GetRoundRestartTime( void ) { return m_flRestartRoundTime; }
  376. virtual bool IsGameRestarting( void ) { return m_bGameRestart; }
  377. float GetMapRemainingTime(); // time till end of map, -1 if timelimit is disabled
  378. float GetMapElapsedTime(); // How much time has elapsed since the map started.
  379. float GetRoundRemainingTime() const; // time till end of round
  380. float GetRoundStartTime(); // When this round started.
  381. float GetRoundElapsedTime(); // How much time has elapsed since the round started.
  382. float GetBuyTimeLength();
  383. int GetRoundLength() const { return m_iRoundTime; }
  384. int SelectDefaultTeam( bool ignoreBots = false );
  385. int GetHumanTeam(); // TEAM_UNASSIGNED if no restrictions
  386. void CalculateMaxGunGameProgressiveWeaponIndex( void );
  387. int GetMaxGunGameProgressiveWeaponIndex( void ) { return m_iMaxGunGameProgressiveWeaponIndex; }
  388. AcquireResult::Type IsWeaponAllowed( const CCSWeaponInfo *pWeaponInfo, int nTeamNumber ,CEconItemView *pItem = NULL );
  389. bool IsBombDefuseMap() const;
  390. bool IsHostageRescueMap() const;
  391. bool MapHasBuyZone() const;
  392. bool CanSpendMoneyInMap();
  393. bool IsIntermission() const;
  394. bool IsLogoMap() const;
  395. bool IsSpawnPointValid( CBaseEntity *pSpot, CBasePlayer *pPlayer );
  396. bool IsSpawnPointHiddenFromOtherPlayers( CBaseEntity *pSpot, CBasePlayer *pPlayer, int nHideFromTeam = 0 );
  397. bool IsBuyTimeElapsed();
  398. bool IsMatchWaitingForResume( void );
  399. void SetMatchWaitingForResume( bool pause ) { m_bMatchWaitingForResume = pause; };
  400. virtual int DefaultFOV();
  401. // Get the view vectors for this mod.
  402. virtual const CViewVectors* GetViewVectors() const;
  403. bool IsCSGOBirthday( void );
  404. int GetStartMoney( void );
  405. int GetMaxMoney( void );
  406. int GetBetweenRoundMoney( void );
  407. bool PlayerCashAwardsEnabled( void );
  408. bool TeamCashAwardsEnabled( void );
  409. void AddHostageRescueTime( void );
  410. bool IsPlayingCustomGametype( void ) const;
  411. bool IsPlayingGunGameProgressive( void ) const;
  412. bool IsPlayingGunGameDeathmatch( void ) const;
  413. bool IsPlayingGunGameTRBomb( void ) const;
  414. bool IsPlayingGunGame( void ) const;
  415. bool IsPlayingClassic( void ) const;
  416. bool IsPlayingOffline( void ) const;
  417. bool IsPlayingTraining( void ) const;
  418. bool IsPlayingCooperativeGametype( void ) const;
  419. bool IsPlayingClassicCasual( void ) const;
  420. bool IsPlayingAnyCompetitiveStrictRuleset( void ) const;
  421. bool IsPlayingCoopGuardian( void ) const;
  422. bool IsPlayingCoopMission( void ) const;
  423. bool IsQueuedMatchmaking( void ) const;
  424. bool IsValveDS( void ) const;
  425. bool IsQuestEligible( void ) const;
  426. bool ShouldRecordMatchStats( void ) const;
  427. virtual bool IgnorePlayerKillCommand( void ) const { return IsQueuedMatchmaking() && !IsWarmupPeriod(); }
  428. bool IsAwardsProgressAllowedForBotDifficulty() const; // returns false if the user is playing offline with trivial bots (no bots, harmless bots)
  429. bool IsTeammateSolid( void ) const; // returns true if teammates are solid obstacles in the current game mode
  430. bool IsArmorFree( void ) const;
  431. bool HasHalfTime( void ) const;
  432. bool IsRoundOver() const;
  433. int GetCustomBotDifficulty( void ) const;
  434. int GetCurrentGunGameWeapon ( int nCurrentWeaponIndex, int nTeamID );
  435. int GetNextGunGameWeapon( int nCurrentWeaponIndex, int nTeamID );
  436. int GetPreviousGunGameWeapon( int nCurrentWeaponIndex, int nTeamID );
  437. bool IsFinalGunGameProgressiveWeapon( int nCurrentWeaponIndex, int nTeamID );
  438. int GetGunGameNumKillsRequiredForWeapon( int nCurrentWeaponIndex, int nTeamID );
  439. void AddGunGameWeapon( const char* pWeaponName, int nNumKillsToUpgrade, int nTeamID );
  440. int GetNumProgressiveGunGameWeapons( int nTeamID ) const;
  441. int GetProgressiveGunGameWeapon( int nWeaponIndex, int nTeamID ) const { return nTeamID == TEAM_CT ? m_GGProgressiveWeaponOrderCT[nWeaponIndex] : m_GGProgressiveWeaponOrderT[nWeaponIndex]; }
  442. int GetProgressiveGunGameWeaponKillRequirement( int nWeaponIndex, int nTeamID ) const { return nTeamID == TEAM_CT ? m_GGProgressiveWeaponKillUpgradeOrderCT[nWeaponIndex] : m_GGProgressiveWeaponKillUpgradeOrderT[nWeaponIndex]; }
  443. int GetGunGameTRBonusGrenade( CCSPlayer *pPlayer );
  444. void IncrementGunGameTerroristWeapons( void );
  445. void IncrementGunGameCTWeapons( void );
  446. bool IsBotOnlyTeam( int nTeamNumber );
  447. int TeamCashAwardValue( TeamCashAward::Type reason);
  448. int PlayerCashAwardValue( PlayerCashAward::Type reason);
  449. int GetMaxSpectatorSlots( void ) const;
  450. float GetTimeUntilNextPhaseStarts( void ) { return m_timeUntilNextPhaseStarts; }
  451. GamePhase GetGamePhase( void ) const { return ( GamePhase ) m_gamePhase.Get(); }
  452. int GetTotalRoundsPlayed( void ) const { return m_totalRoundsPlayed; }
  453. int GetOvertimePlaying( void ) const { return m_nOvertimePlaying; }
  454. int GetNumWinsToClinch( void ) const;
  455. bool IsLastRoundOfMatch() const;
  456. bool IsMatchPoint() const;
  457. // AreTeamsPlayingSwitchedSides() -- will return true when match is in second half, or in the half of overtime period where teams are switched.
  458. // Overtime logic is as follows: TeamA plays CTs as first half of regulation, then Ts as second half of regulation,
  459. // then if tied in regulation continues to play Ts as first half of 1st overtime, then switches to CTs for second half of 1st overtime,
  460. // then if still tied after 1st OT they continue to play CTs as first half of 2nd overtime, then switch to Ts for second half of 2nd overtime,
  461. // then if still tied after 2nd OT they continue to play Ts as first half of 3rd overtime, then switch to CTs for second half of 3rd overtime,
  462. // and so on until the match determines a winner.
  463. // So AreTeamsPlayingSwitchedSides will return true when TeamA is playing T-side and will return false when TeamA plays CT-side as they started match on CT
  464. // in scenario outlined above.
  465. bool AreTeamsPlayingSwitchedSides() const;
  466. void SetIsWarmupPeriod( bool bIsWarmup ) { m_bWarmupPeriod = bIsWarmup; }
  467. bool HasMatchStarted() { return m_bHasMatchStarted; }
  468. int GetWeaponScoreForDeathmatch( int nPos );
  469. float GetRestartRoundTime( void ) const;
  470. #if !defined( CLIENT_DLL )
  471. int GetCoopWaveNumber( void ) { return m_nGuardianModeWaveNumber; }
  472. CGameCoopMissionManager *GetCoopMissionManager( void );
  473. EHANDLE m_coopMissionManager;
  474. void SetCoopMissionManager( CBaseEntity *pPoint ) { m_coopMissionManager = pPoint; }
  475. void CoopSetBotQuotaAndRefreshSpawns( int nMaxEnemiesToSpawn );
  476. void CoopMissionSetNextRespawnIn( float flSeconds, bool bIncrementWaveNumber );
  477. void CoopMissionSpawnFirstEnemies( int nMaxEnemiesToSpawn );
  478. void CoopMissionSpawnNextWave( int nMaxEnemiesToSpawn );
  479. void CoopMissionRespawnDeadPlayers( void );
  480. void CoopCollectBonusCoin( void );
  481. virtual bool OnReplayPrompt( CBasePlayer *pVictim, CBasePlayer *pScorer ) OVERRIDE;
  482. #endif
  483. int GetGuardianRequiredKills( void ) const;
  484. int GetGuardianKillsRemaining( void ) const;
  485. int GetGuardianSpecialWeapon( void ) const;
  486. private:
  487. float GetExplosionDamageAdjustment(Vector & vecSrc, Vector & vecEnd, CBaseEntity *pEntityToIgnore); // returns multiplier between 0.0 and 1.0 that is the percentage of any damage done from vecSrc to vecEnd that actually makes it.
  488. float GetAmountOfEntityVisible(Vector & src, CBaseEntity *player); // returns a value from 0 to 1 that is the percentage of player visible from src.
  489. CNetworkVar( bool, m_bFreezePeriod ); // TRUE at beginning of round, set to FALSE when the period expires
  490. CNetworkVar( bool, m_bWarmupPeriod ); //
  491. CNetworkVar( float, m_fWarmupPeriodEnd ); // OBSOLETE. LEFT IN FOR DEMO COMPATIBILITY.
  492. CNetworkVar( float, m_fWarmupPeriodStart );
  493. CNetworkVar( bool, m_bTerroristTimeOutActive );
  494. CNetworkVar( bool, m_bCTTimeOutActive );
  495. CNetworkVar( float, m_flTerroristTimeOutRemaining );
  496. CNetworkVar( float, m_flCTTimeOutRemaining );
  497. CNetworkVar( int, m_nTerroristTimeOuts );
  498. CNetworkVar( int, m_nCTTimeOuts );
  499. CNetworkVar( bool, m_bMatchWaitingForResume ); // When mp_pause_match is called, this state becomes true and will prevent the next freezetime from ending.
  500. CNetworkVar( int, m_iRoundTime ); // (From mp_roundtime) - How many seconds long this round is.
  501. CNetworkVar( float, m_fMatchStartTime ); // time when match has started
  502. CNetworkVar( float, m_fRoundStartTime ); // time round has started
  503. CNetworkVar( float, m_flRestartRoundTime ); // the global time when the round is supposed to end, if this is not 0
  504. CNetworkVar( bool, m_bGameRestart ); // True = mp_restartgame is being processed
  505. CNetworkVar( float, m_flGameStartTime );
  506. CNetworkVar( float, m_timeUntilNextPhaseStarts );
  507. CNetworkVar( int, m_gamePhase );
  508. CNetworkVar( int, m_totalRoundsPlayed);
  509. CNetworkVar( int, m_nOvertimePlaying);
  510. CNetworkVar( int, m_iHostagesRemaining );
  511. CNetworkVar( bool, m_bAnyHostageReached );
  512. CNetworkVar( bool, m_bMapHasBombTarget );
  513. CNetworkVar( bool, m_bMapHasRescueZone );
  514. CNetworkVar( bool, m_bMapHasBuyZone );
  515. CNetworkVar( bool, m_bIsQueuedMatchmaking );
  516. CNetworkVar( bool, m_bIsValveDS );
  517. CNetworkVar( bool, m_bLogoMap ); // If there's an info_player_logo entity, then it's a logo map.
  518. CNetworkVar( int, m_iNumGunGameProgressiveWeaponsCT ); // total number of CT gun game progressive weapons
  519. CNetworkVar( int, m_iNumGunGameProgressiveWeaponsT ); // total number of T gun game progressive weapons
  520. CNetworkVar( int, m_iSpectatorSlotCount ); // max spectator slots available
  521. CNetworkArray( int, m_GGProgressiveWeaponOrderCT, 60 ); // CT gun game weapon order and # kills per weapon. Size is meant to be larger than the current number of different weapons defined in the CSWeaponID enum
  522. CNetworkArray( int, m_GGProgressiveWeaponOrderT, 60 ); // T gun game weapon order and # kills per weapon. Size is meant to be larger than the current number of different weapons defined in the CSWeaponID enum
  523. CNetworkArray( int, m_GGProgressiveWeaponKillUpgradeOrderCT, 60 ); // CT gun game number of kills per weapon. Size is meant to be larger than the current number of different weapons defined in the CSWeaponID enum
  524. CNetworkArray( int, m_GGProgressiveWeaponKillUpgradeOrderT, 60 ); // T gun game number of kills per weapon. Size is meant to be larger than the current number of different weapons defined in the CSWeaponID enum
  525. CNetworkVar( int, m_MatchDevice );
  526. CNetworkVar( bool, m_bHasMatchStarted );
  527. CNetworkVar( float, m_flDMBonusStartTime );
  528. CNetworkVar( float, m_flDMBonusTimeLength );
  529. CNetworkVar( uint16, m_unDMBonusWeaponLoadoutSlot );
  530. CNetworkVar( bool, m_bDMBonusActive );
  531. CNetworkVar( int, m_nNextMapInMapgroup );
  532. CNetworkString( m_szTournamentEventName, MAX_PATH );
  533. CNetworkString( m_szTournamentEventStage, MAX_PATH );
  534. CNetworkString( m_szMatchStatTxt, MAX_PATH );
  535. CNetworkString( m_szTournamentPredictionsTxt, MAX_PATH );
  536. CNetworkVar( int, m_nTournamentPredictionsPct );
  537. CNetworkVar( float, m_flCMMItemDropRevealStartTime );
  538. CNetworkVar( float, m_flCMMItemDropRevealEndTime );
  539. CNetworkVar( bool, m_bIsDroppingItems ); //
  540. CNetworkVar( bool, m_bIsQuestEligible );
  541. CNetworkVar( int, m_nGuardianModeWaveNumber );
  542. CNetworkVar( int, m_nGuardianModeSpecialKillsRemaining );
  543. CNetworkVar( int, m_nGuardianModeSpecialWeaponNeeded );
  544. int m_nGuardianGrenadesToGiveBots;
  545. public:
  546. // HACK: Low on time, don't have a better place for this. Hang some global data guardian needs to bookkeep heavy spawns.
  547. int m_nNumHeaviesToSpawn;
  548. //
  549. // Holiday gifts global presence
  550. //
  551. CNetworkVar( uint32, m_numGlobalGiftsGiven );
  552. CNetworkVar( uint32, m_numGlobalGifters );
  553. CNetworkVar( uint32, m_numGlobalGiftsPeriodSeconds );
  554. CNetworkArray( uint32, m_arrFeaturedGiftersAccounts, MAX_GIFT_GIVERS_FEATURED_COUNT );
  555. CNetworkArray( uint32, m_arrFeaturedGiftersGifts, MAX_GIFT_GIVERS_FEATURED_COUNT );
  556. #define MAX_PROHIBITED_ITEMS 100
  557. CNetworkArray( uint16, m_arrProhibitedItemIndices, MAX_PROHIBITED_ITEMS );
  558. //
  559. // Tournament Casters
  560. //
  561. CNetworkArray( uint32, m_arrTournamentActiveCasterAccounts, MAX_TOURNAMENT_ACTIVE_CASTER_COUNT );
  562. // These three are part of a hack to move an expensive network call (ClientPrint) out of
  563. // the death code and defer it by a short time. The level of network traffic is causing hitches on ps3.
  564. // CCallQueue m_DeferredCallQueue;
  565. // float m_flDeferredCallDispatchTime;
  566. // Tournament best-of-N
  567. CNetworkVar( int, m_numBestOfMaps );
  568. // halloween mask seed
  569. CNetworkVar( int, m_nHalloweenMaskListSeed );
  570. CNetworkVar( bool, m_bBombDropped );
  571. CNetworkVar( bool, m_bBombPlanted );
  572. CNetworkVar( int, m_iRoundWinStatus ); // 1 == CT's won last round, 2 == Terrorists did, 3 == Draw, no winner
  573. CNetworkVar( int, m_eRoundWinReason ); // see: e_RoundEndReason
  574. CNetworkVar( bool, m_bTCantBuy ); // Who can and can't buy.
  575. CNetworkVar( bool, m_bCTCantBuy );
  576. CNetworkVar( float, m_flGuardianBuyUntilTime );
  577. CNetworkArray( int, m_iMatchStats_RoundResults, MAX_MATCH_STATS_ROUNDS );
  578. CNetworkArray( int, m_iMatchStats_PlayersAlive_CT, MAX_MATCH_STATS_ROUNDS );
  579. CNetworkArray( int, m_iMatchStats_PlayersAlive_T, MAX_MATCH_STATS_ROUNDS );
  580. CNetworkArray( float, m_TeamRespawnWaveTimes, MAX_TEAMS ); // Time between each team's respawn wave
  581. CEconQuestDefinition* GetActiveAssassinationQuest( void ) const;
  582. int GetActiveServerQuestID( void ) const { return m_iActiveAssassinationTargetMissionID; }
  583. protected:
  584. CNetworkArray( float, m_flNextRespawnWave, MAX_TEAMS ); // Minor waste, but cleaner code
  585. CNetworkVar( int, m_iActiveAssassinationTargetMissionID ); // we cannot change the name of this field for networking compatibility, but in coopgametypes this means the server questid
  586. bool m_bDontIncrementCoopWave;
  587. public:
  588. float GetCMMItemDropRevealDuration();
  589. float GetCMMItemDropRevealEndTime() { return m_flCMMItemDropRevealEndTime; }
  590. bool IsDroppingItems() { return m_bIsDroppingItems; }
  591. loadout_positions_t GetDMBonusWeaponLoadoutSlot( void ) { return ( loadout_positions_t )m_unDMBonusWeaponLoadoutSlot.Get(); }
  592. float GetDMBonusStartTime( void ) { return m_flDMBonusStartTime; }
  593. float GetDMBonusTimeLength( void ) { return m_flDMBonusTimeLength; }
  594. bool IsDMBonusActive( void ) { return m_bDMBonusActive; }
  595. void SetNextMapInMapGroup( int nIndex ) { m_nNextMapInMapgroup = nIndex; }
  596. int GetNextMapInMapGroup( void ) { return m_nNextMapInMapgroup; }
  597. #if defined( GAME_DLL )
  598. bool CheckGotGuardianModeSpecialKill( CWeaponCSBase* pAttackerWeapon );
  599. #endif
  600. int GetNumHostagesRemaining( void ) { return m_iHostagesRemaining; }
  601. virtual CBaseCombatWeapon *GetNextBestWeapon( CBaseCombatCharacter *pPlayer, CBaseCombatWeapon *pCurrentWeapon );
  602. virtual const unsigned char *GetEncryptionKey( void ) { return (unsigned char *)"d7NSuLq2"; } // both the client and server need this key
  603. void CreateFriendlyMapNameToken( const char* szShortName, char* szOutBuffer, int nBuffSize );
  604. // This is unlocalized and shouldn't be used for display
  605. const char *GetDefaultTeamName( int nTeam );
  606. void OpenBuyMenu( int nPlayerIndex );
  607. void CloseBuyMenu( int nPlayerIndex );
  608. // respawn
  609. void SetNextTeamRespawnWaveDelay( int iTeam, float flDelay );
  610. virtual float GetNextRespawnWave( int iTeam, CBasePlayer *pPlayer );
  611. float GetMinTimeWhenPlayerMaySpawn( CBasePlayer *pPlayer );
  612. float GetRespawnWaveMaxLength( int iTeam, bool bScaleWithNumPlayers = true );
  613. float GetRespawnTimeScalar( int iTeam );
  614. //float GetTimeUntilEndMatchNextMapVoteEnds( void );
  615. bool IsEndMatchVotingForNextMap();
  616. bool IsEndMatchVotingForNextMapEnabled();
  617. // End Match Voting
  618. CNetworkArray( int, m_nEndMatchMapGroupVoteOptions, MAX_ENDMATCH_VOTE_PANELS ); // For mapgroups >10 maps these will be vote options
  619. // these functions cover recording and sending item drops for display in game modes where you don't allow drops during the match/round
  620. CUtlVector< CEconItemPreviewDataBlock * > m_ItemsPtrDroppedDuringMatch;
  621. const CUtlVector< CEconItemPreviewDataBlock * >& GetItemsDroppedDuringMatch( void ) const
  622. {
  623. return m_ItemsPtrDroppedDuringMatch;
  624. }
  625. void ClearItemsDroppedDuringMatch( void );
  626. void RecordPlayerItemDrop( const CEconItemPreviewDataBlock &iteminfo );
  627. static int GetMaxPlayers(); // always available
  628. // COOP
  629. void CoopResetRoundStartTime( void );
  630. void CoopGiveC4sToCTs( int nC4sToGive );
  631. #ifndef CLIENT_DLL
  632. int m_coopBonusCoinsFound;
  633. bool m_coopBonusPistolsOnly;
  634. bool m_coopPlayersInDeploymentZone;
  635. #endif
  636. #ifdef CLIENT_DLL
  637. DECLARE_CLIENTCLASS_NOBASE(); // This makes datatables able to access our private vars.
  638. CCSGameRules();
  639. ~CCSGameRules();
  640. // helper function - this will eventually support side car info (and will probably move)
  641. const wchar_t* GetFriendlyMapName( const char* szShortName );
  642. bool GetFriendlyMapNameToken( const char* szShortName, char* szOutBuffer, int nBuffSize );
  643. char const * GetTournamentEventName() const;
  644. char const * GetTournamentEventStage() const;
  645. char const * GetTournamentPredictionsTxt() const { return m_szTournamentPredictionsTxt; }
  646. int GetTournamentPredictionsPct() const { return m_nTournamentPredictionsPct; }
  647. char const * GetMatchStatTeamsTxt() const { return m_szMatchStatTxt; }
  648. CUserMessageBinder m_UMCMsgSendPlayerItemDrops;
  649. CUserMessageBinder m_UMCMsgSendPlayerItemFound;
  650. bool m_bMarkClientStopRecordAtRoundEnd;
  651. static void RecvProxy_TournamentActiveCasterAccounts( const CRecvProxyData *pData, void *pStruct, void *pOut );
  652. void ResetCasterConvars( void );
  653. #else
  654. DECLARE_SERVERCLASS_NOBASE(); // This makes datatables able to access our private vars.
  655. CCSGameRules();
  656. virtual ~CCSGameRules();
  657. virtual void RefreshSkillData( bool forceUpdate );
  658. void DumpTimers( void ) const; // debugging to help track down a stuck server (rare?)
  659. CBaseEntity *GetPlayerSpawnSpot( CBasePlayer *pPlayer );
  660. static void EndRound();
  661. virtual void PlayerKilled( CBasePlayer *pVictim, const CTakeDamageInfo &info );
  662. virtual void Think();
  663. void SwitchTeamsAtRoundReset( void );
  664. void ClearGunGameData( void );
  665. void FreezePlayers( void );
  666. // Called at the end of GameFrame (i.e. after all game logic has run this frame)
  667. virtual void EndGameFrame( void );
  668. // Called when game rules are destroyed by CWorld
  669. virtual void LevelShutdown( void );
  670. void UpdateTeamClanNames( int nTeam );
  671. void UpdateTeamPredictions();
  672. // vscript function
  673. void SetPlayerCompletedTraining( bool bCompleted );
  674. bool GetPlayerCompletedTraining( void );
  675. void SetBestTrainingCourseTime( int nTime );
  676. int GetBestTrainingCourseTime( void );
  677. int GetValveTrainingCourseTime( void );
  678. bool IsLocalPlayerUsingController( void );
  679. void TrainingGivePlayerAmmo( void );
  680. void TrainingSetRadarHidden( bool bHide );
  681. void TrainingSetMiniScoreHidden( bool bHide );
  682. void TrainingHighlightAmmoCounter( void );
  683. void TrainingShowFinishMsgBox( void );
  684. void TrainingShowExitDoorMsg( void );
  685. virtual void RegisterScriptFunctions( void );
  686. virtual bool ClientCommand( CBaseEntity *pEdict, const CCommand &args );
  687. virtual void PlayerSpawn( CBasePlayer *pPlayer );
  688. void ShowSpawnPoints( int duration );
  689. virtual void SpawningLatePlayer( CCSPlayer* pLatePlayer );
  690. bool IsPistolRound( void );
  691. void HostageKilled( void ) { m_hostageWasKilled = true; }
  692. void HostageInjured( void ) { m_hostageWasInjured = true; }
  693. bool WasHostageKilled( void ) { return m_hostageWasKilled; }
  694. bool WasHostageInjured( void ) { return m_hostageWasInjured; }
  695. void PlayerTookDamage( CCSPlayer* player, const CTakeDamageInfo &damageInfo );
  696. void SendKickBanToGC( CCSPlayer *pPlayer, EMsgGCCStrike15_v2_MatchmakingKickBanReason_t eReason );
  697. void SendKickBanToGCforAccountId( uint32 uiAccountId, EMsgGCCStrike15_v2_MatchmakingKickBanReason_t eReason );
  698. virtual bool PlayTextureSounds( void ) { return true; }
  699. // Let the game rules specify if fall death should fade screen to black
  700. virtual bool FlPlayerFallDeathDoesScreenFade( CBasePlayer *pl ) { return FALSE; }
  701. virtual void RadiusDamage( const CTakeDamageInfo &info, const Vector &vecSrcIn, float flRadius, int iClassIgnore, CBaseEntity *pEntityIgnore );
  702. void RadiusDamage( const CTakeDamageInfo &info, const Vector &vecSrcIn, float flRadius, int iClassIgnore, bool bIgnoreWorld );
  703. virtual void UpdateClientData( CBasePlayer *pl );
  704. virtual CCSPlayer* CheckAndAwardAssists( CCSPlayer* pCSVictim, CCSPlayer* pKiller );
  705. // Death notices
  706. virtual void DeathNotice( CBasePlayer *pVictim, const CTakeDamageInfo &info );
  707. IGameEvent * CreateWeaponKillGameEvent( char const *szEventName, const CTakeDamageInfo &info );
  708. virtual void InitDefaultAIRelationships( void );
  709. virtual const char *GetGameDescription( void ) { return "Counter-Strike: Global Offensive"; } // this is the game name that gets seen in the server browser
  710. virtual const char *AIClassText(int classType);
  711. virtual bool FShouldSwitchWeapon( CBasePlayer *pPlayer, CBaseCombatWeapon *pWeapon );
  712. virtual const char *SetDefaultPlayerTeam( CBasePlayer *pPlayer );
  713. // Called before entities are created
  714. virtual void LevelInitPreEntity();
  715. // Called after the map has finished loading.
  716. virtual void LevelInitPostEntity();
  717. virtual float FlPlayerFallDamage( CBasePlayer *pPlayer );
  718. virtual bool ClientConnected( edict_t *pEntity, const char *pszName, const char *pszAddress, char *reject, int maxrejectlen );
  719. virtual void ClientDisconnected( edict_t *pClient );
  720. virtual void ClientCommandKeyValues( edict_t *pEntity, KeyValues *pKeyValues );
  721. virtual int GetMaxHumanPlayers() const;
  722. // Recreate all the map entities from the map data (preserving their indices),
  723. // then remove everything else except the players.
  724. // Also get rid of all world decals.
  725. void CleanUpMap();
  726. void CheckFreezePeriodExpired();
  727. void CheckRoundTimeExpired();
  728. // check if the scenario has been won/lost
  729. // return true if the scenario is over, false if the scenario is still in progress
  730. bool CheckWinConditions( void );
  731. // this is used by entities like X and increments the round and ends it
  732. void IncrementAndTerminateRound( float tmDelay, int reason );
  733. void TerminateRound( float tmDelay, int reason );
  734. void ProcessEndOfRoundAchievements( int iWinnerTeam, int iReason );
  735. void SaveRoundDataInformation( char const *szFilenameOverride = NULL );
  736. void LoadRoundDataInformation( char const *szFilename );
  737. void ResetMasterSpawnPointsForCoop( void );
  738. // The following round-related functions are called as follows:
  739. //
  740. // At Match Start:
  741. // PreRestartRound() -> RestartRound() -> PostRestartRound()
  742. //
  743. // During Subsequent Round Gameplay:
  744. // RoundWin() is called at the point when the winner of the round has been determined - prior to free-play commencing
  745. // PreRestartRound() is called with 1 second remaining prior to the round officially ending (This is after a round
  746. // winner has been chosen and players are allowed to continue playing)
  747. // RoundEnd() is then called when the round has completely ended
  748. // RestartRound() is then called immediately after RoundEnd()
  749. // PostRestartRound() is called immediately after RestartRound() has completed
  750. void PreRestartRound( void );
  751. void RestartRound( void );
  752. void PostRestartRound( void );
  753. void RoundWin( void );
  754. void RoundEnd( void );
  755. int GetRoundsPlayed( void ) const { return m_match.GetRoundsPlayed(); }
  756. void BalanceTeams( void );
  757. void HandleScrambleTeams( void );
  758. void HandleSwapTeams( void );
  759. void MoveHumansToHumanTeam( void );
  760. bool TeamFull( int team_id );
  761. int MaxNumPlayersOnTerrTeam();
  762. int MaxNumPlayersOnCTTeam();
  763. bool WillTeamHaveRoomForPlayer( CCSPlayer* pPlayer, int newTeam );
  764. bool TeamStacked( int newTeam_id, int curTeam_id );
  765. bool FPlayerCanRespawn( CBasePlayer *pPlayer );
  766. void UpdateTeamScores();
  767. void CheckMapConditions();
  768. void MarkLivingPlayersOnTeamAsNotReceivingMoneyNextRound(int team);
  769. // Check various conditions to end the map.
  770. bool CheckGameOver();
  771. bool CheckWinLimit();
  772. bool CheckFragLimit();
  773. void CheckLevelInitialized();
  774. void CheckRestartRound();
  775. virtual bool FPlayerCanTakeDamage( CBasePlayer *pPlayer, CBaseEntity *pAttacker );
  776. virtual int IPointsForKill( CBasePlayer *pAttacker, CBasePlayer *pKilled );
  777. bool CanPlayerHearTalker( CBasePlayer* pListener, CBasePlayer *pSpeaker, bool bTeamOnly );
  778. virtual int PlayerRelationship( CBaseEntity *pPlayer, CBaseEntity *pTarget );
  779. virtual bool PlayerCanHearChat( CBasePlayer *pListener, CBasePlayer *pSpeaker, bool bTeamOnly );
  780. void GuardianUpdateBotAccountAndWeapons( CCSPlayer *pBot );
  781. void GiveGuardianBotGrenades( CCSPlayer *pBot );
  782. // repsawning
  783. void SetTeamRespawnWaveTime( int iTeam, float flValue );
  784. virtual bool HasPassedMinRespawnTime( CBasePlayer *pPlayer );
  785. void CheckRespawnWaves( void );
  786. // Checks if it still needs players to start a round, or if it has enough players to start rounds.
  787. // Starts a round and returns true if there are enough players.
  788. bool NeededPlayersCheck( bool &bNeededPlayers );
  789. // Setup counts for m_iNumTerrorist, m_iNumCT, m_iNumSpawnableTerrorist, m_iNumSpawnableCT, etc.
  790. void InitializePlayerCounts(
  791. int &NumAliveTerrorist,
  792. int &NumAliveCT,
  793. int &NumDeadTerrorist,
  794. int &NumDeadCT
  795. );
  796. // Check to see if the round is over for the various game types. Terminates the round
  797. // and returns true if the round should end.
  798. bool PrisonRoundEndCheck();
  799. bool BombRoundEndCheck( bool bNeededPlayers );
  800. bool HostageRescueRoundEndCheck( bool bNeededPlayers );
  801. bool BombPlantedRoundEndCheck();
  802. bool CTsReachedHostageRoundEndCheck();
  803. bool GuardianAllKillsAchievedCheck();
  804. bool m_bHasHostageBeenTouched;
  805. CCSPlayer* CalculateEndOfRoundMVP();
  806. // Check to see if the teams exterminated each other. Ends the round and returns true if so.
  807. bool TeamExterminationCheck(
  808. int NumAliveTerrorist,
  809. int NumAliveCT,
  810. int NumDeadTerrorist,
  811. int NumDeadCT,
  812. bool bNeededPlayers
  813. );
  814. void ReadMultiplayCvars();
  815. void SwapAllPlayers();
  816. void OnTeamsSwappedAtRoundReset();
  817. void ResetForTradeshow( void ); // reset player scores, reset team scores, reset player controls, restart round; used for demos
  818. void BroadcastSound( const char *sound, int team = -1 );
  819. // GUN GAME PROGRESSIVE FUNCTION
  820. bool GunGameProgressiveEndCheck( void );
  821. // BOMB MAP FUNCTIONS
  822. void GiveC4ToRandomPlayer();
  823. void GiveDefuserToRandomPlayer();
  824. CCSPlayer *IsThereABomber();
  825. bool IsThereABomb();
  826. // HOSTAGE MAP FUNCTIONS
  827. void HostageTouched();
  828. // Contribution score helpers
  829. void ScorePlayerKill( CCSPlayer* pPlayer );
  830. void ScorePlayerAssist( CCSPlayer* pPlayer, CCSPlayer* pCSVictim );
  831. void ScorePlayerObjectiveKill( CCSPlayer* pPlayer );
  832. void ScorePlayerSuicide( CCSPlayer* pPlayer );
  833. void ScorePlayerTeamKill( CCSPlayer* pPlayer );
  834. void ScorePlayerDamage( CCSPlayer* pPlayer, float fDamage );
  835. void ScoreBombPlant( CCSPlayer* pPlayer );
  836. void ScoreBombExploded( CCSPlayer* pPlayer );
  837. void ScoreBombDefuse( CCSPlayer* pPlayer, bool bMajorEvent );
  838. void ScoreHostageRescue( CCSPlayer* pPlayer, CHostage* pHostage, bool bMajorEvent );
  839. void ScoreHostageKilled( CCSPlayer* pPlayer );
  840. void ScoreHostageDamage( CCSPlayer* pPlayer, float fDamage );
  841. void ScoreFriendlyFire( CCSPlayer* pPlayer, float fDamage );
  842. void ScoreBlindEnemy( CCSPlayer* pPlayer );
  843. void ScoreBlindFriendly( CCSPlayer* pPlayer );
  844. // Sets up g_pPlayerResource.
  845. virtual void CreateStandardEntities();
  846. virtual const char *GetChatPrefix( bool bTeamOnly, CBasePlayer *pPlayer );
  847. virtual const char *GetChatLocation( bool bTeamOnly, CBasePlayer *pPlayer );
  848. virtual const char *GetChatFormat( bool bTeamOnly, CBasePlayer *pPlayer );
  849. void ClientSettingsChanged( CBasePlayer *pPlayer );
  850. virtual bool CanClientCustomizeOwnIdentity() OVERRIDE;
  851. bool IsCareer( void ) const { return false; } // returns true if this is a CZ "career" game
  852. virtual bool FAllowNPCs( void );
  853. bool CheckSetVoteTime();
  854. void GoToMatchRestartIntermission();
  855. CCSMatch* GetMatch( void );
  856. // Let's the match store recplicated vars in the game rules.
  857. void SetGamePhase( GamePhase newPhase ) { m_gamePhase = newPhase; }
  858. void SetTotalRoundsPlayed( int roundsPlayed ) { m_totalRoundsPlayed = roundsPlayed; }
  859. void SetOvertimePlaying( int nOvertimePlaying ) { m_nOvertimePlaying = nOvertimePlaying; }
  860. void SetScrambleTeamsOnRestart( bool scramble ) { m_bScrambleTeamsOnRestart = scramble; }
  861. bool GetScrambleTeamsOnRestart( void ) { return m_bScrambleTeamsOnRestart; }
  862. void SetSwapTeamsOnRestart( bool swapTeams ) { m_bSwapTeamsOnRestart = swapTeams; }
  863. bool GetSwapTeamsOnRestart( void ) { return m_bSwapTeamsOnRestart; }
  864. bool GameModeSupportsHealthBuffer( void );
  865. protected:
  866. // these functions cover recording and sending item drops for display in game modes where you don't allow drops during the match/round
  867. void SendPlayerItemDropsToClient( void );
  868. bool m_bPlayerItemsHaveBeenDisplayed;
  869. void RewardMatchEndDrops( bool bAbortedMatch );
  870. virtual void GoToIntermission( bool bAbortedMatch = false );
  871. void UpdateMatchStats( CCSPlayer* pPlayer, int winnerIndex ) ;
  872. static void SplitScoreAmongPlayersInZone( int iPoints, int iTeam, CCSPlayer* pExcludePlayer, uint iPlace );
  873. static void SplitScoreAmongPlayersInRange( int iPoints, int iTeam, CCSPlayer* pExcludePlayer, const Vector& center, float fRangeInner, float fRangeOuter );
  874. void GotoTRBombModeHalftime( void );
  875. void EndTRBombModeHalftime( void );
  876. float CalculateAveragePlayerContributionScore( void );
  877. float CalculateAverageBotContributionScore( void );
  878. public:
  879. void ModifyRealtimeBotDifficulty( CCSPlayer* pOnlyBotToProcess = NULL );
  880. public:
  881. bool IsFriendlyFireOn() const;
  882. bool IsLastRoundBeforeHalfTime( void );
  883. virtual void SetAllowWeaponSwitch( bool allow );
  884. virtual bool GetAllowWeaponSwitch( void );
  885. bool ShouldGunGameSpawnBomb( void );
  886. void SetGunGameSpawnBomb( bool allow );
  887. bool IsClanTeam( CTeam *pTeam );
  888. //int GetEndMatchCurrentMapVotes();
  889. // VARIABLES FOR ALL TYPES OF MAPS
  890. bool m_bLevelInitialized;
  891. int m_iTotalRoundsPlayed;
  892. int m_iUnBalancedRounds; // keeps track of the # of consecutive rounds that have gone by where one team outnumbers the other team by more than 2
  893. bool m_endMatchOnRoundReset;
  894. bool m_endMatchOnThink;
  895. float m_flCoopRespawnAndHealTime;
  896. // GAME TIMES
  897. int m_iFreezeTime; // (From mp_freezetime) - How many seconds long the intro round (when players are frozen) is.
  898. int m_iNumTerrorist; // The number of terrorists on the team (this is generated at the end of a round)
  899. int m_iNumCT; // The number of CTs on the team (this is generated at the end of a round)
  900. int m_iNumSpawnableTerrorist;
  901. int m_iNumSpawnableCT;
  902. CUtlVector< int > m_arrSelectedHostageSpawnIndices; // The indices of hostage spawn locations selected for the match
  903. bool m_bFirstConnected;
  904. bool m_bCompleteReset; // Set to TRUE to have the scores reset next time round restarts
  905. bool m_bPickNewTeamsOnReset;
  906. bool m_bScrambleTeamsOnRestart;
  907. bool m_bSwapTeamsOnRestart;
  908. enum EEndMatchMapVoteState_t
  909. {
  910. k_EEndMatchMapVoteState_MatchInProgress,
  911. k_EEndMatchMapVoteState_VoteInProgress,
  912. k_EEndMatchMapVoteState_VoteTimeEnded,
  913. k_EEndMatchMapVoteState_AllPlayersVoted,
  914. k_EEndMatchMapVoteState_SelectingWinner,
  915. k_EEndMatchMapVoteState_SettingNextLevel,
  916. k_EEndMatchMapVoteState_VoteAllDone,
  917. };
  918. #ifndef CLIENT_DLL
  919. EEndMatchMapVoteState_t m_eEndMatchMapVoteState;
  920. int m_nEndMatchMapVoteWinner;
  921. CUtlVector<int> m_nEndMatchTiedVotes;
  922. void CreateEndMatchMapGroupVoteOptions( void );
  923. enum EQueuedMatchmakingRematchState_t
  924. {
  925. k_EQueuedMatchmakingRematchState_MatchInProgress,
  926. k_EQueuedMatchmakingRematchState_VoteStarting,
  927. k_EQueuedMatchmakingRematchState_VoteToRematchInProgress,
  928. k_EQueuedMatchmakingRematchState_VoteToRematchSucceeded,
  929. k_EQueuedMatchmakingRematchState_VoteToRematchFailed,
  930. k_EQueuedMatchmakingRematchState_VoteToRematchFailed_Done,
  931. k_EQueuedMatchmakingRematchState_VoteToRematch_Done,
  932. k_EQueuedMatchmakingRematchState_VoteToRematch_T_Surrender,
  933. k_EQueuedMatchmakingRematchState_VoteToRematch_CT_Surrender,
  934. k_EQueuedMatchmakingRematchState_VoteToRematch_Aborted,
  935. };
  936. EQueuedMatchmakingRematchState_t m_eQueuedMatchmakingRematchState;
  937. bool m_bNeedToAskPlayersForContinueVote;
  938. uint32 m_numQueuedMatchmakingAccounts;
  939. char *m_pQueuedMatchmakingReservationString;
  940. uint32 m_numTotalTournamentDrops;
  941. uint32 m_numSpectatorsCountMax;
  942. uint32 m_numSpectatorsCountMaxTV;
  943. uint32 m_numSpectatorsCountMaxLnk;
  944. CMsgGCCStrike15_v2_MatchmakingServerRoundStats *m_pQueuedMatchmakingReportedRoundStats;
  945. static CMsgGCCStrike15_v2_MatchmakingGC2ServerReserve sm_QueuedServerReservation;
  946. void ReportRoundEndStatsToGC( CMsgGCCStrike15_v2_MatchmakingServerRoundStats **ppAllocateStats = NULL );
  947. struct CQMMPlayerData_t
  948. {
  949. CQMMPlayerData_t()
  950. {
  951. Q_memset( this, 0, offsetof( CQMMPlayerData_t, m_uiCustomNonPodFields ) );
  952. }
  953. void Reset()
  954. { // Reset everything starting from m_numKills to the end
  955. Q_memset( ( ( char * ) this ) + offsetof( CQMMPlayerData_t, m_numKills ), 0,
  956. offsetof( CQMMPlayerData_t, m_uiCustomNonPodFields ) - offsetof( CQMMPlayerData_t, m_numKills ) );
  957. }
  958. uint32 m_uiPlayerAccountId; // QMM player account ID
  959. int m_iDraftIndex; // Index of the player in the draft [0-4: team 1; 5-9: team 2]
  960. uint32 m_msDisconnectionTimestamp; // Timestamp of player's disconnection if not 0
  961. uint32 m_uiAbandonRecordedReason; // We recorded the fact that the player abandoned the match and this is the reason
  962. bool m_bAbandonAllowsSurrender; // This player abandoning the match allows for his teammates to surrender
  963. char m_chPlayerName[128]; // Last known player name
  964. bool m_bEverFullyConnected; // Has this player ever connected to the server
  965. bool m_bDisconnection1MinWarningPrinted; // Whether 1 minute warning has been printed
  966. // RESETTABLE SECTION:
  967. int m_numKills; // number of kills
  968. int m_numAssists; // number of assists
  969. int m_numDeaths; // number of deaths
  970. int m_numScorePoints; // number of score points
  971. int m_numMVPs; // number of MVP rounds
  972. int m_cash; // player's cash
  973. int m_numTeamKills; // number of team kills
  974. int m_numTeamDamagePoints; // number of team damage points
  975. int m_numHostageKills; // number of hostages killed
  976. int m_numEnemyKills; // number of enemies killed
  977. int m_numEnemyKillHeadshots; // number of enemies killed with headshot
  978. int m_numEnemy3Ks; // number of 3Ks
  979. int m_numEnemy4Ks; // number of 4Ks
  980. int m_numEnemy5Ks; // number of 5Ks
  981. int m_numEnemyKillsAgg; // number of enemies killed on aggregate
  982. int m_numRoundsWon; // rounds won
  983. int m_numFirstKills; // number of times this player got first kill of the round
  984. int m_numClutchKills; // number of times this player got a kill with no teammates alive
  985. int m_numPistolKills; // number of pistol kills this player got
  986. int m_numSniperKills; // number of sniper kills this player got
  987. int m_numHealthPointsRemovedTotal; // total number of health points removed (used for coop gameplay)
  988. int m_numHealthPointsDealtTotal; // total number of health points dmg dealt to enemies (used for coop gameplay)
  989. int m_numShotsFiredTotal; // total number of shots fired (incremented by one every time player pulls trigger, not per each shotgun pellet; used for coop gameplay)
  990. int m_numShotsOnTargetTotal; // total number of shots on target (incremented by no moer than one per each time player pulls trigger, not per each shotgun pellet; used for coop gameplay)
  991. bool m_bReceiveNoMoneyNextRound; // player is marked to not receive any money next round
  992. // match stat data for the spectator graphs
  993. int m_iMatchStats_Kills[MAX_MATCH_STATS_ROUNDS];
  994. int m_iMatchStats_Damage[MAX_MATCH_STATS_ROUNDS];
  995. int m_iMatchStats_EquipmentValue[MAX_MATCH_STATS_ROUNDS];
  996. int m_iMatchStats_MoneySaved[MAX_MATCH_STATS_ROUNDS];
  997. int m_iMatchStats_KillReward[MAX_MATCH_STATS_ROUNDS];
  998. int m_iMatchStats_LiveTime[MAX_MATCH_STATS_ROUNDS];
  999. int m_iMatchStats_Deaths[ MAX_MATCH_STATS_ROUNDS ];
  1000. int m_iMatchStats_Assists[ MAX_MATCH_STATS_ROUNDS ];
  1001. int m_iMatchStats_HeadShotKills[ MAX_MATCH_STATS_ROUNDS ];
  1002. int m_iMatchStats_Objective[ MAX_MATCH_STATS_ROUNDS ];
  1003. int m_iMatchStats_CashEarned[ MAX_MATCH_STATS_ROUNDS ];
  1004. int m_iMatchStats_UtilityDamage[ MAX_MATCH_STATS_ROUNDS ];
  1005. int m_iMatchStats_EnemiesFlashed[ MAX_MATCH_STATS_ROUNDS ];
  1006. // per weapon kills
  1007. uint32 m_uiCustomNonPodFields;
  1008. // END RESETTABLE SECTION
  1009. CUtlMap< uint32, uint32, int, CDefLess< uint32 > > m_mapQuestEventPoints;
  1010. // TODO: If we have more attributes we want to be processed with the timed rewards job, try to generify this
  1011. typedef CUtlMap< itemid_t, attrib_value_t, int, CDefLess< itemid_t > > StattrakMusicKitValues_t;
  1012. StattrakMusicKitValues_t m_mapMusicKitUpdates;
  1013. // once the player purchases an econ item, cache it and rebuy it from the cache.
  1014. typedef CUtlMap< uint16, item_definition_index_t, int16, CDefLess< uint16 > > LoadoutSlotToDefIndexMap_t;
  1015. LoadoutSlotToDefIndexMap_t m_mapLoadoutSlotToItem[ 2 ];
  1016. };
  1017. typedef CUtlMap< uint32, CQMMPlayerData_t *, int32, CDefLess< uint32 > > QueuedMatchmakingPlayersDataMap_t;
  1018. QueuedMatchmakingPlayersDataMap_t m_mapQueuedMatchmakingPlayersData;
  1019. CQMMPlayerData_t * QueuedMatchmakingPlayersDataFind( uint32 uiAccountID ) const
  1020. {
  1021. if ( !uiAccountID ) return NULL;
  1022. QueuedMatchmakingPlayersDataMap_t::IndexType_t idx = m_mapQueuedMatchmakingPlayersData.Find( uiAccountID );
  1023. return ( idx == m_mapQueuedMatchmakingPlayersData.InvalidIndex() ) ? NULL : m_mapQueuedMatchmakingPlayersData.Element( idx );
  1024. }
  1025. CQMMPlayerData_t * QueuedMatchmakingPlayersDataFindOrCreate( CCSPlayer *pPlayer );
  1026. struct CGcBanInformation_t
  1027. {
  1028. uint32 m_uiReason;
  1029. double m_dblExpiration;
  1030. };
  1031. typedef CUtlMap< uint32, CGcBanInformation_t > GcBanInformationMap_t;
  1032. static GcBanInformationMap_t sm_mapGcBanInformation;
  1033. bool m_bForceTeamChangeSilent;
  1034. bool m_bLoadingRoundBackupData;
  1035. class ICalculateEndOfRoundMVPHook_t
  1036. {
  1037. public:
  1038. virtual CCSPlayer* CalculateEndOfRoundMVP() = 0;
  1039. };
  1040. ICalculateEndOfRoundMVPHook_t *m_pfnCalculateEndOfRoundMVPHook;
  1041. typedef CUtlMap< int32, uint32, int32, CDefLess< int32 > > MapMatchInfoShownCounts;
  1042. MapMatchInfoShownCounts m_mapMatchInfoShownCounts; // tracks how many times each match info piece was shown
  1043. enum MapMatchInfoShownCountsSpecial_t
  1044. {
  1045. k_MapMatchInfoShownCounts_None = 0xF0000,
  1046. k_MapMatchInfoShownCounts_Predictions = 0xF0001,
  1047. k_MapMatchInfoShownCounts_MapDraft = 0xF0002,
  1048. };
  1049. int m_nMatchInfoShowType; // which match info is preferred to be shown
  1050. float m_flMatchInfoDecidedTime; // what curtime moment was when match info was decided
  1051. struct ServerPlayerDecalData_t
  1052. {
  1053. ServerPlayerDecalData_t() { V_memset( this, 0, sizeof(*this) ); }
  1054. bool operator == ( ServerPlayerDecalData_t const &x ) const { return !V_memcmp( this, &x, offsetof( ServerPlayerDecalData_t, m_rtGcTime ) ); }
  1055. AccountID_t m_unAccountID;
  1056. int m_nTraceID;
  1057. Vector m_vecOrigin;
  1058. Vector m_vecStart;
  1059. Vector m_vecRight;
  1060. Vector m_vecNormal;
  1061. int m_nEquipSlot;
  1062. int m_nPlayer;
  1063. int m_nEntity;
  1064. int m_nHitbox;
  1065. int m_nTintID;
  1066. float m_flCreationTime;
  1067. uint32 m_rtGcTime; // not participating in memcmp (set by GC, authoritative)
  1068. void CopyToMsg( CCSUsrMsg_PlayerDecalDigitalSignature &msg ) const;
  1069. void InitFromMsg( CCSUsrMsg_PlayerDecalDigitalSignature const &msg );
  1070. };
  1071. CUtlVector< ServerPlayerDecalData_t > m_arrServerPlayerDecalData;
  1072. #endif
  1073. int m_iAccountTerrorist;
  1074. int m_iAccountCT;
  1075. int m_iNumConsecutiveCTLoses; //SupraFiend: the number of rounds the CTs have lost in a row.
  1076. int m_iNumConsecutiveTerroristLoses;//SupraFiend: the number of rounds the Terrorists have lost in a row.
  1077. int m_iSpawnPointCount_Terrorist; // Number of Terrorist spawn points
  1078. int m_iSpawnPointCount_CT; // Number of CT spawn points
  1079. int m_iMaxNumTerrorists;
  1080. int m_iMaxNumCTs;
  1081. int m_iLoserBonus; // SupraFiend: the amount of money the losing team gets. This scales up as they lose more rounds in a row
  1082. float m_tmNextPeriodicThink;
  1083. bool m_bVoiceWonMatchBragFired;
  1084. float m_fWarmupNextChatNoticeTime;
  1085. CHandle<CCSPlayer> m_pMVP;
  1086. // HOSTAGE RESCUE VARIABLES
  1087. int m_iHostagesRescued;
  1088. int m_iHostagesTouched;
  1089. float m_flNextHostageAnnouncement;
  1090. // [tj] Accessor for weapons donation ability
  1091. bool GetCanDonateWeapon( void ) { return m_bCanDonateWeapons; }
  1092. // [tj] flawless and lossless round related flags
  1093. bool m_bNoTerroristsKilled;
  1094. bool m_bNoCTsKilled;
  1095. bool m_bNoTerroristsDamaged;
  1096. bool m_bNoCTsDamaged;
  1097. bool m_bNoEnemiesKilled;
  1098. // [tj] Find out if dropped weapons count as donations
  1099. bool m_bCanDonateWeapons;
  1100. // [tj] Keep track of first kill
  1101. CHandle<CCSPlayer> m_pFirstKill;
  1102. float m_firstKillTime;
  1103. // [menglish] Keep track of first blood
  1104. CHandle<CCSPlayer> m_pFirstBlood;
  1105. float m_firstBloodTime;
  1106. // [dwenger] Rescue-related achievement values
  1107. CUtlVector< CHandle<CCSPlayer> > m_arrRescuers;
  1108. bool m_hostageWasInjured;
  1109. bool m_hostageWasKilled;
  1110. // [menglish] Fun Fact Manager
  1111. CCSFunFactMgr *m_pFunFactManager;
  1112. // Automatic vote called near the end of a map
  1113. bool m_bVoteCalled;
  1114. bool m_bServerVoteOnReset;
  1115. float m_flVoteCheckThrottle;
  1116. // [tj] To avoid rewriting the same piece of code, we can get all the information
  1117. // we want from one call that fills in an array of structures.
  1118. struct TeamPlayerCounts
  1119. {
  1120. int totalPlayers;
  1121. int totalAlivePlayers;
  1122. int totalDeadPlayers; //sum of killedPlayers + suicidedPlayers + unenteredPlayers
  1123. int killedPlayers;
  1124. int suicidedPlayers;
  1125. int unenteredPlayers;
  1126. };
  1127. void GetPlayerCounts( TeamPlayerCounts teamCounts[TEAM_MAXCOUNT] );
  1128. bool m_bBuyTimeEnded;
  1129. int m_nLastFreezeEndBeep;
  1130. // PRISON ESCAPE VARIABLES
  1131. int m_iHaveEscaped;
  1132. bool m_bMapHasEscapeZone;
  1133. int m_iNumEscapers;
  1134. int m_iNumEscapeRounds; // keeps track of the # of consecutive rounds of escape played.. Teams will be swapped after 8 rounds
  1135. // BOMB MAP VARIABLES
  1136. bool m_bTargetBombed; // whether or not the bomb has been bombed
  1137. bool m_bBombDefused; // whether or not the bomb has been defused
  1138. bool m_bMapHasBombZone;
  1139. /* bool m_bBombPlanted;*/
  1140. bool m_bGunGameRespawnWithBomb; // Whether or not the next terrorist to spawn should have the bomb
  1141. float m_fGunGameBombRespawnTimer; // Time until the bomb can be respawned
  1142. void AddTeamAccount( int team, TeamCashAward::Type reason );
  1143. void AddTeamAccount( int team, TeamCashAward::Type reason, int amount, const char* szAwardText = NULL );
  1144. public:
  1145. CBaseEntity* GetNextSpawnpoint( int teamNumber );
  1146. void DoCoopSpawnAndNavInit( void );
  1147. void AddSpawnPointToMasterList( SpawnPoint* pSpawnPoint );
  1148. void GenerateSpawnPointListsFirstTime( void );
  1149. void RefreshCurrentSpawnPointLists( void );
  1150. CCSMatch m_match;
  1151. Vector m_vecMainCTSpawnPos;
  1152. void ShuffleSpawnPointLists( void );
  1153. void ShuffleMasterSpawnPointLists( void );
  1154. void SortSpawnPointLists( void );
  1155. void SortMasterSpawnPointLists( void );
  1156. void ShufflePlayerList( CUtlVector< CCSPlayer* > &playersList );
  1157. protected:
  1158. CUtlVector< SpawnPoint* > m_CTSpawnPointsMasterList; // The master list of CT spawn points (contains all points whether enabled or disabled)
  1159. CUtlVector< SpawnPoint* > m_TerroristSpawnPointsMasterList; // The master list of Terrorist spawn points (contains all points whether enabled or disabled)
  1160. int m_iNextCTSpawnPoint; // Used when picking the next CT spawn point to assign
  1161. int m_iNextTerroristSpawnPoint; // Used when picking the next Terrorist spawn point to assign
  1162. CUtlVector< SpawnPoint* > m_CTSpawnPoints; // List of CT spawn points sorted by their priorities
  1163. CUtlVector< SpawnPoint* > m_TerroristSpawnPoints; // List of Terrorist spawn points sorted by their priorities
  1164. private:
  1165. float m_fAutobalanceDisplayTime;
  1166. AutobalanceStatus::Type m_AutobalanceStatus;
  1167. CRecipientFilter m_AutoBalanceTraitors;
  1168. CRecipientFilter m_AutoBalanceLoyalists;
  1169. // Don't allow switching weapons while gaining new technologies
  1170. bool m_bAllowWeaponSwitch;
  1171. bool m_bRoundTimeWarningTriggered;
  1172. float m_phaseChangeAnnouncementTime;
  1173. float m_fNextUpdateTeamClanNamesTime;
  1174. float m_flLastThinkTime;
  1175. CRecipientFilter m_filterTerrorist;
  1176. CRecipientFilter m_filterCT;
  1177. #endif
  1178. // Methods & memeber variables on both client and server DLLs
  1179. public:
  1180. virtual bool ForceSplitScreenPlayersOnToSameTeam( void );
  1181. void UpdatePlayerEloBracket( CCSPlayer *pPlayer, int32 bracket );
  1182. bool IsSwitchingTeamsAtRoundReset( void ) { return m_bSwitchingTeamsAtRoundReset; }
  1183. float CheckTotalSmokedLength( float flRadius, Vector vecGrenadePos, Vector from, Vector to );
  1184. protected:
  1185. loadout_positions_t PickRandomWeaponForDMBonus( void );
  1186. void AssignStartingMoneyToAllPlayers( void );
  1187. void InitializeGameTypeAndMode( void );
  1188. bool m_bHasTriggeredRoundStartMusic;
  1189. bool m_bHasTriggeredCoopSpawnReset;
  1190. public:
  1191. BotProfileDevice_t GetMatchDevice( void ) const { return ( BotProfileDevice_t )( m_MatchDevice.Get() ); }
  1192. void AddDroppedWeaponToList( CWeaponCSBase *pWeapon );
  1193. void RemoveDroppedWeaponFromList( CWeaponCSBase *pWeapon );
  1194. int GetTotalDroppedWeaponsInWorld( void ) { return m_weaponsDroppedInWorld.Count(); }
  1195. protected:
  1196. void ProcessAutoBalance( void );
  1197. private:
  1198. void UnfreezeAllPlayers( void );
  1199. bool m_bSwitchingTeamsAtRoundReset;
  1200. int m_iMaxGunGameProgressiveWeaponIndex;
  1201. CUtlVector< CHandle<CWeaponCSBase> > m_weaponsDroppedInWorld;
  1202. };
  1203. bool EconEntity_OnOwnerKillEaterEvent( CEconItemView *pEconItemView, CCSPlayer *pOwner, CCSPlayer *pVictim, kill_eater_event_t eEventType, int iAmount = 1, uint32 *pNewValue = NULL );
  1204. //-----------------------------------------------------------------------------
  1205. // Gets us at the team fortress game rules
  1206. //-----------------------------------------------------------------------------
  1207. inline CCSGameRules* CSGameRules()
  1208. {
  1209. return static_cast<CCSGameRules*>(g_pGameRules);
  1210. }
  1211. #define IGNORE_SPECTATORS false
  1212. #define IGNORE_UNASSIGNED true
  1213. int UTIL_HumansInGame( bool ignoreSpectators = false, bool ignoreUnassigned = false );
  1214. int UTIL_SpectatorsInGame( void );
  1215. //-----------------------------------------------------------------------------
  1216. // Music Selection
  1217. //-----------------------------------------------------------------------------
  1218. enum CsMusicType_t
  1219. {
  1220. CSMUSIC_NONE = 0,
  1221. CSMUSIC_STARTGG,
  1222. CSMUSIC_START,
  1223. CSMUSIC_ACTION,
  1224. CSMUSIC_DEATHCAM,
  1225. CSMUSIC_BOMB,
  1226. CSMUSIC_BOMBTEN,
  1227. CSMUSIC_ROUNDTEN,
  1228. CSMUSIC_WONROUND,
  1229. CSMUSIC_LOSTROUND,
  1230. CSMUSIC_HOSTAGE,
  1231. CSMUSIC_MVP,
  1232. CSMUSIC_SELECTION,
  1233. CSMUSIC_HALFTIME
  1234. };
  1235. #define CSMUSIC_NOPACK 0
  1236. #ifdef CLIENT_DLL
  1237. void PlayMusicSelection( IRecipientFilter& filter, CsMusicType_t nMusicType , int nPlayerEntIndex = 0 , float flPreElapsedTime = 0.0 );
  1238. #endif
  1239. //-----------------------------------------------------------------------------
  1240. // Purpose: Useful utility functions
  1241. //-----------------------------------------------------------------------------
  1242. #ifdef CLIENT_DLL
  1243. #else
  1244. class CTFTeam;
  1245. CTFTeam *GetOpposingTeam( CTeam *pTeam );
  1246. bool EntityPlacementTest( CBaseEntity *pMainEnt, const Vector &vOrigin, Vector &outPos, bool bDropToGround, unsigned int mask = MASK_SOLID, ITraceFilter *pFilter = NULL );
  1247. #endif
  1248. // Assassination quest helper funcs
  1249. bool IsAssassinationQuest( const CEconQuestDefinition *pQuest );
  1250. bool IsAssassinationQuest( uint32 questID );
  1251. bool IsAssassinationQuestActive( const CEconQuestDefinition *pQuest );
  1252. extern const float g_flWarmupToFreezetimeDelay;
  1253. #endif // TF_GAMERULES_H