diff --git a/GameVersion.cpp b/GameVersion.cpp index 9a13800d..67389461 100644 --- a/GameVersion.cpp +++ b/GameVersion.cpp @@ -23,12 +23,12 @@ INT16 zVersionLabel[256] = { L"Beta v. 0.98" }; #else //RELEASE BUILD VERSION - wchar_t zVersionLabel[256] = { L"Release v1.13.781" }; + wchar_t zVersionLabel[256] = { L"Release v1.13.797" }; #endif -INT8 czVersionNumber[16] = { "Build 07.03.13" }; //YY.MM.DD +INT8 czVersionNumber[16] = { "Build 07.03.25" }; //YY.MM.DD wchar_t zTrackingNumber[16] = { L"Z" }; diff --git a/JA2.vcproj b/JA2.vcproj index bd1ce677..2d6e2805 100644 --- a/JA2.vcproj +++ b/JA2.vcproj @@ -546,7 +546,7 @@ inv[ HANDPOS ].usItem; - if ( ( !(Item[ usInHand ].usItemClass & IC_GRENADE) ) ) + if ( ( !(Item[ usInHand ].usItemClass & IC_GRENADE) ) ) { + //AXP 25.03.2007: See if we are about to throw grenade (grenade was not in hand, but in temp object) + if ( pSoldier->pTempObject != NULL && pSoldier->pThrowParams != NULL && + pSoldier->pThrowParams->ubActionCode == THROW_ARM_ITEM && (Item[ pSoldier->pTempObject->usItem ].usItemClass & IC_GRENADE) ) + { + //nothing here + } + else + { #ifdef JA2TESTVERSION - ScreenMsg( MSG_FONT_YELLOW, MSG_DEBUG, L"MinAPsToThrow - Called when in-hand item is %s", usInHand ); + ScreenMsg( MSG_FONT_YELLOW, MSG_DEBUG, L"MinAPsToThrow - Called when in-hand item is %s", usInHand ); #endif - return(0); + return(0); + } } - if ( sGridNo != NOWHERE ) - { - // Given a gridno here, check if we are on a guy - if so - get his gridno - if ( FindSoldier( sGridNo, &usTargID, &uiMercFlags, FIND_SOLDIER_GRIDNO ) ) - { + if ( sGridNo != NOWHERE ) + { + // Given a gridno here, check if we are on a guy - if so - get his gridno + if ( FindSoldier( sGridNo, &usTargID, &uiMercFlags, FIND_SOLDIER_GRIDNO ) ) + { sGridNo = MercPtrs[ usTargID ]->sGridNo; - } + } - // OK, get a direction and see if we need to turn... - if (ubAddTurningCost) - { - ubDirection = (UINT8)GetDirectionFromGridNo( sGridNo, pSoldier ); + // OK, get a direction and see if we need to turn... + if (ubAddTurningCost) + { + ubDirection = (UINT8)GetDirectionFromGridNo( sGridNo, pSoldier ); - // Is it the same as he's facing? - if ( ubDirection != pSoldier->bDirection ) + // Is it the same as he's facing? + if ( ubDirection != pSoldier->bDirection ) { - //iAPCost += GetAPsToLook( pSoldier ); + //Lalien: disabled it again + //AXP 25.03.2007: Reenabled look cost + //iAPCost += GetAPsToLook( pSoldier ); } - } - } - else - { + } + } + else + { // Assume we need to add cost! //iAPCost += GetAPsToLook( pSoldier ); - } + } - // if attacking a new target (or if the specific target is uncertain) - if ( ( sGridNo != pSoldier->sLastTarget ) ) - { - iAPCost += AP_CHANGE_TARGET; - } + // if attacking a new target (or if the specific target is uncertain) + //AXP 25.03.2007: Aim-at-same-tile AP cost/bonus doesn't make any sense for thrown objects + //if ( ( sGridNo != pSoldier->sLastTarget ) ) + //{ + // iAPCost += AP_CHANGE_TARGET; + //} - iAPCost += GetAPsToChangeStance( pSoldier, ANIM_STAND ); + iAPCost += GetAPsToChangeStance( pSoldier, ANIM_STAND ); // Calculate default top & bottom of the magic "aiming" formula) @@ -2188,29 +2199,29 @@ INT16 MinAPsToThrow( SOLDIERTYPE *pSoldier, INT16 sGridNo, UINT8 ubAddTurningCos iTop = 2 * iFullAPs; // if it's anything but a mortar -// if ( usInHand != MORTAR) - // tosses per turn is for max dexterity, drops down to 1/2 at dexterity = 0 - // bottom = (TOSSES_PER_10TURNS * (50 + (ptr->dexterity / 2)) / 10); - //else - iBottom = ( TOSSES_PER_10TURNS * (50 + ( pSoldier->bDexterity / 2 ) ) / 10 ); + // if ( usInHand != MORTAR) + // tosses per turn is for max dexterity, drops down to 1/2 at dexterity = 0 + // bottom = (TOSSES_PER_10TURNS * (50 + (ptr->dexterity / 2)) / 10); + //else + iBottom = ( TOSSES_PER_10TURNS * (50 + ( pSoldier->bDexterity / 2 ) ) / 10 ); - // add minimum aiming time to the overall minimum AP_cost - // This here ROUNDS UP fractions of 0.5 or higher using integer math - // This works because 'top' is 2x what it really should be throughout + // add minimum aiming time to the overall minimum AP_cost + // This here ROUNDS UP fractions of 0.5 or higher using integer math + // This works because 'top' is 2x what it really should be throughout iAPCost += ( ( ( 100 * iTop ) / iBottom) + 1) / 2; - // the minimum AP cost of ANY throw can NEVER be more than merc has APs! - if ( iAPCost > iFullAPs ) - iAPCost = iFullAPs; + // the minimum AP cost of ANY throw can NEVER be more than merc has APs! + if ( iAPCost > iFullAPs ) + iAPCost = iFullAPs; - // this SHOULD be impossible, but nevertheless... - if ( iAPCost < 1 ) - iAPCost = 1; + // this SHOULD be impossible, but nevertheless... + if ( iAPCost < 1 ) + iAPCost = 1; - return ( (INT16)iAPCost ); + return ( (INT16)iAPCost ); } UINT16 GetAPsToDropBomb( SOLDIERTYPE *pSoldier ) diff --git a/Tactical/Soldier Ani.cpp b/Tactical/Soldier Ani.cpp index cf6f9323..b6ccf711 100644 --- a/Tactical/Soldier Ani.cpp +++ b/Tactical/Soldier Ani.cpp @@ -963,6 +963,7 @@ BOOLEAN AdjustToNextAnimationFrame( SOLDIERTYPE *pSoldier ) // ATE: If we are armmed... if ( pSoldier->pThrowParams->ubActionCode == THROW_ARM_ITEM ) { + //AXP 25.03.2007: MinAPsToThrow now actually returns the real cost, not 0 // ATE: Deduct points! DeductPoints( pSoldier, MinAPsToThrow( pSoldier, pSoldier->sTargetGridNo, FALSE ), 0 ); } diff --git a/Tactical/Soldier Control.cpp b/Tactical/Soldier Control.cpp index 5e597fcc..9bab232c 100644 --- a/Tactical/Soldier Control.cpp +++ b/Tactical/Soldier Control.cpp @@ -9391,6 +9391,14 @@ void HaultSoldierFromSighting( SOLDIERTYPE *pSoldier, BOOLEAN fFromSightingEnemy { // Place it back into inv.... AutoPlaceObject( pSoldier, pSoldier->pTempObject, FALSE ); + + //AXP 25.03.2007: Not needed anymore, grenade costs are only deducted on throwing the object + //AXP 24.03.2007: Give APs back if we wanted to throw grenade, but interrupt/spotting occured + //if ( pSoldier->pThrowParams->ubActionCode == THROW_ARM_ITEM ) + //{ + // DeductPoints( pSoldier, -MinAPsToAttack( pSoldier, pSoldier->sTargetGridNo, FALSE ), 0 ); + //} + MemFree( pSoldier->pTempObject ); pSoldier->pTempObject = NULL; pSoldier->usPendingAnimation = NO_PENDING_ANIMATION; diff --git a/Tactical/Weapons.cpp b/Tactical/Weapons.cpp index 742fd8e6..8fbe3ba3 100644 --- a/Tactical/Weapons.cpp +++ b/Tactical/Weapons.cpp @@ -2586,6 +2586,17 @@ BOOLEAN UseThrown( SOLDIERTYPE *pSoldier, INT16 sTargetGridNo ) CalculateLaunchItemParamsForThrow( pSoldier, sTargetGridNo, pSoldier->bTargetLevel, (INT16)(pSoldier->bTargetLevel * 256 ), &(pSoldier->inv[ HANDPOS ] ), (INT8)(uiDiceRoll - uiHitChance), THROW_ARM_ITEM, 0 ); + //AXP 25.03.2007: Cleaned up throwing AP costs. Now only turning + stance change AP + // costs are deducted. Final throw cost is deducted on creating the grenade object + if ( (UINT8)GetDirectionFromGridNo( sTargetGridNo, pSoldier ) != pSoldier->bDirection ) + sAPCost += (INT16)GetAPsToLook( pSoldier ); + sAPCost += (INT16)GetAPsToChangeStance( pSoldier, ANIM_STAND ); + + HandleSoldierThrowItem( pSoldier, pSoldier->sTargetGridNo ); + DeductPoints( pSoldier, sAPCost, 0 ); + RemoveObjs( &(pSoldier->inv[ HANDPOS ] ), 1 ); + + /* // Madd: Next 2 lines added: Deduct points! sAPCost = CalcTotalAPsToAttack( pSoldier, sTargetGridNo, FALSE, pSoldier->bAimTime ); @@ -2597,7 +2608,7 @@ BOOLEAN UseThrown( SOLDIERTYPE *pSoldier, INT16 sTargetGridNo ) // Kaiden: Deducting points too early, moving the line down DeductPoints( pSoldier, sAPCost, 0 ); RemoveObjs( &(pSoldier->inv[ HANDPOS ] ), 1 ); - + */ return( TRUE ); } diff --git a/TacticalAI/AIMain.cpp b/TacticalAI/AIMain.cpp index 1f7c553d..fdad1684 100644 --- a/TacticalAI/AIMain.cpp +++ b/TacticalAI/AIMain.cpp @@ -1142,7 +1142,7 @@ void ActionDone(SOLDIERTYPE *pSoldier) { #ifdef TESTAI DebugMsg( TOPIC_JA2AI, DBG_LEVEL_3, - String("Cancelling actiondone: our action %d, desdir %d dir %d",pSoldier->bAction,pSoldier->bDesiredDirection,pSoldier->bDirection) ); + String("Cancelling actiondone: our action %d, desdir %d dir %d",pSoldier->bAction,pSoldier->bDesiredDirection,pSoldier->bDirection) ); #endif } @@ -1157,23 +1157,30 @@ void ActionDone(SOLDIERTYPE *pSoldier) // cancel any turning & movement by making current settings desired ones pSoldier->sFinalDestination = pSoldier->sGridNo; - if ( !pSoldier->fNoAPToFinishMove ) - { - EVENT_StopMerc( pSoldier, pSoldier->sGridNo, pSoldier->bDirection ); - AdjustNoAPToFinishMove( pSoldier, FALSE ); - } + if ( !pSoldier->fNoAPToFinishMove ) + { + EVENT_StopMerc( pSoldier, pSoldier->sGridNo, pSoldier->bDirection ); + AdjustNoAPToFinishMove( pSoldier, FALSE ); + } + + //Lalien: moved later in ExecuteAction() case AI_ACTION_RAISE_GUN: + //AXP 23.03.2007: Sniper deadlock fix + //if ( pSoldier->bOrders == SNIPER && pSoldier->bAction == AI_ACTION_RAISE_GUN && pSoldier->bLastAction == AI_ACTION_RAISE_GUN) + //{ + // pSoldier->bNextAction = AI_ACTION_END_TURN; + //} // cancel current action - pSoldier->bLastAction = pSoldier->bAction; - pSoldier->bAction = AI_ACTION_NONE; - pSoldier->usActionData = NOWHERE; + pSoldier->bLastAction = pSoldier->bAction; + pSoldier->bAction = AI_ACTION_NONE; + pSoldier->usActionData = NOWHERE; pSoldier->bActionInProgress = FALSE; pSoldier->fDelayedMovement = FALSE; -/* + /* if ( pSoldier->bLastAction == AI_ACTION_CHANGE_STANCE || pSoldier->bLastAction == AI_ACTION_COWER || pSoldier->bLastAction == AI_ACTION_STOP_COWERING ) { - SoldierGotoStationaryStance( pSoldier ); + SoldierGotoStationaryStance( pSoldier ); } */ @@ -2561,6 +2568,13 @@ INT8 ExecuteAction(SOLDIERTYPE *pSoldier) case AI_ACTION_RAISE_GUN: //Madd: action added for snipers to ready weapon and use vision range bonuses SoldierReadyWeapon(pSoldier); HandleSight(pSoldier, SIGHT_LOOK | SIGHT_RADIO); + + //AXP 23.03.2007: Sniper deadlock fix + if ( pSoldier->bOrders == SNIPER && pSoldier->bLastAction == AI_ACTION_RAISE_GUN) + { + pSoldier->bNextAction = AI_ACTION_END_TURN; + } + ActionDone( pSoldier ); break;