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.

206 lines
5.4 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. //
  4. //=============================================================================
  5. #ifndef TF_WEAPON_MINIGUN_H
  6. #define TF_WEAPON_MINIGUN_H
  7. #ifdef _WIN32
  8. #pragma once
  9. #endif
  10. #include "GameEventListener.h"
  11. #include "tf_weaponbase_gun.h"
  12. #ifdef CLIENT_DLL
  13. #include "particles_new.h"
  14. #endif
  15. // Client specific.
  16. #ifdef CLIENT_DLL
  17. #define CTFMinigun C_TFMinigun
  18. #endif
  19. #ifdef GAME_DLL
  20. class ITFProjectile;
  21. #endif // GAME_DLL
  22. enum MinigunState_t
  23. {
  24. // Firing states.
  25. AC_STATE_IDLE = 0,
  26. AC_STATE_STARTFIRING,
  27. AC_STATE_FIRING,
  28. AC_STATE_SPINNING,
  29. AC_STATE_DRYFIRE
  30. };
  31. enum minigun_weapontypes_t
  32. {
  33. MINIGUN_STANDARD = 0,
  34. MINIGUN_STUN, // Natascha
  35. };
  36. //=============================================================================
  37. //
  38. // TF Weapon Minigun
  39. //
  40. class CTFMinigun : public CTFWeaponBaseGun
  41. {
  42. public:
  43. DECLARE_CLASS( CTFMinigun, CTFWeaponBaseGun );
  44. DECLARE_NETWORKCLASS();
  45. DECLARE_PREDICTABLE();
  46. // Server specific.
  47. #ifndef CLIENT_DLL
  48. DECLARE_DATADESC();
  49. #endif
  50. CTFMinigun();
  51. ~CTFMinigun();
  52. virtual void Precache( void );
  53. virtual int GetWeaponID( void ) const { return TF_WEAPON_MINIGUN; }
  54. virtual void ItemPostFrame( void );
  55. virtual void PrimaryAttack();
  56. virtual void SecondaryAttack();
  57. void SharedAttack();
  58. virtual void WeaponIdle();
  59. virtual bool SendWeaponAnim( int iActivity );
  60. virtual bool CanHolster( void ) const;
  61. virtual bool Holster( CBaseCombatWeapon *pSwitchingTo );
  62. virtual bool HolsterOnDetach() { return true; }
  63. virtual bool Lower( void );
  64. virtual void HandleFireOnEmpty( void );
  65. virtual void WeaponReset( void );
  66. virtual float GetProjectileDamage( void );
  67. virtual bool ShouldDoMuzzleFlash( void ) { return false; }
  68. virtual float GetWeaponSpread( void );
  69. virtual void FireGameEvent( IGameEvent *event );
  70. #ifdef GAME_DLL
  71. virtual int UpdateTransmitState( void );
  72. void AttackEnemyProjectiles( void );
  73. void ActivatePushBackAttackMode( void );
  74. #endif
  75. void RingOfFireAttack( int nDamage );
  76. virtual int GetCustomDamageType() const { return TF_DMG_CUSTOM_MINIGUN; }
  77. int GetMinigunType( void ) const { int iMode = 0; CALL_ATTRIB_HOOK_INT( iMode, set_weapon_mode ); return iMode; };
  78. bool HasSpinSounds( void ) const { int iMode = 0; CALL_ATTRIB_HOOK_INT( iMode, minigun_no_spin_sounds ); return iMode!=1; };
  79. bool CanHolsterWhileSpinning( void ) const { int iMode = 0; CALL_ATTRIB_HOOK_INT( iMode, mod_minigun_can_holster_while_spinning ); return iMode!=0; };
  80. float GetFiringDuration( void ) { return ( m_flStartedFiringAt >= 0.f ) ? ( gpGlobals->curtime - m_flStartedFiringAt ) : 0.f; }
  81. float GetWindUpDuration( void ) { return ( m_flStartedWindUpAt >= 0.f ) ? ( gpGlobals->curtime - m_flStartedWindUpAt ) : 0.f; }
  82. float GetProgress( void );
  83. bool IsRageFull( void ); // same as GetProgress() without the division by 100.0f
  84. const char* GetEffectLabelText( void ) { return "#TF_Rage"; }
  85. bool EffectMeterShouldFlash( void );
  86. virtual bool CanInspect() const OVERRIDE;
  87. #ifdef GAME_DLL
  88. virtual CDmgAccumulator *GetDmgAccumulator( void ) { return &m_Accumulator; }
  89. #endif // GAME_DLL
  90. #ifdef CLIENT_DLL
  91. float GetBarrelRotation();
  92. #endif
  93. private:
  94. CTFMinigun( const CTFMinigun & ) {}
  95. void WindUp( void );
  96. void WindDown( void );
  97. #ifdef GAME_DLL
  98. CDmgAccumulator m_Accumulator;
  99. #endif // GAME_DLL
  100. #ifdef CLIENT_DLL
  101. // Barrel spinning
  102. virtual CStudioHdr *OnNewModel( void );
  103. virtual void StandardBlendingRules( CStudioHdr *hdr, Vector pos[], Quaternion q[], float currentTime, int boneMask );
  104. virtual void UpdateOnRemove( void );
  105. void CreateMove( float flInputSampleTime, CUserCmd *pCmd, const QAngle &vecOldViewAngles );
  106. void OnDataChanged( DataUpdateType_t type );
  107. virtual void ItemPreFrame( void );
  108. // Firing sound
  109. void WeaponSoundUpdate( void );
  110. void PlayStopFiringSound();
  111. void UpdateBarrelMovement( void );
  112. virtual void SetDormant( bool bDormant );
  113. virtual void ViewModelAttachmentBlending( CStudioHdr *hdr, Vector pos[], Quaternion q[], float currentTime, int boneMask );
  114. #endif
  115. virtual bool CanReload( void ){ return false; }
  116. private:
  117. virtual void PlayWeaponShootSound( void ) {} // override base class call to play shoot sound; we handle that ourselves separately
  118. void SetWeaponState( MinigunState_t nState );
  119. CNetworkVar( MinigunState_t, m_iWeaponState );
  120. CNetworkVar( bool, m_bCritShot );
  121. float m_flNextFiringSpeech;
  122. float m_flStartedFiringAt;
  123. float m_flStartedWindUpAt;
  124. float m_flBarrelCurrentVelocity;
  125. float m_flBarrelTargetVelocity;
  126. int m_iBarrelBone;
  127. float m_flBarrelAngle;
  128. CSoundPatch *m_pSoundCur; // the weapon sound currently being played
  129. int m_iMinigunSoundCur; // the enum value of the weapon sound currently being played
  130. float m_flMinigunSoundCurrentPitch;
  131. #ifdef GAME_DLL
  132. float m_flAegisCheckTime;
  133. #endif
  134. float m_flNextRingOfFireAttackTime;
  135. float m_flAccumulatedAmmoDrain;
  136. float m_flLastAmmoDrainTime;
  137. bool m_bAttack3Down;
  138. #ifdef CLIENT_DLL
  139. void StartBrassEffect();
  140. void StopBrassEffect();
  141. void HandleBrassEffect();
  142. EHANDLE m_hEjectBrassWeapon;
  143. CNewParticleEffect *m_pEjectBrassEffect;
  144. int m_iEjectBrassAttachment;
  145. void StartMuzzleEffect();
  146. void StopMuzzleEffect();
  147. void HandleMuzzleEffect();
  148. EHANDLE m_hMuzzleEffectWeapon;
  149. CNewParticleEffect *m_pMuzzleEffect;
  150. int m_iMuzzleAttachment;
  151. int m_nShotsFired;
  152. bool m_bRageDraining;
  153. bool m_bPrevRageDraining;
  154. MinigunState_t m_iPrevMinigunState;
  155. #endif
  156. };
  157. #endif // TF_WEAPON_MINIGUN_H