From 54806c883832f0e7d2e9884c497ce2815ebf2ca4 Mon Sep 17 00:00:00 2001 From: Bassoonian Date: Sat, 17 May 2025 11:20:35 +0200 Subject: [PATCH] Add no-whiteout feature (#6795) --- asm/macros/battle_script.inc | 5 +++++ data/battle_scripts_1.s | 1 + include/config/battle.h | 1 + src/battle_script_commands.c | 10 ++++++++++ src/battle_setup.c | 2 +- src/overworld.c | 1 + 6 files changed, 19 insertions(+), 1 deletion(-) diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc index 2c19ebb515..41b61288ac 100644 --- a/asm/macros/battle_script.inc +++ b/asm/macros/battle_script.inc @@ -2558,3 +2558,8 @@ printstring STRINGID_EMPTYSTRING3 waitmessage 1 .endm + + .macro jumpifnowhiteout jumpInstr:req + callnative BS_JumpIfNoWhiteOut + .4byte \jumpInstr + .endm diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index a154d31715..9938299db9 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -5394,6 +5394,7 @@ BattleScript_LocalBattleLost:: jumpifbattletype BATTLE_TYPE_TRAINER_HILL, BattleScript_LocalBattleLostPrintTrainersWinText jumpifbattletype BATTLE_TYPE_EREADER_TRAINER, BattleScript_LocalBattleLostEnd jumpifhalfword CMP_EQUAL, gTrainerBattleParameter + 2, TRAINER_SECRET_BASE, BattleScript_LocalBattleLostEnd + jumpifnowhiteout BattleScript_LocalBattleLostEnd_ BattleScript_LocalBattleLostPrintWhiteOut:: .if B_WHITEOUT_MONEY >= GEN_4 jumpifbattletype BATTLE_TYPE_TRAINER, BattleScript_LocalBattleLostEnd diff --git a/include/config/battle.h b/include/config/battle.h index becf2c8c9a..b940d1dbf5 100644 --- a/include/config/battle.h +++ b/include/config/battle.h @@ -211,6 +211,7 @@ #define B_FLAG_TERA_ORB_CHARGED 0 // If this flag is set, the Tera Orb is charged. It is automatically set upon healing and cleared upon Terastallizing once configured. #define B_FLAG_TERA_ORB_NO_COST 0 // If this flag is set, the Tera Orb does not use up its charge upon Terastallization. In S/V, this occurs after an event with Terapagos. #define B_FLAG_SLEEP_CLAUSE 0 // If this flag is set, sleep clause is enabled; if the player / AI has already put a Pokémon on the opponent's side to sleep and it is still sleeping, another one can't be put to sleep. AI requires AI_FLAG_CHECK_BAD_MOVE to understand. +#define B_FLAG_NO_WHITEOUT 0 // If this flag is set, the player can not white out against Trainers. Please note that the party is not healed automatically! // Var Settings // To use the following features, change the 0 for a var present in include/constants/vars.h, preferably an unused one. diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index cd71a35e8c..6bcf8be569 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -18690,3 +18690,13 @@ void BS_JumpIfLastUsedItemHoldEffect(void) else gBattlescriptCurrInstr = cmd->nextInstr; } + +void BS_JumpIfNoWhiteOut(void) +{ + NATIVE_ARGS(const u8 *jumpInstr); + + if (FlagGet(B_FLAG_NO_WHITEOUT)) + gBattlescriptCurrInstr = cmd->jumpInstr; + else + gBattlescriptCurrInstr = cmd->nextInstr; +} diff --git a/src/battle_setup.c b/src/battle_setup.c index f2d4ebd497..674ee2520c 100644 --- a/src/battle_setup.c +++ b/src/battle_setup.c @@ -1299,7 +1299,7 @@ static void CB2_EndTrainerBattle(void) } else if (IsPlayerDefeated(gBattleOutcome) == TRUE) { - if (InBattlePyramid() || InTrainerHillChallenge() || (!NoAliveMonsForPlayer())) + if (InBattlePyramid() || InTrainerHillChallenge() || (!NoAliveMonsForPlayer()) || FlagGet(B_FLAG_NO_WHITEOUT)) SetMainCallback2(CB2_ReturnToFieldContinueScriptPlayMapMusic); else SetMainCallback2(CB2_WhiteOut); diff --git a/src/overworld.c b/src/overworld.c index 2cdb6ddf8c..33af588e2a 100644 --- a/src/overworld.c +++ b/src/overworld.c @@ -440,6 +440,7 @@ void Overworld_ResetBattleFlagsAndVars(void) FlagClear(B_FLAG_NO_RUNNING); FlagClear(B_FLAG_DYNAMAX_BATTLE); FlagClear(B_FLAG_SKY_BATTLE); + FlagClear(B_FLAG_NO_WHITEOUT); } #endif