Support for multi battles where Trainer has only one mon (#2670)

This commit is contained in:
DizzyEggg 2023-04-20 16:12:11 +02:00 committed by GitHub
parent 6c7f5881e4
commit ae80d545c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 5 deletions

View File

@ -228,9 +228,11 @@ static void Intro_DelayAndEnd(void)
}
}
static bool32 TwoIntroMons(u32 battlerId) // Double battle with both player pokemon active.
static bool32 TwoIntroMons(u32 battlerId) // Double battle with both opponent pokemon active.
{
return (IsDoubleBattle() && IsValidForBattle(&gEnemyParty[gBattlerPartyIndexes[BATTLE_PARTNER(battlerId)]]));
return (IsDoubleBattle()
&& IsValidForBattle(&gEnemyParty[gBattlerPartyIndexes[battlerId]])
&& IsValidForBattle(&gEnemyParty[gBattlerPartyIndexes[BATTLE_PARTNER(battlerId)]]));
}
static void Intro_WaitForShinyAnimAndHealthbox(void)
@ -1969,7 +1971,7 @@ static void SpriteCB_FreeOpponentSprite(struct Sprite *sprite)
static void Task_StartSendOutAnim(u8 taskId)
{
u8 savedActiveBank = gActiveBattler;
u8 savedActiveBattler = gActiveBattler;
gActiveBattler = gTasks[taskId].data[0];
if ((!TwoIntroMons(gActiveBattler) || (gBattleTypeFlags & BATTLE_TYPE_MULTI)) && !BATTLE_TWO_VS_ONE_OPPONENT)
@ -1977,7 +1979,7 @@ static void Task_StartSendOutAnim(u8 taskId)
gBattleResources->bufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler];
StartSendOutAnim(gActiveBattler, FALSE);
}
else if ((gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS))
else if ((gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS) || (BATTLE_TWO_VS_ONE_OPPONENT && !TwoIntroMons(gActiveBattler)))
{
gBattleResources->bufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler];
StartSendOutAnim(gActiveBattler, FALSE);
@ -1992,7 +1994,7 @@ static void Task_StartSendOutAnim(u8 taskId)
gActiveBattler ^= BIT_FLANK;
}
gBattlerControllerFuncs[gActiveBattler] = Intro_TryShinyAnimShowHealthbox;
gActiveBattler = savedActiveBank;
gActiveBattler = savedActiveBattler;
DestroyTask(taskId);
}

View File

@ -690,12 +690,17 @@ static void InitLastUsedBallAssets(void)
}
// This function is here to cover a specific case - one player's mon in a 2 vs 1 double battle. In this scenario - display singles layout.
// The same goes for a 2 vs 1 where opponent has only one pokemon.
u32 WhichBattleCoords(u32 battlerId) // 0 - singles, 1 - doubles
{
if (GetBattlerPosition(battlerId) == B_POSITION_PLAYER_LEFT
&& gPlayerPartyCount == 1
&& !(gBattleTypeFlags & BATTLE_TYPE_MULTI))
return 0;
else if (GetBattlerPosition(battlerId) == B_POSITION_OPPONENT_LEFT
&& gEnemyPartyCount == 1
&& !(gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS))
return 0;
else
return IsDoubleBattle();
}

View File

@ -594,6 +594,7 @@ static void CB2_InitBattleInternal(void)
if (gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS && !BATTLE_TWO_VS_ONE_OPPONENT)
CreateNPCTrainerParty(&gEnemyParty[PARTY_SIZE / 2], gTrainerBattleOpponent_B, FALSE);
SetWildMonHeldItem();
CalculateEnemyPartyCount();
}
gMain.inBattle = TRUE;