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.

123 lines
4.2 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $Workfile: $
  6. // $Date: $
  7. //
  8. //-----------------------------------------------------------------------------
  9. // $Log: $
  10. //
  11. // $NoKeywords: $
  12. //=============================================================================//
  13. #ifndef TEAMPLAY_GAMERULES_H
  14. #define TEAMPLAY_GAMERULES_H
  15. #pragma once
  16. #include "gamerules.h"
  17. #include "multiplay_gamerules.h"
  18. #ifdef CLIENT_DLL
  19. #define CTeamplayRules C_TeamplayRules
  20. #else
  21. #include "takedamageinfo.h"
  22. #endif
  23. //
  24. // teamplay_gamerules.h
  25. //
  26. #define MAX_TEAMNAME_LENGTH 16
  27. #define MAX_TEAMS 32
  28. #define TEAMPLAY_TEAMLISTLENGTH MAX_TEAMS*MAX_TEAMNAME_LENGTH
  29. class CTeamplayRules : public CMultiplayRules
  30. {
  31. public:
  32. DECLARE_CLASS( CTeamplayRules, CMultiplayRules );
  33. // Return the value of this player towards capturing a point
  34. virtual int GetCaptureValueForPlayer( CBasePlayer *pPlayer ) { return 1; }
  35. virtual bool TeamMayCapturePoint( int iTeam, int iPointIndex ) { return true; }
  36. virtual bool PlayerMayCapturePoint( CBasePlayer *pPlayer, int iPointIndex, char *pszReason = NULL, int iMaxReasonLength = 0 ) { return true; }
  37. virtual bool PlayerMayBlockPoint( CBasePlayer *pPlayer, int iPointIndex, char *pszReason = NULL, int iMaxReasonLength = 0 ) { return false; }
  38. // Return false if players aren't allowed to cap points at this time (i.e. in WaitingForPlayers)
  39. virtual bool PointsMayBeCaptured( void ) { return true; }
  40. virtual void SetLastCapPointChanged( int iIndex ) { return; }
  41. #ifdef CLIENT_DLL
  42. #else
  43. CTeamplayRules();
  44. virtual ~CTeamplayRules() {};
  45. virtual void Precache( void );
  46. virtual bool ClientCommand( CBaseEntity *pEdict, const CCommand &args );
  47. virtual void ClientSettingsChanged( CBasePlayer *pPlayer );
  48. virtual bool IsTeamplay( void );
  49. virtual bool FPlayerCanTakeDamage( CBasePlayer *pPlayer, CBaseEntity *pAttacker );
  50. virtual int PlayerRelationship( CBaseEntity *pPlayer, CBaseEntity *pTarget );
  51. virtual bool PlayerCanHearChat( CBasePlayer *pListener, CBasePlayer *pSpeaker, bool bTeamOnly );
  52. virtual bool ShouldAutoAim( CBasePlayer *pPlayer, edict_t *target );
  53. virtual int IPointsForKill( CBasePlayer *pAttacker, CBasePlayer *pKilled );
  54. virtual void InitHUD( CBasePlayer *pl );
  55. virtual void DeathNotice( CBasePlayer *pVictim, const CTakeDamageInfo &info );
  56. virtual const char *GetGameDescription( void ) { return "Teamplay"; } // this is the game name that gets seen in the server browser
  57. virtual void PlayerKilled( CBasePlayer *pVictim, const CTakeDamageInfo &info );
  58. virtual void Think ( void );
  59. virtual int GetTeamIndex( const char *pTeamName );
  60. virtual const char *GetIndexedTeamName( int teamIndex );
  61. virtual bool IsValidTeam( const char *pTeamName );
  62. virtual const char *SetDefaultPlayerTeam( CBasePlayer *pPlayer );
  63. virtual void ChangePlayerTeam( CBasePlayer *pPlayer, const char *pTeamName, bool bKill, bool bGib );
  64. virtual void ClientDisconnected( edict_t *pClient );
  65. virtual bool TimerMayExpire( void ) { return true; }
  66. // A game has been won by the specified team
  67. virtual void SetWinningTeam( int team, int iWinReason, bool bForceMapReset = true, bool bSwitchTeams = false, bool bDontAddScore = false ) { return; }
  68. virtual void SetStalemate( int iReason, bool bForceMapReset = true, bool bSwitchTeams = false ) { return; }
  69. // Used to determine if all players should switch teams
  70. virtual void SetSwitchTeams( bool bSwitch ){ m_bSwitchTeams = bSwitch; }
  71. virtual bool ShouldSwitchTeams( void ){ return m_bSwitchTeams; }
  72. virtual void HandleSwitchTeams( void ){ return; }
  73. // Used to determine if we should scramble the teams
  74. virtual void SetScrambleTeams( bool bScramble ){ m_bScrambleTeams = bScramble; }
  75. virtual bool ShouldScrambleTeams( void ){ return m_bScrambleTeams; }
  76. virtual void HandleScrambleTeams( void ){ return; }
  77. protected:
  78. bool m_DisableDeathMessages;
  79. private:
  80. void RecountTeams( void );
  81. const char *TeamWithFewestPlayers( void );
  82. bool m_DisableDeathPenalty;
  83. bool m_teamLimit; // This means the server set only some teams as valid
  84. char m_szTeamList[TEAMPLAY_TEAMLISTLENGTH];
  85. bool m_bSwitchTeams;
  86. bool m_bScrambleTeams;
  87. #endif
  88. };
  89. inline CTeamplayRules* TeamplayGameRules()
  90. {
  91. return static_cast<CTeamplayRules*>(g_pGameRules);
  92. }
  93. #endif // TEAMPLAY_GAMERULES_H