From 0d734b73ddf684edc359b13a46d65b35bcdf87de Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Mon, 30 Oct 2023 20:18:33 +0100 Subject: [PATCH] Fix Weak Armor interrupting multi hit moves --- data/battle_scripts_1.s | 2 ++ src/battle_util.c | 4 ++-- test/battle/ability/weak_armor.c | 17 +++++++++-------- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 5d2e18cb4b06..898be404b5c6 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -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: @@ -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: diff --git a/src/battle_util.c b/src/battle_util.c index d64acb6fb503..c9ef0b08bdc8 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -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 diff --git a/test/battle/ability/weak_armor.c b/test/battle/ability/weak_armor.c index f23f67cbabdf..8fc09bb2871f 100644 --- a/test/battle/ability/weak_armor.c +++ b/test/battle/ability/weak_armor.c @@ -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); } @@ -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); } @@ -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); } }