From 9554146738079cb53bdcde44dc14f7c9f47b9f7a Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Thu, 22 May 2025 08:27:28 -0400 Subject: [PATCH] Fixed forfeit money for `B_WHITEOUT_MONEY <= GEN_3` (#6942) --- data/battle_scripts_1.s | 7 +++++-- src/battle_script_commands.c | 31 +++++++++++++++++++------------ src/overworld.c | 2 -- 3 files changed, 24 insertions(+), 16 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 9938299db9..3ad7e71f82 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -5396,18 +5396,17 @@ BattleScript_LocalBattleLost:: jumpifhalfword CMP_EQUAL, gTrainerBattleParameter + 2, TRAINER_SECRET_BASE, BattleScript_LocalBattleLostEnd jumpifnowhiteout BattleScript_LocalBattleLostEnd_ BattleScript_LocalBattleLostPrintWhiteOut:: + getmoneyreward .if B_WHITEOUT_MONEY >= GEN_4 jumpifbattletype BATTLE_TYPE_TRAINER, BattleScript_LocalBattleLostEnd printstring STRINGID_PLAYERWHITEOUT waitmessage B_WAIT_TIME_LONG - getmoneyreward printstring STRINGID_PLAYERWHITEOUT2 waitmessage B_WAIT_TIME_LONG end2 BattleScript_LocalBattleLostEnd:: printstring STRINGID_PLAYERLOSTTOENEMYTRAINER waitmessage B_WAIT_TIME_LONG - getmoneyreward printstring STRINGID_PLAYERPAIDPRIZEMONEY waitmessage B_WAIT_TIME_LONG end2 @@ -9998,7 +9997,11 @@ BattleScript_QuestionForfeitBattle:: BattleScript_ForfeitBattleGaveMoney:: getmoneyreward +.if B_WHITEOUT_MONEY >= GEN_4 printstring STRINGID_FORFEITBATTLEGAVEMONEY +.else + printstring STRINGID_PLAYERWHITEOUT2 +.endif waitmessage B_WAIT_TIME_LONG end2 diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 439299ac28..14c89c2010 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -8808,22 +8808,29 @@ static void Cmd_getmoneyreward(void) } else { - s32 i, count; - for (i = 0; i < PARTY_SIZE; i++) + if (B_WHITEOUT_MONEY <= GEN_3) { - if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES_OR_EGG) != SPECIES_NONE - && GetMonData(&gPlayerParty[i], MON_DATA_SPECIES_OR_EGG) != SPECIES_EGG) + money = GetMoney(&gSaveBlock1Ptr->money) / 2; + } + else + { + s32 i, count; + for (i = 0; i < PARTY_SIZE; i++) { - if (GetMonData(&gPlayerParty[i], MON_DATA_LEVEL) > sPartyLevel) - sPartyLevel = GetMonData(&gPlayerParty[i], MON_DATA_LEVEL); + if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES_OR_EGG) != SPECIES_NONE + && GetMonData(&gPlayerParty[i], MON_DATA_SPECIES_OR_EGG) != SPECIES_EGG) + { + if (GetMonData(&gPlayerParty[i], MON_DATA_LEVEL) > sPartyLevel) + sPartyLevel = GetMonData(&gPlayerParty[i], MON_DATA_LEVEL); + } } + for (count = 0, i = 0; i < ARRAY_COUNT(gBadgeFlags); i++) + { + if (FlagGet(gBadgeFlags[i]) == TRUE) + ++count; + } + money = sWhiteOutBadgeMoney[count] * sPartyLevel; } - for (count = 0, i = 0; i < ARRAY_COUNT(gBadgeFlags); i++) - { - if (FlagGet(gBadgeFlags[i]) == TRUE) - ++count; - } - money = sWhiteOutBadgeMoney[count] * sPartyLevel; RemoveMoney(&gSaveBlock1Ptr->money, money); } diff --git a/src/overworld.c b/src/overworld.c index 33af588e2a..6ffe73c6ed 100644 --- a/src/overworld.c +++ b/src/overworld.c @@ -378,8 +378,6 @@ static void (*const sMovementStatusHandler[])(struct LinkPlayerObjectEvent *, st void DoWhiteOut(void) { RunScriptImmediately(EventScript_WhiteOut); - if (B_WHITEOUT_MONEY == GEN_3) - SetMoney(&gSaveBlock1Ptr->money, GetMoney(&gSaveBlock1Ptr->money) / 2); HealPlayerParty(); Overworld_ResetStateAfterWhiteOut(); SetWarpDestinationToLastHealLocation();