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.

155 lines
4.2 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #include "cbase.h"
  7. #include "weapon_dodsniper.h"
  8. #if defined( CLIENT_DLL )
  9. #define CWeaponK98Scoped C_WeaponK98Scoped
  10. #endif
  11. class CWeaponK98Scoped : public CDODSniperWeapon
  12. {
  13. public:
  14. DECLARE_CLASS( CWeaponK98Scoped, CDODSniperWeapon );
  15. DECLARE_NETWORKCLASS();
  16. DECLARE_PREDICTABLE();
  17. DECLARE_ACTTABLE();
  18. CWeaponK98Scoped() {}
  19. virtual void Spawn( void );
  20. virtual DODWeaponID GetWeaponID( void ) const { return WEAPON_K98_SCOPED; }
  21. // weapon id for stats purposes
  22. virtual DODWeaponID GetStatsWeaponID( void )
  23. {
  24. if ( IsFullyZoomed() )
  25. return WEAPON_K98_SCOPED_ZOOMED;
  26. else
  27. return WEAPON_K98_SCOPED;
  28. }
  29. virtual bool ShouldAutoEjectBrass( void ) { return false; }
  30. virtual bool ShouldDrawCrosshair( void ) { return false; }
  31. virtual bool ShouldDrawViewModel( void )
  32. {
  33. CBasePlayer *pPlayer = ToBasePlayer( GetOwner() );
  34. Assert( pPlayer );
  35. if ( !pPlayer )
  36. return false;
  37. if ( pPlayer->GetFOV() < 90 )
  38. return false;
  39. // handle case when we are spectating someone and don't know their fov
  40. if ( IsFullyZoomed() )
  41. return false;
  42. return BaseClass::ShouldDrawViewModel();
  43. }
  44. virtual bool ShouldDrawMuzzleFlash( void )
  45. {
  46. return ShouldDrawViewModel();
  47. }
  48. virtual Activity GetPrimaryAttackActivity( void );
  49. virtual float GetFireDelay( void );
  50. virtual float GetRecoil( void ) { return 6.0f; }
  51. private:
  52. CWeaponK98Scoped( const CWeaponK98Scoped & );
  53. };
  54. IMPLEMENT_NETWORKCLASS_ALIASED( WeaponK98Scoped, DT_WeaponK98Scoped )
  55. BEGIN_NETWORK_TABLE( CWeaponK98Scoped, DT_WeaponK98Scoped )
  56. END_NETWORK_TABLE()
  57. BEGIN_PREDICTION_DATA( CWeaponK98Scoped )
  58. END_PREDICTION_DATA()
  59. LINK_ENTITY_TO_CLASS( weapon_k98_scoped, CWeaponK98Scoped );
  60. PRECACHE_WEAPON_REGISTER( weapon_k98_scoped );
  61. void CWeaponK98Scoped::Spawn( void )
  62. {
  63. m_iAltFireHint = HINT_USE_ZOOM;
  64. BaseClass::Spawn();
  65. }
  66. acttable_t CWeaponK98Scoped::m_acttable[] =
  67. {
  68. { ACT_DOD_STAND_AIM, ACT_DOD_STAND_AIM_BOLT, false },
  69. { ACT_DOD_CROUCH_AIM, ACT_DOD_CROUCH_AIM_BOLT, false },
  70. { ACT_DOD_CROUCHWALK_AIM, ACT_DOD_CROUCHWALK_AIM_BOLT, false },
  71. { ACT_DOD_WALK_AIM, ACT_DOD_WALK_AIM_BOLT, false },
  72. { ACT_DOD_RUN_AIM, ACT_DOD_RUN_AIM_BOLT, false },
  73. { ACT_PRONE_IDLE, ACT_DOD_PRONE_AIM_BOLT, false },
  74. { ACT_PRONE_FORWARD, ACT_DOD_PRONEWALK_IDLE_BOLT, false },
  75. { ACT_DOD_STAND_IDLE, ACT_DOD_STAND_IDLE_BOLT, false },
  76. { ACT_DOD_CROUCH_IDLE, ACT_DOD_CROUCH_IDLE_BOLT, false },
  77. { ACT_DOD_CROUCHWALK_IDLE, ACT_DOD_CROUCHWALK_IDLE_BOLT, false },
  78. { ACT_DOD_WALK_IDLE, ACT_DOD_WALK_IDLE_BOLT, false },
  79. { ACT_DOD_RUN_IDLE, ACT_DOD_RUN_IDLE_BOLT, false },
  80. { ACT_SPRINT, ACT_DOD_SPRINT_IDLE_BOLT, false },
  81. // Zoomed Aim
  82. { ACT_DOD_IDLE_ZOOMED, ACT_DOD_STAND_ZOOM_BOLT, false },
  83. { ACT_DOD_CROUCH_ZOOMED, ACT_DOD_CROUCH_ZOOM_BOLT, false },
  84. { ACT_DOD_CROUCHWALK_ZOOMED, ACT_DOD_CROUCHWALK_ZOOM_BOLT, false },
  85. { ACT_DOD_WALK_ZOOMED, ACT_DOD_WALK_ZOOM_BOLT, false },
  86. { ACT_DOD_PRONE_ZOOMED, ACT_DOD_PRONE_ZOOM_BOLT, false },
  87. { ACT_DOD_PRONE_FORWARD_ZOOMED, ACT_DOD_PRONE_ZOOM_FORWARD_BOLT, false },
  88. // Attack ( prone? )
  89. { ACT_RANGE_ATTACK1, ACT_DOD_PRIMARYATTACK_BOLT, false },
  90. { ACT_DOD_PRIMARYATTACK_CROUCH, ACT_DOD_PRIMARYATTACK_BOLT, false },
  91. { ACT_DOD_PRIMARYATTACK_PRONE, ACT_DOD_PRIMARYATTACK_PRONE_BOLT, false },
  92. // Reload ( prone ? )
  93. { ACT_RELOAD, ACT_DOD_RELOAD_BOLT, false },
  94. { ACT_DOD_RELOAD_CROUCH, ACT_DOD_RELOAD_CROUCH_BOLT, false },
  95. { ACT_DOD_RELOAD_PRONE, ACT_DOD_RELOAD_PRONE_BOLT, false },
  96. // Hand Signals
  97. { ACT_DOD_HS_IDLE, ACT_DOD_HS_IDLE_K98, false },
  98. { ACT_DOD_HS_CROUCH, ACT_DOD_HS_CROUCH_K98, false },
  99. };
  100. IMPLEMENT_ACTTABLE( CWeaponK98Scoped );
  101. Activity CWeaponK98Scoped::GetPrimaryAttackActivity( void )
  102. {
  103. Activity actPrim;
  104. if( m_iClip1 <= 0 )
  105. actPrim = ACT_VM_PRIMARYATTACK_EMPTY;
  106. else
  107. actPrim = ACT_VM_PRIMARYATTACK;
  108. return actPrim;
  109. }
  110. float CWeaponK98Scoped::GetFireDelay( void )
  111. {
  112. if ( m_iClip1 <= 0 )
  113. {
  114. return SequenceDuration();
  115. }
  116. return BaseClass::GetFireDelay();
  117. }