diff options
| author | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
|---|---|---|
| committer | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
| commit | 3bf9df6b2785fa6d951086978a3e66f49427166a (patch) | |
| tree | 2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /game/server/hl2/weapon_irifle.cpp | |
| download | archived-source-engine-2018-hl2-src-master.tar.xz archived-source-engine-2018-hl2-src-master.zip | |
Diffstat (limited to 'game/server/hl2/weapon_irifle.cpp')
| -rw-r--r-- | game/server/hl2/weapon_irifle.cpp | 132 |
1 files changed, 132 insertions, 0 deletions
diff --git a/game/server/hl2/weapon_irifle.cpp b/game/server/hl2/weapon_irifle.cpp new file mode 100644 index 0000000..471534c --- /dev/null +++ b/game/server/hl2/weapon_irifle.cpp @@ -0,0 +1,132 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +// +//=============================================================================// +//========= Copyright � 1996-2003, Valve LLC, All rights reserved. ============ +// +// Purpose: This is the incendiary rifle. +// +//============================================================================= + + +#include "cbase.h" +#include "npcevent.h" +#include "basehlcombatweapon.h" +#include "basecombatcharacter.h" +#include "soundent.h" +#include "player.h" +#include "IEffects.h" +#include "vstdlib/random.h" +#include "engine/IEngineSound.h" +#include "weapon_flaregun.h" + +// memdbgon must be the last include file in a .cpp file!!! +#include "tier0/memdbgon.h" + +//########################################################################### +// >> CWeaponIRifle +//########################################################################### + +class CWeaponIRifle : public CBaseHLCombatWeapon +{ +public: + + CWeaponIRifle(); + + DECLARE_SERVERCLASS(); + DECLARE_CLASS( CWeaponIRifle, CBaseHLCombatWeapon ); + + void Precache( void ); + bool Deploy( void ); + + void PrimaryAttack( void ); + virtual float GetFireRate( void ) { return 1; }; + + int CapabilitiesGet( void ) { return bits_CAP_WEAPON_RANGE_ATTACK1; } + + virtual const Vector& GetBulletSpread( void ) + { + static Vector cone = VECTOR_CONE_3DEGREES; + return cone; + } + + DECLARE_ACTTABLE(); +}; + +IMPLEMENT_SERVERCLASS_ST(CWeaponIRifle, DT_WeaponIRifle) +END_SEND_TABLE() + +LINK_ENTITY_TO_CLASS( weapon_irifle, CWeaponIRifle ); +PRECACHE_WEAPON_REGISTER(weapon_irifle); + +//--------------------------------------------------------- +// Activity table +//--------------------------------------------------------- +acttable_t CWeaponIRifle::m_acttable[] = +{ + { ACT_RANGE_ATTACK1, ACT_RANGE_ATTACK_ML, true }, +}; +IMPLEMENT_ACTTABLE(CWeaponIRifle); + +//--------------------------------------------------------- +// Constructor +//--------------------------------------------------------- +CWeaponIRifle::CWeaponIRifle() +{ + m_bReloadsSingly = true; + + m_fMinRange1 = 65; + m_fMinRange2 = 65; + m_fMaxRange1 = 200; + m_fMaxRange2 = 200; +} + +//--------------------------------------------------------- +//--------------------------------------------------------- +void CWeaponIRifle::Precache( void ) +{ + BaseClass::Precache(); +} + +//--------------------------------------------------------- +//--------------------------------------------------------- +void CWeaponIRifle::PrimaryAttack( void ) +{ + CBasePlayer *pOwner = ToBasePlayer( GetOwner() ); + + if ( pOwner == NULL ) + return; + + m_iClip1 = m_iClip1 - 1; + + SendWeaponAnim( ACT_VM_PRIMARYATTACK ); + pOwner->m_flNextAttack = gpGlobals->curtime + 1; + + CFlare *pFlare = CFlare::Create( pOwner->Weapon_ShootPosition(), pOwner->EyeAngles(), pOwner, FLARE_DURATION ); + + if ( pFlare == NULL ) + return; + + Vector forward; + pOwner->EyeVectors( &forward ); + + pFlare->SetAbsVelocity( forward * 1500 ); + + WeaponSound( SINGLE ); +} + +//--------------------------------------------------------- +// BUGBUG - don't give ammo here. +//--------------------------------------------------------- +bool CWeaponIRifle::Deploy( void ) +{ + CBaseCombatCharacter *pOwner = GetOwner(); + if (pOwner) + { + pOwner->GiveAmmo( 90, m_iPrimaryAmmoType); + } + return BaseClass::Deploy(); +} |