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.

109 lines
3.2 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #include "cbase.h"
  7. #include "util.h"
  8. #include "weapon_tfc_super_nailgun.h"
  9. #include "decals.h"
  10. #include "in_buttons.h"
  11. #include "nailgun_nail.h"
  12. #if defined( CLIENT_DLL )
  13. #include "c_tfc_player.h"
  14. #else
  15. #include "tfc_player.h"
  16. #endif
  17. // ----------------------------------------------------------------------------- //
  18. // CTFCSuperNailgun tables.
  19. // ----------------------------------------------------------------------------- //
  20. IMPLEMENT_NETWORKCLASS_ALIASED( TFCSuperNailgun, DT_WeaponSuperNailgun )
  21. BEGIN_NETWORK_TABLE( CTFCSuperNailgun, DT_WeaponSuperNailgun )
  22. END_NETWORK_TABLE()
  23. BEGIN_PREDICTION_DATA( CTFCSuperNailgun )
  24. END_PREDICTION_DATA()
  25. LINK_ENTITY_TO_CLASS( weapon_super_nailgun, CTFCSuperNailgun );
  26. PRECACHE_WEAPON_REGISTER( weapon_super_nailgun );
  27. #ifndef CLIENT_DLL
  28. BEGIN_DATADESC( CTFCSuperNailgun )
  29. END_DATADESC()
  30. #endif
  31. // ----------------------------------------------------------------------------- //
  32. // CTFCSuperNailgun implementation.
  33. // ----------------------------------------------------------------------------- //
  34. CTFCSuperNailgun::CTFCSuperNailgun()
  35. {
  36. }
  37. TFCWeaponID CTFCSuperNailgun::GetWeaponID() const
  38. {
  39. return WEAPON_SUPER_NAILGUN;
  40. }
  41. void CTFCSuperNailgun::PrimaryAttack()
  42. {
  43. CTFCPlayer *pOwner = GetPlayerOwner();
  44. if ( !pOwner )
  45. return;
  46. Assert( HasPrimaryAmmo() );
  47. // Effects.
  48. WeaponSound( SINGLE );
  49. SendWeaponAnim( ACT_VM_PRIMARYATTACK );
  50. pOwner->DoAnimationEvent( PLAYERANIMEVENT_FIRE_GUN );
  51. // Create the nail.
  52. int iCurrentAmmoCount = pOwner->GetAmmoCount( GetPrimaryAmmoType() );
  53. #ifdef GAME_DLL // TFCTODO: predict this
  54. Vector vecSrc = pOwner->Weapon_ShootPosition();
  55. CTFNailgunNail *pNail = NULL;
  56. if ( iCurrentAmmoCount < 4 )
  57. pNail = CTFNailgunNail::CreateNail( false, vecSrc, pOwner->EyeAngles(), pOwner, this, true );
  58. else
  59. pNail = CTFNailgunNail::CreateSuperNail( vecSrc, pOwner->EyeAngles(), pOwner, this );
  60. #endif
  61. // Uses 2 nails if it can
  62. pOwner->RemoveAmmo( MIN( 2, iCurrentAmmoCount ), GetPrimaryAmmoType() );
  63. // Setup fire delays
  64. m_flNextPrimaryAttack = gpGlobals->curtime + 0.1;
  65. m_flTimeWeaponIdle = gpGlobals->curtime + 10;
  66. }
  67. #ifdef CLIENT_DLL
  68. // ------------------------------------------------------------------------------------------------ //
  69. // ------------------------------------------------------------------------------------------------ //
  70. // CLIENT DLL SPECIFIC CODE
  71. // ------------------------------------------------------------------------------------------------ //
  72. // ------------------------------------------------------------------------------------------------ //
  73. #else
  74. // ------------------------------------------------------------------------------------------------ //
  75. // ------------------------------------------------------------------------------------------------ //
  76. // GAME DLL SPECIFIC CODE
  77. // ------------------------------------------------------------------------------------------------ //
  78. // ------------------------------------------------------------------------------------------------ //
  79. #endif