From b72581985cc3d62165dab03b86271a84592e9a43 Mon Sep 17 00:00:00 2001 From: Bassoonian Date: Mon, 27 Nov 2023 12:42:53 +0100 Subject: [PATCH] Add bad poison downgrade config (#3605) Co-authored-by: Alex <93446519+AlexOn1ine@users.noreply.github.com> --- include/config/battle.h | 1 + src/battle_setup.c | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/include/config/battle.h b/include/config/battle.h index 622054ab28..503ce9328e 100644 --- a/include/config/battle.h +++ b/include/config/battle.h @@ -219,6 +219,7 @@ #define B_OBEDIENCE_MECHANICS GEN_LATEST // In PLA+ (here Gen8+), obedience restrictions also apply to non-outsider Pokémon, albeit based on their level met rather than actual level #define B_USE_FROSTBITE FALSE // In PLA, Frostbite replaces Freeze. Enabling this flag does the same here. Moves can still be cherry-picked to either Freeze or Frostbite. Freeze-Dry, Secret Power & Tri Attack depend on this config. #define B_OVERWORLD_SNOW GEN_LATEST // In Gen9+, overworld Snow will summon snow instead of hail. +#define B_TOXIC_REVERSAL GEN_LATEST // In Gen5+, bad poison will change to regular poison at the end of battles. // Animation Settings #define B_NEW_SWORD_PARTICLE TRUE // If set to TRUE, it updates Swords Dance's particle. diff --git a/src/battle_setup.c b/src/battle_setup.c index 5459c04925..750191d74f 100644 --- a/src/battle_setup.c +++ b/src/battle_setup.c @@ -677,6 +677,19 @@ void StartRegiBattle(void) TryUpdateGymLeaderRematchFromWild(); } +static void DowngradeBadPoison(void) +{ + u8 i; + u32 status = STATUS1_POISON; + if (B_TOXIC_REVERSAL < GEN_5) + return; + for(i = 0; i < PARTY_SIZE; i++) + { + if (GetMonData(&gPlayerParty[i], MON_DATA_SANITY_HAS_SPECIES) && GetMonData(&gPlayerParty[i], MON_DATA_STATUS) == STATUS1_TOXIC_POISON) + SetMonData(&gPlayerParty[i], MON_DATA_STATUS, &status); + } +} + static void CB2_EndWildBattle(void) { CpuFill16(0, (void *)(BG_PLTT), BG_PLTT_SIZE); @@ -689,6 +702,7 @@ static void CB2_EndWildBattle(void) else { SetMainCallback2(CB2_ReturnToField); + DowngradeBadPoison(); gFieldCallback = FieldCB_ReturnToFieldNoScriptCheckMusic; } } @@ -707,6 +721,7 @@ static void CB2_EndScriptedWildBattle(void) } else { + DowngradeBadPoison(); SetMainCallback2(CB2_ReturnToFieldContinueScriptPlayMapMusic); } } @@ -997,6 +1012,7 @@ static void CB2_StartFirstBattle(void) static void CB2_EndFirstBattle(void) { Overworld_ClearSavedMusic(); + DowngradeBadPoison(); SetMainCallback2(CB2_ReturnToFieldContinueScriptPlayMapMusic); } @@ -1414,6 +1430,7 @@ static void CB2_EndTrainerBattle(void) if (gTrainerBattleOpponent_A == TRAINER_SECRET_BASE) { + DowngradeBadPoison(); SetMainCallback2(CB2_ReturnToFieldContinueScriptPlayMapMusic); } else if (IsPlayerDefeated(gBattleOutcome) == TRUE) @@ -1426,6 +1443,7 @@ static void CB2_EndTrainerBattle(void) else { SetMainCallback2(CB2_ReturnToFieldContinueScriptPlayMapMusic); + DowngradeBadPoison(); if (!InBattlePyramid() && !InTrainerHillChallenge()) { RegisterTrainerInMatchCall(); @@ -1438,6 +1456,7 @@ static void CB2_EndRematchBattle(void) { if (gTrainerBattleOpponent_A == TRAINER_SECRET_BASE) { + DowngradeBadPoison(); SetMainCallback2(CB2_ReturnToFieldContinueScriptPlayMapMusic); } else if (IsPlayerDefeated(gBattleOutcome) == TRUE) @@ -1450,6 +1469,7 @@ static void CB2_EndRematchBattle(void) RegisterTrainerInMatchCall(); SetBattledTrainersFlags(); HandleRematchVarsOnBattleEnd(); + DowngradeBadPoison(); } }