Adds Generational config for Magic Guard (Fix for Gen4+) (#5893)

This commit is contained in:
Alex 2024-12-30 09:01:20 +01:00 committed by GitHub
parent 009de5c98c
commit f864bf8b70
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 34 additions and 1 deletions

View file

@ -155,6 +155,7 @@
// In Gen3, Effect Spore has a 10% chance to sleep, poison or paralyze, with an equal chance.
// In Gen4, it's 30%. In Gen5+ it has 11% to sleep, 9% chance to poison and 10% chance to paralyze.
#define B_PICKUP_WILD GEN_LATEST // In Gen9+, Pickup allows its user to pickup its own used item at the end of the turn in wild battles.
#define B_MAGIC_GUARD GEN_LATEST // In Gen4+, Magic Guard ignores immobilization caused by paralysis
// Item settings
#define B_HP_BERRIES GEN_LATEST // In Gen4+, berries which restore HP activate immediately after HP drops to half. In Gen3, the effect occurs at the end of the turn.

View file

@ -3484,7 +3484,10 @@ u8 AtkCanceller_UnableToUseMove(u32 moveType)
gBattleStruct->atkCancellerTracker++;
break;
case CANCELLER_PARALYSED: // paralysis
if (!gBattleStruct->isAtkCancelerForCalledMove && (gBattleMons[gBattlerAttacker].status1 & STATUS1_PARALYSIS) && !RandomPercentage(RNG_PARALYSIS, 75))
if (!gBattleStruct->isAtkCancelerForCalledMove
&& gBattleMons[gBattlerAttacker].status1 & STATUS1_PARALYSIS
&& (GetBattlerAbility(gBattlerAttacker) != ABILITY_MAGIC_GUARD && B_MAGIC_GUARD >= GEN_4)
&& !RandomPercentage(RNG_PARALYSIS, 75))
{
gProtectStructs[gBattlerAttacker].prlzImmobility = TRUE;
// This is removed in FRLG and Emerald for some reason

View file

@ -15,3 +15,32 @@ SINGLE_BATTLE_TEST("Magic Guard prevents recoil damage to the user")
NOT HP_BAR(player);
}
}
SINGLE_BATTLE_TEST("Magic Guard ignores immobilization that can be caused by paralysis")
{
if (B_MAGIC_GUARD >= GEN_4)
PASSES_RANDOMLY(1, 1, RNG_PARALYSIS);
else
PASSES_RANDOMLY(75, 100, RNG_PARALYSIS);
GIVEN {
PLAYER(SPECIES_CLEFABLE) { Ability(ABILITY_MAGIC_GUARD); Status1(STATUS1_PARALYSIS);}
OPPONENT(SPECIES_WOBBUFFET);
} WHEN {
TURN { MOVE(player, MOVE_CELEBRATE); }
} SCENE {
ANIMATION(ANIM_TYPE_MOVE, MOVE_CELEBRATE, player);
}
}
SINGLE_BATTLE_TEST("Magic Guard does not ignore speed stat changes caused by paralysis")
{
GIVEN {
PLAYER(SPECIES_CLEFABLE) { Speed(100); Ability(ABILITY_MAGIC_GUARD); Status1(STATUS1_PARALYSIS);}
OPPONENT(SPECIES_WOBBUFFET) { Speed(99); }
} WHEN {
TURN { }
} SCENE {
ANIMATION(ANIM_TYPE_MOVE, MOVE_CELEBRATE, opponent);
ANIMATION(ANIM_TYPE_MOVE, MOVE_CELEBRATE, player);
}
}