diff options
| author | Jørgen P. Tjernø <[email protected]> | 2013-12-02 19:31:46 -0800 |
|---|---|---|
| committer | Jørgen P. Tjernø <[email protected]> | 2013-12-02 19:46:31 -0800 |
| commit | f56bb35301836e56582a575a75864392a0177875 (patch) | |
| tree | de61ddd39de3e7df52759711950b4c288592f0dc /mp/src/game/shared/sdk/weapon_mp5.cpp | |
| parent | Mark some more files as text. (diff) | |
| download | source-sdk-2013-f56bb35301836e56582a575a75864392a0177875.tar.xz source-sdk-2013-f56bb35301836e56582a575a75864392a0177875.zip | |
Fix line endings. WHAMMY.
Diffstat (limited to 'mp/src/game/shared/sdk/weapon_mp5.cpp')
| -rw-r--r-- | mp/src/game/shared/sdk/weapon_mp5.cpp | 336 |
1 files changed, 168 insertions, 168 deletions
diff --git a/mp/src/game/shared/sdk/weapon_mp5.cpp b/mp/src/game/shared/sdk/weapon_mp5.cpp index 69a32f97..691f1a9c 100644 --- a/mp/src/game/shared/sdk/weapon_mp5.cpp +++ b/mp/src/game/shared/sdk/weapon_mp5.cpp @@ -1,168 +1,168 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-//=============================================================================//
-
-#include "cbase.h"
-#include "weapon_sdkbase.h"
-#include "sdk_fx_shared.h"
-
-
-#if defined( CLIENT_DLL )
-
- #define CWeaponMP5 C_WeaponMP5
- #include "c_sdk_player.h"
-
-#else
-
- #include "sdk_player.h"
-
-#endif
-
-
-class CWeaponMP5 : public CWeaponSDKBase
-{
-public:
- DECLARE_CLASS( CWeaponMP5, CWeaponSDKBase );
- DECLARE_NETWORKCLASS();
- DECLARE_PREDICTABLE();
-
- CWeaponMP5();
-
- virtual void PrimaryAttack();
- virtual bool Deploy();
- virtual bool Reload();
- virtual void WeaponIdle();
-
- virtual SDKWeaponID GetWeaponID( void ) const { return WEAPON_MP5; }
-
-
-private:
-
- CWeaponMP5( const CWeaponMP5 & );
-
- void Fire( float flSpread );
-};
-
-IMPLEMENT_NETWORKCLASS_ALIASED( WeaponMP5, DT_WeaponMP5 )
-
-BEGIN_NETWORK_TABLE( CWeaponMP5, DT_WeaponMP5 )
-END_NETWORK_TABLE()
-
-BEGIN_PREDICTION_DATA( CWeaponMP5 )
-END_PREDICTION_DATA()
-
-LINK_ENTITY_TO_CLASS( weapon_mp5, CWeaponMP5 );
-PRECACHE_WEAPON_REGISTER( weapon_mp5 );
-
-
-
-CWeaponMP5::CWeaponMP5()
-{
-}
-
-bool CWeaponMP5::Deploy( )
-{
- CSDKPlayer *pPlayer = GetPlayerOwner();
- pPlayer->m_iShotsFired = 0;
-
- return BaseClass::Deploy();
-}
-
-bool CWeaponMP5::Reload( )
-{
- CSDKPlayer *pPlayer = GetPlayerOwner();
-
- if (pPlayer->GetAmmoCount( GetPrimaryAmmoType() ) <= 0)
- return false;
-
- int iResult = DefaultReload( GetMaxClip1(), GetMaxClip2(), ACT_VM_RELOAD );
- if ( !iResult )
- return false;
-
- pPlayer->SetAnimation( PLAYER_RELOAD );
-
-#ifndef CLIENT_DLL
- if ((iResult) && (pPlayer->GetFOV() != pPlayer->GetDefaultFOV()))
- {
- pPlayer->SetFOV( pPlayer, pPlayer->GetDefaultFOV() );
- }
-#endif
-
- pPlayer->m_iShotsFired = 0;
-
- return true;
-}
-
-void CWeaponMP5::PrimaryAttack( void )
-{
- const CSDKWeaponInfo &pWeaponInfo = GetSDKWpnData();
- CSDKPlayer *pPlayer = GetPlayerOwner();
-
- float flCycleTime = pWeaponInfo.m_flCycleTime;
-
- bool bPrimaryMode = true;
-
- float flSpread = 0.01f;
-
- // more spread when jumping
- if ( !FBitSet( pPlayer->GetFlags(), FL_ONGROUND ) )
- flSpread = 0.05f;
-
- pPlayer->m_iShotsFired++;
-
- // Out of ammo?
- if ( m_iClip1 <= 0 )
- {
- if (m_bFireOnEmpty)
- {
- PlayEmptySound();
- m_flNextPrimaryAttack = gpGlobals->curtime + 0.2;
- }
- }
-
- SendWeaponAnim( ACT_VM_PRIMARYATTACK );
-
- m_iClip1--;
-
- // player "shoot" animation
- pPlayer->SetAnimation( PLAYER_ATTACK1 );
-
- FX_FireBullets(
- pPlayer->entindex(),
- pPlayer->Weapon_ShootPosition(),
- pPlayer->EyeAngles() + pPlayer->GetPunchAngle(),
- GetWeaponID(),
- bPrimaryMode?Primary_Mode:Secondary_Mode,
- CBaseEntity::GetPredictionRandomSeed() & 255,
- flSpread );
-
- pPlayer->DoMuzzleFlash();
-
- m_flNextPrimaryAttack = m_flNextSecondaryAttack = gpGlobals->curtime + flCycleTime;
-
- if (!m_iClip1 && pPlayer->GetAmmoCount( m_iPrimaryAmmoType ) <= 0)
- {
- // HEV suit - indicate out of ammo condition
- pPlayer->SetSuitUpdate("!HEV_AMO0", false, 0);
- }
-
- // start idle animation in 5 seconds
- SetWeaponIdleTime( gpGlobals->curtime + 5.0 );
-}
-
-void CWeaponMP5::WeaponIdle()
-{
- if (m_flTimeWeaponIdle > gpGlobals->curtime)
- return;
-
- // only idle if the slid isn't back
- if ( m_iClip1 != 0 )
- {
- SetWeaponIdleTime( gpGlobals->curtime + 5.0f );
- SendWeaponAnim( ACT_VM_IDLE );
- }
-}
-
-
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +//=============================================================================// + +#include "cbase.h" +#include "weapon_sdkbase.h" +#include "sdk_fx_shared.h" + + +#if defined( CLIENT_DLL ) + + #define CWeaponMP5 C_WeaponMP5 + #include "c_sdk_player.h" + +#else + + #include "sdk_player.h" + +#endif + + +class CWeaponMP5 : public CWeaponSDKBase +{ +public: + DECLARE_CLASS( CWeaponMP5, CWeaponSDKBase ); + DECLARE_NETWORKCLASS(); + DECLARE_PREDICTABLE(); + + CWeaponMP5(); + + virtual void PrimaryAttack(); + virtual bool Deploy(); + virtual bool Reload(); + virtual void WeaponIdle(); + + virtual SDKWeaponID GetWeaponID( void ) const { return WEAPON_MP5; } + + +private: + + CWeaponMP5( const CWeaponMP5 & ); + + void Fire( float flSpread ); +}; + +IMPLEMENT_NETWORKCLASS_ALIASED( WeaponMP5, DT_WeaponMP5 ) + +BEGIN_NETWORK_TABLE( CWeaponMP5, DT_WeaponMP5 ) +END_NETWORK_TABLE() + +BEGIN_PREDICTION_DATA( CWeaponMP5 ) +END_PREDICTION_DATA() + +LINK_ENTITY_TO_CLASS( weapon_mp5, CWeaponMP5 ); +PRECACHE_WEAPON_REGISTER( weapon_mp5 ); + + + +CWeaponMP5::CWeaponMP5() +{ +} + +bool CWeaponMP5::Deploy( ) +{ + CSDKPlayer *pPlayer = GetPlayerOwner(); + pPlayer->m_iShotsFired = 0; + + return BaseClass::Deploy(); +} + +bool CWeaponMP5::Reload( ) +{ + CSDKPlayer *pPlayer = GetPlayerOwner(); + + if (pPlayer->GetAmmoCount( GetPrimaryAmmoType() ) <= 0) + return false; + + int iResult = DefaultReload( GetMaxClip1(), GetMaxClip2(), ACT_VM_RELOAD ); + if ( !iResult ) + return false; + + pPlayer->SetAnimation( PLAYER_RELOAD ); + +#ifndef CLIENT_DLL + if ((iResult) && (pPlayer->GetFOV() != pPlayer->GetDefaultFOV())) + { + pPlayer->SetFOV( pPlayer, pPlayer->GetDefaultFOV() ); + } +#endif + + pPlayer->m_iShotsFired = 0; + + return true; +} + +void CWeaponMP5::PrimaryAttack( void ) +{ + const CSDKWeaponInfo &pWeaponInfo = GetSDKWpnData(); + CSDKPlayer *pPlayer = GetPlayerOwner(); + + float flCycleTime = pWeaponInfo.m_flCycleTime; + + bool bPrimaryMode = true; + + float flSpread = 0.01f; + + // more spread when jumping + if ( !FBitSet( pPlayer->GetFlags(), FL_ONGROUND ) ) + flSpread = 0.05f; + + pPlayer->m_iShotsFired++; + + // Out of ammo? + if ( m_iClip1 <= 0 ) + { + if (m_bFireOnEmpty) + { + PlayEmptySound(); + m_flNextPrimaryAttack = gpGlobals->curtime + 0.2; + } + } + + SendWeaponAnim( ACT_VM_PRIMARYATTACK ); + + m_iClip1--; + + // player "shoot" animation + pPlayer->SetAnimation( PLAYER_ATTACK1 ); + + FX_FireBullets( + pPlayer->entindex(), + pPlayer->Weapon_ShootPosition(), + pPlayer->EyeAngles() + pPlayer->GetPunchAngle(), + GetWeaponID(), + bPrimaryMode?Primary_Mode:Secondary_Mode, + CBaseEntity::GetPredictionRandomSeed() & 255, + flSpread ); + + pPlayer->DoMuzzleFlash(); + + m_flNextPrimaryAttack = m_flNextSecondaryAttack = gpGlobals->curtime + flCycleTime; + + if (!m_iClip1 && pPlayer->GetAmmoCount( m_iPrimaryAmmoType ) <= 0) + { + // HEV suit - indicate out of ammo condition + pPlayer->SetSuitUpdate("!HEV_AMO0", false, 0); + } + + // start idle animation in 5 seconds + SetWeaponIdleTime( gpGlobals->curtime + 5.0 ); +} + +void CWeaponMP5::WeaponIdle() +{ + if (m_flTimeWeaponIdle > gpGlobals->curtime) + return; + + // only idle if the slid isn't back + if ( m_iClip1 != 0 ) + { + SetWeaponIdleTime( gpGlobals->curtime + 5.0f ); + SendWeaponAnim( ACT_VM_IDLE ); + } +} + + |