Skip to content

Commit

Permalink
Fixed AI not considering Hidden Abilities in its team during switchin…
Browse files Browse the repository at this point in the history
…g logic (#2908)
  • Loading branch information
mrgriffin authored Apr 14, 2023
2 parents 0397a1d + 958bc34 commit 48fba7a
Showing 1 changed file with 9 additions and 19 deletions.
28 changes: 9 additions & 19 deletions src/battle_ai_switch_items.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,8 @@ static bool8 FindMonThatAbsorbsOpponentsMove(void)

if (GetMonData(&party[i], MON_DATA_HP) == 0)
continue;
if (GetMonData(&party[i], MON_DATA_SPECIES_OR_EGG) == SPECIES_NONE)
continue;
if (GetMonData(&party[i], MON_DATA_SPECIES_OR_EGG) == SPECIES_EGG)
species = GetMonData(&party[i], MON_DATA_SPECIES_OR_EGG);
if (species == SPECIES_NONE || species == SPECIES_EGG)
continue;
if (i == gBattlerPartyIndexes[battlerIn1])
continue;
Expand All @@ -213,12 +212,7 @@ static bool8 FindMonThatAbsorbsOpponentsMove(void)
if (IsAceMon(gActiveBattler, i))
continue;


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];
monAbility = GetMonAbility(&party[i]);

if (absorbingTypeAbility == monAbility && Random() & 1)
{
Expand Down Expand Up @@ -570,9 +564,8 @@ static bool8 FindMonWithFlagsAndSuperEffective(u16 flags, u8 moduloPercent)

if (GetMonData(&party[i], MON_DATA_HP) == 0)
continue;
if (GetMonData(&party[i], MON_DATA_SPECIES_OR_EGG) == SPECIES_NONE)
continue;
if (GetMonData(&party[i], MON_DATA_SPECIES_OR_EGG) == SPECIES_EGG)
species = GetMonData(&party[i], MON_DATA_SPECIES_OR_EGG);
if (species == SPECIES_NONE || species == SPECIES_EGG)
continue;
if (i == gBattlerPartyIndexes[battlerIn1])
continue;
Expand All @@ -585,12 +578,7 @@ static bool8 FindMonWithFlagsAndSuperEffective(u16 flags, u8 moduloPercent)
if (IsAceMon(gActiveBattler, i))
continue;


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];
monAbility = GetMonAbility(&party[i]);

CalcPartyMonTypeEffectivenessMultiplier(gLastLandedMoves[gActiveBattler], species, monAbility);
if (gMoveResultFlags & flags)
Expand Down Expand Up @@ -964,7 +952,9 @@ u8 GetMostSuitableMonToSwitchInto(void)
// Get invalid slots ids.
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
|| gBattlerPartyIndexes[battlerIn1] == i
|| gBattlerPartyIndexes[battlerIn2] == i
Expand Down

0 comments on commit 48fba7a

Please sign in to comment.