From 5317371fea83dad230527d8b6a86c654bd32e95f Mon Sep 17 00:00:00 2001 From: Alex <93446519+AlexOn1ine@users.noreply.github.com> Date: Mon, 6 Jan 2025 12:03:41 +0100 Subject: [PATCH] Last fix for Sparkling Aria / Covert Cloak / Shield Dust interaction (#5956) --- include/battle_util.h | 1 + src/battle_script_commands.c | 2 +- src/battle_util.c | 17 +++++++++++++++++ test/battle/ability/shield_dust.c | 1 - test/battle/hold_effect/covert_cloak.c | 25 +++++++++++++++++++++++++ 5 files changed, 44 insertions(+), 2 deletions(-) diff --git a/include/battle_util.h b/include/battle_util.h index 1d316667e0..5ab3c3495b 100644 --- a/include/battle_util.h +++ b/include/battle_util.h @@ -338,5 +338,6 @@ bool32 IsSleepClauseEnabled(); void ClearDamageCalcResults(void); u32 DoesDestinyBondFail(u32 battler); bool32 IsMoveEffectBlockedByTarget(u32 ability); +u32 NumAffectedSpreadMoveTargets(void); #endif // GUARD_BATTLE_UTIL_H diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index b08b53a044..1c5c7bbc17 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -6275,7 +6275,7 @@ static void Cmd_moveend(void) if ((gBattleMons[gBattlerTarget].status1 & argStatus) && IsBattlerAlive(gBattlerTarget) && !DoesSubstituteBlockMove(gBattlerAttacker, gBattlerTarget, gCurrentMove) - && (gBattleStruct->numSpreadTargets > 1 || !IsMoveEffectBlockedByTarget(GetBattlerAbility(gBattlerTarget)))) + && (NumAffectedSpreadMoveTargets() > 1 || !IsMoveEffectBlockedByTarget(GetBattlerAbility(gBattlerTarget)))) { gBattleMons[gBattlerTarget].status1 &= ~(argStatus); diff --git a/src/battle_util.c b/src/battle_util.c index 19551f8854..a6429d935b 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -12224,3 +12224,20 @@ bool32 IsMoveEffectBlockedByTarget(u32 ability) return FALSE; } + +u32 NumAffectedSpreadMoveTargets(void) +{ + u32 targetCount = 1; + + if (!IsDoubleSpreadMove()) + return targetCount; + + targetCount = 0; + for (u32 battler = 0; battler < gBattlersCount; battler++) + { + if (MoveResultHasEffect(battler)) + targetCount++; + } + + return targetCount; +} diff --git a/test/battle/ability/shield_dust.c b/test/battle/ability/shield_dust.c index 5833615027..bb56f84211 100644 --- a/test/battle/ability/shield_dust.c +++ b/test/battle/ability/shield_dust.c @@ -149,7 +149,6 @@ DOUBLE_BATTLE_TEST("Shield Dust does or does not block Sparkling Aria depending DOUBLE_BATTLE_TEST("Shield Dust blocks Sparkling Aria if all other targets avoid getting hit by") { - KNOWN_FAILING; // #4636 GIVEN { PLAYER(SPECIES_PRIMARINA); PLAYER(SPECIES_VIVILLON) { Ability(ABILITY_SHIELD_DUST); Status1(STATUS1_BURN); } diff --git a/test/battle/hold_effect/covert_cloak.c b/test/battle/hold_effect/covert_cloak.c index 150ddcbba3..183033cb71 100644 --- a/test/battle/hold_effect/covert_cloak.c +++ b/test/battle/hold_effect/covert_cloak.c @@ -150,6 +150,31 @@ DOUBLE_BATTLE_TEST("Covert Cloak does or does not block Sparkling Aria depending } } +DOUBLE_BATTLE_TEST("Covert Cloak does block Sparkling Aria when only one mon is hit") +{ + u32 move; + PARAMETRIZE { move = MOVE_PROTECT; } + PARAMETRIZE { move = MOVE_FLY; } + + GIVEN { + PLAYER(SPECIES_WYNAUT); + PLAYER(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_WOBBUFFET) { Item(ITEM_COVERT_CLOAK); Status1(STATUS1_BURN); } + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(opponentRight, move, target: playerLeft); + MOVE(playerRight, move, target: opponentRight); + MOVE(playerLeft, MOVE_SPARKLING_ARIA); } + } SCENE { + ANIMATION(ANIM_TYPE_MOVE, move, opponentRight); + ANIMATION(ANIM_TYPE_MOVE, MOVE_SPARKLING_ARIA, playerLeft); + NONE_OF { + MESSAGE("The opposing Wobbuffet's burn was cured!"); + STATUS_ICON(opponentLeft, none: TRUE); + } + } +} + SINGLE_BATTLE_TEST("Covert Cloak blocks Sparkling Aria in singles") { GIVEN {