Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
135 changes: 72 additions & 63 deletions game/server/hl2/weapon_shotgun.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -552,9 +552,9 @@ void CWeaponShotgun::SecondaryAttack( void )
//-----------------------------------------------------------------------------
// 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)
{
return;
Expand All @@ -563,23 +563,23 @@ void CWeaponShotgun::ItemPostFrame( void )
if (m_bInReload)
{
// 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_bNeedPump = false;
m_bInReload = false;
m_bNeedPump = false;
m_bDelayedFire1 = true;
}
// 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_bNeedPump = false;
m_bInReload = false;
m_bNeedPump = false;
m_bDelayedFire2 = true;
}
else if (m_flNextPrimaryAttack <= gpGlobals->curtime)
{
// If out of ammo end reload
if (pOwner->GetAmmoCount(m_iPrimaryAmmoType) <=0)
if (pOwner->GetAmmoCount(m_iPrimaryAmmoType) <= 0)
{
FinishReload();
return;
Expand All @@ -599,88 +599,97 @@ void CWeaponShotgun::ItemPostFrame( void )
}
}
else
{
{
// Make shotgun shell invisible
SetBodygroup(1,1);
SetBodygroup(1, 1);
}

if ((m_bNeedPump) && (m_flNextPrimaryAttack <= gpGlobals->curtime))
{
Pump();
return;
}
// Shotgun uses same timing and ammo for secondary attack
if ((m_bDelayedFire2 || pOwner->m_nButtons & IN_ATTACK2)&&(m_flNextPrimaryAttack <= gpGlobals->curtime))

#ifdef GAME_DLL
if (!m_bLowered)
{
m_bDelayedFire2 = false;

if ( (m_iClip1 <= 1 && UsesClipsForAmmo1()))
#endif // GAME_DLL


// Shotgun uses same timing and ammo for secondary attack
if ((m_bDelayedFire2 || pOwner->m_nButtons & IN_ATTACK2) && (m_flNextPrimaryAttack <= gpGlobals->curtime))
{
// If only one shell is left, do a single shot instead
if ( m_iClip1 == 1 )
m_bDelayedFire2 = false;

if ((m_iClip1 <= 1 && UsesClipsForAmmo1()))
{
PrimaryAttack();
// If only one shell is left, do a single shot instead
if (m_iClip1 == 1)
{
PrimaryAttack();
}
else if (!pOwner->GetAmmoCount(m_iPrimaryAmmoType))
{
DryFire();
}
else
{
StartReload();
}
}
else if (!pOwner->GetAmmoCount(m_iPrimaryAmmoType))

// Fire underwater?
else if (GetOwner()->GetWaterLevel() == 3 && m_bFiresUnderwater == false)
{
DryFire();
WeaponSound(EMPTY);
m_flNextPrimaryAttack = gpGlobals->curtime + 0.2;
return;
}
else
{
StartReload();
// If the firing button was just pressed, reset the firing time
if (pOwner->m_afButtonPressed & IN_ATTACK)
{
m_flNextPrimaryAttack = gpGlobals->curtime;
}
SecondaryAttack();
}
}

// Fire underwater?
else if (GetOwner()->GetWaterLevel() == 3 && m_bFiresUnderwater == false)
else if ((m_bDelayedFire1 || pOwner->m_nButtons & IN_ATTACK) && m_flNextPrimaryAttack <= gpGlobals->curtime)
{
WeaponSound(EMPTY);
m_flNextPrimaryAttack = gpGlobals->curtime + 0.2;
return;
}
else
{
// If the firing button was just pressed, reset the firing time
if ( pOwner->m_afButtonPressed & IN_ATTACK )
m_bDelayedFire1 = false;
if ((m_iClip1 <= 0 && UsesClipsForAmmo1()) || (!UsesClipsForAmmo1() && !pOwner->GetAmmoCount(m_iPrimaryAmmoType)))
{
m_flNextPrimaryAttack = gpGlobals->curtime;
if (!pOwner->GetAmmoCount(m_iPrimaryAmmoType))
{
DryFire();
}
else
{
StartReload();
}
}
SecondaryAttack();
}
}
else if ( (m_bDelayedFire1 || pOwner->m_nButtons & IN_ATTACK) && m_flNextPrimaryAttack <= gpGlobals->curtime)
{
m_bDelayedFire1 = false;
if ( (m_iClip1 <= 0 && UsesClipsForAmmo1()) || ( !UsesClipsForAmmo1() && !pOwner->GetAmmoCount(m_iPrimaryAmmoType) ) )
{
if (!pOwner->GetAmmoCount(m_iPrimaryAmmoType))
// Fire underwater?
else if (pOwner->GetWaterLevel() == 3 && m_bFiresUnderwater == false)
{
DryFire();
WeaponSound(EMPTY);
m_flNextPrimaryAttack = gpGlobals->curtime + 0.2;
return;
}
else
{
StartReload();
}
}
// Fire underwater?
else if (pOwner->GetWaterLevel() == 3 && m_bFiresUnderwater == false)
{
WeaponSound(EMPTY);
m_flNextPrimaryAttack = gpGlobals->curtime + 0.2;
return;
}
else
{
// If the firing button was just pressed, reset the firing time
CBasePlayer *pPlayer = ToBasePlayer( GetOwner() );
if ( pPlayer && pPlayer->m_afButtonPressed & IN_ATTACK )
{
m_flNextPrimaryAttack = gpGlobals->curtime;
// If the firing button was just pressed, reset the firing time
CBasePlayer* pPlayer = ToBasePlayer(GetOwner());
if (pPlayer && pPlayer->m_afButtonPressed & IN_ATTACK)
{
m_flNextPrimaryAttack = gpGlobals->curtime;
}
PrimaryAttack();
}
PrimaryAttack();
}
#ifdef GAME_DLL
}
#endif // GAME_DLL

if ( pOwner->m_nButtons & IN_RELOAD && UsesClipsForAmmo1() && !m_bInReload )
{
Expand Down
Loading