From 47abc33c84f5b374d9513245d6c8a41f534378b7 Mon Sep 17 00:00:00 2001 From: Hungry Pickle <81360291+HungryPickle@users.noreply.github.com> Date: Fri, 9 Feb 2024 09:35:40 -0500 Subject: [PATCH] Fixes Stench ability triggering on non-damaging attacks (#4159) * Fixes Stench ability triggering on non-damaging attacks * adds stench ability test * added stench ability test for partner pokemon --------- Co-authored-by: HungryPickle --- src/battle_util.c | 2 +- test/battle/ability/stench.c | 48 ++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/src/battle_util.c b/src/battle_util.c index 0674329c3a8f..cbc5898f911c 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -5792,7 +5792,7 @@ u32 AbilityBattleEffects(u32 caseID, u32 battler, u32 ability, u32 special, u32 && gBattleMons[gBattlerTarget].hp != 0 && !gProtectStructs[gBattlerAttacker].confusionSelfDmg && RandomWeighted(RNG_STENCH, 9, 1) - && !IS_MOVE_STATUS(move) + && TARGET_TURN_DAMAGED && gBattleMoves[gCurrentMove].effect != EFFECT_FLINCH_HIT && gBattleMoves[gCurrentMove].effect != EFFECT_FLINCH_STATUS && gBattleMoves[gCurrentMove].effect != EFFECT_TRIPLE_ARROWS) diff --git a/test/battle/ability/stench.c b/test/battle/ability/stench.c index 4153e6b15503..62944a2f4d0e 100644 --- a/test/battle/ability/stench.c +++ b/test/battle/ability/stench.c @@ -31,4 +31,52 @@ SINGLE_BATTLE_TEST("Stench does not stack with King's Rock") } } +DOUBLE_BATTLE_TEST("Stench only triggers if target takes damage") +{ + GIVEN { + ASSUME(gBattleMoves[MOVE_TACKLE].power > 0); + ASSUME(gBattleMoves[MOVE_FAKE_OUT].effect == EFFECT_FAKE_OUT); + PLAYER(SPECIES_WOBBUFFET); + PLAYER(SPECIES_WYNAUT); + OPPONENT(SPECIES_GRIMER) { Ability(ABILITY_STENCH); } + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { + MOVE(playerLeft, MOVE_FAKE_OUT, target: opponentLeft); + MOVE(opponentLeft, MOVE_TACKLE, WITH_RNG(RNG_STENCH, TRUE), target: playerRight); + MOVE(playerRight, MOVE_TACKLE, target: opponentRight); + } + TURN { + MOVE(opponentLeft, MOVE_SCARY_FACE, WITH_RNG(RNG_STENCH, TRUE), target: playerRight); + MOVE(playerRight, MOVE_TACKLE, target: opponentRight); + } + } SCENE { + NONE_OF { MESSAGE("Wynaut flinched!"); } + } +} + +DOUBLE_BATTLE_TEST("Stench doesn't trigger if partner uses a move") +{ + GIVEN { + ASSUME(gBattleMoves[MOVE_TACKLE].power > 0); + ASSUME(gBattleMoves[MOVE_FAKE_OUT].effect == EFFECT_FAKE_OUT); + PLAYER(SPECIES_WOBBUFFET) { Speed(20); } + PLAYER(SPECIES_WYNAUT) { Speed(10); } + OPPONENT(SPECIES_GRIMER) { Speed(100); Ability(ABILITY_STENCH); } + OPPONENT(SPECIES_WOBBUFFET) {Speed(50); } + } WHEN { + TURN { + MOVE(playerLeft, MOVE_FAKE_OUT, target: opponentLeft); + MOVE(opponentRight, MOVE_TACKLE, target: playerRight); + MOVE(playerRight, MOVE_TACKLE, target: opponentRight); + } + } SCENE { + ANIMATION(ANIM_TYPE_MOVE, MOVE_FAKE_OUT, playerLeft); + MESSAGE("Foe Grimer flinched!"); + ANIMATION(ANIM_TYPE_MOVE, MOVE_TACKLE, opponentRight); + NOT MESSAGE("Wynaut flinched!"); + ANIMATION(ANIM_TYPE_MOVE, MOVE_TACKLE, playerRight); + } +} + // TODO: Test against interaction with multi hits