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.

132 lines
3.2 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //
  7. //=============================================================================//
  8. //========= Copyright � 1996-2003, Valve LLC, All rights reserved. ============
  9. //
  10. // Purpose: This is the incendiary rifle.
  11. //
  12. //=============================================================================
  13. #include "cbase.h"
  14. #include "npcevent.h"
  15. #include "basehlcombatweapon.h"
  16. #include "basecombatcharacter.h"
  17. #include "soundent.h"
  18. #include "player.h"
  19. #include "IEffects.h"
  20. #include "vstdlib/random.h"
  21. #include "engine/IEngineSound.h"
  22. #include "weapon_flaregun.h"
  23. // memdbgon must be the last include file in a .cpp file!!!
  24. #include "tier0/memdbgon.h"
  25. //###########################################################################
  26. // >> CWeaponIRifle
  27. //###########################################################################
  28. class CWeaponIRifle : public CBaseHLCombatWeapon
  29. {
  30. public:
  31. CWeaponIRifle();
  32. DECLARE_SERVERCLASS();
  33. DECLARE_CLASS( CWeaponIRifle, CBaseHLCombatWeapon );
  34. void Precache( void );
  35. bool Deploy( void );
  36. void PrimaryAttack( void );
  37. virtual float GetFireRate( void ) { return 1; };
  38. int CapabilitiesGet( void ) { return bits_CAP_WEAPON_RANGE_ATTACK1; }
  39. virtual const Vector& GetBulletSpread( void )
  40. {
  41. static Vector cone = VECTOR_CONE_3DEGREES;
  42. return cone;
  43. }
  44. DECLARE_ACTTABLE();
  45. };
  46. IMPLEMENT_SERVERCLASS_ST(CWeaponIRifle, DT_WeaponIRifle)
  47. END_SEND_TABLE()
  48. LINK_ENTITY_TO_CLASS( weapon_irifle, CWeaponIRifle );
  49. PRECACHE_WEAPON_REGISTER(weapon_irifle);
  50. //---------------------------------------------------------
  51. // Activity table
  52. //---------------------------------------------------------
  53. acttable_t CWeaponIRifle::m_acttable[] =
  54. {
  55. { ACT_RANGE_ATTACK1, ACT_RANGE_ATTACK_ML, true },
  56. };
  57. IMPLEMENT_ACTTABLE(CWeaponIRifle);
  58. //---------------------------------------------------------
  59. // Constructor
  60. //---------------------------------------------------------
  61. CWeaponIRifle::CWeaponIRifle()
  62. {
  63. m_bReloadsSingly = true;
  64. m_fMinRange1 = 65;
  65. m_fMinRange2 = 65;
  66. m_fMaxRange1 = 200;
  67. m_fMaxRange2 = 200;
  68. }
  69. //---------------------------------------------------------
  70. //---------------------------------------------------------
  71. void CWeaponIRifle::Precache( void )
  72. {
  73. BaseClass::Precache();
  74. }
  75. //---------------------------------------------------------
  76. //---------------------------------------------------------
  77. void CWeaponIRifle::PrimaryAttack( void )
  78. {
  79. CBasePlayer *pOwner = ToBasePlayer( GetOwner() );
  80. if ( pOwner == NULL )
  81. return;
  82. m_iClip1 = m_iClip1 - 1;
  83. SendWeaponAnim( ACT_VM_PRIMARYATTACK );
  84. pOwner->m_flNextAttack = gpGlobals->curtime + 1;
  85. CFlare *pFlare = CFlare::Create( pOwner->Weapon_ShootPosition(), pOwner->EyeAngles(), pOwner, FLARE_DURATION );
  86. if ( pFlare == NULL )
  87. return;
  88. Vector forward;
  89. pOwner->EyeVectors( &forward );
  90. pFlare->SetAbsVelocity( forward * 1500 );
  91. WeaponSound( SINGLE );
  92. }
  93. //---------------------------------------------------------
  94. // BUGBUG - don't give ammo here.
  95. //---------------------------------------------------------
  96. bool CWeaponIRifle::Deploy( void )
  97. {
  98. CBaseCombatCharacter *pOwner = GetOwner();
  99. if (pOwner)
  100. {
  101. pOwner->GiveAmmo( 90, m_iPrimaryAmmoType);
  102. }
  103. return BaseClass::Deploy();
  104. }