diff --git a/JA2.suo b/JA2.suo index af6cd20c3..241cee8e2 100644 Binary files a/JA2.suo and b/JA2.suo differ diff --git a/Tactical/Handle UI.cpp b/Tactical/Handle UI.cpp index 69769326d..68f6702c2 100644 --- a/Tactical/Handle UI.cpp +++ b/Tactical/Handle UI.cpp @@ -3969,6 +3969,10 @@ INT8 DrawUIMovementPath( SOLDIERTYPE *pSoldier, UINT16 usMapPos, UINT32 uiFlags if ( sGotLocation != NOWHERE ) { sAPCost += MinAPsToAttack( pSoldier, sAdjustedGridNo, TRUE ); + + // WANNE: Turn around APs were missing! + //sAPCost += APsToTurnAround(pSoldier, sAdjustedGridNo); + sAPCost += UIPlotPath( pSoldier, sGotLocation, NO_COPYROUTE, fPlot, TEMPORARY, (UINT16)pSoldier->usUIMovementMode, NOT_STEALTH, FORWARD, pSoldier->bActionPoints); if ( sGotLocation != pSoldier->sGridNo && fGotAdjacent ) @@ -4083,6 +4087,39 @@ INT8 DrawUIMovementPath( SOLDIERTYPE *pSoldier, UINT16 usMapPos, UINT32 uiFlags return( bReturnCode ); } +// WANNE: Calculate the APs to turn around +INT16 APsToTurnAround(SOLDIERTYPE *pSoldier, INT16 sAdjustedGridNo) +{ + INT16 sAPCost = 0; + BOOLEAN fInitalMove = FALSE; + + // Get the new direction + UINT8 ubDirection = (UINT8)GetDirectionFromGridNo( sAdjustedGridNo, pSoldier ); + + // If new direction is not the same than the old direction + if ( pSoldier->bDesiredDirection != ubDirection) + { + if ( gAnimControl[ pSoldier->usAnimState ].uiFlags & ( ANIM_BREATH | ANIM_OK_CHARGE_AP_FOR_TURN | ANIM_FIREREADY ) && !fInitalMove && !pSoldier->fDontChargeTurningAPs ) + { + // Which position has the soldier? + switch( gAnimControl[ pSoldier->usAnimState ].ubEndHeight ) + { + case ANIM_STAND: + sAPCost += AP_LOOK_STANDING; + break; + case ANIM_CROUCH: + sAPCost += AP_LOOK_CROUCHED; + break; + case ANIM_PRONE: + sAPCost += AP_LOOK_PRONE; + break; + } + } + } + + return sAPCost; +} + BOOLEAN UIMouseOnValidAttackLocation( SOLDIERTYPE *pSoldier ) { diff --git a/Tactical/Handle UI.h b/Tactical/Handle UI.h index a869c07fb..3760657f0 100644 --- a/Tactical/Handle UI.h +++ b/Tactical/Handle UI.h @@ -268,6 +268,9 @@ extern BOOLEAN gfUIForceReExamineCursorData; extern INT16 guiCreateGuyIndex; extern INT16 guiCreateBadGuyIndex; +// WANNE: Calculate the APs to turn around +INT16 APsToTurnAround(SOLDIERTYPE *pSoldier, INT16 sAdjustedGridNo); + // FUNCTIONS IN INPUT MODULES void GetKeyboardInput( UINT32 *puiNewEvent ); void GetPolledKeyboardInput( UINT32 *puiNewEvent ); diff --git a/Tactical/Points.cpp b/Tactical/Points.cpp index d4338a1d2..cfa088e79 100644 --- a/Tactical/Points.cpp +++ b/Tactical/Points.cpp @@ -1073,6 +1073,7 @@ UINT8 CalcTotalAPsToAttack( SOLDIERTYPE *pSoldier, INT16 sGridNo, UINT8 ubAddTur // Add points to attack sAPCost += MinAPsToAttack( pSoldier, sAdjustedGridNo, ubAddTurningCost ); + //sAPCost += APsToTurnAround(pSoldier, sAdjustedGridNo); } else { diff --git a/Tactical/Soldier Control.cpp b/Tactical/Soldier Control.cpp index dd00bc03b..6db24f635 100644 --- a/Tactical/Soldier Control.cpp +++ b/Tactical/Soldier Control.cpp @@ -124,6 +124,9 @@ enum EX_DIRECTION_IRRELEVANT } ExtendedWorldDirections; +// WANNE +BOOLEAN bPreDeductPunchAPs = FALSE; + // LUT for conversion from 8-direction to extended direction UINT8 ubExtDirection[] = { @@ -4836,23 +4839,27 @@ void EVENT_InternalSetSoldierDesiredDirection( SOLDIERTYPE *pSoldier, UINT16 usN if ( pSoldier->bDesiredDirection != pSoldier->bDirection ) { - if ( gAnimControl[ usAnimState ].uiFlags & ( ANIM_BREATH | ANIM_OK_CHARGE_AP_FOR_TURN | ANIM_FIREREADY ) && !fInitalMove && !pSoldier->fDontChargeTurningAPs ) + // WANNE: If we punch the enemy, do not pre deduct the aps! + if (bPreDeductPunchAPs == TRUE) { - // Deduct points for initial turn! - switch( gAnimControl[ usAnimState ].ubEndHeight ) + if ( gAnimControl[ usAnimState ].uiFlags & ( ANIM_BREATH | ANIM_OK_CHARGE_AP_FOR_TURN | ANIM_FIREREADY ) && !fInitalMove && !pSoldier->fDontChargeTurningAPs ) { - // Now change to appropriate animation - case ANIM_STAND: - DeductPoints( pSoldier, AP_LOOK_STANDING, 0 ); - break; + // Deduct points for initial turn! + switch( gAnimControl[ usAnimState ].ubEndHeight ) + { + // Now change to appropriate animation + case ANIM_STAND: + DeductPoints( pSoldier, AP_LOOK_STANDING, 0 ); + break; - case ANIM_CROUCH: - DeductPoints( pSoldier, AP_LOOK_CROUCHED, 0 ); - break; + case ANIM_CROUCH: + DeductPoints( pSoldier, AP_LOOK_CROUCHED, 0 ); + break; - case ANIM_PRONE: - DeductPoints( pSoldier, AP_LOOK_PRONE, 0 ); - break; + case ANIM_PRONE: + DeductPoints( pSoldier, AP_LOOK_PRONE, 0 ); + break; + } } } @@ -8812,9 +8819,14 @@ void EVENT_SoldierBeginPunchAttack( SOLDIERTYPE *pSoldier, INT16 sGridNo, UINT8 if ( fChangeDirection ) { - // CHANGE DIRECTION AND GOTO ANIMATION NOW + // WANNE: Do not pre deduct APs for punching. These APs are calculated later! + bPreDeductPunchAPs = FALSE; + + // CHANGE DIRECTION AND GOTO ANIMATION NOW EVENT_SetSoldierDesiredDirection( pSoldier, ubDirection ); EVENT_SetSoldierDirection( pSoldier, ubDirection ); + + bPreDeductPunchAPs = TRUE; }