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.

195 lines
5.2 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // TF Rocket Launcher
  4. //
  5. //=============================================================================
  6. #ifndef TF_WEAPON_ROCKETLAUNCHER_H
  7. #define TF_WEAPON_ROCKETLAUNCHER_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "tf_weaponbase_gun.h"
  12. #include "tf_weaponbase_rocket.h"
  13. #include "tf_weapon_sniperrifle.h"
  14. #ifdef CLIENT_DLL
  15. #include "particle_property.h"
  16. #endif
  17. // Client specific.
  18. #ifdef CLIENT_DLL
  19. #define CTFRocketLauncher C_TFRocketLauncher
  20. #define CTFRocketLauncher_DirectHit C_TFRocketLauncher_DirectHit
  21. #define CTFRocketLauncher_AirStrike C_TFRocketLauncher_AirStrike
  22. #define CTFRocketLauncher_Mortar C_TFRocketLauncher_Mortar
  23. #define CTFCrossbow C_TFCrossbow
  24. #endif // CLIENT_DLL
  25. //=============================================================================
  26. //
  27. // TF Weapon Rocket Launcher.
  28. //
  29. class CTFRocketLauncher : public CTFWeaponBaseGun
  30. {
  31. public:
  32. DECLARE_CLASS( CTFRocketLauncher, CTFWeaponBaseGun );
  33. DECLARE_NETWORKCLASS();
  34. DECLARE_PREDICTABLE();
  35. // Server specific.
  36. #ifdef GAME_DLL
  37. DECLARE_DATADESC();
  38. #endif
  39. CTFRocketLauncher();
  40. ~CTFRocketLauncher();
  41. #ifndef CLIENT_DLL
  42. virtual void Precache();
  43. #endif
  44. virtual void ModifyEmitSoundParams( EmitSound_t &params );
  45. virtual int GetWeaponID( void ) const { return TF_WEAPON_ROCKETLAUNCHER; }
  46. virtual void Misfire( void );
  47. virtual CBaseEntity *FireProjectile( CTFPlayer *pPlayer );
  48. virtual void ItemPostFrame( void );
  49. virtual bool DefaultReload( int iClipSize1, int iClipSize2, int iActivity );
  50. virtual int GetWeaponProjectileType( void ) const OVERRIDE;
  51. virtual bool IsBlastImpactWeapon( void ) const { return !IsEnergyWeapon(); }
  52. virtual bool CheckReloadMisfire( void ) OVERRIDE;
  53. virtual bool ShouldBlockPrimaryFire() OVERRIDE;
  54. #ifdef CLIENT_DLL
  55. virtual void CreateMuzzleFlashEffects( C_BaseEntity *pAttachEnt, int nIndex );
  56. #endif
  57. private:
  58. float m_flShowReloadHintAt;
  59. // Since the ammo in the clip can be predicted/networked out of order from when the reload sound happens
  60. // We need to keep track of this invividually on client and server to modify the pitch
  61. int m_nReloadPitchStep;
  62. #ifdef GAME_DLL
  63. int m_iConsecutiveCrits;
  64. bool m_bIsOverloading;
  65. #endif
  66. CTFRocketLauncher( const CTFRocketLauncher & ) {}
  67. };
  68. // ------------------------------------------------------------------------------------------------------------------------
  69. class CTFRocketLauncher_DirectHit : public CTFRocketLauncher
  70. {
  71. public:
  72. DECLARE_CLASS( CTFRocketLauncher_DirectHit, CTFRocketLauncher );
  73. DECLARE_NETWORKCLASS();
  74. DECLARE_PREDICTABLE();
  75. // Server specific.
  76. #ifdef GAME_DLL
  77. DECLARE_DATADESC();
  78. #endif
  79. virtual int GetWeaponID( void ) const { return TF_WEAPON_ROCKETLAUNCHER_DIRECTHIT; }
  80. };
  81. // ------------------------------------------------------------------------------------------------------------------------
  82. class CTFRocketLauncher_AirStrike : public CTFRocketLauncher
  83. {
  84. public:
  85. DECLARE_CLASS( CTFRocketLauncher_AirStrike, CTFRocketLauncher );
  86. DECLARE_NETWORKCLASS();
  87. DECLARE_PREDICTABLE();
  88. // Server specific.
  89. #ifdef GAME_DLL
  90. DECLARE_DATADESC();
  91. #endif
  92. CTFRocketLauncher_AirStrike();
  93. virtual int GetWeaponID( void ) const { return TF_WEAPON_ROCKETLAUNCHER; }
  94. const char* GetEffectLabelText( void ) { return "#TF_KILLS"; }
  95. virtual int GetCount( void );
  96. #ifdef GAME_DLL
  97. virtual void OnPlayerKill( CTFPlayer *pVictim, const CTakeDamageInfo &info );
  98. #endif
  99. };
  100. // ------------------------------------------------------------------------------------------------------------------------
  101. class CTFRocketLauncher_Mortar : public CTFRocketLauncher
  102. {
  103. public:
  104. DECLARE_CLASS( CTFRocketLauncher_Mortar, CTFRocketLauncher );
  105. DECLARE_NETWORKCLASS();
  106. DECLARE_PREDICTABLE();
  107. // Server specific.
  108. #ifdef GAME_DLL
  109. DECLARE_DATADESC();
  110. #endif
  111. //CTFRocketLauncher_Mortar();
  112. virtual int GetWeaponID( void ) const { return TF_WEAPON_ROCKETLAUNCHER; }
  113. virtual CBaseEntity *FireProjectile( CTFPlayer *pPlayer );
  114. virtual void SecondaryAttack( void );
  115. virtual void ItemPostFrame( void );
  116. virtual void ItemBusyFrame( void );
  117. private:
  118. void RedirectRockets();
  119. #ifdef GAME_DLL
  120. CUtlVector< EHANDLE > m_vecRockets;
  121. #endif // GAME_DLL
  122. };
  123. // ------------------------------------------------------------------------------------------------------------------------
  124. class CTFCrossbow : public CTFRocketLauncher
  125. {
  126. public:
  127. DECLARE_CLASS( CTFCrossbow, CTFRocketLauncher );
  128. DECLARE_NETWORKCLASS();
  129. DECLARE_PREDICTABLE();
  130. // Server specific.
  131. #ifdef GAME_DLL
  132. DECLARE_DATADESC();
  133. #endif
  134. virtual bool Holster( CBaseCombatWeapon *pSwitchingTo ) OVERRIDE;
  135. virtual int GetWeaponID( void ) const { return TF_WEAPON_CROSSBOW; }
  136. virtual void SecondaryAttack( void );
  137. virtual float GetProjectileSpeed( void );
  138. virtual float GetProjectileGravity( void );
  139. virtual bool IsViewModelFlipped( void );
  140. virtual void ItemPostFrame( void );
  141. virtual void ModifyProjectile( CBaseEntity* pProj );
  142. virtual void WeaponRegenerate( void );
  143. float GetProgress( void );
  144. const char* GetEffectLabelText( void ) { return "#TF_BOLT"; }
  145. CNetworkVar( float, m_flRegenerateDuration );
  146. CNetworkVar( float, m_flLastUsedTimestamp );
  147. private:
  148. bool m_bMilkNextAttack;
  149. };
  150. #endif // TF_WEAPON_ROCKETLAUNCHER_H