Skip to content

Commit

Permalink
Merge pull request #40 from TomyLobo/fix-akimbo-quickreload
Browse files Browse the repository at this point in the history
Fix akimbo quickreload
  • Loading branch information
TomyLobo committed Mar 31, 2016
2 parents 7847471 + 1f62667 commit 78ff251
Show file tree
Hide file tree
Showing 10 changed files with 187 additions and 168 deletions.
2 changes: 1 addition & 1 deletion mp/src/game/client/sdk/hud/sdk_hud_ammo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ void CHudAmmo::ShotFired(C_WeaponSDKBase* pWeapon, bool bAkimbo, bool bRight)
if (ConVarRef("da_vr_hud").GetBool() || UseVR())
{
if (bAkimbo)
CWeaponSDKBase::VRBulletFired(bRight?pWeapon->rightclip.Get():pWeapon->leftclip.Get(), bRight);
CWeaponSDKBase::VRBulletFired(bRight?pWeapon->m_iRightClip.Get():pWeapon->m_iLeftClip.Get(), bRight);
else
CWeaponSDKBase::VRBulletFired(m_iAmmo, true);
}
Expand Down
6 changes: 3 additions & 3 deletions mp/src/game/server/sdk/sdk_player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2509,9 +2509,9 @@ void CSDKPlayer::SDKThrowWeapon( CWeaponSDKBase *pWeapon, const Vector &vecForwa
pThrow->VPhysicsDestroyObject();
pThrow->VPhysicsInitShadow(true, true);
if (i == 0)
pThrow->m_iClip1 = pAkimbos->rightclip;
pThrow->m_iClip1 = pAkimbos->m_iRightClip;
else
pThrow->m_iClip1 = pAkimbos->leftclip;
pThrow->m_iClip1 = pAkimbos->m_iLeftClip;

SDKThrowWeaponInternal(pThrow, vecForward, vecAngles, flDiameter);
}
Expand Down Expand Up @@ -2540,7 +2540,7 @@ void CSDKPlayer::SDKThrowWeapon( CWeaponSDKBase *pWeapon, const Vector &vecForwa

// Whatever's in our mag right now, consider that to be the left one and toss it.
pThrow->m_iClip1 = pWeapon->m_iClip1;
pWeapon->m_iClip1 = pAkimbo->rightclip;
pWeapon->m_iClip1 = pAkimbo->m_iRightClip;

SDKThrowWeaponInternal(pThrow, vecForward, vecAngles, flDiameter);

Expand Down
61 changes: 34 additions & 27 deletions mp/src/game/shared/basecombatweapon_shared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,6 @@ CBaseCombatWeapon::CBaseCombatWeapon()
m_nCritChecks = 1;
m_nCritSeedRequests = 0;
#endif // TF

reload_delegate = NULL;
}

