diff --git a/PKHeX.Core/Legality/Encounters/EncounterGenerator.cs b/PKHeX.Core/Legality/Encounters/EncounterGenerator.cs index d9cd01299..b74111970 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterGenerator.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterGenerator.cs @@ -475,17 +475,34 @@ private static bool GetIsMatchStatic(PKM pkm, EncounterStatic e, int lvl) if (pkm.Egg_Location != 0) return false; } - else - switch (pkm.GenNumber) + else if (pkm.Gen4) { - case 4: - if (pkm.Egg_Location != 2002) // Link Trade + if (pkm.Egg_Location != 2002) // Link Trade + { + // check Pt/HGSS data + if (pkm.Format <= 4) + return false; // must match + if (e.EggLocation >= 3000 || e.EggLocation <= 2010) // non-Pt/HGSS egg gift return false; - break; - default: - if (pkm.Egg_Location != 30002) // Link Trade + + // transferring 4->5 clears pt/hgss location value and keeps Faraway Place + if (pkm.Egg_Location != 3002) // Faraway Place return false; - break; + } + } + else + { + if (pkm.Egg_Location != 30002) // Link Trade + return false; + } + } + else if (e.EggLocation != 0 && pkm.Gen4) + { + // Check the inverse scenario for 4->5 eggs + if (e.EggLocation < 3000 && e.EggLocation > 2010) // Pt/HGSS egg gift + { + if (pkm.Format > 4) + return false; // locations match when it shouldn't } } diff --git a/PKHeX.Core/PKM/PK4.cs b/PKHeX.Core/PKM/PK4.cs index 8e432d96f..4a186a7f4 100644 --- a/PKHeX.Core/PKM/PK4.cs +++ b/PKHeX.Core/PKM/PK4.cs @@ -438,7 +438,9 @@ public PK5 ConvertToPK5() pk5.Met_Location = pk5.Gen4 && pk5.FatefulEncounter && Legal.CrownBeasts.Contains(pk5.Species) ? (pk5.Species == 251 ? Legal.Transfer4_CelebiUnused : Legal.Transfer4_CrownUnused) // Celebi : Beast : Legal.Transfer4; // Pokétransfer (not Crown) - pk5.Egg_Location = Egg_Location; + + // Egg Location is not modified; when clearing Pt/HGSS egg data, the location will revert to Faraway Place + // pk5.Egg_Location = Egg_Location; // Delete HGSS Data BitConverter.GetBytes((ushort)0).CopyTo(pk5.Data, 0x86); diff --git a/PKHeX.Core/PKM/PK5.cs b/PKHeX.Core/PKM/PK5.cs index d21f87b0e..f3652554f 100644 --- a/PKHeX.Core/PKM/PK5.cs +++ b/PKHeX.Core/PKM/PK5.cs @@ -8,7 +8,7 @@ public sealed class PK5 : PKM, IRibbonSetEvent3, IRibbonSetEvent4, IRibbonSetUni { public static readonly byte[] ExtraBytes = { - 0x42, 0x43, 0x5E, 0x63, 0x64, 0x65, 0x66, 0x67, 0x87 + 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x5E, 0x63, 0x64, 0x65, 0x66, 0x67, 0x87 }; public override int SIZE_PARTY => PKX.SIZE_5PARTY; public override int SIZE_STORED => PKX.SIZE_5STORED;