From afe09e96532165c044848ace9a3a3ed034567041 Mon Sep 17 00:00:00 2001 From: Martin Griffin Date: Sun, 19 Feb 2023 21:08:30 +0000 Subject: [PATCH] Test Dragon Tail Remove the "But it failed!" message if the foe cannot be switched. --- data/battle_scripts_1.s | 7 ++- include/battle_scripts.h | 1 - src/battle_script_commands.c | 2 +- test/move_effect_hit_switch_target.c | 72 ++++++++++++++++++++++++++++ 4 files changed, 76 insertions(+), 6 deletions(-) create mode 100644 test/move_effect_hit_switch_target.c diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 6fa0cd7ad..53925b578 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -2128,9 +2128,9 @@ BattleScript_EffectHitSwitchTarget: moveendall jumpifability BS_TARGET, ABILITY_SUCTION_CUPS, BattleScript_AbilityPreventsPhasingOut jumpifstatus3 BS_TARGET, STATUS3_ROOTED, BattleScript_PrintMonIsRooted - tryhitswitchtarget BattleScript_EffectHitSwitchTargetMoveEnd -BattleScript_EffectHitSwitchTargetMoveEnd: - end + tryhitswitchtarget BattleScript_MoveEnd + forcerandomswitch BattleScript_MoveEnd + goto BattleScript_MoveEnd BattleScript_EffectClearSmog: setmoveeffect MOVE_EFFECT_CLEAR_SMOG @@ -3708,7 +3708,6 @@ BattleScript_EffectRoar:: accuracycheck BattleScript_ButItFailed, NO_ACC_CALC_CHECK_LOCK_ON accuracycheck BattleScript_MoveMissedPause, ACC_CURR_MOVE jumpifbattletype BATTLE_TYPE_ARENA, BattleScript_ButItFailed -BattleScript_ForceRandomSwitch:: forcerandomswitch BattleScript_ButItFailed BattleScript_EffectMultiHit:: diff --git a/include/battle_scripts.h b/include/battle_scripts.h index 70d398e2a..d4e4d4b3c 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -293,7 +293,6 @@ extern const u8 BattleScript_WishMegaEvolution[]; extern const u8 BattleScript_MoveEffectRecoilWithStatus[]; extern const u8 BattleScript_EffectWithChance[]; extern const u8 BattleScript_MoveEffectClearSmog[]; -extern const u8 BattleScript_ForceRandomSwitch[]; extern const u8 BattleScript_SideStatusWoreOffReturn[]; extern const u8 BattleScript_MoveEffectSmackDown[]; extern const u8 BattleScript_MoveEffectFlameBurst[]; diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index b4bafd215..fdd3d4f07 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -9792,7 +9792,7 @@ static void Cmd_various(void) && GetBattlerAbility(gBattlerTarget) != ABILITY_GUARD_DOG) { gBattleScripting.switchCase = B_SWITCH_HIT; - gBattlescriptCurrInstr = BattleScript_ForceRandomSwitch; + gBattlescriptCurrInstr = cmd->nextInstr; } else { diff --git a/test/move_effect_hit_switch_target.c b/test/move_effect_hit_switch_target.c new file mode 100644 index 000000000..9c50a4e4c --- /dev/null +++ b/test/move_effect_hit_switch_target.c @@ -0,0 +1,72 @@ +#include "global.h" +#include "test_battle.h" + +ASSUMPTIONS +{ + ASSUME(gBattleMoves[MOVE_DRAGON_TAIL].effect == EFFECT_HIT_SWITCH_TARGET); + ASSUME(gBattleMoves[MOVE_LOCK_ON].effect == EFFECT_LOCK_ON); +} + +SINGLE_BATTLE_TEST("Dragon Tail switches the target with a random non-fainted replacement") +{ + KNOWN_FAILING; // Only 18/50. Waiting for an improved PASSES_RANDOMLY. + PASSES_RANDOMLY(90 * 1, 100 * 2); + GIVEN { + PLAYER(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_BULBASAUR); + OPPONENT(SPECIES_CHARMANDER); + OPPONENT(SPECIES_SQUIRTLE) { HP(0); } + } WHEN { + TURN { MOVE(player, MOVE_DRAGON_TAIL); } + } SCENE { + ANIMATION(ANIM_TYPE_MOVE, MOVE_DRAGON_TAIL, player); + MESSAGE("Foe Bulbasaur was dragged out!"); + } +} + +DOUBLE_BATTLE_TEST("Dragon Tail switches the target with a random non-battler, non-fainted replacement") +{ + PASSES_RANDOMLY(90 * 1, 100 * 2); + GIVEN { + PLAYER(SPECIES_WOBBUFFET); + PLAYER(SPECIES_WYNAUT); + OPPONENT(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_WYNAUT); + OPPONENT(SPECIES_BULBASAUR); + OPPONENT(SPECIES_CHARMANDER); + OPPONENT(SPECIES_SQUIRTLE) { HP(0); } + } WHEN { + TURN { MOVE(playerLeft, MOVE_DRAGON_TAIL, target: opponentRight); } + } SCENE { + ANIMATION(ANIM_TYPE_MOVE, MOVE_DRAGON_TAIL, playerLeft); + MESSAGE("Foe Bulbasaur was dragged out!"); + } +} + +SINGLE_BATTLE_TEST("Dragon Tail does not fail if no replacements") +{ + GIVEN { + PLAYER(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(player, MOVE_DRAGON_TAIL); } + } SCENE { + ANIMATION(ANIM_TYPE_MOVE, MOVE_DRAGON_TAIL, player); + NOT MESSAGE("But it failed!"); + } +} + +SINGLE_BATTLE_TEST("Dragon Tail does not fail if replacements fainted") +{ + GIVEN { + PLAYER(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_WYNAUT) { HP(0); } + } WHEN { + TURN { MOVE(player, MOVE_DRAGON_TAIL); } + } SCENE { + ANIMATION(ANIM_TYPE_MOVE, MOVE_DRAGON_TAIL, player); + NOT MESSAGE("But it failed!"); + } +}