From 22c584737ae184ac1cbd41c0471997253ba140d1 Mon Sep 17 00:00:00 2001 From: AERDU Date: Wed, 15 Jan 2025 23:39:03 +0000 Subject: [PATCH 1/5] fixed bug giving immunity to full para when B_MAGIC_GUARD is >= GEN_4 This should fix a bug reproducible by setting `B_MAGIC_GUARD` to `GEN_3` or lower. I'm pretty sure the previous logic made it so, if your ability is NOT magic guard, you get full-paralysis immunity. My approach isn't ideal as `RNG_PARALYSIS` will now needlessly roll, but I wrote this fix for personal use and figured it couldn't hurt. --- src/battle_util.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/battle_util.c b/src/battle_util.c index 6d56a40e53d..4f23a98b51f 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -3507,15 +3507,21 @@ u8 AtkCanceller_UnableToUseMove(u32 moveType) case CANCELLER_PARALYSED: // paralysis 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 - //CancelMultiTurnMoves(gBattlerAttacker); - gBattlescriptCurrInstr = BattleScript_MoveUsedIsParalyzed; - gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE; - effect = 1; + if (GetBattlerAbility(gBattlerAttacker) == ABILITY_MAGIC_GUARD && B_MAGIC_GUARD >= GEN_4) + { + // Don't get fully paralyzed + } + else + { + gProtectStructs[gBattlerAttacker].prlzImmobility = TRUE; + // This is removed in FRLG and Emerald for some reason + //CancelMultiTurnMoves(gBattlerAttacker); + gBattlescriptCurrInstr = BattleScript_MoveUsedIsParalyzed; + gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE; + effect = 1; + } } gBattleStruct->atkCancellerTracker++; break; From aaf28705f52cc9a2c7367f0f781d408cad35e1c3 Mon Sep 17 00:00:00 2001 From: AERDU Date: Fri, 17 Jan 2025 00:24:51 +0000 Subject: [PATCH 2/5] Update battle_util.c --- src/battle_util.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/src/battle_util.c b/src/battle_util.c index 4f23a98b51f..0d8972179a1 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -3507,21 +3507,15 @@ u8 AtkCanceller_UnableToUseMove(u32 moveType) case CANCELLER_PARALYSED: // paralysis if (!gBattleStruct->isAtkCancelerForCalledMove && gBattleMons[gBattlerAttacker].status1 & STATUS1_PARALYSIS + && !(B_MAGIC_GUARD >= GEN_4 && GetBattlerAbility(gBattlerAttacker) == ABILITY_MAGIC_GUARD) && !RandomPercentage(RNG_PARALYSIS, 75)) { - if (GetBattlerAbility(gBattlerAttacker) == ABILITY_MAGIC_GUARD && B_MAGIC_GUARD >= GEN_4) - { - // Don't get fully paralyzed - } - else - { - gProtectStructs[gBattlerAttacker].prlzImmobility = TRUE; - // This is removed in FRLG and Emerald for some reason - //CancelMultiTurnMoves(gBattlerAttacker); - gBattlescriptCurrInstr = BattleScript_MoveUsedIsParalyzed; - gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE; - effect = 1; - } + gProtectStructs[gBattlerAttacker].prlzImmobility = TRUE; + // This is removed in FRLG and Emerald for some reason + //CancelMultiTurnMoves(gBattlerAttacker); + gBattlescriptCurrInstr = BattleScript_MoveUsedIsParalyzed; + gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE; + effect = 1; } gBattleStruct->atkCancellerTracker++; break; From 2bdf4fdce896bd160e0aa3cdc620fdcdf8923fd9 Mon Sep 17 00:00:00 2001 From: AERDU Date: Fri, 17 Jan 2025 23:40:01 +0000 Subject: [PATCH 3/5] Update battle.h --- include/config/battle.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/config/battle.h b/include/config/battle.h index 8853d043247..e3bde0d30c2 100644 --- a/include/config/battle.h +++ b/include/config/battle.h @@ -156,7 +156,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 +#define B_MAGIC_GUARD GEN_LATEST // In Gen4 only, 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. From 02348fa9a58591e0a434de09553ae4fccf62c257 Mon Sep 17 00:00:00 2001 From: AERDU Date: Fri, 17 Jan 2025 23:40:50 +0000 Subject: [PATCH 4/5] Update battle_util.c --- src/battle_util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/battle_util.c b/src/battle_util.c index 0d8972179a1..d4debdd0de1 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -3507,7 +3507,7 @@ u8 AtkCanceller_UnableToUseMove(u32 moveType) case CANCELLER_PARALYSED: // paralysis if (!gBattleStruct->isAtkCancelerForCalledMove && gBattleMons[gBattlerAttacker].status1 & STATUS1_PARALYSIS - && !(B_MAGIC_GUARD >= GEN_4 && GetBattlerAbility(gBattlerAttacker) == ABILITY_MAGIC_GUARD) + && !(B_MAGIC_GUARD == GEN_4 && GetBattlerAbility(gBattlerAttacker) == ABILITY_MAGIC_GUARD) && !RandomPercentage(RNG_PARALYSIS, 75)) { gProtectStructs[gBattlerAttacker].prlzImmobility = TRUE; From 6aaface581c8a150b8aeae225611555c0eea5f5d Mon Sep 17 00:00:00 2001 From: AERDU Date: Fri, 17 Jan 2025 23:41:38 +0000 Subject: [PATCH 5/5] Update magic_guard.c --- test/battle/ability/magic_guard.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/battle/ability/magic_guard.c b/test/battle/ability/magic_guard.c index 20e8eb779c3..344db46e3df 100644 --- a/test/battle/ability/magic_guard.c +++ b/test/battle/ability/magic_guard.c @@ -18,7 +18,7 @@ SINGLE_BATTLE_TEST("Magic Guard prevents recoil damage to the user") SINGLE_BATTLE_TEST("Magic Guard ignores immobilization that can be caused by paralysis") { - if (B_MAGIC_GUARD >= GEN_4) + if (B_MAGIC_GUARD == GEN_4) PASSES_RANDOMLY(1, 1, RNG_PARALYSIS); else PASSES_RANDOMLY(75, 100, RNG_PARALYSIS);