Skip to content

Commit

Permalink
Fix Weak Armor interrupting multi hit moves (#3497)
Browse files Browse the repository at this point in the history
  • Loading branch information
DizzyEggg authored Oct 30, 2023
1 parent 3788d84 commit 72dad4d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
2 changes: 2 additions & 0 deletions data/battle_scripts_1.s
Original file line number Diff line number Diff line change
Expand Up @@ -9122,6 +9122,7 @@ BattleScript_WeakArmorActivates::
jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, B_MSG_STAT_FELL_EMPTY, BattleScript_WeakArmorActivatesSpeed
pause B_WAIT_TIME_SHORTEST
printfromtable gStatDownStringIds
bichalfword gMoveResultFlags, MOVE_RESULT_MISSED @ Set by statbuffchange when stat can't be decreased
waitmessage B_WAIT_TIME_LONG
goto BattleScript_WeakArmorActivatesSpeed
BattleScript_WeakArmorDefAnim:
Expand All @@ -9136,6 +9137,7 @@ BattleScript_WeakArmorActivatesSpeed:
jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, B_MSG_STAT_ROSE_EMPTY, BattleScript_WeakArmorActivatesEnd
pause B_WAIT_TIME_SHORTEST
printstring STRINGID_TARGETSTATWONTGOHIGHER
bichalfword gMoveResultFlags, MOVE_RESULT_MISSED
waitmessage B_WAIT_TIME_LONG
goto BattleScript_WeakArmorActivatesEnd
BattleScript_WeakArmorSpeedAnim:
Expand Down
4 changes: 2 additions & 2 deletions src/battle_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -5231,8 +5231,8 @@ u32 AbilityBattleEffects(u32 caseID, u32 battler, u32 ability, u32 special, u32
&& TARGET_TURN_DAMAGED
&& IsBattlerAlive(battler)
&& IS_MOVE_PHYSICAL(gCurrentMove)
&& (CompareStat(battler, STAT_SPEED, MAX_STAT_STAGE, CMP_LESS_THAN) // Don't activate if speed cannot be raised
|| CompareStat(battler, STAT_DEF, MIN_STAT_STAGE, CMP_GREATER_THAN))) // Don't activate if defense cannot be lowered
&& (CompareStat(battler, STAT_SPEED, MAX_STAT_STAGE, CMP_LESS_THAN) // Don't activate if both Speed and Defense cannot be raised.
|| CompareStat(battler, STAT_DEF, MIN_STAT_STAGE, CMP_GREATER_THAN)))
{
if (gBattleMoves[gCurrentMove].effect == EFFECT_HIT_ESCAPE && CanBattlerSwitch(gBattlerAttacker))
gProtectStructs[battler].disableEjectPack = TRUE; // Set flag for target
Expand Down
17 changes: 9 additions & 8 deletions test/battle/ability/weak_armor.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ SINGLE_BATTLE_TEST("Weak Armor still lowers Defense if Speed can't go any higher
SINGLE_BATTLE_TEST("Weak Armor doesn't interrupt multi hit moves if Defense can't go any lower")
{
u32 j;
KNOWN_FAILING;
GIVEN {
PLAYER(SPECIES_MAGCARGO) { Ability(ABILITY_WEAK_ARMOR); Defense(999); }
OPPONENT(SPECIES_CLOYSTER) { Ability(ABILITY_SKILL_LINK); }
Expand All @@ -156,20 +155,22 @@ SINGLE_BATTLE_TEST("Weak Armor doesn't interrupt multi hit moves if Defense can'
for (j = 0; j < 2; j++)
{
ANIMATION(ANIM_TYPE_MOVE, MOVE_FURY_SWIPES, opponent);
ABILITY_POPUP(player, ABILITY_WEAK_ARMOR);
MESSAGE("Magcargo's Defense won't go lower!");
MESSAGE("Slugma's Speed won't go higher!");
// Ability doesn't activate if neither stat can be changed.
NONE_OF {
ABILITY_POPUP(player, ABILITY_WEAK_ARMOR);
MESSAGE("Magcargo's Defense won't go lower!");
MESSAGE("Magcargo's Speed won't go higher!");
}
}
} THEN {
EXPECT_EQ(player->statStages[STAT_DEF], MIN_STAT_STAGE);
EXPECT_EQ(player->statStages[STAT_SPEED], DEFAULT_STAT_STAGE + 2);
EXPECT_EQ(player->statStages[STAT_SPEED], MAX_STAT_STAGE);
}
}

SINGLE_BATTLE_TEST("Weak Armor doesn't interrupt multi hit moves if Speed can't go any higher")
{
u32 j;
KNOWN_FAILING;
GIVEN {
PLAYER(SPECIES_MAGCARGO) { Ability(ABILITY_WEAK_ARMOR); Defense(999); }
OPPONENT(SPECIES_CLOYSTER) { Ability(ABILITY_SKILL_LINK); }
Expand All @@ -190,7 +191,7 @@ SINGLE_BATTLE_TEST("Weak Armor doesn't interrupt multi hit moves if Speed can't
MESSAGE("Magcargo's Speed won't go higher!");
}
} THEN {
EXPECT_EQ(player->statStages[STAT_DEF], MIN_STAT_STAGE);
EXPECT_EQ(player->statStages[STAT_SPEED], DEFAULT_STAT_STAGE + 2);
EXPECT_EQ(player->statStages[STAT_DEF], DEFAULT_STAT_STAGE - 5);
EXPECT_EQ(player->statStages[STAT_SPEED], MAX_STAT_STAGE);
}
}

0 comments on commit 72dad4d

Please sign in to comment.