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.

140 lines
3.8 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 CWeaponK98 C_WeaponK98
  10. #endif
  11. class CWeaponK98 : public CDODSniperWeapon
  12. {
  13. public:
  14. DECLARE_CLASS( CWeaponK98, CDODSniperWeapon );
  15. DECLARE_NETWORKCLASS();
  16. DECLARE_PREDICTABLE();
  17. DECLARE_ACTTABLE();
  18. CWeaponK98() {}
  19. virtual void Spawn( void );
  20. virtual DODWeaponID GetWeaponID( void ) const { return WEAPON_K98; }
  21. // weapon id for stats purposes
  22. virtual DODWeaponID GetStatsWeaponID( void )
  23. {
  24. if ( IsFullyZoomed() )
  25. return WEAPON_K98_ZOOMED;
  26. else
  27. return WEAPON_K98;
  28. }
  29. virtual bool ShouldAutoEjectBrass( void ) { return false; }
  30. virtual float GetZoomedFOV( void ) { return 55; }
  31. virtual bool HideViewModelWhenZoomed( void ) { return false; }
  32. virtual bool ShouldRezoomAfterReload( void ) { return true; }
  33. virtual Activity GetPrimaryAttackActivity( void );
  34. virtual float GetFireDelay( void );
  35. virtual float GetRecoil( void ) { return 8.0f; }
  36. private:
  37. CWeaponK98( const CWeaponK98 & );
  38. };
  39. IMPLEMENT_NETWORKCLASS_ALIASED( WeaponK98, DT_WeaponK98 )
  40. BEGIN_NETWORK_TABLE( CWeaponK98, DT_WeaponK98 )
  41. END_NETWORK_TABLE()
  42. BEGIN_PREDICTION_DATA( CWeaponK98 )
  43. END_PREDICTION_DATA()
  44. LINK_ENTITY_TO_CLASS( weapon_k98, CWeaponK98 );
  45. PRECACHE_WEAPON_REGISTER( weapon_k98 );
  46. void CWeaponK98::Spawn( void )
  47. {
  48. m_iAltFireHint = HINT_USE_IRON_SIGHTS;
  49. BaseClass::Spawn();
  50. m_bShouldRezoomAfterShot = false;
  51. }
  52. acttable_t CWeaponK98::m_acttable[] =
  53. {
  54. { ACT_DOD_STAND_AIM, ACT_DOD_STAND_AIM_BOLT, false },
  55. { ACT_DOD_CROUCH_AIM, ACT_DOD_CROUCH_AIM_BOLT, false },
  56. { ACT_DOD_CROUCHWALK_AIM, ACT_DOD_CROUCHWALK_AIM_BOLT, false },
  57. { ACT_DOD_WALK_AIM, ACT_DOD_WALK_AIM_BOLT, false },
  58. { ACT_DOD_RUN_AIM, ACT_DOD_RUN_AIM_BOLT, false },
  59. { ACT_PRONE_IDLE, ACT_DOD_PRONE_AIM_BOLT, false },
  60. { ACT_PRONE_FORWARD, ACT_DOD_PRONEWALK_IDLE_BOLT, false },
  61. { ACT_DOD_STAND_IDLE, ACT_DOD_STAND_IDLE_BOLT, false },
  62. { ACT_DOD_CROUCH_IDLE, ACT_DOD_CROUCH_IDLE_BOLT, false },
  63. { ACT_DOD_CROUCHWALK_IDLE, ACT_DOD_CROUCHWALK_IDLE_BOLT, false },
  64. { ACT_DOD_WALK_IDLE, ACT_DOD_WALK_IDLE_BOLT, false },
  65. { ACT_DOD_RUN_IDLE, ACT_DOD_RUN_IDLE_BOLT, false },
  66. { ACT_SPRINT, ACT_DOD_SPRINT_IDLE_BOLT, false },
  67. // Zoomed Aim
  68. { ACT_DOD_IDLE_ZOOMED, ACT_DOD_STAND_ZOOM_BOLT, false },
  69. { ACT_DOD_CROUCH_ZOOMED, ACT_DOD_CROUCH_ZOOM_BOLT, false },
  70. { ACT_DOD_CROUCHWALK_ZOOMED, ACT_DOD_CROUCHWALK_ZOOM_BOLT, false },
  71. { ACT_DOD_WALK_ZOOMED, ACT_DOD_WALK_ZOOM_BOLT, false },
  72. { ACT_DOD_PRONE_ZOOMED, ACT_DOD_PRONE_ZOOM_BOLT, false },
  73. { ACT_DOD_PRONE_FORWARD_ZOOMED, ACT_DOD_PRONE_ZOOM_FORWARD_BOLT, false },
  74. // Attack ( prone? )
  75. { ACT_RANGE_ATTACK1, ACT_DOD_PRIMARYATTACK_BOLT, false },
  76. { ACT_DOD_PRIMARYATTACK_CROUCH, ACT_DOD_PRIMARYATTACK_BOLT, false },
  77. { ACT_DOD_PRIMARYATTACK_PRONE, ACT_DOD_PRIMARYATTACK_PRONE_BOLT, false },
  78. // Reload ( prone ? )
  79. { ACT_RELOAD, ACT_DOD_RELOAD_BOLT, false },
  80. { ACT_DOD_RELOAD_CROUCH, ACT_DOD_RELOAD_CROUCH_BOLT, false },
  81. { ACT_DOD_RELOAD_PRONE, ACT_DOD_RELOAD_PRONE_BOLT, false },
  82. // Hand Signals
  83. { ACT_DOD_HS_IDLE, ACT_DOD_HS_IDLE_K98, false },
  84. { ACT_DOD_HS_CROUCH, ACT_DOD_HS_CROUCH_K98, false },
  85. };
  86. IMPLEMENT_ACTTABLE( CWeaponK98 );
  87. Activity CWeaponK98::GetPrimaryAttackActivity( void )
  88. {
  89. Activity actPrim;
  90. if( m_iClip1 <= 0 )
  91. actPrim = ACT_VM_PRIMARYATTACK_EMPTY;
  92. else
  93. actPrim = ACT_VM_PRIMARYATTACK;
  94. return actPrim;
  95. }
  96. float CWeaponK98::GetFireDelay( void )
  97. {
  98. if ( m_iClip1 <= 0 )
  99. {
  100. return SequenceDuration();
  101. }
  102. return BaseClass::GetFireDelay();
  103. }