Skip to content

Commit

Permalink
Fixes Stench ability triggering on non-damaging attacks (rh-hideout#4159
Browse files Browse the repository at this point in the history
)

* Fixes Stench ability triggering on non-damaging attacks

* adds stench ability test

* added stench ability test for partner pokemon

---------

Co-authored-by: HungryPickle <beardybirdy@gmail.com>
  • Loading branch information
HungryPickle and HungryPickle authored Feb 9, 2024
1 parent e89f8e0 commit 47abc33
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/battle_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
48 changes: 48 additions & 0 deletions test/battle/ability/stench.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 47abc33

Please sign in to comment.