From f9bb0bfb29bfeea8cf8dc391f52d8945a4012260 Mon Sep 17 00:00:00 2001 From: walkingeyerobot Date: Wed, 25 Jan 2023 15:15:58 -0500 Subject: [PATCH] better handle throwing balls in a double wild battle (#2587) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Handle throwing balls in a double wild battle where the player has only a single Pokémon. --- src/battle_main.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/battle_main.c b/src/battle_main.c index c29775082..7ec8ad285 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -4005,7 +4005,8 @@ static void HandleTurnActionSelectionState(void) } else if (WILD_DOUBLE_BATTLE && position == B_POSITION_PLAYER_RIGHT - && (gBattleStruct->throwingPokeBall || gChosenActionByBattler[GetBattlerAtPosition(B_POSITION_PLAYER_LEFT)] == B_ACTION_RUN)) + && (gBattleStruct->throwingPokeBall || gChosenActionByBattler[GetBattlerAtPosition(B_POSITION_PLAYER_LEFT)] == B_ACTION_RUN) + && gChosenActionByBattler[GetBattlerAtPosition(B_POSITION_PLAYER_LEFT)] != B_ACTION_NOTHING_FAINTED) { gBattleStruct->throwingPokeBall = FALSE; gChosenActionByBattler[gActiveBattler] = B_ACTION_NOTHING_FAINTED; // Not fainted, but it cannot move, because of the throwing ball. @@ -4419,10 +4420,13 @@ static void HandleTurnActionSelectionState(void) { RecordedBattle_CheckMovesetChanges(B_RECORD_MODE_RECORDING); - if (WILD_DOUBLE_BATTLE && gBattleStruct->throwingPokeBall) { + if (WILD_DOUBLE_BATTLE + && gBattleStruct->throwingPokeBall + && gChosenActionByBattler[GetBattlerAtPosition(B_POSITION_PLAYER_RIGHT)] != B_ACTION_NOTHING_FAINTED) + { // if we choose to throw a ball with our second mon, skip the action of the first // (if we have chosen throw ball with first, second's is already skipped) - gChosenActionByBattler[B_POSITION_PLAYER_LEFT] = B_ACTION_NOTHING_FAINTED; + gChosenActionByBattler[GetBattlerAtPosition(B_POSITION_PLAYER_LEFT)] = B_ACTION_NOTHING_FAINTED; } gBattleMainFunc = SetActionsAndBattlersTurnOrder;