Even with met location and met level lost after transfer pokemon from gen 3 to 4, 4 to 5 and 1 to 7 Met Level can still be used to filter some invalid encounter slots, those whose min level is greater that the met level of the pokemon

Even without knowing the real met level, it can be greater than the transfer level
For GB and GBC pokemon the same but with the current level instead. This will make illegal any level 7 glitch Articuno
This commit is contained in:
javierhimura
2017-02-16 00:47:44 +01:00
parent fc14a2ec50
commit 980ffac9d3
2 changed files with 46 additions and 10 deletions

View File

@@ -294,6 +294,11 @@ internal static EncounterStatic getValidStaticEncounter(PKM pkm)
if (e.Level != pkm.Met_Level)
continue;
}
else
{
if (e.Level > pkm.Met_Level)
continue;
}
if (e.Gender != -1 && e.Gender != pkm.Gender)
continue;
if (e.Form != pkm.AltForm && !FormChange.Contains(pkm.Species) && !e.SkipFormCheck)
@@ -350,7 +355,9 @@ internal static EncounterTrade getValidIngameTrade(PKM pkm)
return null;
if (pkm.HasOriginalMetLocation && z.Location != pkm.Met_Location)
return null;
if (z.Level != pkm.Met_Level)
if (pkm.HasOriginalMetLocation && z.Level != pkm.Met_Level)
return null;
if (!pkm.HasOriginalMetLocation && z.Level > pkm.Met_Level)
return null;
if (z.Nature != Nature.Random && (int)z.Nature != pkm.Nature)
return null;
@@ -421,7 +428,7 @@ internal static int getMaxSpeciesOrigin(int generation)
default: return -1;
}
}
internal static int[] getFutureGenEvolutions(int generation)
{
switch (generation)
@@ -1016,14 +1023,31 @@ private static IEnumerable<EncounterSlot> getValidEncounterSlots(PKM pkm, Encoun
bool ignoreSlotLevel = ignoreLevel;
IEnumerable<EncounterSlot> slots = loc.Slots.Where(slot => vs.Any(evo => evo.Species == slot.Species && (ignoreSlotLevel || evo.Level >= slot.LevelMin - df)));
if (pkm.Format < 3 || pkm.VC)
return slots; // no met level or special encounter considerations
// Filter for Met Level
int lvl = pkm.Met_Level;
int lvl = (pkm.Format < 3) ? pkm.CurrentLevel : pkm.Met_Level;
int gen = pkm.GenNumber;
bool ignoreMetLevel = ignoreLevel || gen <= 4 && pkm.Format != gen;
var encounterSlots = slots.Where(slot => ignoreMetLevel || slot.LevelMin - df <= lvl && lvl <= slot.LevelMax + (slot.AllowDexNav ? dn : df)).ToList();
IEnumerable<EncounterSlot> encounterSlots;
if(pkm.HasOriginalMetLocation)
encounterSlots = slots.Where(slot => ignoreLevel || slot.LevelMin - df <= lvl && lvl <= slot.LevelMax + (slot.AllowDexNav ? dn : df)).ToList();
else
{
//See comments in getEvolutionChainsAllGens for more info in this sentence
if (gen == 3 && pkm.Format > 4 && lvl == pkm.CurrentLevel && FutureEvolutionsGen3_LevelUp.Contains(pkm.Species))
lvl--;
//Those encounters with level min greater that met level are not valid for this pokemon
encounterSlots = slots.Where(slot => ignoreLevel || slot.LevelMin <= lvl).ToList();
}
if(gen <= 2)
{
//For gen 1 and 2 return minimun level slot
//Minimun level is needed to check available moves, because there is no move reminder in gen 1,
//There are moves in the level up table that cant be legally obtained
EncounterSlot slotMin = encounterSlots.OrderBy(slot => slot.LevelMin).FirstOrDefault();
if (slotMin != null)
slotdata.Add(slotMin);
return slotdata;
}
// Pressure Slot
EncounterSlot slotMax = encounterSlots.OrderByDescending(slot => slot.LevelMax).FirstOrDefault();
@@ -1036,7 +1060,7 @@ private static IEnumerable<EncounterSlot> getValidEncounterSlots(PKM pkm, Encoun
slotdata.Add(slotMax);
return slotdata;
}
if (!DexNav)
if (gen == 6 || !DexNav)
{
// Filter for Form Specific
slotdata.AddRange(WildForms.Contains(pkm.Species)
@@ -1048,6 +1072,11 @@ private static IEnumerable<EncounterSlot> getValidEncounterSlots(PKM pkm, Encoun
}
List<EncounterSlot> eslots = encounterSlots.Where(slot => !WildForms.Contains(pkm.Species) || slot.Form == pkm.AltForm).ToList();
if(gen <=4)
{
slotdata.AddRange(eslots);
return slotdata;
}
if (slotMax != null)
eslots.Add(slotMax);
foreach (EncounterSlot s in eslots)
@@ -1092,7 +1121,7 @@ private static IEnumerable<DexLevel> getValidPreEvolutions(PKM pkm, int lvl = -1
return new List<DexLevel>
{
new DexLevel { Species = 292, Level = lvl, MinLevel =20 },
new DexLevel { Species = 290, Level = lvl - 1, MinLevel = 1 }
new DexLevel { Species = 290, Level = lvl-1, MinLevel = 1 }
};
var et = getEvolutionTable(pkm);

View File

@@ -87,5 +87,12 @@ public static partial class Legal
{
407,424,429,430,461,462,463,464,465,466,467,468,469,470,471,472,473,474,475,476,477,700
};
internal static readonly int[] FutureEvolutionsGen3_LevelUp = new int[]
{
424, 461, 462, 463, 465, 469, 470, 471, 472, 473, 476
};
// Ambipom Weavile Magnezone Lickilicky Tangrowth
// Yanmega Leafeon Glaceon Mamoswine Gliscor Probopass
}
}