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.

122 lines
3.5 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #ifndef BASECSGRENADE_PROJECTILE_H
  7. #define BASECSGRENADE_PROJECTILE_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "basegrenade_shared.h"
  12. #ifdef CLIENT_DLL
  13. #define CBaseCSGrenadeProjectile C_BaseCSGrenadeProjectile
  14. #else
  15. class CCSWeaponInfo;
  16. #endif
  17. class CBaseCSGrenadeProjectile : public CBaseGrenade
  18. {
  19. public:
  20. DECLARE_CLASS( CBaseCSGrenadeProjectile, CBaseGrenade );
  21. DECLARE_NETWORKCLASS();
  22. virtual void Spawn();
  23. //virtual bool IsGrenadeProjectile( void ) { return true; };
  24. public:
  25. // This gets sent to the client and placed in the client's interpolation history
  26. // so the projectile starts out moving right off the bat.
  27. CNetworkVector( m_vInitialVelocity );
  28. CNetworkVar( int, m_nBounces );
  29. #ifdef CLIENT_DLL
  30. CBaseCSGrenadeProjectile() {}
  31. CBaseCSGrenadeProjectile( const CBaseCSGrenadeProjectile& ) {}
  32. virtual ~CBaseCSGrenadeProjectile();
  33. virtual int DrawModel( int flags, const RenderableInstance_t &instance );
  34. virtual void PostDataUpdate( DataUpdateType_t type );
  35. virtual void ClientThink( void );
  36. void CreateGrenadeTrail( void );
  37. float m_flSpawnTime;
  38. Vector vecLastTrailLinePos;
  39. float flNextTrailLineTime;
  40. #else
  41. DECLARE_DATADESC();
  42. CBaseCSGrenadeProjectile() : m_pWeaponInfo(NULL), m_bDetonationRecorded(false) {}
  43. virtual void PostConstructor( const char *className );
  44. virtual ~CBaseCSGrenadeProjectile();
  45. virtual void Precache();
  46. virtual int UpdateTransmitState();
  47. virtual int ShouldTransmit( const CCheckTransmitInfo *pInfo );
  48. //Constants for all CS Grenades
  49. static inline float GetGrenadeGravity() { return 0.4f; }
  50. static inline const float GetGrenadeFriction() { return 0.2f; }
  51. static inline const float GetGrenadeElasticity() { return 0.45f; }
  52. //Think function to emit danger sounds for the AI
  53. void DangerSoundThink( void );
  54. virtual void OnBounced( void ) {}
  55. virtual void Explode( trace_t *pTrace, int bitsDamageType );
  56. virtual float GetShakeAmplitude( void ) { return 0.0f; }
  57. virtual void Splash();
  58. virtual GrenadeType_t GetGrenadeType( void ) { return GRENADE_TYPE_EXPLOSIVE; }
  59. // Specify what velocity we want the grenade to have on the client immediately.
  60. // Without this, the entity wouldn't have an interpolation history initially, so it would
  61. // sit still until it had gotten a few updates from the server.
  62. void SetupInitialTransmittedGrenadeVelocity( const Vector &velocity );
  63. // [jpaquin] give grenade projectiles a link back to the type
  64. // of weapon they are
  65. const CCSWeaponInfo *m_pWeaponInfo;
  66. enum
  67. {
  68. GRENADE_EXTINGUISHED_INFERNO = 1 << 0,
  69. };
  70. uint8 m_unOGSExtraFlags; // Misc flags about the grenade's effect in game to report to ogs
  71. EHANDLE m_lastHitPlayer;
  72. void DetonateOnNextThink( void ) { m_flDetonateTime = 0.0f; }
  73. virtual unsigned int PhysicsSolidMaskForEntity( void ) const;
  74. protected:
  75. //Set the time to detonate ( now + timer )
  76. void SetDetonateTimerLength( float timer );
  77. // Called when this grenade explodes. If your decended class overides some part of the detonation process
  78. // and prevents detonate from being called, you need to call this to make ogs still records it.
  79. void RecordDetonation( void );
  80. bool m_bDetonationRecorded;
  81. private:
  82. //Custom collision to allow for constant elasticity on hit surfaces
  83. virtual void ResolveFlyCollisionCustom( trace_t &trace, Vector &vecVelocity );
  84. float m_flDetonateTime;
  85. #endif
  86. };
  87. #endif // BASECSGRENADE_PROJECTILE_H