summaryrefslogtreecommitdiff
path: root/game/shared/cstrike/weapon_p90.cpp
diff options
context:
space:
mode:
authorFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
committerFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
commit3bf9df6b2785fa6d951086978a3e66f49427166a (patch)
tree2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /game/shared/cstrike/weapon_p90.cpp
downloadarchived-source-engine-2018-hl2-src-master.tar.xz
archived-source-engine-2018-hl2-src-master.zip
Diffstat (limited to 'game/shared/cstrike/weapon_p90.cpp')
-rw-r--r--game/shared/cstrike/weapon_p90.cpp97
1 files changed, 97 insertions, 0 deletions
diff --git a/game/shared/cstrike/weapon_p90.cpp b/game/shared/cstrike/weapon_p90.cpp
new file mode 100644
index 0000000..80ac973
--- /dev/null
+++ b/game/shared/cstrike/weapon_p90.cpp
@@ -0,0 +1,97 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+//=============================================================================//
+
+#include "cbase.h"
+#include "weapon_csbasegun.h"
+
+
+#if defined( CLIENT_DLL )
+
+ #define CWeaponP90 C_WeaponP90
+ #include "c_cs_player.h"
+
+#else
+
+ #include "cs_player.h"
+
+#endif
+
+
+class CWeaponP90 : public CWeaponCSBaseGun
+{
+public:
+ DECLARE_CLASS( CWeaponP90, CWeaponCSBaseGun );
+ DECLARE_NETWORKCLASS();
+ DECLARE_PREDICTABLE();
+
+ CWeaponP90();
+
+ virtual void PrimaryAttack();
+
+ virtual float GetInaccuracy() const;
+
+ virtual CSWeaponID GetWeaponID( void ) const { return WEAPON_P90; }
+
+
+private:
+ CWeaponP90( const CWeaponP90 & );
+};
+
+IMPLEMENT_NETWORKCLASS_ALIASED( WeaponP90, DT_WeaponP90 )
+
+BEGIN_NETWORK_TABLE( CWeaponP90, DT_WeaponP90 )
+END_NETWORK_TABLE()
+
+BEGIN_PREDICTION_DATA( CWeaponP90 )
+END_PREDICTION_DATA()
+
+LINK_ENTITY_TO_CLASS( weapon_p90, CWeaponP90 );
+PRECACHE_WEAPON_REGISTER( weapon_p90 );
+
+
+
+CWeaponP90::CWeaponP90()
+{
+}
+
+float CWeaponP90::GetInaccuracy() const
+{
+ if ( weapon_accuracy_model.GetInt() == 1 )
+ {
+ CCSPlayer *pPlayer = GetPlayerOwner();
+ if ( !pPlayer )
+ return 0.0f;
+
+ if ( !FBitSet( pPlayer->GetFlags(), FL_ONGROUND ) )
+ return 0.3f * m_flAccuracy;
+ else if (pPlayer->GetAbsVelocity().Length2D() > 170)
+ return 0.115f * m_flAccuracy;
+ else
+ return 0.045f * m_flAccuracy;
+ }
+ else
+ return BaseClass::GetInaccuracy();
+}
+
+void CWeaponP90::PrimaryAttack()
+{
+ CCSPlayer *pPlayer = GetPlayerOwner();
+ if ( !pPlayer )
+ return;
+
+ if ( !CSBaseGunFire( GetCSWpnData().m_flCycleTime, Primary_Mode ) )
+ return;
+
+ // Kick the gun based on the state of the player.
+ if ( !FBitSet( pPlayer->GetFlags(), FL_ONGROUND ) )
+ pPlayer->KickBack (0.9, 0.45, 0.35, 0.04, 5.25, 3.5, 4);
+ else if (pPlayer->GetAbsVelocity().Length2D() > 5)
+ pPlayer->KickBack (0.45, 0.3, 0.2, 0.0275, 4, 2.25, 7);
+ else if ( FBitSet( pPlayer->GetFlags(), FL_DUCKING ) )
+ pPlayer->KickBack (0.275, 0.2, 0.125, 0.02, 3, 1, 9);
+ else
+ pPlayer->KickBack (0.3, 0.225, 0.125, 0.02, 3.25, 1.25, 8);
+}