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.

140 lines
3.5 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef BASEGRENADE_SHARED_H
  8. #define BASEGRENADE_SHARED_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "baseprojectile.h"
  13. #if defined( CLIENT_DLL )
  14. #define CBaseGrenade C_BaseGrenade
  15. #include "c_basecombatcharacter.h"
  16. #else
  17. #include "basecombatcharacter.h"
  18. #include "player_pickup.h"
  19. #endif
  20. #define BASEGRENADE_EXPLOSION_VOLUME 1024
  21. class CTakeDamageInfo;
  22. #if !defined( CLIENT_DLL )
  23. class CBaseGrenade : public CBaseProjectile, public CDefaultPlayerPickupVPhysics
  24. #else
  25. class CBaseGrenade : public CBaseProjectile
  26. #endif
  27. {
  28. DECLARE_CLASS( CBaseGrenade, CBaseProjectile );
  29. public:
  30. CBaseGrenade(void);
  31. ~CBaseGrenade(void);
  32. DECLARE_PREDICTABLE();
  33. DECLARE_NETWORKCLASS();
  34. #if !defined( CLIENT_DLL )
  35. DECLARE_DATADESC();
  36. #endif
  37. virtual void Precache( void );
  38. virtual void Explode( trace_t *pTrace, int bitsDamageType );
  39. void Smoke( void );
  40. void BounceTouch( CBaseEntity *pOther );
  41. void SlideTouch( CBaseEntity *pOther );
  42. void ExplodeTouch( CBaseEntity *pOther );
  43. void DangerSoundThink( void );
  44. void PreDetonate( void );
  45. virtual void Detonate( void );
  46. void DetonateUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
  47. void TumbleThink( void );
  48. virtual Vector GetBlastForce() { return vec3_origin; }
  49. virtual void BounceSound( void );
  50. virtual int BloodColor( void ) { return DONT_BLEED; }
  51. virtual void Event_Killed( const CTakeDamageInfo &info );
  52. virtual float GetShakeAmplitude( void ) { return 25.0; }
  53. virtual float GetShakeRadius( void ) { return 750.0; }
  54. // Damage accessors.
  55. virtual float GetDamage()
  56. {
  57. return m_flDamage;
  58. }
  59. virtual float GetDamageRadius()
  60. {
  61. return m_DmgRadius;
  62. }
  63. virtual void SetDamage(float flDamage)
  64. {
  65. m_flDamage = flDamage;
  66. }
  67. virtual void SetDamageRadius(float flDamageRadius)
  68. {
  69. m_DmgRadius = flDamageRadius;
  70. }
  71. // Bounce sound accessors.
  72. void SetBounceSound( const char *pszBounceSound )
  73. {
  74. m_iszBounceSound = MAKE_STRING( pszBounceSound );
  75. }
  76. CBaseCombatCharacter *GetThrower( void );
  77. void SetThrower( CBaseCombatCharacter *pThrower );
  78. CBaseEntity *GetOriginalThrower() { return m_hOriginalThrower; }
  79. #if !defined( CLIENT_DLL )
  80. // Allow +USE pickup
  81. int ObjectCaps()
  82. {
  83. return (BaseClass::ObjectCaps() | FCAP_IMPULSE_USE | FCAP_USE_IN_RADIUS);
  84. }
  85. void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
  86. #endif
  87. public:
  88. IMPLEMENT_NETWORK_VAR_FOR_DERIVED( m_vecVelocity );
  89. IMPLEMENT_NETWORK_VAR_FOR_DERIVED( m_fFlags );
  90. bool m_bHasWarnedAI; // whether or not this grenade has issued its DANGER sound to the world sound list yet.
  91. CNetworkVar( bool, m_bIsLive ); // Is this grenade live, or can it be picked up?
  92. CNetworkVar( float, m_DmgRadius ); // How far do I do damage?
  93. CNetworkVar( float, m_flNextAttack );
  94. float m_flDetonateTime; // Time at which to detonate.
  95. float m_flWarnAITime; // Time at which to warn the AI
  96. protected:
  97. CNetworkVar( float, m_flDamage ); // Damage to inflict.
  98. string_t m_iszBounceSound; // The sound to make on bouncing. If not NULL, overrides the BounceSound() function.
  99. private:
  100. CNetworkHandle( CBaseEntity, m_hThrower ); // Who threw this grenade
  101. EHANDLE m_hOriginalThrower; // Who was the original thrower of this grenade
  102. CBaseGrenade( const CBaseGrenade & ); // not defined, not accessible
  103. };
  104. #endif // BASEGRENADE_SHARED_H