Fixes Magic Guard not preventing Salt Cure (#5583)
This commit is contained in:
parent
5dcf3e7664
commit
ad16fa76f2
2 changed files with 47 additions and 26 deletions
|
@ -2318,14 +2318,14 @@ s32 GetDrainedBigRootHp(u32 battler, s32 hp)
|
||||||
return hp * -1;
|
return hp * -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define MAGIC_GUARD_CHECK \
|
static inline bool32 IsBattlerProtectedByMagicGuard(u32 battler, u32 ability)
|
||||||
if (ability == ABILITY_MAGIC_GUARD) \
|
{
|
||||||
{\
|
if (ability != ABILITY_MAGIC_GUARD)
|
||||||
RecordAbilityBattle(battler, ability);\
|
return FALSE;
|
||||||
gBattleStruct->turnEffectsTracker++;\
|
|
||||||
break;\
|
|
||||||
}
|
|
||||||
|
|
||||||
|
RecordAbilityBattle(battler, ability);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
u8 DoBattlerEndTurnEffects(void)
|
u8 DoBattlerEndTurnEffects(void)
|
||||||
{
|
{
|
||||||
|
@ -2453,10 +2453,9 @@ u8 DoBattlerEndTurnEffects(void)
|
||||||
case ENDTURN_LEECH_SEED: // leech seed
|
case ENDTURN_LEECH_SEED: // leech seed
|
||||||
if ((gStatuses3[battler] & STATUS3_LEECHSEED)
|
if ((gStatuses3[battler] & STATUS3_LEECHSEED)
|
||||||
&& IsBattlerAlive(gStatuses3[battler] & STATUS3_LEECHSEED_BATTLER)
|
&& 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.
|
gBattlerTarget = gStatuses3[battler] & STATUS3_LEECHSEED_BATTLER; // Notice gBattlerTarget is actually the HP receiver.
|
||||||
gBattleMoveDamage = GetNonDynamaxMaxHP(battler) / 8;
|
gBattleMoveDamage = GetNonDynamaxMaxHP(battler) / 8;
|
||||||
if (gBattleMoveDamage == 0)
|
if (gBattleMoveDamage == 0)
|
||||||
|
@ -2470,10 +2469,9 @@ u8 DoBattlerEndTurnEffects(void)
|
||||||
break;
|
break;
|
||||||
case ENDTURN_POISON: // poison
|
case ENDTURN_POISON: // poison
|
||||||
if ((gBattleMons[battler].status1 & STATUS1_POISON)
|
if ((gBattleMons[battler].status1 & STATUS1_POISON)
|
||||||
&& IsBattlerAlive(battler))
|
&& IsBattlerAlive(battler)
|
||||||
|
&& !IsBattlerProtectedByMagicGuard(battler, ability))
|
||||||
{
|
{
|
||||||
MAGIC_GUARD_CHECK;
|
|
||||||
|
|
||||||
if (ability == ABILITY_POISON_HEAL)
|
if (ability == ABILITY_POISON_HEAL)
|
||||||
{
|
{
|
||||||
if (!BATTLER_MAX_HP(battler) && !(gStatuses3[battler] & STATUS3_HEAL_BLOCK))
|
if (!BATTLER_MAX_HP(battler) && !(gStatuses3[battler] & STATUS3_HEAL_BLOCK))
|
||||||
|
@ -2499,10 +2497,9 @@ u8 DoBattlerEndTurnEffects(void)
|
||||||
break;
|
break;
|
||||||
case ENDTURN_BAD_POISON: // toxic poison
|
case ENDTURN_BAD_POISON: // toxic poison
|
||||||
if ((gBattleMons[battler].status1 & STATUS1_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 (ability == ABILITY_POISON_HEAL)
|
||||||
{
|
{
|
||||||
if (!BATTLER_MAX_HP(battler) && !(gStatuses3[battler] & STATUS3_HEAL_BLOCK))
|
if (!BATTLER_MAX_HP(battler) && !(gStatuses3[battler] & STATUS3_HEAL_BLOCK))
|
||||||
|
@ -2531,9 +2528,9 @@ u8 DoBattlerEndTurnEffects(void)
|
||||||
break;
|
break;
|
||||||
case ENDTURN_BURN: // burn
|
case ENDTURN_BURN: // burn
|
||||||
if ((gBattleMons[battler].status1 & STATUS1_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);
|
gBattleMoveDamage = GetNonDynamaxMaxHP(battler) / (B_BURN_DAMAGE >= GEN_7 ? 16 : 8);
|
||||||
if (ability == ABILITY_HEATPROOF)
|
if (ability == ABILITY_HEATPROOF)
|
||||||
{
|
{
|
||||||
|
@ -2550,9 +2547,9 @@ u8 DoBattlerEndTurnEffects(void)
|
||||||
break;
|
break;
|
||||||
case ENDTURN_FROSTBITE: // burn
|
case ENDTURN_FROSTBITE: // burn
|
||||||
if ((gBattleMons[battler].status1 & STATUS1_FROSTBITE)
|
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);
|
gBattleMoveDamage = GetNonDynamaxMaxHP(battler) / (B_BURN_DAMAGE >= GEN_7 ? 16 : 8);
|
||||||
if (gBattleMoveDamage == 0)
|
if (gBattleMoveDamage == 0)
|
||||||
gBattleMoveDamage = 1;
|
gBattleMoveDamage = 1;
|
||||||
|
@ -2563,9 +2560,9 @@ u8 DoBattlerEndTurnEffects(void)
|
||||||
break;
|
break;
|
||||||
case ENDTURN_NIGHTMARES: // spooky nightmares
|
case ENDTURN_NIGHTMARES: // spooky nightmares
|
||||||
if ((gBattleMons[battler].status2 & STATUS2_NIGHTMARE)
|
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
|
// 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.
|
// persist even after the affected Pokémon has been awakened by Shed Skin.
|
||||||
if (gBattleMons[battler].status1 & STATUS1_SLEEP)
|
if (gBattleMons[battler].status1 & STATUS1_SLEEP)
|
||||||
|
@ -2585,9 +2582,9 @@ u8 DoBattlerEndTurnEffects(void)
|
||||||
break;
|
break;
|
||||||
case ENDTURN_CURSE: // curse
|
case ENDTURN_CURSE: // curse
|
||||||
if ((gBattleMons[battler].status2 & STATUS2_CURSED)
|
if ((gBattleMons[battler].status2 & STATUS2_CURSED)
|
||||||
&& IsBattlerAlive(battler))
|
&& IsBattlerAlive(battler)
|
||||||
|
&& !IsBattlerProtectedByMagicGuard(battler, ability))
|
||||||
{
|
{
|
||||||
MAGIC_GUARD_CHECK;
|
|
||||||
gBattleMoveDamage = GetNonDynamaxMaxHP(battler) / 4;
|
gBattleMoveDamage = GetNonDynamaxMaxHP(battler) / 4;
|
||||||
if (gBattleMoveDamage == 0)
|
if (gBattleMoveDamage == 0)
|
||||||
gBattleMoveDamage = 1;
|
gBattleMoveDamage = 1;
|
||||||
|
@ -2601,7 +2598,11 @@ u8 DoBattlerEndTurnEffects(void)
|
||||||
{
|
{
|
||||||
if (--gDisableStructs[battler].wrapTurns != 0) // damaged by wrap
|
if (--gDisableStructs[battler].wrapTurns != 0) // damaged by wrap
|
||||||
{
|
{
|
||||||
MAGIC_GUARD_CHECK;
|
if (IsBattlerProtectedByMagicGuard(battler, ability))
|
||||||
|
{
|
||||||
|
gBattleStruct->turnEffectsTracker++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
gBattleScripting.animArg1 = gBattleStruct->wrappedMove[battler];
|
gBattleScripting.animArg1 = gBattleStruct->wrappedMove[battler];
|
||||||
gBattleScripting.animArg2 = gBattleStruct->wrappedMove[battler] >> 8;
|
gBattleScripting.animArg2 = gBattleStruct->wrappedMove[battler] >> 8;
|
||||||
|
@ -2905,7 +2906,9 @@ u8 DoBattlerEndTurnEffects(void)
|
||||||
gBattleStruct->turnEffectsTracker++;
|
gBattleStruct->turnEffectsTracker++;
|
||||||
break;
|
break;
|
||||||
case ENDTURN_SALT_CURE:
|
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;
|
gBattlerTarget = battler;
|
||||||
if (IS_BATTLER_OF_TYPE(gBattlerTarget, TYPE_STEEL) || IS_BATTLER_OF_TYPE(gBattlerTarget, TYPE_WATER))
|
if (IS_BATTLER_OF_TYPE(gBattlerTarget, TYPE_STEEL) || IS_BATTLER_OF_TYPE(gBattlerTarget, TYPE_WATER))
|
||||||
|
|
|
@ -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!");
|
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!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue