Skip to content

Commit

Permalink
Add check for Magic Guard to avoid taking recoil damage (rh-hideout#4578
Browse files Browse the repository at this point in the history
)

* 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
  • Loading branch information
iriv24 authored and Pid64 committed Jun 2, 2024
1 parent 1b4ec35 commit 00e1e51
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
1 change: 1 addition & 0 deletions data/battle_scripts_1.s
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 17 additions & 0 deletions test/battle/ability/magic_guard.c
Original file line number Diff line number Diff line change
@@ -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);
}
}
3 changes: 2 additions & 1 deletion test/battle/move_effect/max_hp_50_recoil.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
3 changes: 2 additions & 1 deletion test/battle/move_effect/mind_blown.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down

0 comments on commit 00e1e51

Please sign in to comment.