From c9743d1494b8a9cca4e1e83d6d5ca2fa0da10788 Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Wed, 6 Oct 2021 10:05:49 -0400 Subject: [PATCH] fix wild battles freezing --- src/battle_controller_opponent.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/battle_controller_opponent.c b/src/battle_controller_opponent.c index c965c4854..5975ab2a1 100644 --- a/src/battle_controller_opponent.c +++ b/src/battle_controller_opponent.c @@ -1552,8 +1552,9 @@ static void OpponentHandleChooseAction(void) else { u8 chosenMoveId; - struct ChooseMoveStruct *moveInfo = (struct ChooseMoveStruct*)(&gBattleResources->bufferA[gActiveBattler][4]); - + struct ChooseMoveStruct moveInfo; + + FillChooseMoveStruct(&moveInfo); if (gBattleTypeFlags & (BATTLE_TYPE_TRAINER | BATTLE_TYPE_FIRST_BATTLE | BATTLE_TYPE_SAFARI | BATTLE_TYPE_ROAMER)) { BattleAI_SetupAIData(0xF); @@ -1573,9 +1574,9 @@ static void OpponentHandleChooseAction(void) BtlController_EmitTwoReturnValues(1, B_ACTION_RUN, 0); break; default: - if (gBattleMoves[moveInfo->moves[chosenMoveId]].target & (MOVE_TARGET_USER_OR_SELECTED | MOVE_TARGET_USER)) + if (gBattleMoves[moveInfo.moves[chosenMoveId]].target & (MOVE_TARGET_USER_OR_SELECTED | MOVE_TARGET_USER)) gBattlerTarget = gActiveBattler; - if (gBattleMoves[moveInfo->moves[chosenMoveId]].target & MOVE_TARGET_BOTH) + if (gBattleMoves[moveInfo.moves[chosenMoveId]].target & MOVE_TARGET_BOTH) { gBattlerTarget = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT); if (gAbsentBattlerFlags & gBitTable[gBattlerTarget]) @@ -1596,7 +1597,7 @@ static void OpponentHandleChooseAction(void) do { chosenMoveId = Random() & 3; - move = moveInfo->moves[chosenMoveId]; + move = moveInfo.moves[chosenMoveId]; } while (move == MOVE_NONE); if (gBattleMoves[move].target & (MOVE_TARGET_USER_OR_SELECTED | MOVE_TARGET_USER))