better handle throwing balls in a double wild battle (#2587)

* Handle throwing balls in a double wild battle where the player has only a single Pokémon.
This commit is contained in:
walkingeyerobot 2023-01-25 15:15:58 -05:00 committed by GitHub
parent 1202f0366c
commit f9bb0bfb29
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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;