From 0577d8d04d439a0fded1ecb80e3ac89f6e0b0aa0 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Mon, 13 Feb 2023 14:44:34 +0100 Subject: [PATCH] Fix Mirror Armor against Clear Body --- data/battle_scripts_1.s | 2 +- include/constants/battle_script_commands.h | 1 + src/battle_script_commands.c | 11 ++++++----- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 25386dbf0..7fecdccd5 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -3584,7 +3584,7 @@ BattleScript_MirrorArmorReflect:: call BattleScript_AbilityPopUp jumpifsubstituteblocks BattleScript_AbilityNoSpecificStatLoss BattleScript_MirrorArmorReflectStatLoss: - statbuffchange MOVE_EFFECT_AFFECTS_USER | STAT_CHANGE_NOT_PROTECT_AFFECTED | STAT_CHANGE_ALLOW_PTR, BattleScript_MirrorArmorReflectEnd + statbuffchange MOVE_EFFECT_AFFECTS_USER | STAT_CHANGE_MIRROR_ARMOR | STAT_CHANGE_NOT_PROTECT_AFFECTED | STAT_CHANGE_ALLOW_PTR, BattleScript_MirrorArmorReflectEnd jumpifbyte CMP_LESS_THAN, cMULTISTRING_CHOOSER, B_MSG_STAT_WONT_DECREASE, BattleScript_MirrorArmorReflectAnim goto BattleScript_MirrorArmorReflectWontFall BattleScript_MirrorArmorReflectAnim: diff --git a/include/constants/battle_script_commands.h b/include/constants/battle_script_commands.h index 123fb5d49..935121394 100644 --- a/include/constants/battle_script_commands.h +++ b/include/constants/battle_script_commands.h @@ -273,6 +273,7 @@ // Cmd_statbuffchange #define STAT_CHANGE_ALLOW_PTR (1 << 0) // If set, allow use of jumpptr. Set in every use of statbuffchange +#define STAT_CHANGE_MIRROR_ARMOR (1 << 1) // Stat change redirection caused by Mirror Armor ability. #define STAT_CHANGE_NOT_PROTECT_AFFECTED (1 << 5) #define STAT_CHANGE_UPDATE_MOVE_EFFECT (1 << 6) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index be5e2ee21..c9488167f 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -10877,8 +10877,9 @@ static u32 ChangeStatBuffs(s8 statValue, u32 statId, u32 flags, const u8 *BS_ptr bool32 certain = FALSE; bool32 notProtectAffected = FALSE; u32 index; - bool32 affectsUser = (flags & MOVE_EFFECT_AFFECTS_USER); u16 activeBattlerAbility; + bool32 affectsUser = (flags & MOVE_EFFECT_AFFECTS_USER); + bool32 mirrorArmored = (flags & STAT_CHANGE_MIRROR_ARMOR); if (affectsUser) gActiveBattler = gBattlerAttacker; @@ -10889,10 +10890,10 @@ static u32 ChangeStatBuffs(s8 statValue, u32 statId, u32 flags, const u8 *BS_ptr gSpecialStatuses[gActiveBattler].changedStatsBattlerId = gBattlerAttacker; - flags &= ~MOVE_EFFECT_AFFECTS_USER; + flags &= ~(MOVE_EFFECT_AFFECTS_USER | STAT_CHANGE_MIRROR_ARMOR); if (flags & MOVE_EFFECT_CERTAIN) - certain++; + certain = TRUE; flags &= ~MOVE_EFFECT_CERTAIN; if (flags & STAT_CHANGE_NOT_PROTECT_AFFECTED) @@ -10948,7 +10949,7 @@ static u32 ChangeStatBuffs(s8 statValue, u32 statId, u32 flags, const u8 *BS_ptr || activeBattlerAbility == ABILITY_CLEAR_BODY || activeBattlerAbility == ABILITY_FULL_METAL_BODY || activeBattlerAbility == ABILITY_WHITE_SMOKE) - && !affectsUser && !certain && gCurrentMove != MOVE_CURSE) + && (!affectsUser || mirrorArmored) && !certain && gCurrentMove != MOVE_CURSE) { if (GetBattlerHoldEffect(gActiveBattler, TRUE) == HOLD_EFFECT_CLEAR_AMULET) { @@ -11010,7 +11011,7 @@ static u32 ChangeStatBuffs(s8 statValue, u32 statId, u32 flags, const u8 *BS_ptr } return STAT_CHANGE_DIDNT_WORK; } - else if (activeBattlerAbility == ABILITY_MIRROR_ARMOR && !affectsUser && gBattlerAttacker != gBattlerTarget && gActiveBattler == gBattlerTarget) + else if (activeBattlerAbility == ABILITY_MIRROR_ARMOR && !affectsUser && !mirrorArmored && gBattlerAttacker != gBattlerTarget && gActiveBattler == gBattlerTarget) { if (flags == STAT_CHANGE_ALLOW_PTR) {