From 215604f5f75b130424f16236f2b9a5c226430617 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Thu, 27 Oct 2022 20:44:43 +0200 Subject: [PATCH 1/3] fix battle palace bug --- src/battle_ai_main.c | 13 ++- src/battle_controller_opponent.c | 174 +++++++++++++++---------------- src/battle_controller_player.c | 4 +- src/battle_gfx_sfx_util.c | 2 +- src/battle_main.c | 9 +- 5 files changed, 103 insertions(+), 99 deletions(-) diff --git a/src/battle_ai_main.c b/src/battle_ai_main.c index b1154e7934..b4b6a8d30e 100644 --- a/src/battle_ai_main.c +++ b/src/battle_ai_main.c @@ -235,8 +235,17 @@ u8 BattleAI_ChooseMoveOrAction(void) u8 ComputeBattleAiScores(u8 battler) { sBattler_AI = battler; - BattleAI_SetupAIData(0xF); - return BattleAI_ChooseMoveOrAction(); + if (gBattleTypeFlags & BATTLE_TYPE_PALACE) + { + u16 retVal = ChooseMoveAndTargetInBattlePalace(); // first byte is moveId, secondId is target + gBattleStruct->aiChosenTarget[sBattler_AI] = (retVal >> 8) & 0xFF; + return (retVal & 0xFF); + } + else + { + BattleAI_SetupAIData(0xF); + return BattleAI_ChooseMoveOrAction(); + } } static void CopyBattlerDataToAIParty(u32 bPosition, u32 side) diff --git a/src/battle_controller_opponent.c b/src/battle_controller_opponent.c index 5a307cfc9c..55efd60910 100644 --- a/src/battle_controller_opponent.c +++ b/src/battle_controller_opponent.c @@ -1548,116 +1548,108 @@ static void OpponentHandleYesNoBox(void) static void OpponentHandleChooseMove(void) { - if (gBattleTypeFlags & BATTLE_TYPE_PALACE) + u8 chosenMoveId; + struct ChooseMoveStruct *moveInfo = (struct ChooseMoveStruct *)(&gBattleResources->bufferA[gActiveBattler][4]); + + if (gBattleTypeFlags & (BATTLE_TYPE_TRAINER | BATTLE_TYPE_FIRST_BATTLE | BATTLE_TYPE_SAFARI | BATTLE_TYPE_ROAMER) + || IsWildMonSmart()) { - BtlController_EmitTwoReturnValues(BUFFER_B, 10, ChooseMoveAndTargetInBattlePalace()); + chosenMoveId = gBattleStruct->aiMoveOrAction[gActiveBattler]; + gBattlerTarget = gBattleStruct->aiChosenTarget[gActiveBattler]; + switch (chosenMoveId) + { + case AI_CHOICE_WATCH: + BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_SAFARI_WATCH_CAREFULLY, 0); + break; + case AI_CHOICE_FLEE: + BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_RUN, 0); + break; + case AI_CHOICE_SWITCH: + BtlController_EmitTwoReturnValues(BUFFER_B, 10, 0xFFFF); + break; + case 6: + BtlController_EmitTwoReturnValues(BUFFER_B, 15, gBattlerTarget); + break; + default: + { + u16 chosenMove = moveInfo->moves[chosenMoveId]; + + if (GetBattlerMoveTargetType(gActiveBattler, chosenMove) & (MOVE_TARGET_USER_OR_SELECTED | MOVE_TARGET_USER)) + gBattlerTarget = gActiveBattler; + if (GetBattlerMoveTargetType(gActiveBattler, chosenMove) & MOVE_TARGET_BOTH) + { + gBattlerTarget = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT); + if (gAbsentBattlerFlags & gBitTable[gBattlerTarget]) + gBattlerTarget = GetBattlerAtPosition(B_POSITION_PLAYER_RIGHT); + } + if (ShouldUseZMove(gActiveBattler, gBattlerTarget, chosenMove)) + QueueZMove(gActiveBattler, chosenMove); + if (CanMegaEvolve(gActiveBattler)) // If opponent can mega evolve, do it. + BtlController_EmitTwoReturnValues(BUFFER_B, 10, (chosenMoveId) | (RET_MEGA_EVOLUTION) | (gBattlerTarget << 8)); + else + BtlController_EmitTwoReturnValues(BUFFER_B, 10, (chosenMoveId) | (gBattlerTarget << 8)); + } + break; + } OpponentBufferExecCompleted(); } - else + else // Wild pokemon - use random move { - u8 chosenMoveId; - struct ChooseMoveStruct *moveInfo = (struct ChooseMoveStruct *)(&gBattleResources->bufferA[gActiveBattler][4]); - - if (gBattleTypeFlags & (BATTLE_TYPE_TRAINER | BATTLE_TYPE_FIRST_BATTLE | BATTLE_TYPE_SAFARI | BATTLE_TYPE_ROAMER) - || IsWildMonSmart()) + u16 move; + u8 target; + do { - chosenMoveId = gBattleStruct->aiMoveOrAction[gActiveBattler]; - gBattlerTarget = gBattleStruct->aiChosenTarget[gActiveBattler]; - switch (chosenMoveId) - { - case AI_CHOICE_WATCH: - BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_SAFARI_WATCH_CAREFULLY, 0); - break; - case AI_CHOICE_FLEE: - BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_RUN, 0); - break; - case AI_CHOICE_SWITCH: - BtlController_EmitTwoReturnValues(BUFFER_B, 10, 0xFFFF); - break; - case 6: - BtlController_EmitTwoReturnValues(BUFFER_B, 15, gBattlerTarget); - break; - default: - { - u16 chosenMove = moveInfo->moves[chosenMoveId]; + chosenMoveId = Random() & 3; + move = moveInfo->moves[chosenMoveId]; + } while (move == MOVE_NONE); - if (GetBattlerMoveTargetType(gActiveBattler, chosenMove) & (MOVE_TARGET_USER_OR_SELECTED | MOVE_TARGET_USER)) - gBattlerTarget = gActiveBattler; - if (GetBattlerMoveTargetType(gActiveBattler, chosenMove) & MOVE_TARGET_BOTH) - { - gBattlerTarget = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT); - if (gAbsentBattlerFlags & gBitTable[gBattlerTarget]) - gBattlerTarget = GetBattlerAtPosition(B_POSITION_PLAYER_RIGHT); - } - if (ShouldUseZMove(gActiveBattler, gBattlerTarget, chosenMove)) - QueueZMove(gActiveBattler, chosenMove); - if (CanMegaEvolve(gActiveBattler)) // If opponent can mega evolve, do it. - BtlController_EmitTwoReturnValues(BUFFER_B, 10, (chosenMoveId) | (RET_MEGA_EVOLUTION) | (gBattlerTarget << 8)); - else - BtlController_EmitTwoReturnValues(BUFFER_B, 10, (chosenMoveId) | (gBattlerTarget << 8)); - } - break; - } - OpponentBufferExecCompleted(); - } - else // Wild pokemon - use random move + if (GetBattlerMoveTargetType(gActiveBattler, move) & (MOVE_TARGET_USER_OR_SELECTED | MOVE_TARGET_USER)) + BtlController_EmitTwoReturnValues(BUFFER_B, 10, (chosenMoveId) | (gActiveBattler << 8)); + else if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) { - u16 move; - u8 target; - do - { - chosenMoveId = Random() & 3; - move = moveInfo->moves[chosenMoveId]; - } while (move == MOVE_NONE); + do { + target = GetBattlerAtPosition(Random() & 2); + } while (!CanTargetBattler(gActiveBattler, target, move)); - if (GetBattlerMoveTargetType(gActiveBattler, move) & (MOVE_TARGET_USER_OR_SELECTED | MOVE_TARGET_USER)) - BtlController_EmitTwoReturnValues(BUFFER_B, 10, (chosenMoveId) | (gActiveBattler << 8)); - else if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) + #if B_WILD_NATURAL_ENEMIES == TRUE + // Don't bother to loop through table if the move can't attack ally + if (!(gBattleMoves[move].target & MOVE_TARGET_BOTH)) { - do { - target = GetBattlerAtPosition(Random() & 2); - } while (!CanTargetBattler(gActiveBattler, target, move)); - - #if B_WILD_NATURAL_ENEMIES == TRUE - // Don't bother to loop through table if the move can't attack ally - if (!(gBattleMoves[move].target & MOVE_TARGET_BOTH)) + u16 i, speciesAttacker, speciesTarget, isPartnerEnemy = FALSE; + static const u16 naturalEnemies[][2] = { - u16 i, speciesAttacker, speciesTarget, isPartnerEnemy = FALSE; - static const u16 naturalEnemies[][2] = - { - // Attacker Target - {SPECIES_ZANGOOSE, SPECIES_SEVIPER}, - {SPECIES_SEVIPER, SPECIES_ZANGOOSE}, - {SPECIES_HEATMOR, SPECIES_DURANT}, - {SPECIES_DURANT, SPECIES_HEATMOR}, - {SPECIES_SABLEYE, SPECIES_CARBINK}, - {SPECIES_MAREANIE, SPECIES_CORSOLA}, - }; - speciesAttacker = gBattleMons[gActiveBattler].species; - speciesTarget = gBattleMons[GetBattlerAtPosition(BATTLE_PARTNER(gActiveBattler))].species; + // Attacker Target + {SPECIES_ZANGOOSE, SPECIES_SEVIPER}, + {SPECIES_SEVIPER, SPECIES_ZANGOOSE}, + {SPECIES_HEATMOR, SPECIES_DURANT}, + {SPECIES_DURANT, SPECIES_HEATMOR}, + {SPECIES_SABLEYE, SPECIES_CARBINK}, + {SPECIES_MAREANIE, SPECIES_CORSOLA}, + }; + speciesAttacker = gBattleMons[gActiveBattler].species; + speciesTarget = gBattleMons[GetBattlerAtPosition(BATTLE_PARTNER(gActiveBattler))].species; - for (i = 0; i < ARRAY_COUNT(naturalEnemies); i++) + for (i = 0; i < ARRAY_COUNT(naturalEnemies); i++) + { + if (speciesAttacker == naturalEnemies[i][0] && speciesTarget == naturalEnemies[i][1]) { - if (speciesAttacker == naturalEnemies[i][0] && speciesTarget == naturalEnemies[i][1]) - { - isPartnerEnemy = TRUE; - break; - } + isPartnerEnemy = TRUE; + break; } - if (isPartnerEnemy && CanTargetBattler(gActiveBattler, target, move)) - BtlController_EmitTwoReturnValues(BUFFER_B, 10, (chosenMoveId) | (GetBattlerAtPosition(BATTLE_PARTNER(gActiveBattler)) << 8)); - else - BtlController_EmitTwoReturnValues(BUFFER_B, 10, (chosenMoveId) | (target << 8)); } + if (isPartnerEnemy && CanTargetBattler(gActiveBattler, target, move)) + BtlController_EmitTwoReturnValues(BUFFER_B, 10, (chosenMoveId) | (GetBattlerAtPosition(BATTLE_PARTNER(gActiveBattler)) << 8)); else - #endif BtlController_EmitTwoReturnValues(BUFFER_B, 10, (chosenMoveId) | (target << 8)); } else - BtlController_EmitTwoReturnValues(BUFFER_B, 10, (chosenMoveId) | (GetBattlerAtPosition(B_POSITION_PLAYER_LEFT) << 8)); - - OpponentBufferExecCompleted(); + #endif + BtlController_EmitTwoReturnValues(BUFFER_B, 10, (chosenMoveId) | (target << 8)); } + else + BtlController_EmitTwoReturnValues(BUFFER_B, 10, (chosenMoveId) | (GetBattlerAtPosition(B_POSITION_PLAYER_LEFT) << 8)); + + OpponentBufferExecCompleted(); } } diff --git a/src/battle_controller_player.c b/src/battle_controller_player.c index 4be3426402..95af66ac0b 100644 --- a/src/battle_controller_player.c +++ b/src/battle_controller_player.c @@ -2843,8 +2843,10 @@ static void PlayerChooseMoveInBattlePalace(void) { if (--*(gBattleStruct->arenaMindPoints + gActiveBattler) == 0) { + u32 chosenMoveId = gBattleStruct->aiMoveOrAction[gActiveBattler]; + gBattlerTarget = gBattleStruct->aiChosenTarget[gActiveBattler]; gBattlePalaceMoveSelectionRngValue = gRngValue; - BtlController_EmitTwoReturnValues(BUFFER_B, 10, ChooseMoveAndTargetInBattlePalace()); + BtlController_EmitTwoReturnValues(BUFFER_B, 10, (chosenMoveId) | (gBattlerTarget << 8)); PlayerBufferExecCompleted(); } } diff --git a/src/battle_gfx_sfx_util.c b/src/battle_gfx_sfx_util.c index 37dbf0aab6..e2dcce3cff 100644 --- a/src/battle_gfx_sfx_util.c +++ b/src/battle_gfx_sfx_util.c @@ -171,7 +171,7 @@ u16 ChooseMoveAndTargetInBattlePalace(void) // If no moves matched the selected group, pick a new move from groups the pokemon has // In this case the AI is not checked again, so the choice may be worse // If a move is chosen this way, there's a 50% chance that it will be unable to use it anyway - if (chosenMoveId == -1) + if (chosenMoveId == -1 || chosenMoveId >= MAX_MON_MOVES) { if (unusableMovesBits != 0xF) { diff --git a/src/battle_main.c b/src/battle_main.c index 5b6e724c90..7b48d92d06 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -3159,7 +3159,7 @@ void SwitchInClearSetData(void) // Reset damage to prevent things like red card activating if the switched-in mon is holding it gSpecialStatuses[gActiveBattler].physicalDmg = 0; gSpecialStatuses[gActiveBattler].specialDmg = 0; - + gBattleStruct->overwrittenAbilities[gActiveBattler] = ABILITY_NONE; Ai_UpdateSwitchInData(gActiveBattler); @@ -3264,7 +3264,7 @@ void FaintClearSetData(void) UndoMegaEvolution(gBattlerPartyIndexes[gActiveBattler]); gBattleStruct->overwrittenAbilities[gActiveBattler] = ABILITY_NONE; - + // If the fainted mon was involved in a Sky Drop if (gBattleStruct->skyDropTargets[gActiveBattler] != 0xFF) { @@ -3303,7 +3303,7 @@ void FaintClearSetData(void) } } } - + // Clear Z-Move data gBattleStruct->zmove.active = FALSE; gBattleStruct->zmove.toBeUsed[gActiveBattler] = MOVE_NONE; @@ -3973,7 +3973,8 @@ static void HandleTurnActionSelectionState(void) gBattleCommunication[gActiveBattler] = STATE_BEFORE_ACTION_CHOSEN; // Do AI score computations here so we can use them in AI_TrySwitchOrUseItem - if ((gBattleTypeFlags & BATTLE_TYPE_HAS_AI || IsWildMonSmart()) && IsBattlerAIControlled(gActiveBattler)) { + if ((gBattleTypeFlags & BATTLE_TYPE_HAS_AI || IsWildMonSmart()) + && (IsBattlerAIControlled(gActiveBattler) || gBattleTypeFlags & BATTLE_TYPE_PALACE)) { gBattleStruct->aiMoveOrAction[gActiveBattler] = ComputeBattleAiScores(gActiveBattler); } break; From ea43b7732ca80a7ae809c3e4342d1d4e1161d8c0 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Mon, 31 Oct 2022 13:16:48 +0100 Subject: [PATCH 2/3] Fix battle tent again --- src/battle_ai_main.c | 14 +------ src/battle_controller_opponent.c | 69 ++++++++++++++++++-------------- src/battle_controller_player.c | 4 +- src/battle_gfx_sfx_util.c | 2 + src/battle_main.c | 2 +- 5 files changed, 44 insertions(+), 47 deletions(-) diff --git a/src/battle_ai_main.c b/src/battle_ai_main.c index b4b6a8d30e..500680135b 100644 --- a/src/battle_ai_main.c +++ b/src/battle_ai_main.c @@ -234,18 +234,8 @@ u8 BattleAI_ChooseMoveOrAction(void) // damages/other info computed in GetAIDataAndCalcDmg u8 ComputeBattleAiScores(u8 battler) { - sBattler_AI = battler; - if (gBattleTypeFlags & BATTLE_TYPE_PALACE) - { - u16 retVal = ChooseMoveAndTargetInBattlePalace(); // first byte is moveId, secondId is target - gBattleStruct->aiChosenTarget[sBattler_AI] = (retVal >> 8) & 0xFF; - return (retVal & 0xFF); - } - else - { - BattleAI_SetupAIData(0xF); - return BattleAI_ChooseMoveOrAction(); - } + BattleAI_SetupAIData(0xF); + return BattleAI_ChooseMoveOrAction(); } static void CopyBattlerDataToAIParty(u32 bPosition, u32 side) diff --git a/src/battle_controller_opponent.c b/src/battle_controller_opponent.c index 55efd60910..3e168828d1 100644 --- a/src/battle_controller_opponent.c +++ b/src/battle_controller_opponent.c @@ -1554,42 +1554,49 @@ static void OpponentHandleChooseMove(void) if (gBattleTypeFlags & (BATTLE_TYPE_TRAINER | BATTLE_TYPE_FIRST_BATTLE | BATTLE_TYPE_SAFARI | BATTLE_TYPE_ROAMER) || IsWildMonSmart()) { - chosenMoveId = gBattleStruct->aiMoveOrAction[gActiveBattler]; - gBattlerTarget = gBattleStruct->aiChosenTarget[gActiveBattler]; - switch (chosenMoveId) + if (gBattleTypeFlags & BATTLE_TYPE_PALACE) { - case AI_CHOICE_WATCH: - BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_SAFARI_WATCH_CAREFULLY, 0); - break; - case AI_CHOICE_FLEE: - BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_RUN, 0); - break; - case AI_CHOICE_SWITCH: - BtlController_EmitTwoReturnValues(BUFFER_B, 10, 0xFFFF); - break; - case 6: - BtlController_EmitTwoReturnValues(BUFFER_B, 15, gBattlerTarget); - break; - default: + BtlController_EmitTwoReturnValues(BUFFER_B, 10, ChooseMoveAndTargetInBattlePalace()); + } + else + { + chosenMoveId = gBattleStruct->aiMoveOrAction[gActiveBattler]; + gBattlerTarget = gBattleStruct->aiChosenTarget[gActiveBattler]; + switch (chosenMoveId) { - u16 chosenMove = moveInfo->moves[chosenMoveId]; - - if (GetBattlerMoveTargetType(gActiveBattler, chosenMove) & (MOVE_TARGET_USER_OR_SELECTED | MOVE_TARGET_USER)) - gBattlerTarget = gActiveBattler; - if (GetBattlerMoveTargetType(gActiveBattler, chosenMove) & MOVE_TARGET_BOTH) + case AI_CHOICE_WATCH: + BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_SAFARI_WATCH_CAREFULLY, 0); + break; + case AI_CHOICE_FLEE: + BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_RUN, 0); + break; + case AI_CHOICE_SWITCH: + BtlController_EmitTwoReturnValues(BUFFER_B, 10, 0xFFFF); + break; + case 6: + BtlController_EmitTwoReturnValues(BUFFER_B, 15, gBattlerTarget); + break; + default: { - gBattlerTarget = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT); - if (gAbsentBattlerFlags & gBitTable[gBattlerTarget]) - gBattlerTarget = GetBattlerAtPosition(B_POSITION_PLAYER_RIGHT); + u16 chosenMove = moveInfo->moves[chosenMoveId]; + + if (GetBattlerMoveTargetType(gActiveBattler, chosenMove) & (MOVE_TARGET_USER_OR_SELECTED | MOVE_TARGET_USER)) + gBattlerTarget = gActiveBattler; + if (GetBattlerMoveTargetType(gActiveBattler, chosenMove) & MOVE_TARGET_BOTH) + { + gBattlerTarget = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT); + if (gAbsentBattlerFlags & gBitTable[gBattlerTarget]) + gBattlerTarget = GetBattlerAtPosition(B_POSITION_PLAYER_RIGHT); + } + if (ShouldUseZMove(gActiveBattler, gBattlerTarget, chosenMove)) + QueueZMove(gActiveBattler, chosenMove); + if (CanMegaEvolve(gActiveBattler)) // If opponent can mega evolve, do it. + BtlController_EmitTwoReturnValues(BUFFER_B, 10, (chosenMoveId) | (RET_MEGA_EVOLUTION) | (gBattlerTarget << 8)); + else + BtlController_EmitTwoReturnValues(BUFFER_B, 10, (chosenMoveId) | (gBattlerTarget << 8)); } - if (ShouldUseZMove(gActiveBattler, gBattlerTarget, chosenMove)) - QueueZMove(gActiveBattler, chosenMove); - if (CanMegaEvolve(gActiveBattler)) // If opponent can mega evolve, do it. - BtlController_EmitTwoReturnValues(BUFFER_B, 10, (chosenMoveId) | (RET_MEGA_EVOLUTION) | (gBattlerTarget << 8)); - else - BtlController_EmitTwoReturnValues(BUFFER_B, 10, (chosenMoveId) | (gBattlerTarget << 8)); + break; } - break; } OpponentBufferExecCompleted(); } diff --git a/src/battle_controller_player.c b/src/battle_controller_player.c index 95af66ac0b..4be3426402 100644 --- a/src/battle_controller_player.c +++ b/src/battle_controller_player.c @@ -2843,10 +2843,8 @@ static void PlayerChooseMoveInBattlePalace(void) { if (--*(gBattleStruct->arenaMindPoints + gActiveBattler) == 0) { - u32 chosenMoveId = gBattleStruct->aiMoveOrAction[gActiveBattler]; - gBattlerTarget = gBattleStruct->aiChosenTarget[gActiveBattler]; gBattlePalaceMoveSelectionRngValue = gRngValue; - BtlController_EmitTwoReturnValues(BUFFER_B, 10, (chosenMoveId) | (gBattlerTarget << 8)); + BtlController_EmitTwoReturnValues(BUFFER_B, 10, ChooseMoveAndTargetInBattlePalace()); PlayerBufferExecCompleted(); } } diff --git a/src/battle_gfx_sfx_util.c b/src/battle_gfx_sfx_util.c index e2dcce3cff..1b78ec11c1 100644 --- a/src/battle_gfx_sfx_util.c +++ b/src/battle_gfx_sfx_util.c @@ -164,6 +164,7 @@ u16 ChooseMoveAndTargetInBattlePalace(void) { gBattleStruct->palaceFlags &= 0xF; gBattleStruct->palaceFlags |= (selectedMoves << 4); + sBattler_AI = gActiveBattler; BattleAI_SetupAIData(selectedMoves); chosenMoveId = BattleAI_ChooseMoveOrAction(); } @@ -173,6 +174,7 @@ u16 ChooseMoveAndTargetInBattlePalace(void) // If a move is chosen this way, there's a 50% chance that it will be unable to use it anyway if (chosenMoveId == -1 || chosenMoveId >= MAX_MON_MOVES) { + chosenMoveId = -1; if (unusableMovesBits != 0xF) { validMoveFlags = 0, numValidMoveGroups = 0; diff --git a/src/battle_main.c b/src/battle_main.c index 7b48d92d06..f83ae13bb6 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -3974,7 +3974,7 @@ static void HandleTurnActionSelectionState(void) // Do AI score computations here so we can use them in AI_TrySwitchOrUseItem if ((gBattleTypeFlags & BATTLE_TYPE_HAS_AI || IsWildMonSmart()) - && (IsBattlerAIControlled(gActiveBattler) || gBattleTypeFlags & BATTLE_TYPE_PALACE)) { + && (IsBattlerAIControlled(gActiveBattler) && !(gBattleTypeFlags & BATTLE_TYPE_PALACE))) { gBattleStruct->aiMoveOrAction[gActiveBattler] = ComputeBattleAiScores(gActiveBattler); } break; From 51d8b57dccff24b0c947eaaaaa0c0982a027795f Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Mon, 31 Oct 2022 13:19:10 +0100 Subject: [PATCH 3/3] restore deleted line --- src/battle_ai_main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/battle_ai_main.c b/src/battle_ai_main.c index 500680135b..b1154e7934 100644 --- a/src/battle_ai_main.c +++ b/src/battle_ai_main.c @@ -234,6 +234,7 @@ u8 BattleAI_ChooseMoveOrAction(void) // damages/other info computed in GetAIDataAndCalcDmg u8 ComputeBattleAiScores(u8 battler) { + sBattler_AI = battler; BattleAI_SetupAIData(0xF); return BattleAI_ChooseMoveOrAction(); }