Fix Mirror Armor against Clear Body

This commit is contained in:
DizzyEggg 2023-02-13 14:44:34 +01:00
parent 5d958e245a
commit 0577d8d04d
3 changed files with 8 additions and 6 deletions

View File

@ -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:

View File

@ -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)

View File

@ -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)
{