//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -1958,46 +1956,55 @@ void CBaseCombatWeapon::StopWeaponSound( WeaponSound_t sound_type )
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
bool CBaseCombatWeapon::DefaultReload( int iClipSize1, int iClipSize2, int iActivity )
bool CBaseCombatWeapon::NeedsReload( int iClipSize1, int iClipSize2 )
{
CBaseCombatCharacter *pOwner = GetOwner();
if (!pOwner)
{
return false;
}
bool bReload = false;
if (NULL != reload_delegate)
{
bReload = reload_delegate (this);
}
else
{
// If I don't have any spare ammo, I can't reload
if ( pOwner->GetAmmoCount(m_iPrimaryAmmoType) <= 0 )
return false;

// If you don't have clips, then don't try to reload them.
if ( UsesClipsForAmmo1() )
// If I don't have any spare ammo, I can't reload
if ( pOwner->GetAmmoCount(m_iPrimaryAmmoType) <= 0 )
return false;

// If you don't have clips, then don't try to reload them.
if ( UsesClipsForAmmo1() )
{
// need to reload primary clip?
int primary = MIN(iClipSize1 - m_iClip1, pOwner->GetAmmoCount(m_iPrimaryAmmoType));
if ( primary != 0 )
{
// need to reload primary clip?
int primary = MIN(iClipSize1 - m_iClip1, pOwner->GetAmmoCount(m_iPrimaryAmmoType));
if ( primary != 0 )
{
bReload = true;
}
bReload = true;
}
}

if ( UsesClipsForAmmo2() )
if ( UsesClipsForAmmo2() )
{
// need to reload secondary clip?
int secondary = MIN(iClipSize2 - m_iClip2, pOwner->GetAmmoCount(m_iSecondaryAmmoType));
if ( secondary != 0 )
{
// need to reload secondary clip?
int secondary = MIN(iClipSize2 - m_iClip2, pOwner->GetAmmoCount(m_iSecondaryAmmoType));
if ( secondary != 0 )
{
bReload = true;
}
bReload = true;
}
}

return bReload;
}

//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
bool CBaseCombatWeapon::DefaultReload( int iClipSize1, int iClipSize2, int iActivity )
{
CBaseCombatCharacter *pOwner = GetOwner();
if (!pOwner)
{
return false;
}

bool bReload = NeedsReload(iClipSize1, iClipSize2);
if ( !bReload )
return false;

Expand Down
5 changes: 2 additions & 3 deletions mp/src/game/shared/basecombatweapon_shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -633,10 +633,9 @@ class CBaseCombatWeapon : public BASECOMBATWEAPON_DERIVED_FROM
int m_iOldState;

#endif // End Client .dll only
public:
protected:
/*Called in DefaultReload for sane akimbo implementation*/
typedef bool (*delegate_t) (CBaseCombatWeapon *self);
delegate_t reload_delegate;
virtual bool NeedsReload( int iClipSize1, int iClipSize2 );
};

#endif // COMBATWEAPON_SHARED_H
6 changes: 3 additions & 3 deletions mp/src/game/shared/sdk/da_viewmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ void CDAViewModel::DoMuzzleFlash()
id = GetDAWeapon ()->GetWeaponID ();
if (SDK_WEAPON_AKIMBO_BERETTA == id || SDK_WEAPON_AKIMBO_M1911 == id)
{/*HACK: Alternate attachment for akimbos, where else to put this?*/
if (((CAkimboBase *)GetDAWeapon ())->shootright)
if (((CAkimboBase *)GetDAWeapon ())->m_bShootRight)
ParticleProp()->Create ("muzzleflash_pistol", PATTACH_POINT_FOLLOW, "2");
else
ParticleProp()->Create ("muzzleflash_pistol", PATTACH_POINT_FOLLOW, "1");
Expand Down Expand Up @@ -154,14 +154,14 @@ int CDAViewModel::DrawModel(int flags)
{
CWeaponSDKBase* pWeapon = dynamic_cast<CWeaponSDKBase*>(GetActiveWeapon());
if (pWeapon)
CWeaponSDKBase::DrawVRBullets(vecAmmo1, vecAmmo2, pWeapon->rightclip, pWeapon->GetMaxClip1()/2, true);
CWeaponSDKBase::DrawVRBullets(vecAmmo1, vecAmmo2, pWeapon->m_iRightClip, pWeapon->GetMaxClip1()/2, true);
}

if (GetAttachment(iAmmoL1, vecAmmo1) && GetAttachment(iAmmoL2, vecAmmo2))
{
CWeaponSDKBase* pWeapon = dynamic_cast<CWeaponSDKBase*>(GetActiveWeapon());
if (pWeapon)
CWeaponSDKBase::DrawVRBullets(vecAmmo1, vecAmmo2, pWeapon->leftclip, pWeapon->GetMaxClip1()/2, false);
CWeaponSDKBase::DrawVRBullets(vecAmmo1, vecAmmo2, pWeapon->m_iLeftClip, pWeapon->GetMaxClip1()/2, false);
}
}

Expand Down
2 changes: 1 addition & 1 deletion mp/src/game/shared/sdk/sdk_fx_shared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ void FX_FireBullets(
CAkimboBase* pAkimbo = dynamic_cast<CAkimboBase*>(pWeapon);
Assert(pAkimbo);
if (pAkimbo)
pPlayer->DoMuzzleFlash(pAkimbo->shootright?2:1);
pPlayer->DoMuzzleFlash(pAkimbo->m_bShootRight?2:1);
}
}
else
Expand Down
Loading

0 comments on commit 78ff251

Please sign in to comment.