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.

110 lines
3.3 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Weapon Base Gun
  4. //
  5. //=============================================================================
  6. #ifndef TF_WEAPONBASE_GUN_H
  7. #define TF_WEAPONBASE_GUN_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "tf_shareddefs.h"
  12. #include "tf_weaponbase.h"
  13. #define CREATE_SIMPLE_WEAPON_TABLE( WpnName, entityname ) \
  14. \
  15. IMPLEMENT_NETWORKCLASS_ALIASED( WpnName, DT_##WpnName ) \
  16. \
  17. BEGIN_NETWORK_TABLE( C##WpnName, DT_##WpnName ) \
  18. END_NETWORK_TABLE() \
  19. \
  20. BEGIN_PREDICTION_DATA( C##WpnName ) \
  21. END_PREDICTION_DATA() \
  22. \
  23. LINK_ENTITY_TO_CLASS( entityname, C##WpnName ); \
  24. PRECACHE_WEAPON_REGISTER( entityname );
  25. #if defined( CLIENT_DLL )
  26. #define CTFWeaponBaseGun C_TFWeaponBaseGun
  27. #endif
  28. #define ZOOM_CONTEXT "ZoomContext"
  29. #define ZOOM_REZOOM_TIME 1.4f
  30. //=============================================================================
  31. //
  32. // Weapon Base Melee Gun
  33. //
  34. class CTFWeaponBaseGun : public CTFWeaponBase
  35. {
  36. public:
  37. DECLARE_CLASS( CTFWeaponBaseGun, CTFWeaponBase );
  38. DECLARE_NETWORKCLASS();
  39. DECLARE_PREDICTABLE();
  40. #if !defined( CLIENT_DLL )
  41. DECLARE_DATADESC();
  42. #endif
  43. CTFWeaponBaseGun();
  44. virtual void PrimaryAttack();
  45. virtual void SecondaryAttack( void );
  46. virtual bool Holster( CBaseCombatWeapon *pSwitchingTo );
  47. // Derived classes call this to fire a bullet.
  48. //bool TFBaseGunFire( void );
  49. virtual void DoFireEffects();
  50. virtual bool ShouldDoMuzzleFlash( void ) { return true; }
  51. void ToggleZoom( void );
  52. virtual int GetWeaponProjectileType( void ) const { return m_pWeaponInfo->GetWeaponData( m_iWeaponMode ).m_iProjectile; }
  53. virtual CBaseEntity *FireProjectile( CTFPlayer *pPlayer );
  54. virtual void RemoveProjectileAmmo( CTFPlayer *pPlayer );
  55. virtual void ModifyProjectile( CBaseEntity* pProj ) {};
  56. virtual void FireBullet( CTFPlayer *pPlayer );
  57. CBaseEntity *FireRocket( CTFPlayer *pPlayer, int iRocketType=0 );
  58. CBaseEntity *FireNail( CTFPlayer *pPlayer, int iSpecificNail );
  59. virtual CBaseEntity *FirePipeBomb( CTFPlayer *pPlayer, int iPipeBombType );
  60. CBaseEntity *FireFlare( CTFPlayer *pPlayer );
  61. virtual CBaseEntity *FireArrow( CTFPlayer *pPlayer, ProjectileType_t projectileType );
  62. virtual CBaseEntity *FireJar( CTFPlayer *pPlayer );
  63. virtual CBaseEntity *FireFlameRocket( CTFPlayer *pPlayer );
  64. virtual CBaseEntity *FireEnergyBall( CTFPlayer *pPlayer, bool bRing=false );
  65. virtual bool HasLastShotCritical( void );
  66. virtual float GetWeaponSpread( void );
  67. virtual void GetCustomProjectileModel( CAttribute_String *attrCustomProjModel );
  68. virtual float GetProjectileSpeed( void ) { return 0.0f; }
  69. virtual float GetProjectileGravity( void ) { return 0.f; }
  70. virtual float GetProjectileSpread( void ) { return 0.0f; }
  71. virtual int GetAmmoPerShot( void );
  72. void UpdatePunchAngles( CTFPlayer *pPlayer );
  73. virtual float GetProjectileDamage( void );
  74. virtual bool ShouldPlayFireAnim( void ) { return true; }
  75. virtual void ZoomIn( void );
  76. virtual void ZoomOut( void );
  77. void ZoomOutIn( void );
  78. virtual void PlayWeaponShootSound( void );
  79. virtual bool HasPrimaryAmmo( void );
  80. virtual bool CanDeploy( void );
  81. virtual bool CanBeSelected( void );
  82. virtual bool ShouldRemoveDisguiseOnPrimaryAttack() const;
  83. private:
  84. CTFWeaponBaseGun( const CTFWeaponBaseGun & );
  85. };
  86. #endif // TF_WEAPONBASE_GUN_H