From 3d8aeeac77eb78b95a05925406390ee06385d5fe Mon Sep 17 00:00:00 2001 From: benicioneto <71795085+benicioneto@users.noreply.github.com> Date: Sat, 30 Jul 2022 17:33:48 -0300 Subject: [PATCH] Fix the AI The AI was using only the first move, and soft locking when the first move's PP ends --- src/battle_controller_opponent.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/battle_controller_opponent.c b/src/battle_controller_opponent.c index 44e8bf08f..501e31704 100644 --- a/src/battle_controller_opponent.c +++ b/src/battle_controller_opponent.c @@ -1578,24 +1578,19 @@ static void OpponentHandleChooseMove(void) BtlController_EmitTwoReturnValues(BUFFER_B, 15, gBattlerTarget); break; default: - if (GetBattlerMoveTargetType(gActiveBattler, moveInfo->moves[chosenMoveId]) & (MOVE_TARGET_USER_OR_SELECTED | MOVE_TARGET_USER)) - gBattlerTarget = gActiveBattler; - if (GetBattlerMoveTargetType(gActiveBattler, moveInfo->moves[chosenMoveId]) & MOVE_TARGET_BOTH) { u16 chosenMove = moveInfo->moves[chosenMoveId]; - - if (gBattleMoves[chosenMove].target & (MOVE_TARGET_USER_OR_SELECTED | MOVE_TARGET_USER)) + + if (GetBattlerMoveTargetType(gActiveBattler, chosenMove) & (MOVE_TARGET_USER_OR_SELECTED | MOVE_TARGET_USER)) gBattlerTarget = gActiveBattler; - if (gBattleMoves[chosenMove].target & MOVE_TARGET_BOTH) + 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); - + 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