From 773ecd4c24aeaae1c49e86f30f93925ff53cc59e Mon Sep 17 00:00:00 2001 From: Alex <93446519+AlexOn1ine@users.noreply.github.com> Date: Wed, 25 Jun 2025 21:00:49 +0200 Subject: [PATCH] Fixes OOB for Teatime and Flower Shield (#7214) --- data/battle_scripts_1.s | 7 ++++++- src/battle_script_commands.c | 5 +++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index a10dfaa40c..2b9f5e36e4 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -1503,11 +1503,12 @@ BattleScript_EffectFlowerShield:: attackcanceler attackstring ppreduce + savetarget selectfirstvalidtarget BattleScript_FlowerShieldIsAnyGrass: jumpiftype BS_TARGET, TYPE_GRASS, BattleScript_FlowerShieldLoopStart jumpifnexttargetvalid BattleScript_FlowerShieldIsAnyGrass - goto BattleScript_ButItFailed + goto BattleScript_RestoreTargetButItFailed BattleScript_FlowerShieldLoopStart: selectfirstvalidtarget BattleScript_FlowerShieldLoop: @@ -1532,6 +1533,7 @@ BattleScript_FlowerShieldString: BattleScript_FlowerShieldMoveTargetEnd: moveendto MOVEEND_NEXT_TARGET jumpifnexttargetvalid BattleScript_FlowerShieldLoop + restoretarget end BattleScript_EffectRototiller:: @@ -4513,6 +4515,9 @@ BattleScript_ButItFailed:: BattleScript_RestoreAttackerButItFailed: restoreattacker goto BattleScript_ButItFailed +BattleScript_RestoreTargetButItFailed: + restoretarget + goto BattleScript_ButItFailed BattleScript_NotAffected:: pause B_WAIT_TIME_SHORT diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index bd2ef1509e..2b67c7116f 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -11751,9 +11751,14 @@ static void Cmd_jumpifnexttargetvalid(void) } if (gBattlerTarget >= gBattlersCount) + { + gBattlerTarget = gBattlersCount - 1; gBattlescriptCurrInstr = cmd->nextInstr; + } else + { gBattlescriptCurrInstr = jumpInstr; + } } static void Cmd_tryhealhalfhealth(void)