diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc index 96bbe2d370..c4bfea9a5f 100644 --- a/asm/macros/battle_script.inc +++ b/asm/macros/battle_script.inc @@ -1398,8 +1398,8 @@ callnative BS_AllySwitchSwapBattler .endm - .macro allyswitchfailchance jumpInstr:req - callnative BS_AllySwitchFailChance + .macro tryallyswitch jumpInstr:req + callnative BS_TryAllySwitch .4byte \jumpInstr .endm diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 45bee115b8..f2a2f40f7d 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -1105,8 +1105,7 @@ BattleScript_EffectAllySwitch:: accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE attackstring ppreduce - jumpifnoally BS_ATTACKER, BattleScript_ButItFailed - allyswitchfailchance BattleScript_ButItFailed + tryallyswitch BattleScript_ButItFailed attackanimation waitanimation @ The actual data/gfx swap happens in the move animation. Here it's just the gBattlerAttacker / scripting battler change diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 92adb1d9c8..4e6109e93b 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -17699,25 +17699,34 @@ void BS_AllySwitchSwapBattler(void) gBattlescriptCurrInstr = cmd->nextInstr; } -void BS_AllySwitchFailChance(void) +void BS_TryAllySwitch(void) { NATIVE_ARGS(const u8 *failInstr); - if (B_ALLY_SWITCH_FAIL_CHANCE >= GEN_9) + if (!IsBattlerAlive(BATTLE_PARTNER(gBattlerAttacker)) + || (GetBattlerSide(gBattlerAttacker) == B_SIDE_PLAYER && gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER) + || (GetBattlerSide(gBattlerAttacker) == B_SIDE_OPPONENT && gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS)) + { + gBattlescriptCurrInstr = cmd->failInstr; + } + else if (B_ALLY_SWITCH_FAIL_CHANCE >= GEN_9) { TryResetProtectUseCounter(gBattlerAttacker); if (sProtectSuccessRates[gDisableStructs[gBattlerAttacker].protectUses] < Random()) { gDisableStructs[gBattlerAttacker].protectUses = 0; gBattlescriptCurrInstr = cmd->failInstr; - return; } else { gDisableStructs[gBattlerAttacker].protectUses++; + gBattlescriptCurrInstr = cmd->nextInstr; } } - gBattlescriptCurrInstr = cmd->nextInstr; + else + { + gBattlescriptCurrInstr = cmd->nextInstr; + } } void BS_RunStatChangeItems(void)