From 47ca69f92b5f65f01645bcd698c1cacf0e2ce866 Mon Sep 17 00:00:00 2001 From: Kurt Date: Tue, 5 Sep 2017 18:28:38 -0700 Subject: [PATCH] Legality edge case fixes Some incorrect IDs, some additions (unbreedable hidden abilities in genV) https://projectpokemon.org/forums/forums/topic/41407-pkhex-legality-errors-on-gen-6-updated/?tab=comments#comment-219459 --- PKHeX.Core/Legality/Checks.cs | 6 +++++ .../Legality/Encounters/Data/Encounters5.cs | 4 ++-- .../Legality/Encounters/EncounterGenerator.cs | 2 +- PKHeX.Core/Legality/Tables5.cs | 22 +++++++++++++++++++ PKHeX.Core/Legality/Tables6.cs | 3 ++- PKHeX.Core/Legality/Tables7.cs | 2 +- PKHeX.Core/PKM/PK6.cs | 2 -- PKHeX.Core/PKM/PK7.cs | 2 -- PKHeX.Core/PKM/PKM.cs | 16 +++++++++++++- 9 files changed, 49 insertions(+), 10 deletions(-) diff --git a/PKHeX.Core/Legality/Checks.cs b/PKHeX.Core/Legality/Checks.cs index 0e11365cf..18d96ccbc 100644 --- a/PKHeX.Core/Legality/Checks.cs +++ b/PKHeX.Core/Legality/Checks.cs @@ -957,6 +957,12 @@ private void VerifyAbility5(int[] abilities) if (pkm.AbilityNumber == 4 ^ grotto) AddLine(Severity.Invalid, grotto ? V217 : V108, CheckIdentifier.Ability); break; + + case EncounterEgg e when pkm.AbilityNumber == 4: + // Hidden Abilities for some are unbreedable (male only distribution) + if ((pkm.PersonalInfo.Gender & 0xFF) == 0 || Legal.Ban_BreedHidden.Contains(e.Species)) + AddLine(Severity.Invalid, V112, CheckIdentifier.Ability); + break; } } private void VerifyAbility6(int[] abilities) diff --git a/PKHeX.Core/Legality/Encounters/Data/Encounters5.cs b/PKHeX.Core/Legality/Encounters/Data/Encounters5.cs index 3fab533a4..346baa464 100644 --- a/PKHeX.Core/Legality/Encounters/Data/Encounters5.cs +++ b/PKHeX.Core/Legality/Encounters/Data/Encounters5.cs @@ -710,7 +710,7 @@ private static void MarkG5Slots(ref EncounterArea[] Areas) new EncounterArea {Location = 27, Slots = new[]{new EncounterSlot {Species = 193},},},// Yanma @ Route 14 new EncounterArea {Location = 28, Slots = new[]{new EncounterSlot {Species = 056},},},// Mankey @ Route 15 new EncounterArea {Location = 29, Slots = new[]{new EncounterSlot {Species = 204},},},// Pineco @ Route 16 - new EncounterArea {Location = 30, Slots = new[]{new EncounterSlot {Species = 102},},},// Exeggcutes @ Route 18 + new EncounterArea {Location = 31, Slots = new[]{new EncounterSlot {Species = 102},},},// Exeggcutes @ Route 18 }; private static readonly EncounterArea[] SlotsB_Swarm = SlotsBW_Swarm.Concat(new[] { @@ -824,7 +824,7 @@ private static void MarkG5Slots(ref EncounterArea[] Areas) new EncounterSlot{ Species = 055, LevelMin = 35, LevelMax = 40, }, // Golduck @ Shrine new EncounterSlot{ Species = 333, LevelMin = 35, LevelMax = 40, }, // Swablu @ Shrine new EncounterSlot{ Species = 436, LevelMin = 35, LevelMax = 40, }, // Bronzor @ Near Youngster - new EncounterSlot{ Species = 619, LevelMin = 35, LevelMax = 40, }, // Amoonguss @ Both + new EncounterSlot{ Species = 591, LevelMin = 35, LevelMax = 40, }, // Amoonguss @ Both // Lostlorn Forest new EncounterSlot{ Species = 127, LevelMin = 20, LevelMax = 25, }, // Pinsir new EncounterSlot{ Species = 214, LevelMin = 20, LevelMax = 25, }, // Heracross diff --git a/PKHeX.Core/Legality/Encounters/EncounterGenerator.cs b/PKHeX.Core/Legality/Encounters/EncounterGenerator.cs index 74da3f968..32c3d98c0 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterGenerator.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterGenerator.cs @@ -391,7 +391,7 @@ private static IEnumerable GetMatchingStaticEncounters(PKM pkm, { if (e.Nature != Nature.Random && pkm.Nature != (int)e.Nature) continue; - if (pkm.WasEgg ^ e.EggEncounter && pkm.Egg_Location == 0 && pkm.Format > 3) + if (pkm.WasEgg ^ e.EggEncounter && pkm.Egg_Location == 0 && pkm.Format > 3 && pkm.GenNumber > 3) { if (!pkm.IsEgg) continue; diff --git a/PKHeX.Core/Legality/Tables5.cs b/PKHeX.Core/Legality/Tables5.cs index 11d39fa05..56adea734 100644 --- a/PKHeX.Core/Legality/Tables5.cs +++ b/PKHeX.Core/Legality/Tables5.cs @@ -169,5 +169,27 @@ public static partial class Legal 60002, // Daycare 60003, // Breeder (NPC) }; + + /// + /// Some mixed-gender species were only distributed male-only. Ban hidden abilities on these species when bred in Gen5. + /// + internal static readonly int[] Ban_BreedHidden = + { + 001, // Bulbasaur + 004, // Charmander + 007, // Squirtle + 152, // Chikorita + 155, // Cyndaquil + 158, // Totodile + 252, // Treecko + 255, // Torchic + 258, // Mudkip + 387, // Turtwig + 390, // Chimchar + 393, // Piplup + 511, // Pansage + 513, // Pansear + 515, // Panpour + }; } } diff --git a/PKHeX.Core/Legality/Tables6.cs b/PKHeX.Core/Legality/Tables6.cs index 598651788..e93a25650 100644 --- a/PKHeX.Core/Legality/Tables6.cs +++ b/PKHeX.Core/Legality/Tables6.cs @@ -303,7 +303,7 @@ public static partial class Legal 032, // Via Nidoran-F 313, // Via Illumise - 440, // Via Chansey + 173, // Via Clefairy 239, // Via Electabuzz 240, // Via Magmar 298, // Via Marill @@ -311,6 +311,7 @@ public static partial class Legal 406, // Via Roselia 433, // Via Chimecho 439, // Via Mr. Mime + 440, // Via Chansey }; internal static readonly int[] Inherit_Dream = { diff --git a/PKHeX.Core/Legality/Tables7.cs b/PKHeX.Core/Legality/Tables7.cs index a311cc757..374c518fc 100644 --- a/PKHeX.Core/Legality/Tables7.cs +++ b/PKHeX.Core/Legality/Tables7.cs @@ -194,7 +194,7 @@ public static partial class Legal 095, 096, 098, 102, 104, 108, 109, 111, 113, 114, 115, 116, 118, 122, 124, 125, 126, 129, 131, 143, 147, 161, 163, 165, 167, 170, 177, 179, 183, 185, 187, 190, 191, 193, 194, 198, 200, 202, 203, 204, 206, 207, 209, 211, 213, 214, 215, 216, 218, 220, 222, 223, 225, 226, 227, 228, 231, 234, 235, 241, 246, 261, 263, 265, 273, 276, - 278, 280, 285, 287, 293, 296, 302, 303, 307, 311, 312, 316, 322, 325, 327, 333, 340, 359, 366, 369, 370, 396, + 278, 280, 285, 287, 293, 296, 302, 303, 307, 311, 312, 316, 322, 325, 327, 333, 339, 359, 366, 369, 370, 396, 399, 401, 403, 406, 412, 415, 418, 420, 427, 433, 441, 455, 032, // Via Nidoran-F diff --git a/PKHeX.Core/PKM/PK6.cs b/PKHeX.Core/PKM/PK6.cs index a6a960190..f1abd9658 100644 --- a/PKHeX.Core/PKM/PK6.cs +++ b/PKHeX.Core/PKM/PK6.cs @@ -571,8 +571,6 @@ public void TradeMemory(bool Bank) public override bool WasLink => Met_Location == 30011; public override bool WasEvent => Met_Location > 40000 && Met_Location < 50000 || FatefulEncounter; public override bool WasEventEgg => GenNumber < 5 ? base.WasEventEgg : ((Egg_Location > 40000 && Egg_Location < 50000) || (FatefulEncounter && Egg_Location == 30002)) && Met_Level == 1; - public override bool WasTradedEgg => Egg_Location == 30002 || GenNumber == 4 && Egg_Location == 2002; - public override bool WasIngameTrade => Met_Location == 30001 || GenNumber == 4 && Egg_Location == 2001; // Maximums public override int MaxMoveID => Legal.MaxMoveID_6_AO; diff --git a/PKHeX.Core/PKM/PK7.cs b/PKHeX.Core/PKM/PK7.cs index 0e12e8add..97330e515 100644 --- a/PKHeX.Core/PKM/PK7.cs +++ b/PKHeX.Core/PKM/PK7.cs @@ -606,8 +606,6 @@ public void TradeMemory(bool Bank) public override bool WasLink => Met_Location == 30011; public override bool WasEvent => Met_Location > 40000 && Met_Location < 50000 || FatefulEncounter; public override bool WasEventEgg => GenNumber < 5 ? base.WasEventEgg : ((Egg_Location > 40000 && Egg_Location < 50000) || (FatefulEncounter && Egg_Location == 30002)) && Met_Level == 1; - public override bool WasTradedEgg => Egg_Location == 30002 || GenNumber == 4 && Egg_Location == 2002; - public override bool WasIngameTrade => Met_Location == 30001 || GenNumber == 4 && Egg_Location == 2001; // Maximums public override int MaxMoveID => Legal.MaxMoveID_7; diff --git a/PKHeX.Core/PKM/PKM.cs b/PKHeX.Core/PKM/PKM.cs index d720ff21b..13ee709c9 100644 --- a/PKHeX.Core/PKM/PKM.cs +++ b/PKHeX.Core/PKM/PKM.cs @@ -480,7 +480,21 @@ public virtual bool WasGiftEgg } public virtual bool WasEvent => Met_Location > 40000 && Met_Location < 50000 || FatefulEncounter; public virtual bool WasEventEgg => GenNumber == 4 ? WasEgg && Species == 490 : ((Egg_Location > 40000 && Egg_Location < 50000) || (FatefulEncounter && Egg_Location > 0)) && Met_Level == 1; - public virtual bool WasTradedEgg => Egg_Location == 30002 || GenNumber == 4 && Egg_Location == 2002; + public bool WasTradedEgg + { + get + { + switch (GenNumber) + { + case 4: + return Egg_Location == 2002; + case 5: + return Egg_Location == 30003; + default: + return Egg_Location == 30002; + } + } + } public virtual bool WasIngameTrade => Met_Location == 30001 || GenNumber == 4 && Egg_Location == 2001; public virtual bool IsUntraded => Format >= 6 && string.IsNullOrWhiteSpace(HT_Name) && GenNumber == Format; public virtual bool IsNative => GenNumber == Format;