diff --git a/PKHeX/Legality/Checks.cs b/PKHeX/Legality/Checks.cs index c14e682ec..582240ff3 100644 --- a/PKHeX/Legality/Checks.cs +++ b/PKHeX/Legality/Checks.cs @@ -369,7 +369,7 @@ private CheckResult verifyEncounter() if (pkm.VC) { - int baseSpecies = Legal.getEvolutionChain(pkm, null).Min(entry => entry.Species); + int baseSpecies = Legal.getBaseSpecies(pkm); if ((pkm.VC1 && baseSpecies > Legal.MaxSpeciesID_1) || (pkm.VC2 && baseSpecies > Legal.MaxSpeciesID_2)) return new CheckResult(Severity.Invalid, "VC: Unobtainable species.", CheckIdentifier.Encounter); diff --git a/PKHeX/Legality/Core.cs b/PKHeX/Legality/Core.cs index e6d989a18..7cf9016a8 100644 --- a/PKHeX/Legality/Core.cs +++ b/PKHeX/Legality/Core.cs @@ -365,6 +365,40 @@ private static EvolutionTree getEvolutionTable(PKM pkm) return Evolves6; } } + + private static int getMaxSpeciesOrigin(int generation) + { + switch (generation) + { + case 1: + return Legal.MaxSpeciesID_1; + case 2: + return Legal.MaxSpeciesID_2; + case 3: + return Legal.MaxSpeciesID_3; + case 4: + return Legal.MaxSpeciesID_4; + case 5: + return Legal.MaxSpeciesID_5; + case 6: + return Legal.MaxSpeciesID_6; + case 7: + return Legal.MaxSpeciesID_7; + default: + return Legal.MaxSpeciesID_7; + } + } + + internal static int getMaxSpeciesOrigin(PKM pkm) + { + if (pkm.Format == 1 || pkm.VC1) //Gen1 VC could not trade with gen 2 yet + return getMaxSpeciesOrigin(1); + else if (pkm.Format == 2 || pkm.VC2) + return getMaxSpeciesOrigin(2); + else + return getMaxSpeciesOrigin(pkm.GenNumber); + } + internal static IEnumerable getValidGifts(PKM pkm) { switch (pkm.GenNumber) diff --git a/PKHeX/Legality/Structures/EvolutionTree.cs b/PKHeX/Legality/Structures/EvolutionTree.cs index cfd838f34..d618c1761 100644 --- a/PKHeX/Legality/Structures/EvolutionTree.cs +++ b/PKHeX/Legality/Structures/EvolutionTree.cs @@ -354,6 +354,7 @@ public void Insert(EvolutionStage evo) public IEnumerable getExplicitLineage(PKM pkm, int lvl, bool skipChecks, int maxSpecies) { + int maxSpeciesOrigin = Legal.getMaxSpeciesOrigin(pkm); List dl = new List { new DexLevel { Species = pkm.Species, Level = lvl, Form = pkm.AltForm } }; for (int i = Chain.Count-1; i >= 0; i--) // reverse evolution! { @@ -376,6 +377,8 @@ public IEnumerable getExplicitLineage(PKM pkm, int lvl, bool skipCheck if (!oneValid) break; } + if (dl.Any(d=>d.Species <= maxSpeciesOrigin) && dl.Last().Species > maxSpeciesOrigin) + dl.RemoveAt(dl.Count - 1);//remove future gen preevolutions, no munchlax in a gen3 snorlax, no pichu in a gen1 vc raichu, etc return dl; } }