From 57003e18022a3514d0d5de9908b84c11ba9bb92d Mon Sep 17 00:00:00 2001 From: Sevenfm Date: Thu, 13 May 2021 04:43:06 +0000 Subject: [PATCH] Fixes issues with AP costs for aimed melee attack that allowed to make such attack even without required action points. Note for coders - #defines using conditionals needs to be in parenthesis, otherwise they won't work properly when used in conditionals - which was the case here on many places. (SANDRO catched only few of them. His fixes are reverted since the fix is now in #define itself) (by Shadooow) git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@9020 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- Tactical/UI Cursors.cpp | 45 +++++++++++++++-------------------------- 1 file changed, 16 insertions(+), 29 deletions(-) diff --git a/Tactical/UI Cursors.cpp b/Tactical/UI Cursors.cpp index c500bf9d0..834da1e85 100644 --- a/Tactical/UI Cursors.cpp +++ b/Tactical/UI Cursors.cpp @@ -1671,7 +1671,7 @@ UINT8 HandleKnifeCursor( SOLDIERTYPE *pSoldier, INT32 sGridNo, BOOLEAN fActivate // Calculate action points if ( gTacticalStatus.uiFlags & TURNBASED && (gTacticalStatus.uiFlags & INCOMBAT) ) { - gsCurrentActionPoints = CalcTotalAPsToAttack( pSoldier, sGridNo, TRUE, (INT8)(pSoldier->aiData.bShownAimTime ) ); + gsCurrentActionPoints = CalcTotalAPsToAttack( pSoldier, sGridNo, TRUE, (INT8)(pSoldier->aiData.bShownAimTime / 2) ); gfUIDisplayActionPoints = TRUE; gfUIDisplayActionPointsCenter = TRUE; @@ -1686,8 +1686,7 @@ UINT8 HandleKnifeCursor( SOLDIERTYPE *pSoldier, INT32 sGridNo, BOOLEAN fActivate } } - // SANDRO - changed this - bFutureAim = (INT8)( gGameExternalOptions.fEnhancedCloseCombatSystem ? gSkillTraitValues.ubModifierForAPsAddedOnAimedBladedAttackes : REFINE_KNIFE_2 ); + bFutureAim = (INT8)( REFINE_KNIFE_2 ); sAPCosts = CalcTotalAPsToAttack( pSoldier, sGridNo, TRUE, (INT8)(bFutureAim / 2) ); @@ -1721,7 +1720,6 @@ UINT8 HandleKnifeCursor( SOLDIERTYPE *pSoldier, INT32 sGridNo, BOOLEAN fActivate ////////////////////////////////////////////////////////////// - // SANDRO - slightly changed the formula here if( pSoldier->aiData.bShownAimTime == REFINE_KNIFE_1 ) { if ( gfDisplayFullCountRing ) @@ -1737,7 +1735,7 @@ UINT8 HandleKnifeCursor( SOLDIERTYPE *pSoldier, INT32 sGridNo, BOOLEAN fActivate return( KNIFE_NOGO_AIM1_UICURSOR ); } } - else if( pSoldier->aiData.bShownAimTime == ( gGameExternalOptions.fEnhancedCloseCombatSystem ? gSkillTraitValues.ubModifierForAPsAddedOnAimedBladedAttackes : REFINE_KNIFE_2 ) ) + else if( pSoldier->aiData.bShownAimTime == REFINE_KNIFE_2 ) { if ( gfDisplayFullCountRing ) { @@ -1804,7 +1802,7 @@ UINT8 HandlePunchCursor( SOLDIERTYPE *pSoldier, INT32 sGridNo, BOOLEAN fActivate // Calculate action points if ( gTacticalStatus.uiFlags & TURNBASED ) { - gsCurrentActionPoints = CalcTotalAPsToAttack( pSoldier, sGridNo, TRUE, (INT8)(pSoldier->aiData.bShownAimTime ) ); + gsCurrentActionPoints = CalcTotalAPsToAttack( pSoldier, sGridNo, TRUE, (INT8)(pSoldier->aiData.bShownAimTime / 2) ); gfUIDisplayActionPoints = TRUE; gfUIDisplayActionPointsCenter = TRUE; @@ -1845,15 +1843,13 @@ UINT8 HandlePunchCursor( SOLDIERTYPE *pSoldier, INT32 sGridNo, BOOLEAN fActivate PlayJA2Sample( TARG_REFINE_BEEP, RATE_11025, MIDVOLUME, 1, MIDDLEPAN ); } - // SANDRO - make aimed punch less expensive for APS - pSoldier->aiData.bShownAimTime = (gGameExternalOptions.fEnhancedCloseCombatSystem ? gSkillTraitValues.ubModifierForAPsAddedOnAimedPunches : REFINE_PUNCH_2); + pSoldier->aiData.bShownAimTime = REFINE_PUNCH_2; } } } ////////////////////////////////////////////////////////////// - // SANDRO - slightly changed the formula here if( pSoldier->aiData.bShownAimTime == REFINE_PUNCH_1) { if ( gfDisplayFullCountRing ) @@ -1869,7 +1865,7 @@ UINT8 HandlePunchCursor( SOLDIERTYPE *pSoldier, INT32 sGridNo, BOOLEAN fActivate return( ACTION_PUNCH_NOGO_AIM1_UICURSOR ); } } - else if ( pSoldier->aiData.bShownAimTime == (gGameExternalOptions.fEnhancedCloseCombatSystem ? gSkillTraitValues.ubModifierForAPsAddedOnAimedPunches : REFINE_PUNCH_2) ) + else if ( pSoldier->aiData.bShownAimTime == REFINE_PUNCH_2 ) { if ( gfDisplayFullCountRing ) { @@ -2540,9 +2536,6 @@ void HandleRightClickAdjustCursor( SOLDIERTYPE *pSoldier, INT32 usMapPos ) SOLDIERTYPE *pTSoldier; INT32 sGridNo; INT8 bTargetLevel; - // SANDRO - added these two - INT8 bAimTimeAddedForPunch = 2; - INT8 bAimTimeAddedForKnife = 2; usInHand = pSoldier->inv[HANDPOS].usItem; @@ -2756,23 +2749,20 @@ void HandleRightClickAdjustCursor( SOLDIERTYPE *pSoldier, INT32 usMapPos ) case PUNCHCURS: - // SANDRO - changed the formula here to make aimed punch less expensive for APS - bAimTimeAddedForPunch = (gGameExternalOptions.fEnhancedCloseCombatSystem ? gSkillTraitValues.ubModifierForAPsAddedOnAimedPunches : REFINE_PUNCH_2); + bFutureAim = (INT8)( pSoldier->aiData.bShownAimTime + REFINE_PUNCH_2); - bFutureAim = (INT8)( pSoldier->aiData.bShownAimTime + bAimTimeAddedForPunch ); - - if ( bFutureAim <= bAimTimeAddedForPunch ) + if ( bFutureAim <= REFINE_PUNCH_2) { sAPCosts = CalcTotalAPsToAttack( pSoldier, usMapPos, TRUE, (INT8)(bFutureAim / 2) ); // Determine if we can afford! if ( EnoughPoints( pSoldier, sAPCosts, 0, FALSE ) ) { - pSoldier->aiData.bShownAimTime+= bAimTimeAddedForPunch; + pSoldier->aiData.bShownAimTime+= REFINE_PUNCH_2; - if ( pSoldier->aiData.bShownAimTime > bAimTimeAddedForPunch ) + if ( pSoldier->aiData.bShownAimTime > REFINE_PUNCH_2) { - pSoldier->aiData.bShownAimTime = bAimTimeAddedForPunch; + pSoldier->aiData.bShownAimTime = REFINE_PUNCH_2; } } // Else - goto first level! @@ -2806,23 +2796,20 @@ void HandleRightClickAdjustCursor( SOLDIERTYPE *pSoldier, INT32 usMapPos ) case KNIFECURS: - // SANDRO - changed the formula here to make aimed blade attack less expensive for APS - bAimTimeAddedForKnife = (gGameExternalOptions.fEnhancedCloseCombatSystem ? gSkillTraitValues.ubModifierForAPsAddedOnAimedBladedAttackes : REFINE_KNIFE_2); + bFutureAim = (INT8)( pSoldier->aiData.bShownAimTime + REFINE_KNIFE_2); - bFutureAim = (INT8)( pSoldier->aiData.bShownAimTime + bAimTimeAddedForKnife ); - - if ( bFutureAim <= bAimTimeAddedForKnife ) + if ( bFutureAim <= REFINE_KNIFE_2) { sAPCosts = CalcTotalAPsToAttack( pSoldier, usMapPos, TRUE, (INT8)(bFutureAim / 2) ); // Determine if we can afford! if ( EnoughPoints( pSoldier, sAPCosts, 0, FALSE ) ) { - pSoldier->aiData.bShownAimTime+= bAimTimeAddedForKnife; + pSoldier->aiData.bShownAimTime+= REFINE_KNIFE_2; - if ( pSoldier->aiData.bShownAimTime > bAimTimeAddedForKnife ) + if ( pSoldier->aiData.bShownAimTime > REFINE_KNIFE_2) { - pSoldier->aiData.bShownAimTime = bAimTimeAddedForKnife; + pSoldier->aiData.bShownAimTime = REFINE_KNIFE_2; } } // Else - goto first level!