From 00e1e512b4e8df9a84f12b508a5a4fd7e4df5d98 Mon Sep 17 00:00:00 2001 From: Isaac Rivera <40581123+iriv24@users.noreply.github.com> Date: Wed, 15 May 2024 09:40:40 -0400 Subject: [PATCH] Add check for Magic Guard to avoid taking recoil damage (#4578) * Add check for Magic Guard to avoid taking recoil damage * add test to verify a mon with magic guard does not take recoil damage followed format from "Steel Beam hp loss is prevented by Magic Guard" test * update format of tests with magic guard and some form of recoil damage --- data/battle_scripts_1.s | 1 + test/battle/ability/magic_guard.c | 17 +++++++++++++++++ test/battle/move_effect/max_hp_50_recoil.c | 3 ++- test/battle/move_effect/mind_blown.c | 3 ++- 4 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 test/battle/ability/magic_guard.c diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index f20e13e8ae0a..a0f1e81ae344 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -7467,6 +7467,7 @@ BattleScript_MoveEffectConfusion:: BattleScript_MoveEffectRecoil:: jumpifmove MOVE_STRUGGLE, BattleScript_DoRecoil jumpifability BS_ATTACKER, ABILITY_ROCK_HEAD, BattleScript_RecoilEnd + jumpifability BS_ATTACKER, ABILITY_MAGIC_GUARD, BattleScript_RecoilEnd BattleScript_DoRecoil:: orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_PASSIVE_DAMAGE | HITMARKER_IGNORE_DISGUISE healthbarupdate BS_ATTACKER diff --git a/test/battle/ability/magic_guard.c b/test/battle/ability/magic_guard.c new file mode 100644 index 000000000000..69e8bac9c7fc --- /dev/null +++ b/test/battle/ability/magic_guard.c @@ -0,0 +1,17 @@ +#include "global.h" +#include "test/battle.h" + +SINGLE_BATTLE_TEST("Magic Guard prevents recoil damage to the user") +{ + GIVEN { + ASSUME(gMovesInfo[MOVE_DOUBLE_EDGE].recoil == 33); + PLAYER(SPECIES_CLEFABLE) { Ability(ABILITY_MAGIC_GUARD); } + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(player, MOVE_DOUBLE_EDGE); } + } SCENE { + ANIMATION(ANIM_TYPE_MOVE, MOVE_DOUBLE_EDGE, player); + HP_BAR(opponent); + NOT HP_BAR(player); + } +} diff --git a/test/battle/move_effect/max_hp_50_recoil.c b/test/battle/move_effect/max_hp_50_recoil.c index 8d5cbdaed2cd..1ac98854e095 100644 --- a/test/battle/move_effect/max_hp_50_recoil.c +++ b/test/battle/move_effect/max_hp_50_recoil.c @@ -91,8 +91,9 @@ SINGLE_BATTLE_TEST("Steel Beam hp loss is prevented by Magic Guard") } WHEN { TURN { MOVE(player, MOVE_STEEL_BEAM); } } SCENE { - NOT HP_BAR(player); ANIMATION(ANIM_TYPE_MOVE, MOVE_STEEL_BEAM, player); + HP_BAR(opponent); + NOT HP_BAR(player); } } diff --git a/test/battle/move_effect/mind_blown.c b/test/battle/move_effect/mind_blown.c index f1b7d8b98a46..da39cf18d787 100644 --- a/test/battle/move_effect/mind_blown.c +++ b/test/battle/move_effect/mind_blown.c @@ -114,8 +114,9 @@ SINGLE_BATTLE_TEST("Mind Blown hp loss is prevented by Magic Guard") } WHEN { TURN { MOVE(player, MOVE_MIND_BLOWN); } } SCENE { - NOT HP_BAR(player); ANIMATION(ANIM_TYPE_MOVE, MOVE_MIND_BLOWN, player); + HP_BAR(opponent); + NOT HP_BAR(player); } }