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.

118 lines
3.1 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Game rules for Half-Life 2.
  4. //
  5. //=============================================================================//
  6. #ifndef HL2_GAMERULES_H
  7. #define HL2_GAMERULES_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "gamerules.h"
  12. #include "singleplay_gamerules.h"
  13. #include "hl2_shareddefs.h"
  14. #ifdef CLIENT_DLL
  15. #define CHalfLife2 C_HalfLife2
  16. #define CHalfLife2Proxy C_HalfLife2Proxy
  17. #endif
  18. class CHalfLife2Proxy : public CGameRulesProxy
  19. {
  20. public:
  21. DECLARE_CLASS( CHalfLife2Proxy, CGameRulesProxy );
  22. DECLARE_NETWORKCLASS();
  23. };
  24. class CHalfLife2 : public CSingleplayRules
  25. {
  26. public:
  27. DECLARE_CLASS( CHalfLife2, CSingleplayRules );
  28. // Damage Query Overrides.
  29. virtual bool Damage_IsTimeBased( int iDmgType );
  30. // TEMP:
  31. virtual int Damage_GetTimeBased( void );
  32. virtual bool ShouldCollide( int collisionGroup0, int collisionGroup1 );
  33. virtual bool ShouldUseRobustRadiusDamage(CBaseEntity *pEntity);
  34. #ifndef CLIENT_DLL
  35. virtual bool ShouldAutoAim( CBasePlayer *pPlayer, edict_t *target );
  36. virtual float GetAutoAimScale( CBasePlayer *pPlayer );
  37. virtual float GetAmmoQuantityScale( int iAmmoIndex );
  38. virtual void LevelInitPreEntity();
  39. #endif
  40. private:
  41. // Rules change for the mega physgun
  42. CNetworkVar( bool, m_bMegaPhysgun );
  43. #ifdef CLIENT_DLL
  44. DECLARE_CLIENTCLASS_NOBASE(); // This makes datatables able to access our private vars.
  45. #else
  46. DECLARE_SERVERCLASS_NOBASE(); // This makes datatables able to access our private vars.
  47. CHalfLife2();
  48. virtual ~CHalfLife2() {}
  49. virtual void Think( void );
  50. virtual bool ClientCommand( CBaseEntity *pEdict, const CCommand &args );
  51. virtual void PlayerSpawn( CBasePlayer *pPlayer );
  52. virtual void InitDefaultAIRelationships( void );
  53. virtual const char* AIClassText(int classType);
  54. virtual const char *GetGameDescription( void ) { return "Half-Life 2"; }
  55. // Ammo
  56. virtual void PlayerThink( CBasePlayer *pPlayer );
  57. virtual float GetAmmoDamage( CBaseEntity *pAttacker, CBaseEntity *pVictim, int nAmmoType );
  58. virtual bool ShouldBurningPropsEmitLight();
  59. public:
  60. bool AllowDamage( CBaseEntity *pVictim, const CTakeDamageInfo &info );
  61. bool NPC_ShouldDropGrenade( CBasePlayer *pRecipient );
  62. bool NPC_ShouldDropHealth( CBasePlayer *pRecipient );
  63. void NPC_DroppedHealth( void );
  64. void NPC_DroppedGrenade( void );
  65. bool MegaPhyscannonActive( void ) { return m_bMegaPhysgun; }
  66. virtual bool IsAlyxInDarknessMode();
  67. private:
  68. float m_flLastHealthDropTime;
  69. float m_flLastGrenadeDropTime;
  70. void AdjustPlayerDamageTaken( CTakeDamageInfo *pInfo );
  71. float AdjustPlayerDamageInflicted( float damage );
  72. int DefaultFOV( void ) { return 75; }
  73. #endif
  74. };
  75. //-----------------------------------------------------------------------------
  76. // Gets us at the Half-Life 2 game rules
  77. //-----------------------------------------------------------------------------
  78. inline CHalfLife2* HL2GameRules()
  79. {
  80. #if ( !defined( HL2_DLL ) && !defined( HL2_CLIENT_DLL ) ) || defined( HL2MP )
  81. Assert( 0 ); // g_pGameRules is NOT an instance of CHalfLife2 and bad things happen
  82. #endif
  83. return static_cast<CHalfLife2*>(g_pGameRules);
  84. }
  85. #endif // HL2_GAMERULES_H