diff --git a/src/ui/battle-info.ts b/src/ui/battle-info.ts index f2e48911e07..88bc3230ce3 100644 --- a/src/ui/battle-info.ts +++ b/src/ui/battle-info.ts @@ -260,8 +260,23 @@ export default class BattleInfo extends Phaser.GameObjects.Container { if (!this.player) { const dexEntry = pokemon.scene.gameData.dexData[pokemon.species.speciesId]; this.ownedIcon.setVisible(!!dexEntry.caughtAttr); - const dexAttr = pokemon.getDexAttr(); - if ((dexEntry.caughtAttr & dexAttr) < dexAttr || !(pokemon.scene.gameData.starterData[pokemon.species.getRootSpeciesId()].abilityAttr & Math.pow(2, pokemon.abilityIndex))) + const opponentPokemonDexAttr = pokemon.getDexAttr(); + + // Check if Player owns all genders and forms of the Pokemon + const missingDexAttrs = ((dexEntry.caughtAttr & opponentPokemonDexAttr) < opponentPokemonDexAttr); + + /** + * If the opposing Pokemon only has 1 normal ability and is using the hidden ability it should have the same behavior + * if it had 2 normal abilities. This code checks if that is the case and uses the correct opponent Pokemon abilityIndex (2) + * for calculations so it aligns with where the hidden ability is stored in the starter data's abilityAttr (4) + */ + const opponentPokemonOneNormalAbility = (pokemon.species.getAbilityCount() === 2); + const opponentPokemonAbilityIndex = (opponentPokemonOneNormalAbility && pokemon.abilityIndex === 1) ? 2 : pokemon.abilityIndex; + const opponentPokemonAbilityAttr = Math.pow(2, opponentPokemonAbilityIndex); + + const rootFormHasHiddenAbility = pokemon.scene.gameData.starterData[pokemon.species.getRootSpeciesId()].abilityAttr & opponentPokemonAbilityAttr; + + if (missingDexAttrs || !rootFormHasHiddenAbility) this.ownedIcon.setTint(0x808080); if (this.boss)