diff --git a/PKHeX.Core/Legality/Checks.cs b/PKHeX.Core/Legality/Checks.cs index 056d2a86d..d9c12e7f2 100644 --- a/PKHeX.Core/Legality/Checks.cs +++ b/PKHeX.Core/Legality/Checks.cs @@ -1098,8 +1098,6 @@ private void VerifyCXDStarterCorrelation(PIDIV pidiv) private void VerifyAbility() { int[] abilities = pkm.PersonalInfo.Abilities; - if (abilities[1] == 0) - abilities[1] = abilities[0]; int abilval = Array.IndexOf(abilities, pkm.Ability); if (abilval < 0) { @@ -1226,8 +1224,8 @@ private static bool IsAbilityCapsuleModified(PKM pkm, IReadOnlyList abiliti } private bool? VerifyAbilityGen3Transfer(int[] abilities, int abilval, int Species_g3) { - var abilities_g3 = PersonalTable.E[Species_g3].Abilities.Where(a => a != 0).Distinct().ToArray(); - if (abilities_g3.Length == 2) // Excluding Colosseum/XD, a gen3 pkm must match PID if it has 2 unique abilities + var pers = (PersonalInfoG3)PersonalTable.E[Species_g3]; + if (pers.Ability1 != pers.Ability2) // Excluding Colosseum/XD, a gen3 pkm must match PID if it has 2 unique abilities return pkm.Version != (int)GameVersion.CXD; int Species_g4 = Info.EvoChainsAllGens[4].FirstOrDefault()?.Species ?? 0; @@ -1239,7 +1237,7 @@ private static bool IsAbilityCapsuleModified(PKM pkm, IReadOnlyList abiliti if (Evolutions_g45 > 1) { // Evolutions_g45 > 1 and Species_g45 = Species_g3 with means both options, evolve in gen 4-5 or not evolve, are possible - if (pkm.Ability == abilities_g3[0]) + if (pkm.Ability == pers.Ability1) // It could evolve in gen 4-5 an have generation 3 only ability // that means it have not actually evolved in gen 4-5, ability do not need to match PID return null; @@ -1250,7 +1248,7 @@ private static bool IsAbilityCapsuleModified(PKM pkm, IReadOnlyList abiliti } // Evolutions_g45 == 1 means it have not evolved in gen 4-5 games, // ability do not need to match PID, but only generation 3 ability is allowed - if (pkm.Ability != abilities_g3[0]) + if (pkm.Ability != pers.Ability1) // Not evolved in gen4-5 but do not have generation 3 only ability AddLine(Severity.Invalid, V373, CheckIdentifier.Ability); return null; diff --git a/PKHeX.Core/Legality/Encounters/Data/Encounters5.cs b/PKHeX.Core/Legality/Encounters/Data/Encounters5.cs index a28491f9b..eb5a39ed7 100644 --- a/PKHeX.Core/Legality/Encounters/Data/Encounters5.cs +++ b/PKHeX.Core/Legality/Encounters/Data/Encounters5.cs @@ -90,8 +90,9 @@ private static void MarkG5DreamWorld(ref EncounterStatic[] t) { foreach (EncounterStatic s in t) { - s.Location = 75; //Entree Forest - s.Ability = PersonalTable.B2W2.GetAbilities(s.Species, s.Form)[2] == 0 ? 1 : 4; // Check if has HA + s.Location = 75; // Entree Forest + var p = (PersonalInfoBW)PersonalTable.B2W2[s.Species]; + s.Ability = p.HasHiddenAbility ? 4 : 1; s.Shiny = Shiny.Never; } diff --git a/PKHeX.Core/PKM/PKM.cs b/PKHeX.Core/PKM/PKM.cs index 8cc2cf097..541a899ad 100644 --- a/PKHeX.Core/PKM/PKM.cs +++ b/PKHeX.Core/PKM/PKM.cs @@ -668,7 +668,7 @@ public void RefreshAbility(int n) int[] abilities = PersonalInfo.Abilities; if (n < abilities.Length) { - if (abilities[n] == 0) + if (abilities[n] == abilities[0]) n = 0; Ability = abilities[n]; } diff --git a/PKHeX.Core/PKM/Shared/_K3.cs b/PKHeX.Core/PKM/Shared/_K3.cs index 5a6f44031..52d4d2c93 100644 --- a/PKHeX.Core/PKM/Shared/_K3.cs +++ b/PKHeX.Core/PKM/Shared/_K3.cs @@ -26,7 +26,7 @@ public abstract class _K3 : PKM, IRibbonSetEvent3, IRibbonSetCommon3, IRibbonSet public override bool WasGiftEgg => IsEgg && Met_Location == 253; // Gift Egg, indistinguible from normal eggs after hatch public override bool WasEventEgg => IsEgg && Met_Location == 255; // Event Egg, indistinguible from normal eggs after hatch - public override int Ability { get { int[] abils = PersonalInfo.Abilities; return abils[abils[1] == 0 ? 0 : AbilityNumber >> 1]; } set { } } + public override int Ability { get { var pi = (PersonalInfoG3)PersonalInfo; return pi.Abilities[pi.HasSecondAbility ? AbilityNumber >> 1 : 0]; } set { } } public override uint EncryptionConstant { get => PID; set { } } public override int Nature { get => (int)(PID % 25); set { } } public override int AltForm { get => Species == 201 ? PKX.GetUnownForm(PID) : 0; set { } } diff --git a/PKHeX.Core/PersonalInfo/PersonalInfoBW.cs b/PKHeX.Core/PersonalInfo/PersonalInfoBW.cs index 8ff40d1c9..76657e7be 100644 --- a/PKHeX.Core/PersonalInfo/PersonalInfoBW.cs +++ b/PKHeX.Core/PersonalInfo/PersonalInfoBW.cs @@ -86,5 +86,7 @@ public override int[] Abilities AbilityH = (byte)value[2]; } } + + public bool HasHiddenAbility => AbilityH != Ability1; } } diff --git a/PKHeX.Core/PersonalInfo/PersonalInfoG3.cs b/PKHeX.Core/PersonalInfo/PersonalInfoG3.cs index 9b918b2d6..5fbc96b7f 100644 --- a/PKHeX.Core/PersonalInfo/PersonalInfoG3.cs +++ b/PKHeX.Core/PersonalInfo/PersonalInfoG3.cs @@ -69,5 +69,7 @@ public override int[] Abilities Ability2 = (byte)value[1]; } } + + public bool HasSecondAbility => Ability1 != Ability2; } } diff --git a/PKHeX.Core/Resources/byte/personal_b2w2 b/PKHeX.Core/Resources/byte/personal_b2w2 index dbe6c87e3..9236ad139 100644 Binary files a/PKHeX.Core/Resources/byte/personal_b2w2 and b/PKHeX.Core/Resources/byte/personal_b2w2 differ diff --git a/PKHeX.Core/Resources/byte/personal_bw b/PKHeX.Core/Resources/byte/personal_bw index 78c862814..db73853e2 100644 Binary files a/PKHeX.Core/Resources/byte/personal_bw and b/PKHeX.Core/Resources/byte/personal_bw differ diff --git a/PKHeX.Core/Resources/byte/personal_dp b/PKHeX.Core/Resources/byte/personal_dp index bbc6f343d..671fa7899 100644 Binary files a/PKHeX.Core/Resources/byte/personal_dp and b/PKHeX.Core/Resources/byte/personal_dp differ diff --git a/PKHeX.Core/Resources/byte/personal_e b/PKHeX.Core/Resources/byte/personal_e index b3c0bab02..77957529d 100644 Binary files a/PKHeX.Core/Resources/byte/personal_e and b/PKHeX.Core/Resources/byte/personal_e differ diff --git a/PKHeX.Core/Resources/byte/personal_fr b/PKHeX.Core/Resources/byte/personal_fr index 0e90accb0..0a8d2b851 100644 Binary files a/PKHeX.Core/Resources/byte/personal_fr and b/PKHeX.Core/Resources/byte/personal_fr differ diff --git a/PKHeX.Core/Resources/byte/personal_hgss b/PKHeX.Core/Resources/byte/personal_hgss index 55da3503c..cca533668 100644 Binary files a/PKHeX.Core/Resources/byte/personal_hgss and b/PKHeX.Core/Resources/byte/personal_hgss differ diff --git a/PKHeX.Core/Resources/byte/personal_lg b/PKHeX.Core/Resources/byte/personal_lg index 0e90accb0..0a8d2b851 100644 Binary files a/PKHeX.Core/Resources/byte/personal_lg and b/PKHeX.Core/Resources/byte/personal_lg differ diff --git a/PKHeX.Core/Resources/byte/personal_pt b/PKHeX.Core/Resources/byte/personal_pt index 6f9721033..e6a3e24fb 100644 Binary files a/PKHeX.Core/Resources/byte/personal_pt and b/PKHeX.Core/Resources/byte/personal_pt differ diff --git a/PKHeX.Core/Resources/byte/personal_rs b/PKHeX.Core/Resources/byte/personal_rs index b3c0bab02..77957529d 100644 Binary files a/PKHeX.Core/Resources/byte/personal_rs and b/PKHeX.Core/Resources/byte/personal_rs differ diff --git a/PKHeX.WinForms/Controls/PKM Editor/LoadSave.cs b/PKHeX.WinForms/Controls/PKM Editor/LoadSave.cs index f3342c01e..bd215315e 100644 --- a/PKHeX.WinForms/Controls/PKM Editor/LoadSave.cs +++ b/PKHeX.WinForms/Controls/PKM Editor/LoadSave.cs @@ -355,7 +355,7 @@ private static int GetAbilityIndex4(PKM pk, int[] abils) return 0; if (abilityIndex >= 2) return 2; - if (abils[0] == abils[1] || abils[1] == 0) + if (abils[0] == abils[1]) return pk.PIDAbility; return abilityIndex; } diff --git a/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs b/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs index 3a5fa1ec5..22ea27d66 100644 --- a/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs +++ b/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs @@ -392,14 +392,10 @@ private void SetAbilityList() private static List GetAbilityList(PKM pkm) { var abils = pkm.PersonalInfo.Abilities; - if (abils[1] == 0 && pkm.Format != 3) - abils[1] = abils[0]; + if (pkm.Format == 3 && abils[1] == abils[0]) + abils = new[] {abils[0]}; - var list = abils.Where(a => a != 0).Select(GetItem).ToList(); - if (list.Count == 0) - list.Add(GetItem(0, 0)); - - return list; + return abils.Select(GetItem).ToList(); ComboItem GetItem(int ability, int index) => new ComboItem {