Fixed AI not considering Hidden Abilities in its team during switching logic (#2908)

This commit is contained in:
Martin Griffin 2023-04-14 14:56:46 +01:00 committed by GitHub
commit 48fba7a35c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -198,9 +198,8 @@ static bool8 FindMonThatAbsorbsOpponentsMove(void)
if (GetMonData(&party[i], MON_DATA_HP) == 0) if (GetMonData(&party[i], MON_DATA_HP) == 0)
continue; continue;
if (GetMonData(&party[i], MON_DATA_SPECIES_OR_EGG) == SPECIES_NONE) species = GetMonData(&party[i], MON_DATA_SPECIES_OR_EGG);
continue; if (species == SPECIES_NONE || species == SPECIES_EGG)
if (GetMonData(&party[i], MON_DATA_SPECIES_OR_EGG) == SPECIES_EGG)
continue; continue;
if (i == gBattlerPartyIndexes[battlerIn1]) if (i == gBattlerPartyIndexes[battlerIn1])
continue; continue;
@ -213,12 +212,7 @@ static bool8 FindMonThatAbsorbsOpponentsMove(void)
if (IsAceMon(gActiveBattler, i)) if (IsAceMon(gActiveBattler, i))
continue; continue;
monAbility = GetMonAbility(&party[i]);
species = GetMonData(&party[i], MON_DATA_SPECIES);
if (GetMonData(&party[i], MON_DATA_ABILITY_NUM) != 0)
monAbility = gSpeciesInfo[species].abilities[1];
else
monAbility = gSpeciesInfo[species].abilities[0];
if (absorbingTypeAbility == monAbility && Random() & 1) if (absorbingTypeAbility == monAbility && Random() & 1)
{ {
@ -570,9 +564,8 @@ static bool8 FindMonWithFlagsAndSuperEffective(u16 flags, u8 moduloPercent)
if (GetMonData(&party[i], MON_DATA_HP) == 0) if (GetMonData(&party[i], MON_DATA_HP) == 0)
continue; continue;
if (GetMonData(&party[i], MON_DATA_SPECIES_OR_EGG) == SPECIES_NONE) species = GetMonData(&party[i], MON_DATA_SPECIES_OR_EGG);
continue; if (species == SPECIES_NONE || species == SPECIES_EGG)
if (GetMonData(&party[i], MON_DATA_SPECIES_OR_EGG) == SPECIES_EGG)
continue; continue;
if (i == gBattlerPartyIndexes[battlerIn1]) if (i == gBattlerPartyIndexes[battlerIn1])
continue; continue;
@ -585,12 +578,7 @@ static bool8 FindMonWithFlagsAndSuperEffective(u16 flags, u8 moduloPercent)
if (IsAceMon(gActiveBattler, i)) if (IsAceMon(gActiveBattler, i))
continue; continue;
monAbility = GetMonAbility(&party[i]);
species = GetMonData(&party[i], MON_DATA_SPECIES);
if (GetMonData(&party[i], MON_DATA_ABILITY_NUM) != 0)
monAbility = gSpeciesInfo[species].abilities[1];
else
monAbility = gSpeciesInfo[species].abilities[0];
CalcPartyMonTypeEffectivenessMultiplier(gLastLandedMoves[gActiveBattler], species, monAbility); CalcPartyMonTypeEffectivenessMultiplier(gLastLandedMoves[gActiveBattler], species, monAbility);
if (gMoveResultFlags & flags) if (gMoveResultFlags & flags)
@ -964,7 +952,9 @@ u8 GetMostSuitableMonToSwitchInto(void)
// Get invalid slots ids. // Get invalid slots ids.
for (i = firstId; i < lastId; i++) for (i = firstId; i < lastId; i++)
{ {
if (GetMonData(&party[i], MON_DATA_SPECIES) == SPECIES_NONE u16 species = GetMonData(&party[i], MON_DATA_SPECIES_OR_EGG);
if (species == SPECIES_NONE
|| species == SPECIES_EGG
|| GetMonData(&party[i], MON_DATA_HP) == 0 || GetMonData(&party[i], MON_DATA_HP) == 0
|| gBattlerPartyIndexes[battlerIn1] == i || gBattlerPartyIndexes[battlerIn1] == i
|| gBattlerPartyIndexes[battlerIn2] == i || gBattlerPartyIndexes[battlerIn2] == i