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.

159 lines
4.6 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: TF Pipebomb Grenade.
  4. //
  5. //=============================================================================//
  6. #ifndef TF_WEAPON_GRENADE_PIPEBOMB_H
  7. #define TF_WEAPON_GRENADE_PIPEBOMB_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "tf_weaponbase_grenadeproj.h"
  12. // Client specific.
  13. #ifdef CLIENT_DLL
  14. #define CTFGrenadePipebombProjectile C_TFGrenadePipebombProjectile
  15. #endif
  16. //-----------------------------------------------------------------------------
  17. // Grenade Launcher mode (for pipebombs).
  18. //-----------------------------------------------------------------------------
  19. enum
  20. {
  21. TF_GL_MODE_REGULAR = 0,
  22. TF_GL_MODE_REMOTE_DETONATE,
  23. TF_GL_MODE_REMOTE_DETONATE_PRACTICE,
  24. TF_GL_MODE_CANNONBALL,
  25. //
  26. // ADD NEW ITEMS HERE TO AVOID BREAKING DEMOS
  27. //
  28. };
  29. //=============================================================================
  30. //
  31. // TF Pipebomb Grenade
  32. //
  33. class CTFGrenadePipebombProjectile : public CTFWeaponBaseGrenadeProj
  34. {
  35. public:
  36. DECLARE_CLASS( CTFGrenadePipebombProjectile, CTFWeaponBaseGrenadeProj );
  37. DECLARE_NETWORKCLASS();
  38. CTFGrenadePipebombProjectile();
  39. ~CTFGrenadePipebombProjectile();
  40. // Unique identifier.
  41. virtual int GetWeaponID( void ) const;
  42. int GetType( void ) const { return m_iType; }
  43. virtual int GetDamageType();
  44. bool HasStickyEffects() const { return m_iType == TF_GL_MODE_REMOTE_DETONATE || m_iType == TF_GL_MODE_REMOTE_DETONATE_PRACTICE; }
  45. bool ShouldMiniCritOnReflect() const;
  46. void SetChargeTime( float flChargeTime ) { m_flChargeTime = flChargeTime; }
  47. CNetworkVar( bool, m_bTouched );
  48. CNetworkVar( int, m_iType ); // TF_GL_MODE_REGULAR or TF_GL_MODE_REMOTE_DETONATE
  49. float m_flCreationTime;
  50. float m_flChargeTime;
  51. bool m_bPulsed;
  52. float m_flFullDamage;
  53. void SetFullDamage( float flFullDamage ) { m_flFullDamage = flFullDamage; }
  54. CNetworkVar( bool, m_bDefensiveBomb );
  55. virtual void UpdateOnRemove( void );
  56. virtual void SetCustomPipebombModel() {}
  57. virtual float GetLiveTime( void );
  58. virtual float GetDamageRadius() OVERRIDE;
  59. void SetDetonateOnPulse( bool bDet ) { m_bDetonateOnPulse = bDet; }
  60. #ifdef CLIENT_DLL
  61. virtual void OnDataChanged( DataUpdateType_t updateType );
  62. virtual const char *GetTrailParticleName( void );
  63. virtual int DrawModel( int flags );
  64. virtual void Simulate( void );
  65. virtual void CreateTrailParticles( void );
  66. void SetHighlight( bool bHighlight ) { if ( m_bPulsed ) m_bHighlight = bHighlight; }
  67. bool IsHighlighted( void ) { return m_bHighlight; }
  68. int m_iCachedDeflect;
  69. CNewParticleEffect *pEffectTrail;
  70. CNewParticleEffect *pEffectCrit;
  71. bool m_bHighlight;
  72. bool m_bDetonateOnPulse;
  73. CGlowObject *m_pGlowEffect;
  74. #else
  75. DECLARE_DATADESC();
  76. // Creation.
  77. static CTFGrenadePipebombProjectile *Create( const Vector &position, const QAngle &angles, const Vector &velocity,
  78. const AngularImpulse &angVelocity, CBaseCombatCharacter *pOwner, const CTFWeaponInfo &weaponInfo, int iPipeBombType, float flMultDmg );
  79. static const char* GetPipebombClass( int iPipeBombType );
  80. // Overrides.
  81. virtual void Spawn();
  82. virtual void Precache();
  83. virtual void BounceSound( void );
  84. virtual void Detonate();
  85. virtual void Fizzle();
  86. virtual bool DetonateStickies( void );
  87. bool CanTakeDamage() const { return m_bCanTakeDamage; }
  88. void SetCanTakeDamage( bool bCanTakeDamage ) { m_bCanTakeDamage = bCanTakeDamage; }
  89. virtual void SetPipebombMode( int iPipebombMode = TF_GL_MODE_REGULAR );
  90. bool IsFizzle() { return m_bFizzle; }
  91. virtual void PipebombTouch( CBaseEntity *pOther );
  92. virtual void StickybombTouch( CBaseEntity *pOther );
  93. virtual void VPhysicsCollision( int index, gamevcollisionevent_t *pEvent );
  94. virtual int OnTakeDamage( const CTakeDamageInfo &info );
  95. virtual void IncrementDeflected( void );
  96. virtual void DetonateThink( void );
  97. virtual void PreArmThink( void );
  98. virtual void ArmThink( void );
  99. void CreatePipebombGibs( void );
  100. virtual bool IsDeflectable( void ) { return true; }
  101. virtual void Deflected( CBaseEntity *pDeflectedBy, Vector& vecDir );
  102. virtual int GetDamageCustom();
  103. float GetTouchedTime() { return m_flTouchedTime; }
  104. bool IsTouched() { return m_bTouched; }
  105. public:
  106. bool m_bFizzle;
  107. bool m_bWallShatter;
  108. private:
  109. float m_flMinSleepTime;
  110. float m_flDeflectedTime;
  111. bool m_bSendPlayerDestroyedEvent;
  112. bool m_bDetonateOnPulse;
  113. bool m_bCanTakeDamage;
  114. float m_flTouchedTime;
  115. float GetDamageScaleOnWorldContact();
  116. CUtlVector < CHandle <CTFPlayer> > m_CritMedics;
  117. CUtlVector < CHandle <CBaseEntity> > m_penetratedEntities;
  118. #endif
  119. };
  120. #endif // TF_WEAPON_GRENADE_PIPEBOMB_H