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.

114 lines
2.9 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_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. // CTFCNailgun tables.
  19. // ----------------------------------------------------------------------------- //
  20. IMPLEMENT_NETWORKCLASS_ALIASED( TFCNailgun, DT_WeaponNailgun )
  21. BEGIN_NETWORK_TABLE( CTFCNailgun, DT_WeaponNailgun )
  22. END_NETWORK_TABLE()
  23. BEGIN_PREDICTION_DATA( CTFCNailgun )
  24. END_PREDICTION_DATA()
  25. LINK_ENTITY_TO_CLASS( weapon_nailgun, CTFCNailgun );
  26. PRECACHE_WEAPON_REGISTER( weapon_nailgun );
  27. #ifndef CLIENT_DLL
  28. BEGIN_DATADESC( CTFCNailgun )
  29. END_DATADESC()
  30. #endif
  31. // ----------------------------------------------------------------------------- //
  32. // CTFCNailgun implementation.
  33. // ----------------------------------------------------------------------------- //
  34. CTFCNailgun::CTFCNailgun()
  35. {
  36. }
  37. TFCWeaponID CTFCNailgun::GetWeaponID() const
  38. {
  39. return WEAPON_NAILGUN;
  40. }
  41. void CTFCNailgun::PrimaryAttack()
  42. {
  43. CTFCPlayer *pOwner = GetPlayerOwner();
  44. if ( !pOwner )
  45. return;
  46. Assert( HasPrimaryAmmo() );
  47. WeaponSound( SINGLE );
  48. SendWeaponAnim( ACT_VM_PRIMARYATTACK );
  49. pOwner->DoAnimationEvent( PLAYERANIMEVENT_FIRE_GUN );
  50. // Fire the nail
  51. #ifdef GAME_DLL
  52. Vector vecSrc = pOwner->Weapon_ShootPosition();
  53. CTFNailgunNail *pNail = CTFNailgunNail::CreateNail(
  54. false,
  55. vecSrc,
  56. pOwner->EyeAngles(),
  57. pOwner,
  58. this,
  59. true );
  60. pNail=pNail; // avoid compiler warning..
  61. #endif
  62. pOwner->RemoveAmmo( 1, GetPrimaryAmmoType() );
  63. // Setup fire delays
  64. m_flNextPrimaryAttack = gpGlobals->curtime + 0.1;
  65. m_flTimeWeaponIdle = gpGlobals->curtime + 10;
  66. }
  67. void CTFCNailgun::SecondaryAttack()
  68. {
  69. return;
  70. }
  71. #ifdef CLIENT_DLL
  72. // ------------------------------------------------------------------------------------------------ //
  73. // ------------------------------------------------------------------------------------------------ //
  74. // CLIENT DLL SPECIFIC CODE
  75. // ------------------------------------------------------------------------------------------------ //
  76. // ------------------------------------------------------------------------------------------------ //
  77. #else
  78. // ------------------------------------------------------------------------------------------------ //
  79. // ------------------------------------------------------------------------------------------------ //
  80. // GAME DLL SPECIFIC CODE
  81. // ------------------------------------------------------------------------------------------------ //
  82. // ------------------------------------------------------------------------------------------------ //
  83. #endif