mirror of
https://github.com/1dot13/source.git
synced 2026-08-12 14:10:23 +02:00
Fix: when using two guns, both are reloaded on the reload cursor prompt, even if one of them still has ammo. This has been changed so that now only empty guns get reloaded
git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@9146 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
+34
-27
@@ -3889,12 +3889,12 @@ INT8 FindAmmoToReload( SOLDIERTYPE * pSoldier, INT8 bWeaponIn, INT8 bExcludeSlot
|
||||
}
|
||||
}
|
||||
|
||||
BOOLEAN AutoReload( SOLDIERTYPE * pSoldier )
|
||||
BOOLEAN AutoReload( SOLDIERTYPE * pSoldier, bool aReloadEvenIfNotEmpty )
|
||||
{
|
||||
OBJECTTYPE *pObj, *pObj2;
|
||||
INT8 bSlot;
|
||||
INT16 bAPCost;
|
||||
BOOLEAN fRet;
|
||||
BOOLEAN fRet = FALSE;
|
||||
|
||||
CHECKF( pSoldier );
|
||||
|
||||
@@ -3996,38 +3996,45 @@ BOOLEAN AutoReload( SOLDIERTYPE * pSoldier )
|
||||
|
||||
if (Item[pObj->usItem].usItemClass == IC_GUN || Item[pObj->usItem].usItemClass == IC_LAUNCHER)
|
||||
{
|
||||
bSlot = FindAmmoToReload( pSoldier, HANDPOS, NO_SLOT );
|
||||
if (bSlot != NO_SLOT)
|
||||
// Flugente: only reload if it's empty, or we really want to
|
||||
if ( aReloadEvenIfNotEmpty || !EnoughAmmo( pSoldier, FALSE, HANDPOS ) )
|
||||
{
|
||||
// reload using this ammo!
|
||||
fRet = ReloadGun( pSoldier, pObj, &(pSoldier->inv[bSlot]) );
|
||||
// if we are valid for two-pistol shooting (reloading) and we have enough APs still
|
||||
// then do a reload of both guns!
|
||||
if ( (fRet == TRUE) && pSoldier->IsValidSecondHandShotForReloadingPurposes( ) )
|
||||
bSlot = FindAmmoToReload( pSoldier, HANDPOS, NO_SLOT );
|
||||
if ( bSlot != NO_SLOT )
|
||||
{
|
||||
// Flugente: check for underbarrel weapons and use that object if necessary
|
||||
pObj = pSoldier->GetUsedWeapon( &(pSoldier->inv[SECONDHANDPOS]) );
|
||||
// reload using this ammo!
|
||||
fRet = ReloadGun( pSoldier, pObj, &( pSoldier->inv[bSlot] ) );
|
||||
}
|
||||
}
|
||||
|
||||
bSlot = FindAmmoToReload( pSoldier, SECONDHANDPOS, NO_SLOT );
|
||||
if (bSlot != NO_SLOT)
|
||||
// if we are valid for two-pistol shooting (reloading) and we have enough APs still
|
||||
// then do a reload of both guns!
|
||||
// Flugente: only reload if it's empty, or we really want to
|
||||
if ( pSoldier->IsValidSecondHandShotForReloadingPurposes()
|
||||
&& ( aReloadEvenIfNotEmpty || !EnoughAmmo( pSoldier, FALSE, SECONDHANDPOS ) ) )
|
||||
{
|
||||
// Flugente: check for underbarrel weapons and use that object if necessary
|
||||
pObj = pSoldier->GetUsedWeapon( &( pSoldier->inv[SECONDHANDPOS] ) );
|
||||
|
||||
bSlot = FindAmmoToReload( pSoldier, SECONDHANDPOS, NO_SLOT );
|
||||
if ( bSlot != NO_SLOT )
|
||||
{
|
||||
// ce would reload using this ammo!
|
||||
bAPCost = GetAPsToReloadGunWithAmmo( pSoldier, pObj, &( pSoldier->inv[bSlot] ) );
|
||||
if ( EnoughPoints( pSoldier, (INT16)bAPCost, 0, FALSE ) )
|
||||
{
|
||||
// ce would reload using this ammo!
|
||||
bAPCost = GetAPsToReloadGunWithAmmo( pSoldier, pObj, &(pSoldier->inv[bSlot] ) );
|
||||
if ( EnoughPoints( pSoldier, (INT16) bAPCost, 0, FALSE ) )
|
||||
{
|
||||
// reload the 2nd gun too
|
||||
fRet = ReloadGun( pSoldier, pObj, &(pSoldier->inv[bSlot]) );
|
||||
}
|
||||
else
|
||||
{
|
||||
ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, Message[ STR_RELOAD_ONLY_ONE_GUN ], pSoldier->GetName() );
|
||||
}
|
||||
// reload the 2nd gun too
|
||||
fRet = ReloadGun( pSoldier, pObj, &( pSoldier->inv[bSlot] ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, Message[STR_RELOAD_ONLY_ONE_GUN], pSoldier->GetName() );
|
||||
}
|
||||
}
|
||||
|
||||
DirtyMercPanelInterface( pSoldier, DIRTYLEVEL2 );
|
||||
return( fRet );
|
||||
}
|
||||
|
||||
DirtyMercPanelInterface( pSoldier, DIRTYLEVEL2 );
|
||||
return( fRet );
|
||||
}
|
||||
|
||||
// couldn't reload
|
||||
|
||||
Reference in New Issue
Block a user