mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-12-26 03:34:15 +01:00
Fix ai vs ai battles switch issue (#3283)
This commit is contained in:
parent
755e260da4
commit
4dff0362df
@ -397,19 +397,21 @@ static void PlayerPartnerHandleChoosePokemon(u32 battler)
|
|||||||
chosenMonId = gSelectedMonPartyId = GetFirstFaintedPartyIndex(battler);
|
chosenMonId = gSelectedMonPartyId = GetFirstFaintedPartyIndex(battler);
|
||||||
}
|
}
|
||||||
// Switching out
|
// Switching out
|
||||||
else if (gBattleStruct->monToSwitchIntoId[battler] == PARTY_SIZE)
|
else if (gBattleStruct->monToSwitchIntoId[battler] >= PARTY_SIZE || !IsValidForBattle(&gPlayerParty[gBattleStruct->monToSwitchIntoId[battler]]))
|
||||||
{
|
{
|
||||||
chosenMonId = GetMostSuitableMonToSwitchInto(battler);
|
chosenMonId = GetMostSuitableMonToSwitchInto(battler);
|
||||||
if (chosenMonId == PARTY_SIZE) // just switch to the next mon
|
|
||||||
{
|
|
||||||
u8 playerMonIdentity = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT);
|
|
||||||
u8 selfIdentity = GetBattlerAtPosition(B_POSITION_PLAYER_RIGHT);
|
|
||||||
|
|
||||||
for (chosenMonId = PARTY_SIZE / 2; chosenMonId < PARTY_SIZE; chosenMonId++)
|
if (chosenMonId == PARTY_SIZE || !IsValidForBattle(&gPlayerParty[chosenMonId])) // just switch to the next mon
|
||||||
|
{
|
||||||
|
s32 firstId = (IsAiVsAiBattle()) ? 0 : (PARTY_SIZE / 2);
|
||||||
|
u32 battler1 = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT);
|
||||||
|
u32 battler2 = IsDoubleBattle() ? GetBattlerAtPosition(B_POSITION_PLAYER_RIGHT) : battler1;
|
||||||
|
|
||||||
|
for (chosenMonId = firstId; chosenMonId < PARTY_SIZE; chosenMonId++)
|
||||||
{
|
{
|
||||||
if (GetMonData(&gPlayerParty[chosenMonId], MON_DATA_HP) != 0
|
if (GetMonData(&gPlayerParty[chosenMonId], MON_DATA_HP) != 0
|
||||||
&& chosenMonId != gBattlerPartyIndexes[playerMonIdentity]
|
&& chosenMonId != gBattlerPartyIndexes[battler1]
|
||||||
&& chosenMonId != gBattlerPartyIndexes[selfIdentity])
|
&& chosenMonId != gBattlerPartyIndexes[battler2])
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user