From 312dcbb8a8f9ec3b08be7c3ae1d32389c0bc92d9 Mon Sep 17 00:00:00 2001 From: sneed <56992013+Sneed69@users.noreply.github.com> Date: Fri, 24 May 2024 12:21:35 +0300 Subject: [PATCH] Speed Ignoring effect fixes (#4613) * Custap ties with Quick Draw, Stall with Mycelium * add a test --- src/battle_main.c | 28 ++++++++++++---------------- test/battle/ability/mycelium_might.c | 24 ++++++++++++++++++++++++ test/battle/hold_effect/quick_claw.c | 3 ++- 3 files changed, 38 insertions(+), 17 deletions(-) diff --git a/src/battle_main.c b/src/battle_main.c index 413d50c5856e..0332214b9db3 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -5071,29 +5071,25 @@ s32 GetWhichBattlerFasterArgs(u32 battler1, u32 battler2, bool32 ignoreChosenMov if (priority1 == priority2) { - // QUICK CLAW / CUSTAP - always first - // LAGGING TAIL - always last - // STALL - always last - - if (gProtectStructs[battler1].quickDraw && !gProtectStructs[battler2].quickDraw) - strikesFirst = 1; - else if (!gProtectStructs[battler1].quickDraw && gProtectStructs[battler2].quickDraw) - strikesFirst = -1; - else if (gProtectStructs[battler1].usedCustapBerry && !gProtectStructs[battler2].usedCustapBerry) + // Quick Claw / Quick Draw / Custap Berry - always first + // Stall / Mycelium Might - last but before Lagging Tail + // Lagging Tail - always last + bool32 battler1HasQuickEffect = gProtectStructs[battler1].quickDraw || gProtectStructs[battler1].usedCustapBerry; + bool32 battler2HasQuickEffect = gProtectStructs[battler2].quickDraw || gProtectStructs[battler2].usedCustapBerry; + bool32 battler1HasStallingAbility = ability1 == ABILITY_STALL || (ability1 == ABILITY_MYCELIUM_MIGHT && IS_MOVE_STATUS(gChosenMoveByBattler[battler1])); + bool32 battler2HasStallingAbility = ability2 == ABILITY_STALL || (ability2 == ABILITY_MYCELIUM_MIGHT && IS_MOVE_STATUS(gChosenMoveByBattler[battler2])); + + if (battler1HasQuickEffect && !battler2HasQuickEffect) strikesFirst = 1; - else if (gProtectStructs[battler2].usedCustapBerry && !gProtectStructs[battler1].usedCustapBerry) + else if (battler2HasQuickEffect && !battler1HasQuickEffect) strikesFirst = -1; else if (holdEffectBattler1 == HOLD_EFFECT_LAGGING_TAIL && holdEffectBattler2 != HOLD_EFFECT_LAGGING_TAIL) strikesFirst = -1; else if (holdEffectBattler2 == HOLD_EFFECT_LAGGING_TAIL && holdEffectBattler1 != HOLD_EFFECT_LAGGING_TAIL) strikesFirst = 1; - else if (ability1 == ABILITY_STALL && ability2 != ABILITY_STALL) - strikesFirst = -1; - else if (ability2 == ABILITY_STALL && ability1 != ABILITY_STALL) - strikesFirst = 1; - else if (ability1 == ABILITY_MYCELIUM_MIGHT && ability2 != ABILITY_MYCELIUM_MIGHT && IS_MOVE_STATUS(gChosenMoveByBattler[battler1])) + else if (battler1HasStallingAbility && !battler2HasStallingAbility) strikesFirst = -1; - else if (ability2 == ABILITY_MYCELIUM_MIGHT && ability1 != ABILITY_MYCELIUM_MIGHT && IS_MOVE_STATUS(gChosenMoveByBattler[battler2])) + else if (battler2HasStallingAbility && !battler1HasStallingAbility) strikesFirst = 1; else { diff --git a/test/battle/ability/mycelium_might.c b/test/battle/ability/mycelium_might.c index 1039fca34f38..8491aede5183 100644 --- a/test/battle/ability/mycelium_might.c +++ b/test/battle/ability/mycelium_might.c @@ -43,3 +43,27 @@ SINGLE_BATTLE_TEST("Mycelium Might ignores opposing abilities") NOT ABILITY_POPUP(opponent, ABILITY_CLEAR_BODY); } } + +SINGLE_BATTLE_TEST("Mycelium Might vs Stall action order depends on speed") +{ + u32 speed; + PARAMETRIZE { speed = 99; } + PARAMETRIZE { speed = 101; } + GIVEN { + PLAYER(SPECIES_TOEDSCOOL) { Speed(100); Ability(ABILITY_MYCELIUM_MIGHT); } + OPPONENT(SPECIES_SABLEYE) { Speed(speed); Ability(ABILITY_STALL);} + } WHEN { + TURN { MOVE(opponent, MOVE_CELEBRATE); MOVE(player, MOVE_CELEBRATE); } + } SCENE { + if (speed < 100) + { + ANIMATION(ANIM_TYPE_MOVE, MOVE_CELEBRATE, player); + ANIMATION(ANIM_TYPE_MOVE, MOVE_CELEBRATE, opponent); + } + else + { + ANIMATION(ANIM_TYPE_MOVE, MOVE_CELEBRATE, opponent); + ANIMATION(ANIM_TYPE_MOVE, MOVE_CELEBRATE, player); + } + } +} diff --git a/test/battle/hold_effect/quick_claw.c b/test/battle/hold_effect/quick_claw.c index 3e8cd4d652be..b8b845ec25cd 100644 --- a/test/battle/hold_effect/quick_claw.c +++ b/test/battle/hold_effect/quick_claw.c @@ -4,9 +4,10 @@ ASSUMPTIONS { ASSUME(gItemsInfo[ITEM_QUICK_CLAW].holdEffect == HOLD_EFFECT_QUICK_CLAW); + ASSUME(gItemsInfo[ITEM_QUICK_CLAW].holdEffectParam == 20); } -SINGLE_BATTLE_TEST("Quick Claw activates 10% of the time") +SINGLE_BATTLE_TEST("Quick Claw activates 20% of the time") { PASSES_RANDOMLY(2, 10, RNG_QUICK_CLAW); GIVEN {