diff --git a/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot8.cs b/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot8.cs index 410a53e3c..21f92cf55 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot8.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot8.cs @@ -77,6 +77,10 @@ namespace PKHeX.Core if (Location is 76 && ((EncounterArea8)Area).PermitCrossover) return EncounterMatchRating.PartialMatch; + bool isHidden = pkm.AbilityNumber == 4; + if (isHidden && this.IsPartialMatchHidden(pkm.Species, Species)) + return EncounterMatchRating.PartialMatch; + if (pkm is IRibbonSetMark8 m) { if (m.RibbonMarkCurry && (Weather & AreaWeather8.All) == 0) diff --git a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic8Nest.cs b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic8Nest.cs index dc3f7ff25..8f3ff60ac 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic8Nest.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic8Nest.cs @@ -46,13 +46,15 @@ namespace PKHeX.Core { if (Ability != -1) // Any { + bool CanBeHidden() => ((PersonalInfoSWSH) PersonalTable.SWSH.GetFormEntry(Species, Form)).HasHiddenAbility; + // HA-Only is a strict match. Ability Capsule and Patch can potentially change these. if (Ability == 0 && pkm.AbilityNumber == 4) - return true; // 0/1 + return !CanBeHidden(); // 0/1 if (Ability == 1 && pkm.AbilityNumber != 1) - return true; // 0 + return pkm.AbilityNumber != 4 || !CanBeHidden(); // 0 if (Ability == 2 && pkm.AbilityNumber != 2) - return true; // 1 + return pkm.AbilityNumber != 4 || !CanBeHidden(); // 1 } return base.IsMatchDeferred(pkm); diff --git a/PKHeX.Core/Legality/Verifiers/Ability/AbilityVerifier.cs b/PKHeX.Core/Legality/Verifiers/Ability/AbilityVerifier.cs index faf88a453..17e42ff40 100644 --- a/PKHeX.Core/Legality/Verifiers/Ability/AbilityVerifier.cs +++ b/PKHeX.Core/Legality/Verifiers/Ability/AbilityVerifier.cs @@ -69,8 +69,15 @@ namespace PKHeX.Core if (format >= 8) // Ability Patch { - if (pkm.AbilityNumber == 4 && CanAbilityPatch(format, abilities, pkm.Species)) - return GetValid(LAbilityPatchUsed); + if (pkm.AbilityNumber == 4) + { + if (CanAbilityPatch(format, abilities, pkm.Species)) + return GetValid(LAbilityPatchUsed); + + var e = data.EncounterOriginal; + if (e.Species != pkm.Species && CanAbilityPatch(format, PKX.Personal.GetFormEntry(e.Species, e.Form).Abilities, e.Species)) + return GetValid(LAbilityPatchUsed); + } } var enc = data.EncounterMatch; @@ -118,7 +125,7 @@ namespace PKHeX.Core 5 => VerifyAbility5(data, enc, abilities), 6 => VerifyAbility6(data, enc), 7 => VerifyAbility7(data, enc), - 8 => VerifyAbility8(data, enc), + >=8 => VALID, _ => CheckMatch(data.pkm, abilities, gen, AbilityState.CanMismatch) }; } @@ -369,17 +376,6 @@ namespace PKHeX.Core return VALID; } - private CheckResult VerifyAbility8(LegalityAnalysis data, IEncounterable enc) - { - var pkm = data.pkm; - if (enc is EncounterSlot && pkm.AbilityNumber == 4) - return GetInvalid(LAbilityHiddenUnavailable); - //if (BreedLegality.Ban_NoHidden8.Contains(pkm.SpecForm) && pkm.AbilityNumber == 4) - // return GetInvalid(LAbilityHiddenUnavailable); - - return VALID; - } - /// /// Final checks assuming nothing else has flagged the ability. /// diff --git a/PKHeX.Core/PersonalInfo/PersonalInfoSWSH.cs b/PKHeX.Core/PersonalInfo/PersonalInfoSWSH.cs index eb5c06dc2..5b09f5d6a 100644 --- a/PKHeX.Core/PersonalInfo/PersonalInfoSWSH.cs +++ b/PKHeX.Core/PersonalInfo/PersonalInfoSWSH.cs @@ -135,5 +135,7 @@ namespace PKHeX.Core /// Checks if the entry shows up in any of the built-in Pokédex. /// public bool IsInDex => PokeDexIndex != 0 || ArmorDexIndex != 0 || CrownDexIndex != 0; + + public bool HasHiddenAbility => AbilityH != Ability1; } }