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.

131 lines
3.8 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. #ifndef TF_WEAPON_PIPEBOMBLAUNCHER_H
  7. #define TF_WEAPON_PIPEBOMBLAUNCHER_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "tf_weaponbase_gun.h"
  12. #include "tf_weapon_grenade_pipebomb.h"
  13. // Client specific.
  14. #ifdef CLIENT_DLL
  15. #define CTFPipebombLauncher C_TFPipebombLauncher
  16. #endif
  17. #define TF_PIPEBOMB_MAX_CHARGE_TIME 4.0f
  18. #define TF_DETONATE_MODE_STANDARD 0
  19. #define TF_DETONATE_MODE_DOT 1
  20. #define TF_DETONATE_MODE_AIR 2
  21. // hard code these eventually
  22. #define TF_PIPEBOMB_MIN_CHARGE_VEL 900
  23. #define TF_PIPEBOMB_MAX_CHARGE_VEL 2400
  24. //=============================================================================
  25. //
  26. // TF Weapon Pipebomb Launcher.
  27. //
  28. #ifdef GAME_DLL
  29. class CTFPipebombLauncher : public CTFWeaponBaseGun, public ITFChargeUpWeapon, public IEntityListener
  30. #else
  31. class CTFPipebombLauncher : public CTFWeaponBaseGun, public ITFChargeUpWeapon
  32. #endif
  33. {
  34. public:
  35. DECLARE_CLASS( CTFPipebombLauncher, CTFWeaponBaseGun );
  36. DECLARE_NETWORKCLASS();
  37. DECLARE_PREDICTABLE();
  38. // Server specific.
  39. #ifdef GAME_DLL
  40. DECLARE_DATADESC();
  41. #endif
  42. CTFPipebombLauncher();
  43. ~CTFPipebombLauncher();
  44. virtual void Spawn( void );
  45. virtual int GetWeaponID( void ) const { return TF_WEAPON_PIPEBOMBLAUNCHER; }
  46. virtual CBaseEntity *FireProjectile( CTFPlayer *pPlayer );
  47. virtual void ItemBusyFrame( void );
  48. virtual void ItemPostFrame( void );
  49. virtual void SecondaryAttack();
  50. virtual bool Holster( CBaseCombatWeapon *pSwitchingTo );
  51. virtual bool Deploy( void );
  52. virtual void PrimaryAttack( void );
  53. virtual void WeaponIdle( void );
  54. virtual float GetProjectileSpeed( void );
  55. virtual bool Reload( void );
  56. virtual void WeaponReset( void );
  57. public:
  58. // ITFChargeUpWeapon
  59. virtual bool CanCharge() { return true; }
  60. virtual float GetChargeBeginTime( void ) { return m_flChargeBeginTime; }
  61. virtual float GetChargeMaxTime( void ) { float flChargeTime = TF_PIPEBOMB_MAX_CHARGE_TIME; CALL_ATTRIB_HOOK_FLOAT( flChargeTime, stickybomb_charge_rate ) return flChargeTime; }
  62. virtual float GetChargeForceReleaseTime( void ) { return GetChargeMaxTime(); }
  63. int GetPipeBombCount( void ) { return m_iPipebombCount; }
  64. const CUtlVector< CHandle< CTFGrenadePipebombProjectile > > &GetPipeBombVector( void ) const;
  65. int GetDetonateMode( void ) const { int iMode = 0; CALL_ATTRIB_HOOK_INT( iMode, set_detonate_mode ); return iMode; };
  66. bool CanDestroyStickies( void ) const { int iMode = 0; CALL_ATTRIB_HOOK_INT( iMode, stickies_detonate_stickies ); return (iMode == 1); };
  67. virtual void LaunchGrenade( void );
  68. virtual void ForceLaunchGrenade( void ) { LaunchGrenade(); }
  69. virtual bool DetonateRemotePipebombs( bool bFizzle );
  70. virtual bool ModifyPipebombsInView( int iEffect );
  71. virtual void AddPipeBomb( CTFGrenadePipebombProjectile *pBomb );
  72. void DeathNotice( CBaseEntity *pVictim );
  73. #ifdef CLIENT_DLL
  74. void BombHighlightThink( void );
  75. #endif
  76. #ifdef GAME_DLL
  77. void UpdateOnRemove( void );
  78. virtual void ApplyPostHitEffects( const CTakeDamageInfo &inputInfo, CTFPlayer *pPlayer );
  79. protected:
  80. // This is here so we can network the pipebomb count for prediction purposes
  81. CNetworkVar( int, m_iPipebombCount );
  82. #endif
  83. #ifdef CLIENT_DLL
  84. int m_iPipebombCount;
  85. float m_flNextBombCheckTime;
  86. bool m_bBombThinking;
  87. #endif
  88. // List of active pipebombs
  89. typedef CHandle<CTFGrenadePipebombProjectile> PipebombHandle;
  90. CUtlVector<PipebombHandle> m_Pipebombs;
  91. CNetworkVar( float, m_flChargeBeginTime );
  92. float m_flLastDenySoundTime;
  93. bool m_bNoAutoRelease;
  94. bool m_bWantsToShoot;
  95. private:
  96. CTFPipebombLauncher( const CTFPipebombLauncher & ) {}
  97. };
  98. inline const CUtlVector< CHandle< CTFGrenadePipebombProjectile > > &CTFPipebombLauncher::GetPipeBombVector( void ) const
  99. {
  100. return m_Pipebombs;
  101. }
  102. #endif // TF_WEAPON_PIPEBOMBLAUNCHER_H