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.

84 lines
1.7 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #include "cbase.h"
  7. #include "weapon_dodfullauto_punch.h"
  8. #include "in_buttons.h"
  9. #include "dod_shareddefs.h"
  10. #ifndef CLIENT_DLL
  11. #include "dod_player.h"
  12. #endif
  13. IMPLEMENT_NETWORKCLASS_ALIASED( DODFullAutoPunchWeapon, DT_FullAutoPunchWeapon )
  14. BEGIN_NETWORK_TABLE( CDODFullAutoPunchWeapon, DT_FullAutoPunchWeapon )
  15. END_NETWORK_TABLE()
  16. #ifdef CLIENT_DLL
  17. BEGIN_PREDICTION_DATA( CDODFullAutoPunchWeapon )
  18. END_PREDICTION_DATA()
  19. #endif
  20. void CDODFullAutoPunchWeapon::Spawn( void )
  21. {
  22. m_iAltFireHint = HINT_USE_MELEE;
  23. BaseClass::Spawn();
  24. }
  25. void CDODFullAutoPunchWeapon::SecondaryAttack( void )
  26. {
  27. if ( m_bInReload )
  28. {
  29. m_bInReload = false;
  30. GetPlayerOwner()->m_flNextAttack = gpGlobals->curtime;
  31. }
  32. else if ( GetPlayerOwner()->m_flNextAttack > gpGlobals->curtime )
  33. {
  34. return;
  35. }
  36. Punch();
  37. // start calling ItemPostFrame
  38. GetPlayerOwner()->m_flNextAttack = gpGlobals->curtime;
  39. m_flNextPrimaryAttack = m_flNextSecondaryAttack;
  40. #ifndef CLIENT_DLL
  41. CDODPlayer *pPlayer = GetDODPlayerOwner();
  42. if ( pPlayer )
  43. {
  44. pPlayer->RemoveHintTimer( m_iAltFireHint );
  45. }
  46. #endif
  47. }
  48. bool CDODFullAutoPunchWeapon::Reload( void )
  49. {
  50. bool bSuccess = BaseClass::Reload();
  51. if ( bSuccess )
  52. {
  53. m_flNextSecondaryAttack = gpGlobals->curtime;
  54. }
  55. return bSuccess;
  56. }
  57. void CDODFullAutoPunchWeapon::ItemBusyFrame( void )
  58. {
  59. BaseClass::ItemBusyFrame();
  60. CBasePlayer *pPlayer = GetPlayerOwner();
  61. if ( pPlayer && (pPlayer->m_nButtons & IN_ATTACK2) && (m_flNextSecondaryAttack <= gpGlobals->curtime))
  62. {
  63. SecondaryAttack();
  64. pPlayer->m_nButtons &= ~IN_ATTACK2;
  65. }
  66. }