Skip to content

Commit

Permalink
Speed Ignoring effect fixes (#4613)
Browse files Browse the repository at this point in the history
* Custap ties with Quick Draw, Stall with Mycelium

* add a test
  • Loading branch information
Sneed69 authored May 24, 2024
1 parent edab81b commit 312dcbb
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 17 deletions.
28 changes: 12 additions & 16 deletions src/battle_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
24 changes: 24 additions & 0 deletions test/battle/ability/mycelium_might.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
3 changes: 2 additions & 1 deletion test/battle/hold_effect/quick_claw.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 312dcbb

Please sign in to comment.