From b7d77099b524c818619e8a7e6f4432b93381109a Mon Sep 17 00:00:00 2001 From: Alex <93446519+AlexOn1ine@users.noreply.github.com> Date: Sat, 10 Feb 2024 18:18:29 +0100 Subject: [PATCH] Fixes Opportunist accumulating stat changes (#4168) * Fixes Opportunist accumulating stat changes * move memset to TurnValuesCleanUp * Update test/battle/ability/opportunist.c --------- Co-authored-by: Bassoonian --- src/battle_main.c | 1 + test/battle/ability/opportunist.c | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/src/battle_main.c b/src/battle_main.c index 67f2cf1737..99ab2a87a1 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -4914,6 +4914,7 @@ static void TurnValuesCleanUp(bool8 var0) else { memset(&gProtectStructs[i], 0, sizeof(struct ProtectStruct)); + memset(&gQueuedStatBoosts[i], 0, sizeof(gQueuedStatBoosts)); if (gDisableStructs[i].isFirstTurn) gDisableStructs[i].isFirstTurn--; diff --git a/test/battle/ability/opportunist.c b/test/battle/ability/opportunist.c index 79c6649f59..60e127c708 100644 --- a/test/battle/ability/opportunist.c +++ b/test/battle/ability/opportunist.c @@ -101,6 +101,24 @@ DOUBLE_BATTLE_TEST("Opportunist raises Attack only once when partner has Intimid } } +SINGLE_BATTLE_TEST("Opportunist does not accumulate opposing mon's stat changes") +{ + GIVEN { + PLAYER(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_ESPATHRA) { Ability(ABILITY_OPPORTUNIST); } + } WHEN { + TURN { MOVE(player, MOVE_SWORDS_DANCE); } + TURN { MOVE(player, MOVE_SWORDS_DANCE); } + } SCENE { + ANIMATION(ANIM_TYPE_MOVE, MOVE_SWORDS_DANCE, player); + ABILITY_POPUP(opponent, ABILITY_OPPORTUNIST); + ANIMATION(ANIM_TYPE_MOVE, MOVE_SWORDS_DANCE, player); + ABILITY_POPUP(opponent, ABILITY_OPPORTUNIST); + } THEN { + EXPECT_EQ(opponent->statStages[STAT_ATK], DEFAULT_STAT_STAGE + 4); + } +} + TO_DO_BATTLE_TEST("Opportunist doesn't copy ally stat increases"); TO_DO_BATTLE_TEST("Opportunist doesn't copy foe stat increases gained via Opportunist"); TO_DO_BATTLE_TEST("Opportunist copies foe stat increased gained via Swagger and Flatter");