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.

181 lines
6.1 KiB

  1. //===== Copyright � 1996-2005, Valve Corporation, All rights reserved. ======//
  2. //
  3. // Purpose: Defines the client-side representation of CBaseCombatCharacter.
  4. //
  5. // $NoKeywords: $
  6. //===========================================================================//
  7. #ifndef C_BASECOMBATCHARACTER_H
  8. #define C_BASECOMBATCHARACTER_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "shareddefs.h"
  13. #include "c_baseflex.h"
  14. #define BCC_DEFAULT_LOOK_TOWARDS_TOLERANCE 0.9f
  15. class C_BaseCombatWeapon;
  16. class C_WeaponCombatShield;
  17. class C_BaseCombatCharacter : public C_BaseFlex
  18. {
  19. DECLARE_CLASS( C_BaseCombatCharacter, C_BaseFlex );
  20. public:
  21. DECLARE_CLIENTCLASS();
  22. DECLARE_PREDICTABLE();
  23. C_BaseCombatCharacter( void );
  24. virtual ~C_BaseCombatCharacter( void );
  25. virtual bool IsBaseCombatCharacter( void ) { return true; };
  26. virtual C_BaseCombatCharacter *MyCombatCharacterPointer( void ) { return this; }
  27. virtual void DropPhysicsMag( const char *options ) {}
  28. // -----------------------
  29. // Vision
  30. // -----------------------
  31. enum FieldOfViewCheckType { USE_FOV, DISREGARD_FOV };
  32. bool IsAbleToSee( const CBaseEntity *entity, FieldOfViewCheckType checkFOV ); // Visible starts with line of sight, and adds all the extra game checks like fog, smoke, camo...
  33. bool IsAbleToSee( C_BaseCombatCharacter *pBCC, FieldOfViewCheckType checkFOV ); // Visible starts with line of sight, and adds all the extra game checks like fog, smoke, camo...
  34. virtual bool IsLookingTowards( const CBaseEntity *target, float cosTolerance = BCC_DEFAULT_LOOK_TOWARDS_TOLERANCE ) const; // return true if our view direction is pointing at the given target, within the cosine of the angular tolerance. LINE OF SIGHT IS NOT CHECKED.
  35. virtual bool IsLookingTowards( const Vector &target, float cosTolerance = BCC_DEFAULT_LOOK_TOWARDS_TOLERANCE ) const; // return true if our view direction is pointing at the given target, within the cosine of the angular tolerance. LINE OF SIGHT IS NOT CHECKED.
  36. virtual bool IsInFieldOfView( CBaseEntity *entity ) const; // Calls IsLookingAt with the current field of view.
  37. virtual bool IsInFieldOfView( const Vector &pos ) const;
  38. enum LineOfSightCheckType
  39. {
  40. IGNORE_NOTHING,
  41. IGNORE_ACTORS
  42. };
  43. virtual bool IsLineOfSightClear( CBaseEntity *entity, LineOfSightCheckType checkType = IGNORE_NOTHING ) const;// strictly LOS check with no other considerations
  44. virtual bool IsLineOfSightClear( const Vector &pos, LineOfSightCheckType checkType = IGNORE_NOTHING, CBaseEntity *entityToIgnore = NULL ) const;
  45. int LastHitGroup() const { return m_LastHitGroup; }
  46. // -----------------------
  47. // Ammo
  48. // -----------------------
  49. void RemoveAmmo( int iCount, int iAmmoIndex );
  50. void RemoveAmmo( int iCount, const char *szName );
  51. void RemoveAllAmmo( );
  52. int GetAmmoCount( int iAmmoIndex ) const;
  53. int GetAmmoCount( char *szName ) const;
  54. virtual C_BaseCombatWeapon* Weapon_OwnsThisType( const char *pszWeapon, int iSubType = 0 ) const; // True if already owns a weapon of this class
  55. virtual C_BaseCombatWeapon *Weapon_GetSlot( int slot ) const;
  56. virtual C_BaseCombatWeapon *Weapon_GetPosition( int pos ) const;
  57. virtual bool Weapon_Switch( C_BaseCombatWeapon *pWeapon, int viewmodelindex = 0 );
  58. virtual bool Weapon_CanSwitchTo(C_BaseCombatWeapon *pWeapon);
  59. // I can't use my current weapon anymore. Switch me to the next best weapon.
  60. bool SwitchToNextBestWeapon(C_BaseCombatWeapon *pCurrent);
  61. virtual C_BaseCombatWeapon *GetActiveWeapon( void ) const;
  62. int WeaponCount() const;
  63. virtual C_BaseCombatWeapon *GetWeapon( int i ) const;
  64. // This is a sort of hack back-door only used by physgun!
  65. void SetAmmoCount( int iCount, int iAmmoIndex );
  66. bool HasEverBeenInjured( void ) const;
  67. float GetTimeSinceLastInjury( void ) const;
  68. RelativeDamagedDirection_t GetLastInjuryRelativeDirection( void ) { return m_nRelativeDirectionOfLastInjury; }
  69. float GetNextAttack() const { return m_flNextAttack; }
  70. void SetNextAttack( float flWait ) { m_flNextAttack = flWait; }
  71. virtual int BloodColor();
  72. // Blood color (see BLOOD_COLOR_* macros in baseentity.h)
  73. void SetBloodColor( int nBloodColor );
  74. virtual void DoMuzzleFlash();
  75. public:
  76. // BEGIN PREDICTION DATA COMPACTION (these fields are together to allow for faster copying in prediction system)
  77. float m_flNextAttack;
  78. private:
  79. bool ComputeLOS( const Vector &vecEyePosition, const Vector &vecTarget ) const;
  80. public:
  81. int m_LastHitGroup;
  82. private:
  83. CNetworkArray( int, m_iAmmo, MAX_AMMO_TYPES );
  84. CHandle<C_BaseCombatWeapon> m_hMyWeapons[MAX_WEAPONS];
  85. CHandle< C_BaseCombatWeapon > m_hActiveWeapon;
  86. float m_flTimeOfLastInjury;
  87. RelativeDamagedDirection_t m_nRelativeDirectionOfLastInjury;
  88. // END PREDICTION DATA COMPACTION
  89. protected:
  90. int m_bloodColor; // color of blood particless
  91. private:
  92. private:
  93. C_BaseCombatCharacter( const C_BaseCombatCharacter & ); // not defined, not accessible
  94. //-----------------------
  95. #ifdef INVASION_CLIENT_DLL
  96. public:
  97. virtual void Release( void );
  98. virtual void SetDormant( bool bDormant );
  99. virtual void OnPreDataChanged( DataUpdateType_t updateType );
  100. virtual void OnDataChanged( DataUpdateType_t updateType );
  101. virtual void ClientThink( void );
  102. // TF2 Powerups
  103. virtual bool CanBePoweredUp( void ) { return true; }
  104. bool HasPowerup( int iPowerup ) { return ( m_iPowerups & (1 << iPowerup) ) != 0; };
  105. virtual void PowerupStart( int iPowerup, bool bInitial );
  106. virtual void PowerupEnd( int iPowerup );
  107. void RemoveAllPowerups( void );
  108. // Powerup effects
  109. void AddEMPEffect( float flSize );
  110. void AddBuffEffect( float flSize );
  111. C_WeaponCombatShield *GetShield( void );
  112. public:
  113. int m_iPowerups;
  114. int m_iPrevPowerups;
  115. #endif
  116. public:
  117. virtual void OnDataChanged( DataUpdateType_t updateType );
  118. };
  119. inline C_BaseCombatCharacter *ToBaseCombatCharacter( C_BaseEntity *pEntity )
  120. {
  121. return pEntity ? pEntity->MyCombatCharacterPointer() : NULL;
  122. }
  123. //-----------------------------------------------------------------------------
  124. // Purpose:
  125. //-----------------------------------------------------------------------------
  126. inline int C_BaseCombatCharacter::WeaponCount() const
  127. {
  128. return MAX_WEAPONS;
  129. }
  130. EXTERN_RECV_TABLE(DT_BaseCombatCharacter);
  131. #endif // C_BASECOMBATCHARACTER_H