client and shotgun fixex

This commit is contained in:
celisej567 2025-01-02 23:53:02 +03:00
parent 9026dca97f
commit d24120a99e
4 changed files with 94 additions and 77 deletions

View File

@ -552,9 +552,9 @@ void CWeaponShotgun::SecondaryAttack( void )
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: Override so shotgun can do mulitple reloads in a row // Purpose: Override so shotgun can do mulitple reloads in a row
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void CWeaponShotgun::ItemPostFrame( void ) void CWeaponShotgun::ItemPostFrame(void)
{ {
CBasePlayer *pOwner = ToBasePlayer( GetOwner() ); CBasePlayer* pOwner = ToBasePlayer(GetOwner());
if (!pOwner) if (!pOwner)
{ {
return; return;
@ -563,14 +563,14 @@ void CWeaponShotgun::ItemPostFrame( void )
if (m_bInReload) if (m_bInReload)
{ {
// If I'm primary firing and have one round stop reloading and fire // If I'm primary firing and have one round stop reloading and fire
if ((pOwner->m_nButtons & IN_ATTACK ) && (m_iClip1 >=1)) if ((pOwner->m_nButtons & IN_ATTACK) && (m_iClip1 >= 1))
{ {
m_bInReload = false; m_bInReload = false;
m_bNeedPump = false; m_bNeedPump = false;
m_bDelayedFire1 = true; m_bDelayedFire1 = true;
} }
// If I'm secondary firing and have one round stop reloading and fire // If I'm secondary firing and have one round stop reloading and fire
else if ((pOwner->m_nButtons & IN_ATTACK2 ) && (m_iClip1 >=2)) else if ((pOwner->m_nButtons & IN_ATTACK2) && (m_iClip1 >= 2))
{ {
m_bInReload = false; m_bInReload = false;
m_bNeedPump = false; m_bNeedPump = false;
@ -579,7 +579,7 @@ void CWeaponShotgun::ItemPostFrame( void )
else if (m_flNextPrimaryAttack <= gpGlobals->curtime) else if (m_flNextPrimaryAttack <= gpGlobals->curtime)
{ {
// If out of ammo end reload // If out of ammo end reload
if (pOwner->GetAmmoCount(m_iPrimaryAmmoType) <=0) if (pOwner->GetAmmoCount(m_iPrimaryAmmoType) <= 0)
{ {
FinishReload(); FinishReload();
return; return;
@ -601,7 +601,7 @@ void CWeaponShotgun::ItemPostFrame( void )
else else
{ {
// Make shotgun shell invisible // Make shotgun shell invisible
SetBodygroup(1,1); SetBodygroup(1, 1);
} }
if ((m_bNeedPump) && (m_flNextPrimaryAttack <= gpGlobals->curtime)) if ((m_bNeedPump) && (m_flNextPrimaryAttack <= gpGlobals->curtime))
@ -610,15 +610,21 @@ void CWeaponShotgun::ItemPostFrame( void )
return; return;
} }
#ifdef GAME_DLL
if (!m_bLowered)
{
#endif // GAME_DLL
// Shotgun uses same timing and ammo for secondary attack // Shotgun uses same timing and ammo for secondary attack
if ((m_bDelayedFire2 || pOwner->m_nButtons & IN_ATTACK2)&&(m_flNextPrimaryAttack <= gpGlobals->curtime)) if ((m_bDelayedFire2 || pOwner->m_nButtons & IN_ATTACK2) && (m_flNextPrimaryAttack <= gpGlobals->curtime))
{ {
m_bDelayedFire2 = false; m_bDelayedFire2 = false;
if ( (m_iClip1 <= 1 && UsesClipsForAmmo1())) if ((m_iClip1 <= 1 && UsesClipsForAmmo1()))
{ {
// If only one shell is left, do a single shot instead // If only one shell is left, do a single shot instead
if ( m_iClip1 == 1 ) if (m_iClip1 == 1)
{ {
PrimaryAttack(); PrimaryAttack();
} }
@ -642,17 +648,17 @@ void CWeaponShotgun::ItemPostFrame( void )
else else
{ {
// If the firing button was just pressed, reset the firing time // If the firing button was just pressed, reset the firing time
if ( pOwner->m_afButtonPressed & IN_ATTACK ) if (pOwner->m_afButtonPressed & IN_ATTACK)
{ {
m_flNextPrimaryAttack = gpGlobals->curtime; m_flNextPrimaryAttack = gpGlobals->curtime;
} }
SecondaryAttack(); SecondaryAttack();
} }
} }
else if ( (m_bDelayedFire1 || pOwner->m_nButtons & IN_ATTACK) && m_flNextPrimaryAttack <= gpGlobals->curtime) else if ((m_bDelayedFire1 || pOwner->m_nButtons & IN_ATTACK) && m_flNextPrimaryAttack <= gpGlobals->curtime)
{ {
m_bDelayedFire1 = false; m_bDelayedFire1 = false;
if ( (m_iClip1 <= 0 && UsesClipsForAmmo1()) || ( !UsesClipsForAmmo1() && !pOwner->GetAmmoCount(m_iPrimaryAmmoType) ) ) if ((m_iClip1 <= 0 && UsesClipsForAmmo1()) || (!UsesClipsForAmmo1() && !pOwner->GetAmmoCount(m_iPrimaryAmmoType)))
{ {
if (!pOwner->GetAmmoCount(m_iPrimaryAmmoType)) if (!pOwner->GetAmmoCount(m_iPrimaryAmmoType))
{ {
@ -673,14 +679,17 @@ void CWeaponShotgun::ItemPostFrame( void )
else else
{ {
// If the firing button was just pressed, reset the firing time // If the firing button was just pressed, reset the firing time
CBasePlayer *pPlayer = ToBasePlayer( GetOwner() ); CBasePlayer* pPlayer = ToBasePlayer(GetOwner());
if ( pPlayer && pPlayer->m_afButtonPressed & IN_ATTACK ) if (pPlayer && pPlayer->m_afButtonPressed & IN_ATTACK)
{ {
m_flNextPrimaryAttack = gpGlobals->curtime; m_flNextPrimaryAttack = gpGlobals->curtime;
} }
PrimaryAttack(); PrimaryAttack();
} }
} }
#ifdef GAME_DLL
}
#endif // GAME_DLL
if ( pOwner->m_nButtons & IN_RELOAD && UsesClipsForAmmo1() && !m_bInReload ) if ( pOwner->m_nButtons & IN_RELOAD && UsesClipsForAmmo1() && !m_bInReload )
{ {

View File

@ -94,6 +94,11 @@ CBaseCombatWeapon::CBaseCombatWeapon() : BASECOMBATWEAPON_DERIVED_FROM()
m_hWeaponFileInfo = GetInvalidWeaponInfoHandle(); m_hWeaponFileInfo = GetInvalidWeaponInfoHandle();
#ifdef GAME_DLL
m_bLowered = false;
m_flRaiseTime = gpGlobals->curtime;
#endif
#if defined( TF_DLL ) #if defined( TF_DLL )
UseClientSideAnimation(); UseClientSideAnimation();
#endif #endif

View File

@ -526,7 +526,6 @@ private:
CNetworkVar( CBaseCombatCharacterHandle, m_hOwner ); // Player carrying this weapon CNetworkVar( CBaseCombatCharacterHandle, m_hOwner ); // Player carrying this weapon
protected: protected:
#ifdef GAME_DLL #ifdef GAME_DLL
bool m_bLowered; // Whether the viewmodel is raised or lowered bool m_bLowered; // Whether the viewmodel is raised or lowered
float m_flRaiseTime; // If lowered, the time we should raise the viewmodel float m_flRaiseTime; // If lowered, the time we should raise the viewmodel

View File

@ -58,6 +58,10 @@ public:
protected: protected:
#ifndef GAME_DLL
bool m_bLowered; // Whether the viewmodel is raised or lowered
float m_flRaiseTime; // If lowered, the time we should raise the viewmodel
#endif
float m_flHolsterTime; // When the weapon was holstered float m_flHolsterTime; // When the weapon was holstered
}; };