From 102ee32232b3c85763d13dd99efb439193e3d299 Mon Sep 17 00:00:00 2001 From: Flugente Date: Sat, 24 Jul 2021 11:00:59 +0000 Subject: [PATCH] Fix: when firing from several barrels with two guns, AP cost is deducted twice git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@9145 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- Tactical/Weapons.cpp | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/Tactical/Weapons.cpp b/Tactical/Weapons.cpp index 715b8bae9..68dbc2e13 100644 --- a/Tactical/Weapons.cpp +++ b/Tactical/Weapons.cpp @@ -2502,17 +2502,20 @@ BOOLEAN UseGunNCTH( SOLDIERTYPE *pSoldier , INT32 sTargetGridNo ) PlayWeaponSound(pSoldier, pObjHand, pObjAttHand, usUBItem); // ONLY DEDUCT FOR THE FIRST HAND when doing two-pistol attacks - if (pSoldier->IsValidSecondHandShot() && (*pObjHand)[0]->data.gun.bGunStatus >= USABLE && (*pObjHand)[0]->data.gun.bGunAmmoStatus > 0) + if ( !pSoldier->usBarrelCounter ) { - // only deduct APs when the main gun fires - if (pSoldier->ubAttackingHand == HANDPOS) + if ( pSoldier->IsValidSecondHandShot() && ( *pObjHand )[0]->data.gun.bGunStatus >= USABLE && ( *pObjHand )[0]->data.gun.bGunAmmoStatus > 0 ) { - DeductPoints(pSoldier, sAPCost, iBPCost, AFTERSHOT_INTERRUPT); + // only deduct APs when the main gun fires + if ( pSoldier->ubAttackingHand == HANDPOS ) + { + DeductPoints( pSoldier, sAPCost, iBPCost, AFTERSHOT_INTERRUPT ); + } + } + else + { + DeductPoints( pSoldier, sAPCost, iBPCost, AFTERSHOT_INTERRUPT ); } - } - else - { - DeductPoints(pSoldier, sAPCost, iBPCost, AFTERSHOT_INTERRUPT); } } @@ -3220,17 +3223,20 @@ BOOLEAN UseGun( SOLDIERTYPE *pSoldier , INT32 sTargetGridNo ) PlayWeaponSound(pSoldier, pObjHand, pObjAttHand, usUBItem); // ONLY DEDUCT FOR THE FIRST HAND when doing two-pistol attacks - if (pSoldier->IsValidSecondHandShot() && (*pObjUsed)[0]->data.gun.bGunStatus >= USABLE && (*pObjUsed)[0]->data.gun.bGunAmmoStatus > 0) + if ( !pSoldier->usBarrelCounter ) { - // only deduct APs when the main gun fires - if (pSoldier->ubAttackingHand == HANDPOS) + if ( pSoldier->IsValidSecondHandShot() && ( *pObjUsed )[0]->data.gun.bGunStatus >= USABLE && ( *pObjUsed )[0]->data.gun.bGunAmmoStatus > 0 ) { - DeductPoints(pSoldier, sAPCost, iBPCost, AFTERSHOT_INTERRUPT); + // only deduct APs when the main gun fires + if ( pSoldier->ubAttackingHand == HANDPOS ) + { + DeductPoints( pSoldier, sAPCost, iBPCost, AFTERSHOT_INTERRUPT ); + } + } + else + { + DeductPoints( pSoldier, sAPCost, iBPCost, AFTERSHOT_INTERRUPT ); } - } - else - { - DeductPoints(pSoldier, sAPCost, iBPCost, AFTERSHOT_INTERRUPT); } }