diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index aae89225d0..d1556c2b8e 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -5941,6 +5941,7 @@ BattleScript_PayDayMoneyAndPickUpItems:: end2 BattleScript_LocalBattleLost:: + jumpifbattletype BATTLE_TYPE_INGAME_PARTNER, BattleScript_LocalBattleLostPrintWhiteOut jumpifbattletype BATTLE_TYPE_DOME, BattleScript_CheckDomeDrew jumpifbattletype BATTLE_TYPE_FRONTIER, BattleScript_LocalBattleLostPrintTrainersWinText jumpifbattletype BATTLE_TYPE_TRAINER_HILL, BattleScript_LocalBattleLostPrintTrainersWinText diff --git a/include/constants/battle_config.h b/include/constants/battle_config.h index 2f4bb65c2c..facd4f4019 100644 --- a/include/constants/battle_config.h +++ b/include/constants/battle_config.h @@ -232,8 +232,9 @@ #define B_LAST_USED_BALL TRUE // If TRUE, the "last used ball" feature from Gen 7 will be implemented #define B_LAST_USED_BALL_BUTTON R_BUTTON // If last used ball is implemented, this button (or button combo) will trigger throwing the last used ball. -// Other +// Other settings #define B_DOUBLE_WILD_CHANCE 0 // % chance of encountering two Pokémon in a Wild Encounter. +#define B_MULTI_BATTLE_WHITEOUT GEN_8 // In Gen4+, multi battles end when the Player and also their Partner don't have any more Pokémon to fight. // Animation Settings #define B_NEW_SWORD_PARTICLE FALSE // If set to TRUE, it updates Swords Dance's particle. diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 857a4d819c..eee5ccf03f 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -3942,7 +3942,8 @@ static void Cmd_getexp(void) gBattleScripting.getexpState = 5; gBattleMoveDamage = 0; // used for exp } - else if (GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_LEVEL) == MAX_LEVEL) + else if ((gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER && gBattleStruct->expGetterMonId >= 3) + || GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_LEVEL) == MAX_LEVEL) { *(&gBattleStruct->sentInPokes) >>= 1; gBattleScripting.getexpState = 5; @@ -4134,6 +4135,28 @@ static void Cmd_getexp(void) } } +#ifdef B_MULTI_BATTLE_WHITEOUT >= GEN_4 +static bool32 NoAliveMonsForPlayerAndPartner(void) +{ + u32 i; + u32 HP_count = 0; + + if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER && (gPartnerTrainerId == TRAINER_STEVEN_PARTNER || gPartnerTrainerId >= TRAINER_CUSTOM_PARTNER)) + { + for (i = 0; i < PARTY_SIZE; i++) + { + if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES) && !GetMonData(&gPlayerParty[i], MON_DATA_IS_EGG) + && (!(gBattleTypeFlags & BATTLE_TYPE_ARENA) || !(gBattleStruct->arenaLostPlayerMons & gBitTable[i]))) + { + HP_count += GetMonData(&gPlayerParty[i], MON_DATA_HP); + } + } + } + + return (HP_count == 0); +} +#endif + static bool32 NoAliveMonsForPlayer(void) { u32 i; @@ -4195,8 +4218,21 @@ static void Cmd_checkteamslost(void) if (gBattleControllerExecFlags) return; +#ifdef B_MULTI_BATTLE_WHITEOUT >= GEN_4 + if (gBattleTypeFlags & (BATTLE_TYPE_MULTI | BATTLE_TYPE_INGAME_PARTNER)) + { + if (NoAliveMonsForPlayerAndPartner()) + gBattleOutcome |= B_OUTCOME_LOST; + } + else + { + if (NoAliveMonsForPlayer()) + gBattleOutcome |= B_OUTCOME_LOST; + } +#else if (NoAliveMonsForPlayer()) gBattleOutcome |= B_OUTCOME_LOST; +#endif if (NoAliveMonsForOpponent()) gBattleOutcome |= B_OUTCOME_WON;