Fixes Magic Guard not preventing Salt Cure (#5583)

This commit is contained in:
Alex 2024-10-26 10:11:45 +02:00 committed by GitHub
parent 5dcf3e7664
commit ad16fa76f2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 47 additions and 26 deletions

View file

@ -2318,14 +2318,14 @@ s32 GetDrainedBigRootHp(u32 battler, s32 hp)
return hp * -1;
}
#define MAGIC_GUARD_CHECK \
if (ability == ABILITY_MAGIC_GUARD) \
{\
RecordAbilityBattle(battler, ability);\
gBattleStruct->turnEffectsTracker++;\
break;\
}
static inline bool32 IsBattlerProtectedByMagicGuard(u32 battler, u32 ability)
{
if (ability != ABILITY_MAGIC_GUARD)
return FALSE;
RecordAbilityBattle(battler, ability);
return TRUE;
}
u8 DoBattlerEndTurnEffects(void)
{
@ -2453,10 +2453,9 @@ u8 DoBattlerEndTurnEffects(void)
case ENDTURN_LEECH_SEED: // leech seed
if ((gStatuses3[battler] & STATUS3_LEECHSEED)
&& IsBattlerAlive(gStatuses3[battler] & STATUS3_LEECHSEED_BATTLER)
&& IsBattlerAlive(battler))
&& IsBattlerAlive(battler)
&& !IsBattlerProtectedByMagicGuard(battler, ability))
{
MAGIC_GUARD_CHECK;
gBattlerTarget = gStatuses3[battler] & STATUS3_LEECHSEED_BATTLER; // Notice gBattlerTarget is actually the HP receiver.
gBattleMoveDamage = GetNonDynamaxMaxHP(battler) / 8;
if (gBattleMoveDamage == 0)
@ -2470,10 +2469,9 @@ u8 DoBattlerEndTurnEffects(void)
break;
case ENDTURN_POISON: // poison
if ((gBattleMons[battler].status1 & STATUS1_POISON)
&& IsBattlerAlive(battler))
&& IsBattlerAlive(battler)
&& !IsBattlerProtectedByMagicGuard(battler, ability))
{
MAGIC_GUARD_CHECK;
if (ability == ABILITY_POISON_HEAL)
{
if (!BATTLER_MAX_HP(battler) && !(gStatuses3[battler] & STATUS3_HEAL_BLOCK))
@ -2499,10 +2497,9 @@ u8 DoBattlerEndTurnEffects(void)
break;
case ENDTURN_BAD_POISON: // toxic poison
if ((gBattleMons[battler].status1 & STATUS1_TOXIC_POISON)
&& IsBattlerAlive(battler))
&& IsBattlerAlive(battler)
&& !IsBattlerProtectedByMagicGuard(battler, ability))
{
MAGIC_GUARD_CHECK;
if (ability == ABILITY_POISON_HEAL)
{
if (!BATTLER_MAX_HP(battler) && !(gStatuses3[battler] & STATUS3_HEAL_BLOCK))
@ -2531,9 +2528,9 @@ u8 DoBattlerEndTurnEffects(void)
break;
case ENDTURN_BURN: // burn
if ((gBattleMons[battler].status1 & STATUS1_BURN)
&& IsBattlerAlive(battler))
&& IsBattlerAlive(battler)
&& !IsBattlerProtectedByMagicGuard(battler, ability))
{
MAGIC_GUARD_CHECK;
gBattleMoveDamage = GetNonDynamaxMaxHP(battler) / (B_BURN_DAMAGE >= GEN_7 ? 16 : 8);
if (ability == ABILITY_HEATPROOF)
{
@ -2550,9 +2547,9 @@ u8 DoBattlerEndTurnEffects(void)
break;
case ENDTURN_FROSTBITE: // burn
if ((gBattleMons[battler].status1 & STATUS1_FROSTBITE)
&& IsBattlerAlive(battler))
&& IsBattlerAlive(battler)
&& !IsBattlerProtectedByMagicGuard(battler, ability))
{
MAGIC_GUARD_CHECK;
gBattleMoveDamage = GetNonDynamaxMaxHP(battler) / (B_BURN_DAMAGE >= GEN_7 ? 16 : 8);
if (gBattleMoveDamage == 0)
gBattleMoveDamage = 1;
@ -2563,9 +2560,9 @@ u8 DoBattlerEndTurnEffects(void)
break;
case ENDTURN_NIGHTMARES: // spooky nightmares
if ((gBattleMons[battler].status2 & STATUS2_NIGHTMARE)
&& IsBattlerAlive(battler))
&& IsBattlerAlive(battler)
&& !IsBattlerProtectedByMagicGuard(battler, ability))
{
MAGIC_GUARD_CHECK;
// R/S does not perform this sleep check, which causes the nightmare effect to
// persist even after the affected Pokémon has been awakened by Shed Skin.
if (gBattleMons[battler].status1 & STATUS1_SLEEP)
@ -2585,9 +2582,9 @@ u8 DoBattlerEndTurnEffects(void)
break;
case ENDTURN_CURSE: // curse
if ((gBattleMons[battler].status2 & STATUS2_CURSED)
&& IsBattlerAlive(battler))
&& IsBattlerAlive(battler)
&& !IsBattlerProtectedByMagicGuard(battler, ability))
{
MAGIC_GUARD_CHECK;
gBattleMoveDamage = GetNonDynamaxMaxHP(battler) / 4;
if (gBattleMoveDamage == 0)
gBattleMoveDamage = 1;
@ -2601,7 +2598,11 @@ u8 DoBattlerEndTurnEffects(void)
{
if (--gDisableStructs[battler].wrapTurns != 0) // damaged by wrap
{
MAGIC_GUARD_CHECK;
if (IsBattlerProtectedByMagicGuard(battler, ability))
{
gBattleStruct->turnEffectsTracker++;
break;
}
gBattleScripting.animArg1 = gBattleStruct->wrappedMove[battler];
gBattleScripting.animArg2 = gBattleStruct->wrappedMove[battler] >> 8;
@ -2905,7 +2906,9 @@ u8 DoBattlerEndTurnEffects(void)
gBattleStruct->turnEffectsTracker++;
break;
case ENDTURN_SALT_CURE:
if (gStatuses4[battler] & STATUS4_SALT_CURE && IsBattlerAlive(battler))
if (gStatuses4[battler] & STATUS4_SALT_CURE
&& IsBattlerAlive(battler)
&& !IsBattlerProtectedByMagicGuard(battler, ability))
{
gBattlerTarget = battler;
if (IS_BATTLER_OF_TYPE(gBattlerTarget, TYPE_STEEL) || IS_BATTLER_OF_TYPE(gBattlerTarget, TYPE_WATER))

View file

@ -99,3 +99,21 @@ SINGLE_BATTLE_TEST("Salt Cure does not get applied if hitting a Substitute")
NOT MESSAGE("Foe Wobbuffet is being salt cured!");
}
}
SINGLE_BATTLE_TEST("Salt Cure residual damage does not inflict any damage against Magic Guard")
{
GIVEN {
PLAYER(SPECIES_WOBBUFFET);
OPPONENT(SPECIES_CLEFABLE) { Ability(ABILITY_MAGIC_GUARD); };
} WHEN {
TURN { MOVE(player, MOVE_SALT_CURE); }
} SCENE {
ANIMATION(ANIM_TYPE_MOVE, MOVE_SALT_CURE, player);
HP_BAR(opponent);
NONE_OF {
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_SALT_CURE_DAMAGE, opponent);
HP_BAR(opponent);
MESSAGE("Foe Clefable is hurt by Salt Cure!");
}
}
}