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.

207 lines
4.3 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #include "cbase.h"
  7. #include "weapon_dodbipodgun.h"
  8. #if defined( CLIENT_DLL )
  9. #define CWeaponMG34 C_WeaponMG34
  10. #include "c_dod_player.h"
  11. #else
  12. #include "dod_player.h"
  13. #endif
  14. class CWeaponMG34 : public CDODBipodWeapon
  15. {
  16. public:
  17. DECLARE_CLASS( CWeaponMG34, CDODBipodWeapon );
  18. DECLARE_NETWORKCLASS();
  19. DECLARE_PREDICTABLE();
  20. DECLARE_ACTTABLE();
  21. CWeaponMG34() {}
  22. virtual DODWeaponID GetWeaponID( void ) const { return WEAPON_MG34; }
  23. virtual void PrimaryAttack( void );
  24. virtual bool Reload( void );
  25. Activity GetReloadActivity( void );
  26. Activity GetDrawActivity( void );
  27. Activity GetDeployActivity( void );
  28. Activity GetUndeployActivity( void );
  29. Activity GetIdleActivity( void );
  30. Activity GetPrimaryAttackActivity( void );
  31. virtual bool ShouldDrawCrosshair( void ) { return IsDeployed(); }
  32. private:
  33. CWeaponMG34( const CWeaponMG34 & );
  34. };
  35. IMPLEMENT_NETWORKCLASS_ALIASED( WeaponMG34, DT_WeaponMG34 )
  36. BEGIN_NETWORK_TABLE( CWeaponMG34, DT_WeaponMG34 )
  37. END_NETWORK_TABLE()
  38. BEGIN_PREDICTION_DATA( CWeaponMG34 )
  39. END_PREDICTION_DATA()
  40. LINK_ENTITY_TO_CLASS( weapon_mg34, CWeaponMG34 );
  41. PRECACHE_WEAPON_REGISTER( weapon_mg34 );
  42. acttable_t CWeaponMG34::m_acttable[] =
  43. {
  44. // Aim
  45. { ACT_IDLE, ACT_DOD_STAND_AIM_MG, false },
  46. { ACT_CROUCHIDLE, ACT_DOD_CROUCH_AIM_MG, false },
  47. { ACT_RUN_CROUCH, ACT_DOD_CROUCHWALK_AIM_MG, false },
  48. { ACT_WALK, ACT_DOD_WALK_AIM_MG, false },
  49. { ACT_RUN, ACT_DOD_RUN_AIM_MG, false },
  50. { ACT_PRONE_IDLE, ACT_DOD_PRONE_AIM_MG, false },
  51. // Deployed Aim
  52. { ACT_DOD_DEPLOYED, ACT_DOD_DEPLOY_MG, false },
  53. { ACT_DOD_PRONE_DEPLOYED, ACT_DOD_PRONE_DEPLOY_MG, false },
  54. // Attack ( prone? deployed? )
  55. { ACT_RANGE_ATTACK1, ACT_DOD_PRIMARYATTACK_MG, false },
  56. { ACT_DOD_PRIMARYATTACK_PRONE, ACT_DOD_PRIMARYATTACK_PRONE_MG, false },
  57. { ACT_DOD_PRIMARYATTACK_DEPLOYED, ACT_DOD_PRIMARYATTACK_DEPLOYED_MG, false },
  58. { ACT_DOD_PRIMARYATTACK_PRONE_DEPLOYED, ACT_DOD_PRIMARYATTACK_PRONE_DEPLOYED_MG,false },
  59. // Reload ( prone? deployed? )
  60. { ACT_DOD_RELOAD_DEPLOYED, ACT_DOD_RELOAD_DEPLOYED_MG34, false },
  61. { ACT_DOD_RELOAD_PRONE_DEPLOYED, ACT_DOD_RELOAD_PRONE_DEPLOYED_MG34, false },
  62. };
  63. IMPLEMENT_ACTTABLE( CWeaponMG34 );
  64. void CWeaponMG34::PrimaryAttack( void )
  65. {
  66. #ifdef CLIENT_DLL
  67. C_DODPlayer *pPlayer = ToDODPlayer( GetPlayerOwner() );
  68. #else
  69. CDODPlayer *pPlayer = ToDODPlayer( GetPlayerOwner() );
  70. #endif
  71. Assert( pPlayer );
  72. if( !IsDeployed() )
  73. {
  74. #ifdef CLIENT_DLL
  75. pPlayer->HintMessage( HINT_MG_FIRE_UNDEPLOYED );
  76. #endif
  77. pPlayer->m_Shared.SetSlowedTime( 0.2 );
  78. float flStamina = pPlayer->m_Shared.GetStamina();
  79. pPlayer->m_Shared.SetStamina( flStamina - 15 );
  80. }
  81. BaseClass::PrimaryAttack();
  82. }
  83. bool CWeaponMG34::Reload( void )
  84. {
  85. if( !IsDeployed() )
  86. {
  87. ClientPrint( GetPlayerOwner(), HUD_PRINTCENTER, "#Dod_mg_reload" );
  88. return false;
  89. }
  90. return BaseClass::Reload();
  91. }
  92. Activity CWeaponMG34::GetReloadActivity( void )
  93. {
  94. return ACT_VM_RELOAD;
  95. }
  96. Activity CWeaponMG34::GetDrawActivity( void )
  97. {
  98. Activity actDraw;
  99. if( m_iClip1 <= 0 )
  100. actDraw = ACT_VM_DRAW_EMPTY;
  101. else
  102. actDraw = ACT_VM_DRAW;
  103. return actDraw;
  104. }
  105. Activity CWeaponMG34::GetDeployActivity( void )
  106. {
  107. Activity actDeploy;
  108. if( m_iClip1 <= 0 )
  109. actDeploy = ACT_VM_DEPLOY_EMPTY;
  110. else
  111. actDeploy = ACT_VM_DEPLOY;
  112. return actDeploy;
  113. }
  114. Activity CWeaponMG34::GetUndeployActivity( void )
  115. {
  116. Activity actUndeploy;
  117. if( m_iClip1 <= 0 )
  118. actUndeploy = ACT_VM_UNDEPLOY_EMPTY;
  119. else
  120. actUndeploy = ACT_VM_UNDEPLOY;
  121. return actUndeploy;
  122. }
  123. Activity CWeaponMG34::GetIdleActivity( void )
  124. {
  125. Activity actIdle;
  126. if( IsDeployed() )
  127. {
  128. if( m_iClip1 <= 0 )
  129. actIdle = ACT_VM_IDLE_DEPLOYED_EMPTY;
  130. else
  131. actIdle = ACT_VM_IDLE_DEPLOYED;
  132. }
  133. else
  134. {
  135. if( m_iClip1 <= 0 )
  136. actIdle = ACT_VM_IDLE_EMPTY;
  137. else
  138. actIdle = ACT_VM_IDLE;
  139. }
  140. return actIdle;
  141. }
  142. Activity CWeaponMG34::GetPrimaryAttackActivity( void )
  143. {
  144. Activity actPrim;
  145. if( IsDeployed() )
  146. {
  147. if( m_iClip1 <= 0 )
  148. actPrim = ACT_VM_PRIMARYATTACK_DEPLOYED_EMPTY;
  149. else
  150. actPrim = ACT_VM_PRIMARYATTACK_DEPLOYED;
  151. }
  152. else
  153. {
  154. if( m_iClip1 <= 0 )
  155. actPrim = ACT_VM_PRIMARYATTACK_EMPTY;
  156. else
  157. actPrim = ACT_VM_PRIMARYATTACK;
  158. }
  159. return actPrim;
  160. }