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.

151 lines
4.2 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: TF Base Rockets.
  4. //
  5. //=============================================================================//
  6. #ifndef TF_WEAPONBASE_ROCKET_H
  7. #define TF_WEAPONBASE_ROCKET_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "cbase.h"
  12. #include "tf_shareddefs.h"
  13. #include "baseprojectile.h"
  14. // Server specific.
  15. #ifdef GAME_DLL
  16. #include "smoke_trail.h"
  17. #endif
  18. #ifdef CLIENT_DLL
  19. #define CTFBaseRocket C_TFBaseRocket
  20. #endif
  21. #define TF_ROCKET_RADIUS_FOR_RJS (110.0f * 1.1f) // radius * TF scale up factor (121) - Used when applying damage to attacker.
  22. #define TF_ROCKET_RADIUS (146) // Radius used when applying damage to others
  23. #define TF_FLARE_DET_RADIUS (110) // Special version of the flare that can be detonated by the player
  24. #define TF_FLARE_RADIUS_FOR_FJS (100.0f)
  25. #define TF_ROCKET_DESTROYABLE_TIMER (0.25)
  26. //=============================================================================
  27. //
  28. // TF Base Rocket.
  29. //
  30. class CTFBaseRocket : public CBaseProjectile
  31. {
  32. //=============================================================================
  33. //
  34. // Shared (client/server).
  35. //
  36. public:
  37. DECLARE_CLASS( CTFBaseRocket, CBaseProjectile );
  38. DECLARE_NETWORKCLASS();
  39. CTFBaseRocket();
  40. ~CTFBaseRocket();
  41. void Precache( void );
  42. void Spawn( void );
  43. virtual int GetWeaponID( void ) const { return TF_WEAPON_ROCKETLAUNCHER; }
  44. virtual int GetCustomDamageType() const { return TF_DMG_CUSTOM_NONE; }
  45. virtual void IncrementDeflected( void ) { m_iDeflected++; }
  46. void ResetDeflected( void ) { m_iDeflected = 0; }
  47. int GetDeflected( void ) { return m_iDeflected; }
  48. protected:
  49. // Networked.
  50. CNetworkVector( m_vInitialVelocity );
  51. CNetworkVar( int, m_iDeflected );
  52. //=============================================================================
  53. //
  54. // Client specific.
  55. //
  56. #ifdef CLIENT_DLL
  57. public:
  58. virtual int DrawModel( int flags );
  59. virtual void PostDataUpdate( DataUpdateType_t type );
  60. virtual void OnDataChanged(DataUpdateType_t updateType);
  61. virtual void CreateTrails( void ) { }
  62. CBaseEntity *GetLauncher( void ) { return m_hLauncher; }
  63. protected:
  64. float m_flSpawnTime;
  65. int m_iCachedDeflect;
  66. CNetworkHandle( CBaseEntity, m_hLauncher );
  67. //=============================================================================
  68. //
  69. // Server specific.
  70. //
  71. #else
  72. public:
  73. DECLARE_DATADESC();
  74. static CTFBaseRocket *Create( CBaseEntity *pLauncher, const char *szClassname, const Vector &vecOrigin, const QAngle &vecAngles, CBaseEntity *pOwner = NULL );
  75. virtual void RocketTouch( CBaseEntity *pOther );
  76. virtual void Explode( trace_t *pTrace, CBaseEntity *pOther );
  77. void CheckForStunOnImpact( CTFPlayer* pTarget );
  78. int GetStunLevel( void );
  79. virtual bool ShouldNotDetonate( void );
  80. virtual void Destroy( bool bBlinkOut = true, bool bBreakRocket = false ) OVERRIDE;
  81. virtual float GetDamage() { return m_flDamage; }
  82. virtual int GetDamageType() { return g_aWeaponDamageTypes[ GetWeaponID() ]; }
  83. virtual int GetDamageCustom() { return TF_DMG_CUSTOM_NONE; }
  84. virtual void SetDamage(float flDamage) { m_flDamage = flDamage; }
  85. #ifdef STAGING_ONLY
  86. void DrawRadius( float flRadius );
  87. #endif
  88. virtual float GetRadius();
  89. virtual void SetDamageForceScale( float flScale ) { m_flDamageForceScale = flScale; }
  90. virtual float GetDamageForceScale() { return m_flDamageForceScale; }
  91. unsigned int PhysicsSolidMaskForEntity( void ) const;
  92. void SetupInitialTransmittedGrenadeVelocity( const Vector &velocity ) { m_vInitialVelocity = velocity; }
  93. virtual CBaseEntity *GetEnemy( void ) { return m_hEnemy; }
  94. void SetHomingTarget( CBaseEntity *pHomingTarget );
  95. virtual void SetLauncher( CBaseEntity *pLauncher ) OVERRIDE { m_hLauncher = pLauncher; BaseClass::SetLauncher( pLauncher ); }
  96. CBaseEntity *GetLauncher( void ) { return m_hLauncher; }
  97. virtual bool IsDestroyable( void ){ return gpGlobals->curtime > m_flDestroyableTime; }
  98. CBaseEntity *GetOwnerPlayer( void ) const;
  99. protected:
  100. // Not networked.
  101. float m_flDamage;
  102. CNetworkHandle( CBaseEntity, m_hLauncher );
  103. float m_flDestroyableTime;
  104. bool m_bCritical;
  105. bool m_bStunOnImpact;
  106. float m_flDamageForceScale;
  107. CHandle<CBaseEntity> m_hEnemy;
  108. #endif
  109. };
  110. #endif // TF_WEAPONBASE_ROCKET_H