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.

119 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_shotgun.h"
  9. #include "decals.h"
  10. #include "in_buttons.h"
  11. #if defined( CLIENT_DLL )
  12. #include "c_tfc_player.h"
  13. #else
  14. #include "tfc_player.h"
  15. #endif
  16. // ----------------------------------------------------------------------------- //
  17. // CTFCSuperShotgun tables.
  18. // ----------------------------------------------------------------------------- //
  19. IMPLEMENT_NETWORKCLASS_ALIASED( TFCSuperShotgun, DT_WeaponSuperShotgun )
  20. BEGIN_NETWORK_TABLE( CTFCSuperShotgun, DT_WeaponSuperShotgun )
  21. END_NETWORK_TABLE()
  22. BEGIN_PREDICTION_DATA( CTFCSuperShotgun )
  23. END_PREDICTION_DATA()
  24. LINK_ENTITY_TO_CLASS( weapon_super_shotgun, CTFCSuperShotgun );
  25. PRECACHE_WEAPON_REGISTER( weapon_super_shotgun );
  26. #ifndef CLIENT_DLL
  27. BEGIN_DATADESC( CTFCSuperShotgun )
  28. END_DATADESC()
  29. #endif
  30. // ----------------------------------------------------------------------------- //
  31. // CTFCSuperShotgun implementation.
  32. // ----------------------------------------------------------------------------- //
  33. CTFCSuperShotgun::CTFCSuperShotgun()
  34. {
  35. m_iShellsReloaded = 2;
  36. }
  37. TFCWeaponID CTFCSuperShotgun::GetWeaponID() const
  38. {
  39. return WEAPON_SUPER_SHOTGUN;
  40. }
  41. void CTFCSuperShotgun::PrimaryAttack()
  42. {
  43. CTFCPlayer *pOwner = GetPlayerOwner();
  44. if ( !pOwner )
  45. return;
  46. Assert( Clip1() > 0 );
  47. // If we've only 1 shell left, fire a single shot
  48. if ( Clip1() == 1 )
  49. {
  50. BaseClass::PrimaryAttack();
  51. return;
  52. }
  53. WeaponSound( SINGLE );
  54. SendWeaponAnim( ACT_VM_PRIMARYATTACK );
  55. pOwner->DoAnimationEvent( PLAYERANIMEVENT_FIRE_GUN );
  56. // Shoot!
  57. FireBulletsInfo_t info;
  58. info.m_vecSrc = pOwner->Weapon_ShootPosition();
  59. info.m_vecDirShooting = pOwner->GetAutoaimVector( AUTOAIM_5DEGREES );
  60. info.m_iShots = 14;
  61. info.m_flDistance = 2048;
  62. info.m_iAmmoType = GetPrimaryAmmoType();
  63. info.m_vecSpread = VECTOR_CONE_TF_SHOTGUN;
  64. info.m_iTracerFreq = 4;
  65. info.m_flDamage = 4;
  66. pOwner->FireBullets( info );
  67. m_iClip1 -= 2;
  68. m_flTimeWeaponIdle = gpGlobals->curtime + 5.0;
  69. m_fInSpecialReload = 0;
  70. // Setup fire delays
  71. if ( Clip1() != 0 )
  72. m_flPumpTime = gpGlobals->curtime + 0.7;
  73. m_flNextPrimaryAttack = gpGlobals->curtime + 0.7;
  74. }
  75. #ifdef CLIENT_DLL
  76. // ------------------------------------------------------------------------------------------------ //
  77. // ------------------------------------------------------------------------------------------------ //
  78. // CLIENT DLL SPECIFIC CODE
  79. // ------------------------------------------------------------------------------------------------ //
  80. // ------------------------------------------------------------------------------------------------ //
  81. #else
  82. // ------------------------------------------------------------------------------------------------ //
  83. // ------------------------------------------------------------------------------------------------ //
  84. // GAME DLL SPECIFIC CODE
  85. // ------------------------------------------------------------------------------------------------ //
  86. // ------------------------------------------------------------------------------------------------ //
  87. #endif