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.

141 lines
3.7 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. //
  4. //=============================================================================
  5. #ifndef TF_WEAPON_GRENADELAUNCHER_H
  6. #define TF_WEAPON_GRENADELAUNCHER_H
  7. #ifdef _WIN32
  8. #pragma once
  9. #endif
  10. #include "tf_weaponbase_gun.h"
  11. #include "tf_weaponbase_grenadeproj.h"
  12. // Client specific.
  13. #ifdef CLIENT_DLL
  14. #define CTFGrenadeLauncher C_TFGrenadeLauncher
  15. #define CTFCannon C_TFCannon
  16. #endif
  17. #define TF_GRENADE_LAUNCHER_XBOX_CLIP 4
  18. //=============================================================================
  19. //
  20. // TF Weapon Grenade Launcher.
  21. //
  22. class CTFGrenadeLauncher : public CTFWeaponBaseGun, public ITFChargeUpWeapon
  23. {
  24. public:
  25. DECLARE_CLASS( CTFGrenadeLauncher, CTFWeaponBaseGun );
  26. DECLARE_NETWORKCLASS();
  27. DECLARE_PREDICTABLE();
  28. // Server specific.
  29. #ifdef GAME_DLL
  30. DECLARE_DATADESC();
  31. #endif
  32. CTFGrenadeLauncher();
  33. ~CTFGrenadeLauncher();
  34. virtual void Spawn( void );
  35. virtual int GetWeaponID( void ) const { return TF_WEAPON_GRENADELAUNCHER; }
  36. virtual void SecondaryAttack();
  37. virtual void FireFullClipAtOnce( void );
  38. //virtual CBaseEntity* FirePipeBomb( CTFPlayer *pPlayer, int iPipeBombType );
  39. virtual bool Holster( CBaseCombatWeapon *pSwitchingTo );
  40. virtual bool Deploy( void );
  41. virtual void PrimaryAttack( void );
  42. virtual void ItemPostFrame( void );
  43. virtual void Misfire( void );
  44. virtual void WeaponIdle( void );
  45. virtual bool SendWeaponAnim( int iActivity );
  46. virtual void WeaponReset( void );
  47. virtual float GetProjectileSpeed( void );
  48. int GetDetonateMode( void ) const;
  49. virtual bool Reload( void );
  50. virtual int GetMaxClip1( void ) const;
  51. virtual int GetDefaultClip1( void ) const;
  52. virtual bool IsBlastImpactWeapon( void ) const { return true; }
  53. // ITFChargeUpWeapon
  54. virtual bool CanCharge( void );
  55. virtual float GetChargeBeginTime( void );
  56. virtual float GetChargeMaxTime( void );
  57. void LaunchGrenade( void );
  58. void AddDonkVictim( const CBaseEntity* pVictim );
  59. bool IsDoubleDonk( const CBaseEntity* pVictim ) const;
  60. private:
  61. CTFGrenadeLauncher( const CTFGrenadeLauncher & ) {}
  62. int m_nLauncherSlot;
  63. void FireProjectileInternal( CTFPlayer* pTFPlayer );
  64. void PostFire();
  65. void ResetDetonateTime();
  66. float GetMortarDetonateTimeLength();
  67. CNetworkVar( float, m_flDetonateTime );
  68. // Barrel rotation needs to be in sync
  69. CNetworkVar( int, m_iCurrentTube ); // Which tube is the one we just fired out of
  70. CNetworkVar( int, m_iGoalTube ); // Which tube is the one we would like to fire out of next?
  71. int m_iBarrelBone;
  72. float m_flBarrelRotateBeginTime; // What time did we begin the animation to rotate to the next barrel?
  73. float m_flBarrelAngle; // What is the current rotation of the barrel?
  74. bool m_bCurrentAndGoalTubeEqual;
  75. #ifdef CLIENT_DLL
  76. void StartChargeEffects();
  77. void StopChargeEffects();
  78. CNewParticleEffect *m_pCannonFuseSparkEffect;
  79. CNewParticleEffect *m_pCannonCharge;
  80. // Barrel spinning (cribbed from Minigun)
  81. virtual CStudioHdr *OnNewModel( void );
  82. virtual void StandardBlendingRules( CStudioHdr *hdr, Vector pos[], Quaternion q[], float currentTime, int boneMask );
  83. virtual void OnDataChanged( DataUpdateType_t type );
  84. void UpdateBarrelMovement( void );
  85. virtual void ViewModelAttachmentBlending( CStudioHdr *hdr, Vector pos[], Quaternion q[], float currentTime, int boneMask );
  86. #endif // CLIENT_DLL
  87. virtual void ItemPreFrame( void );
  88. struct Donks_t
  89. {
  90. CHandle <CBaseEntity> m_hVictim;
  91. float m_flExpireTime;
  92. };
  93. CUtlVector< Donks_t > m_vecDonkVictims;
  94. };
  95. class CTFCannon : public CTFGrenadeLauncher
  96. {
  97. public:
  98. DECLARE_CLASS( CTFCannon, CTFGrenadeLauncher );
  99. DECLARE_NETWORKCLASS();
  100. DECLARE_PREDICTABLE();
  101. virtual int GetWeaponID( void ) const { return TF_WEAPON_CANNON; }
  102. };
  103. #endif // TF_WEAPON_GRENADELAUNCHER_H