fix wild battles freezing

This commit is contained in:
ghoulslash 2021-10-06 10:05:49 -04:00
parent e75a8fb67c
commit c9743d1494

View File

@ -1552,8 +1552,9 @@ static void OpponentHandleChooseAction(void)
else else
{ {
u8 chosenMoveId; 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)) if (gBattleTypeFlags & (BATTLE_TYPE_TRAINER | BATTLE_TYPE_FIRST_BATTLE | BATTLE_TYPE_SAFARI | BATTLE_TYPE_ROAMER))
{ {
BattleAI_SetupAIData(0xF); BattleAI_SetupAIData(0xF);
@ -1573,9 +1574,9 @@ static void OpponentHandleChooseAction(void)
BtlController_EmitTwoReturnValues(1, B_ACTION_RUN, 0); BtlController_EmitTwoReturnValues(1, B_ACTION_RUN, 0);
break; break;
default: 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; 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); gBattlerTarget = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT);
if (gAbsentBattlerFlags & gBitTable[gBattlerTarget]) if (gAbsentBattlerFlags & gBitTable[gBattlerTarget])
@ -1596,7 +1597,7 @@ static void OpponentHandleChooseAction(void)
do do
{ {
chosenMoveId = Random() & 3; chosenMoveId = Random() & 3;
move = moveInfo->moves[chosenMoveId]; move = moveInfo.moves[chosenMoveId];
} while (move == MOVE_NONE); } while (move == MOVE_NONE);
if (gBattleMoves[move].target & (MOVE_TARGET_USER_OR_SELECTED | MOVE_TARGET_USER)) if (gBattleMoves[move].target & (MOVE_TARGET_USER_OR_SELECTED | MOVE_TARGET_USER))