From dc0d9101820bc5187db8a577e2529019a6346cb2 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Wed, 22 Oct 2025 10:20:44 -0300 Subject: [PATCH] Fixed Stomping Tantrum not doubling in damage if the user failed Protect (#8008) --- include/random.h | 1 + src/battle_script_commands.c | 3 ++- test/battle/move_effect/stomping_tantrum.c | 25 ++++++++++++++++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/include/random.h b/include/random.h index df3e1579ad..816cf9b40a 100644 --- a/include/random.h +++ b/include/random.h @@ -217,6 +217,7 @@ enum RandomTag RNG_WRAP, RNG_BALLTHROW_CRITICAL, RNG_BALLTHROW_SHAKE, + RNG_PROTECT_FAIL, }; #define RandomWeighted(tag, ...) \ diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index e5bd66a0ac..7cd573f5ae 100755 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -9575,7 +9575,7 @@ static void Cmd_setprotectlike(void) if (gCurrentTurnActionNumber == (gBattlersCount - 1)) notLastTurn = FALSE; - if ((sProtectSuccessRates[gDisableStructs[gBattlerAttacker].protectUses] >= Random() && notLastTurn) + if ((sProtectSuccessRates[gDisableStructs[gBattlerAttacker].protectUses] >= RandomUniform(RNG_PROTECT_FAIL, 0, USHRT_MAX) && notLastTurn) || (protectMethod == PROTECT_WIDE_GUARD && B_WIDE_GUARD != GEN_5) || (protectMethod == PROTECT_QUICK_GUARD && B_QUICK_GUARD != GEN_5)) { @@ -9604,6 +9604,7 @@ static void Cmd_setprotectlike(void) gDisableStructs[gBattlerAttacker].protectUses = 0; gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_PROTECT_FAILED; gBattleStruct->moveResultFlags[gBattlerTarget] |= MOVE_RESULT_MISSED; + gBattleStruct->battlerState[gBattlerAttacker].stompingTantrumTimer = 2; } gBattlescriptCurrInstr = cmd->nextInstr; diff --git a/test/battle/move_effect/stomping_tantrum.c b/test/battle/move_effect/stomping_tantrum.c index 95d93e07e6..06b29334d7 100644 --- a/test/battle/move_effect/stomping_tantrum.c +++ b/test/battle/move_effect/stomping_tantrum.c @@ -90,6 +90,31 @@ SINGLE_BATTLE_TEST("Stomping Tantrum will not deal double damage if target prote } } +SINGLE_BATTLE_TEST("Stomping Tantrum will deal double damage if user failed a Protect") +{ + s16 damage[2]; + GIVEN { + PLAYER(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(player, MOVE_STOMPING_TANTRUM); } + TURN { MOVE(player, MOVE_PROTECT); } + TURN { MOVE(player, MOVE_PROTECT, WITH_RNG(RNG_PROTECT_FAIL, USHRT_MAX)); } + TURN { MOVE(player, MOVE_STOMPING_TANTRUM); } + } SCENE { + ANIMATION(ANIM_TYPE_MOVE, MOVE_STOMPING_TANTRUM, player); + HP_BAR(opponent, captureDamage: &damage[0]); + + ANIMATION(ANIM_TYPE_MOVE, MOVE_PROTECT, player); + NOT ANIMATION(ANIM_TYPE_MOVE, MOVE_PROTECT, player); + + ANIMATION(ANIM_TYPE_MOVE, MOVE_STOMPING_TANTRUM, player); + HP_BAR(opponent, captureDamage: &damage[1]); + } THEN { + EXPECT_MUL_EQ(damage[0], Q_4_12(2.0), damage[1]); + } +} + SINGLE_BATTLE_TEST("Stomping Tantrum will not deal double if it missed") { s16 damage[2];