From c6a207c37b052c954b1e3ccd1bddbc86f0f2b0b3 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Fri, 23 Nov 2018 22:26:36 +0100 Subject: [PATCH] Fix Teleport in double wild battles --- src/battle_script_commands.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index f793dad2e8..d4175643f0 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -6456,10 +6456,25 @@ static void atk76_various(void) return; break; case VARIOUS_SET_TELEPORT_OUTCOME: - if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) + // Don't end the battle if one of the wild mons teleported from the wild double battle + // and its partner is still alive. + if (GetBattlerSide(gActiveBattler) == B_SIDE_OPPONENT && IsBattlerAlive(BATTLE_PARTNER(gActiveBattler))) + { + gAbsentBattlerFlags |= gBitTable[gActiveBattler]; + gHitMarker |= HITMARKER_FAINTED(gActiveBattler); + gBattleMons[gActiveBattler].hp = 0; + SetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_HP, &gBattleMons[gActiveBattler].hp); + SetHealthboxSpriteInvisible(gHealthboxSpriteIds[gActiveBattler]); + FaintClearSetData(); + } + else if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) + { gBattleOutcome = B_OUTCOME_PLAYER_TELEPORTED; + } else + { gBattleOutcome = B_OUTCOME_MON_TELEPORTED; + } break; case VARIOUS_PLAY_TRAINER_DEFEATED_MUSIC: BtlController_EmitPlayFanfareOrBGM(0, MUS_KACHI1, TRUE);