From 68c51f84121f12dc87737ad3283a3e5a974f4093 Mon Sep 17 00:00:00 2001 From: Alex <93446519+AlexOn1ine@users.noreply.github.com> Date: Thu, 19 Sep 2024 12:00:32 +0200 Subject: [PATCH] Fixes Spiky Shield Counter interaction (#5402) * Fixes Spiky Shield Counter interaction * Update test/battle/move_effect/protect.c --------- Co-authored-by: Bassoonian --- src/battle_script_commands.c | 4 +++- test/battle/move_effect/protect.c | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index ee2a148831..0048cf14e4 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -5448,7 +5448,9 @@ static void Cmd_moveend(void) case MOVEEND_PROTECT_LIKE_EFFECT: if (gProtectStructs[gBattlerAttacker].touchedProtectLike) { - if (gProtectStructs[gBattlerTarget].spikyShielded && GetBattlerAbility(gBattlerAttacker) != ABILITY_MAGIC_GUARD) + if (gProtectStructs[gBattlerTarget].spikyShielded + && gMovesInfo[gCurrentMove].effect != EFFECT_COUNTER + && GetBattlerAbility(gBattlerAttacker) != ABILITY_MAGIC_GUARD) { gProtectStructs[gBattlerAttacker].touchedProtectLike = FALSE; gBattleMoveDamage = GetNonDynamaxMaxHP(gBattlerAttacker) / 8; diff --git a/test/battle/move_effect/protect.c b/test/battle/move_effect/protect.c index aca5ef859d..60b55ebb75 100644 --- a/test/battle/move_effect/protect.c +++ b/test/battle/move_effect/protect.c @@ -547,3 +547,22 @@ DOUBLE_BATTLE_TEST("Crafty Shield does not protect against moves that target all MESSAGE("Foe Sunflora's Defense rose!"); } } + +SINGLE_BATTLE_TEST("Spiky Shield does not damage users on Counter or Mirror Coat") +{ + u32 move; + PARAMETRIZE { move = MOVE_MIRROR_COAT; } + PARAMETRIZE { move = MOVE_COUNTER; } + GIVEN { + PLAYER(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(player, MOVE_SPIKY_SHIELD); MOVE(opponent, move); } + } SCENE { + ANIMATION(ANIM_TYPE_MOVE, MOVE_SPIKY_SHIELD, player); + NONE_OF { + ANIMATION(ANIM_TYPE_MOVE, move, opponent); + HP_BAR(opponent); + } + } +}