mirror of
https://github.com/kwsch/PKHeX
synced 2025-02-17 05:48:44 +00:00
Static encounter refactor to return a list for pokemon with multiple statics but different moves (#1023)
* Refactor getValidStaticEncounter to return a list instead only one encounter, for those encounters with the same data except moves like Dream World Dragonite The treatment of the encounters is similar to the list of mystery gift encounters parseMovesIsEggPreRelearn change to use only the split breed species equal to the egg species Remove EventEggMoves array for parseMovesRelearn function, that array is only used for gen2-3 encounters that can be normal eggs or special eggs, gen 4-7 event eggs have the event moves in the SpecialMoves array * Add optional paramter to the methods for getting evolution tree to use for gen 1 and 2 encounters, when searching for a gen 2 encounter maxSpecies should use gen 2 max and for gen 1 encounters gen 1 max species no matter in what format is the pkm Also changed the ordenation of encounters by min species to use the less evolution form including generation 2 pre evolutions, for example for a gen 2 Hitmonlee whose static encounter could be gen 2 Tyrogue gift * Added the same maxspeciesorigin criteria for wild encounters * Fix memory card restore backup * Fixed some other parseMoves function where staticencounter was not changed to staticencounter list Separate VC Events for GB Era Events, VC Events was filter out for valid static encounters if was selected not allow GBCartEra exclusive encounters * Fix getValidPreEvolutions
This commit is contained in:
parent
0d65973421
commit
71d452a9c3
8 changed files with 105 additions and 53 deletions
|
@ -43,8 +43,9 @@
|
|||
GBCartEraOnly,
|
||||
Stadium,
|
||||
Stadium2,
|
||||
EventsGen1,
|
||||
EventsGen2,
|
||||
EventsGBGen1,
|
||||
EventsGBGen2,
|
||||
VCEvents
|
||||
}
|
||||
|
||||
public static class Extension
|
||||
|
@ -58,21 +59,22 @@
|
|||
case GameVersion.RBY:
|
||||
return (g2 == GameVersion.RD || g2 == GameVersion.BU || g2 == GameVersion.YW || g2 == GameVersion.GN);
|
||||
case GameVersion.Gen1:
|
||||
return ( GameVersion.RBY.Contains(g2) || g2 == GameVersion.Stadium|| g2 == GameVersion.EventsGen1);
|
||||
return ( GameVersion.RBY.Contains(g2) || g2 == GameVersion.Stadium || g2 == GameVersion.EventsGBGen1 || g2 == GameVersion.VCEvents);
|
||||
case GameVersion.Stadium:
|
||||
case GameVersion.EventsGen1:
|
||||
case GameVersion.EventsGBGen1:
|
||||
case GameVersion.VCEvents:
|
||||
return GameVersion.RBY.Contains(g2);
|
||||
|
||||
case GameVersion.GS: return (g2 == GameVersion.GD || g2 == GameVersion.SV);
|
||||
case GameVersion.GSC:
|
||||
return (GameVersion.GS.Contains(g2) || g2 == GameVersion.C);
|
||||
case GameVersion.Gen2:
|
||||
return (GameVersion.GSC.Contains(g2) || g2 == GameVersion.Stadium2 || g2 == GameVersion.EventsGen2);
|
||||
return (GameVersion.GSC.Contains(g2) || g2 == GameVersion.Stadium2 || g2 == GameVersion.EventsGBGen2);
|
||||
case GameVersion.Stadium2:
|
||||
case GameVersion.EventsGen2:
|
||||
case GameVersion.EventsGBGen2:
|
||||
return GameVersion.GSC.Contains(g2);
|
||||
case GameVersion.GBCartEraOnly:
|
||||
return g2 == GameVersion.Stadium || g2 == GameVersion.Stadium2 || g2 == GameVersion.EventsGen1 || g2 == GameVersion.EventsGen2;
|
||||
return g2 == GameVersion.Stadium || g2 == GameVersion.Stadium2 || g2 == GameVersion.EventsGBGen1 || g2 == GameVersion.EventsGBGen2;
|
||||
|
||||
case GameVersion.RS: return (g2 == GameVersion.R || g2 == GameVersion.S);
|
||||
case GameVersion.FRLG: return (g2 == GameVersion.FR || g2 == GameVersion.LG);
|
||||
|
|
|
@ -16,6 +16,7 @@ namespace PKHeX.Core
|
|||
private bool EncounterIsMysteryGift => EncounterType.IsSubclassOf(typeof (MysteryGift));
|
||||
private string EncounterName => Legal.getEncounterTypeName(pkm, EncounterOriginal ?? EncounterMatch);
|
||||
private List<MysteryGift> EventGiftMatch;
|
||||
private List<EncounterStatic> EncounterStaticMatch;
|
||||
private CheckResult Encounter, History;
|
||||
private int[] RelearnBase;
|
||||
// private bool SecondaryChecked;
|
||||
|
|
|
@ -719,8 +719,12 @@ namespace PKHeX.Core
|
|||
}
|
||||
if (EncounterMatch is EncounterSlot[])
|
||||
return verifyEncounterWild();
|
||||
if (EncounterMatch is EncounterStatic)
|
||||
if (EncounterMatch is List<EncounterStatic>)
|
||||
{
|
||||
EncounterStaticMatch = (List<EncounterStatic>)EncounterMatch;
|
||||
EncounterMatch = EncounterStaticMatch.First();
|
||||
return verifyEncounterStatic();
|
||||
}
|
||||
if (EncounterMatch is EncounterTrade)
|
||||
return verifyEncounterTrade();
|
||||
|
||||
|
@ -772,8 +776,9 @@ namespace PKHeX.Core
|
|||
return result;
|
||||
}
|
||||
|
||||
if (null != (EncounterMatch = Legal.getValidStaticEncounter(pkm)))
|
||||
if (null != (EncounterStaticMatch = Legal.getValidStaticEncounter(pkm)))
|
||||
{
|
||||
EncounterMatch = EncounterStaticMatch.First();
|
||||
var result = verifyEncounterStatic();
|
||||
if (result != null)
|
||||
return result;
|
||||
|
@ -825,8 +830,9 @@ namespace PKHeX.Core
|
|||
if ((G3Result = verifyEncounterWild())?.Valid ?? false)
|
||||
G3Encounter = EncounterMatch;
|
||||
}
|
||||
else if (null != (EncounterMatch = Legal.getValidStaticEncounter(pkm)))
|
||||
else if (null != (EncounterStaticMatch = Legal.getValidStaticEncounter(pkm)))
|
||||
{
|
||||
EncounterMatch = EncounterStaticMatch.First();
|
||||
if ((G3Result = verifyEncounterStatic())?.Valid ?? false)
|
||||
G3Encounter = EncounterMatch;
|
||||
}
|
||||
|
@ -882,8 +888,9 @@ namespace PKHeX.Core
|
|||
Gen4Result = result;
|
||||
}
|
||||
|
||||
if (Gen4Result == null && null != (EncounterMatch = Legal.getValidStaticEncounter(pkm)))
|
||||
if (Gen4Result == null && null != (EncounterStaticMatch = Legal.getValidStaticEncounter(pkm)))
|
||||
{
|
||||
EncounterMatch = EncounterStaticMatch.First();
|
||||
var result = verifyEncounterStatic();
|
||||
if (result != null)
|
||||
return result;
|
||||
|
@ -946,11 +953,12 @@ namespace PKHeX.Core
|
|||
if ((EncounterOriginal ?? EncounterMatch) == null)
|
||||
return new CheckResult(Severity.Invalid, V80, CheckIdentifier.Encounter);
|
||||
|
||||
var s = EncounterMatch as EncounterStatic;
|
||||
if (s != null && GameVersion.GBCartEraOnly.Contains(s.Version))
|
||||
var s = EncounterMatch as List<EncounterStatic>;
|
||||
var sgb = s?.Where(v => GameVersion.GBCartEraOnly.Contains(v.Version) || v.Version == GameVersion.VCEvents).FirstOrDefault();
|
||||
if (sgb != null)
|
||||
{
|
||||
bool exceptions = false;
|
||||
exceptions |= baseSpecies == 151 && pkm.TID == 22796;
|
||||
exceptions |= sgb.Version == GameVersion.VCEvents && baseSpecies == 151 && pkm.TID == 22796;
|
||||
if (!exceptions)
|
||||
AddLine(new CheckResult(Severity.Invalid, V79, CheckIdentifier.Encounter));
|
||||
}
|
||||
|
@ -2298,12 +2306,8 @@ namespace PKHeX.Core
|
|||
res = parseMovesSketch(Moves);
|
||||
else if (pkm.GenNumber < 6)
|
||||
res = parseMovesPre3DS(game, validLevelMoves, validTMHM, validTutor, Moves);
|
||||
else if (EventGiftMatch?.Count > 1) // Multiple possible Mystery Gifts matched, get the best match too
|
||||
res = parseMovesGetGift(Moves, validLevelMoves, validTMHM, validTutor);
|
||||
else if (pkm.WasEgg && Legal.SplitBreed.Contains(pkm.Species))
|
||||
res = parseMovesRelearnSplitBreed(Moves, validLevelMoves, validTMHM, validTutor, game);
|
||||
else // Everything else
|
||||
res = parseMovesRelearn(Moves, validLevelMoves, validTMHM, validTutor, 0, game);
|
||||
else
|
||||
res = parseMoves3DS(game, validLevelMoves, validTMHM, validTutor, Moves);
|
||||
|
||||
// Duplicate Moves Check
|
||||
verifyNoEmptyDuplicates(Moves, res);
|
||||
|
@ -2383,6 +2387,10 @@ namespace PKHeX.Core
|
|||
{
|
||||
for (int i = 0; i <= splitctr; i++)
|
||||
{
|
||||
var baseSpecies = Legal.getBaseSpecies(pkm, i);
|
||||
if (baseSpecies != pkm.Species)
|
||||
continue;
|
||||
|
||||
var baseEggMoves = Legal.getBaseEggMoves(pkm, i, ver, pkm.GenNumber < 4 ? 5 : 1)?.ToList() ?? new List<int>();
|
||||
var InheritedLvlMoves = Legal.getBaseEggMoves(pkm, i, ver, 100)?.ToList() ?? new List<int>();
|
||||
var EggMoves = Legal.getEggMoves(pkm, i, ver)?.ToList() ?? new List<int>();
|
||||
|
@ -2417,7 +2425,9 @@ namespace PKHeX.Core
|
|||
// Gen 3 could have an egg origin and a non-egg origin, check first non-egg origin
|
||||
if (pkm.GenNumber == 3 && !pkm.HasOriginalMetLocation && EncounterMatch !=null)
|
||||
{
|
||||
res = EventGiftMatch?.Count > 1
|
||||
res = EncounterStaticMatch?.Count > 1
|
||||
? parseMovesStaticEncounters(Moves, validLevelMoves, validTMHM, validTutor)
|
||||
: EventGiftMatch?.Count > 1
|
||||
? parseMovesGetGift(Moves, validLevelMoves, validTMHM, validTutor) // Multiple possible Mystery Gifts matched, get the best match too
|
||||
: parseMovesPreRelearnEncounter(Moves, validLevelMoves, validTMHM, validTutor, GameVersion.Any); // Everything else, non-egg encounters only
|
||||
if (res.All(r => r.Valid)) // moves are satisfactory
|
||||
|
@ -2446,7 +2456,7 @@ namespace PKHeX.Core
|
|||
int splitctr = Legal.SplitBreed.Contains(pkm.Species) ? 1 : 0;
|
||||
foreach (var ver in Games)
|
||||
{
|
||||
var EventEggMoves = pkm.WasEgg && !pkm.WasGiftEgg ? Legal.getSpecialEggMoves(pkm, ver).ToArray() : new int[0];
|
||||
var EventEggMoves = pkm.WasEgg && !pkm.WasGiftEgg? Legal.getSpecialEggMoves(pkm, ver).ToArray() : new int[0];
|
||||
for (int i = 0; i <= splitctr; i++)
|
||||
{
|
||||
var baseEggMoves = Legal.getBaseEggMoves(pkm, i, ver, 100)?.ToArray() ?? new int[0];
|
||||
|
@ -2485,6 +2495,17 @@ namespace PKHeX.Core
|
|||
: new CheckResult(CheckIdentifier.Move);
|
||||
return res;
|
||||
}
|
||||
private CheckResult[] parseMoves3DS(GameVersion game, List<int>[] validLevelMoves, List<int>[] validTMHM, List<int>[] validTutor, int[] Moves)
|
||||
{
|
||||
if (EventGiftMatch?.Count > 1) // Multiple possible Mystery Gifts matched, get the best match too
|
||||
return parseMovesGetGift(Moves, validLevelMoves, validTMHM, validTutor);
|
||||
else if (EncounterStaticMatch?.Count > 1) // Multiple possible Static Encounters matched, get the best match too
|
||||
return parseMovesStaticEncounters(Moves, validLevelMoves, validTMHM, validTutor);
|
||||
else if (pkm.WasEgg && Legal.SplitBreed.Contains(pkm.Species))
|
||||
return parseMovesRelearnSplitBreed(Moves, validLevelMoves, validTMHM, validTutor, game);
|
||||
else // Everything else
|
||||
return parseMovesRelearn(Moves, validLevelMoves, validTMHM, validTutor, 0, game);
|
||||
}
|
||||
private CheckResult[] parseMovesPre3DS(GameVersion game, List<int>[] validLevelMoves, List<int>[] validTMHM, List<int>[] validTutor, int[] Moves)
|
||||
{
|
||||
if (pkm.IsEgg)
|
||||
|
@ -2493,8 +2514,8 @@ namespace PKHeX.Core
|
|||
return parseMovesIsEggPreRelearnEvent(Moves);
|
||||
|
||||
int[] SpecialMoves = (EncounterMatch as MysteryGift)?.Moves ??
|
||||
(EncounterMatch as EncounterStatic)?.Moves ??
|
||||
(EncounterMatch as EncounterTrade)?.Moves;
|
||||
(EncounterMatch as List<EncounterStatic>)?.First().Moves ??
|
||||
(EncounterMatch as EncounterTrade)?.Moves;
|
||||
var allowinherited = SpecialMoves == null && !pkm.WasGiftEgg && !pkm.WasEventEgg;
|
||||
return parseMovesIsEggPreRelearn(Moves, SpecialMoves ?? new int[0], allowinherited);
|
||||
}
|
||||
|
@ -2504,12 +2525,15 @@ namespace PKHeX.Core
|
|||
if (EventGiftMatch?.Count > 1)
|
||||
// Multiple possible non-egg Mystery Gifts matched, get the best match too
|
||||
return parseMovesGetGift(Moves, validLevelMoves, validTMHM, validTutor);
|
||||
if (EncounterStaticMatch?.Count > 1)
|
||||
// Multiple possible Static Encounters matched, get the best match too
|
||||
return parseMovesStaticEncounters(Moves, validLevelMoves, validTMHM, validTutor);
|
||||
|
||||
return parseMovesPreRelearnEncounter(Moves, validLevelMoves, validTMHM, validTutor, game);
|
||||
}
|
||||
private CheckResult[] parseMovesGetGift(int[] Moves, List<int>[] validLevelMoves, List<int>[] validTMHM, List<int>[] validTutor)
|
||||
{
|
||||
int[] RelearnMoves = pkm.RelearnMoves;
|
||||
int[] RelearnMoves = pkm.GenNumber < 6 ? new int[0] : pkm.RelearnMoves;
|
||||
foreach (MysteryGift mg in EventGiftMatch)
|
||||
{
|
||||
int[] SpecialMoves = mg.Moves;
|
||||
|
@ -2519,17 +2543,34 @@ namespace PKHeX.Core
|
|||
|
||||
// Match Found
|
||||
EncounterMatch = mg;
|
||||
RelearnBase = mg.RelearnMoves;
|
||||
if(pkm.GenNumber >= 6)
|
||||
RelearnBase = mg.RelearnMoves;
|
||||
return res;
|
||||
}
|
||||
|
||||
// no Mystery Gifts matched
|
||||
return parseMoves(Moves, validLevelMoves, RelearnMoves, validTMHM, validTutor, new int[0], new int[0], new int[0], new int[0]);
|
||||
}
|
||||
private CheckResult[] parseMovesStaticEncounters(int[] Moves, List<int>[] validLevelMoves, List<int>[] validTMHM, List<int>[] validTutor)
|
||||
{
|
||||
CheckResult[] res = null;
|
||||
foreach (EncounterStatic stenc in EncounterStaticMatch)
|
||||
{
|
||||
int[] SpecialMoves = stenc.Moves;
|
||||
res = parseMoves(Moves, validLevelMoves, new int[0], validTMHM, validTutor, SpecialMoves, new int[0], new int[0], new int[0]);
|
||||
if (res.Any(r => !r.Valid))
|
||||
continue;
|
||||
|
||||
// Match Found
|
||||
EncounterMatch = stenc;
|
||||
return res;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
private CheckResult[] parseMovesPreRelearnEncounter(int[] Moves, List<int>[] validLevelMoves, List<int>[] validTMHM, List<int>[] validTutor, GameVersion game)
|
||||
{
|
||||
int[] SpecialMoves = (EncounterMatch as MysteryGift)?.Moves ??
|
||||
(EncounterMatch as EncounterStatic)?.Moves ??
|
||||
(EncounterMatch as List<EncounterStatic>)?.First().Moves ??
|
||||
(EncounterMatch as EncounterTrade)?.Moves ??
|
||||
new int[0];
|
||||
|
||||
|
@ -2551,15 +2592,14 @@ namespace PKHeX.Core
|
|||
}
|
||||
private CheckResult[] parseMovesRelearn(int[] Moves, List<int>[] validLevelMoves, List<int>[] validTMHM, List<int>[] validTutor, int SkipOption, GameVersion game)
|
||||
{
|
||||
int[] EggMoves = pkm.WasEgg && !pkm.WasGiftEgg? Legal.getEggMoves(pkm, SkipOption, game).ToArray() : new int[0];
|
||||
int[] EventEggMoves = pkm.WasEgg && !pkm.WasGiftEgg ? Legal.getSpecialEggMoves(pkm, game).ToArray() : new int[0];
|
||||
int[] EggMoves = pkm.WasEgg && !pkm.WasGiftEgg && !pkm.WasEventEgg? Legal.getEggMoves(pkm, SkipOption, game).ToArray() : new int[0];
|
||||
int[] RelearnMoves = pkm.RelearnMoves;
|
||||
int[] SpecialMoves = (EncounterMatch as MysteryGift)?.Moves ??
|
||||
(EncounterMatch as EncounterStatic)?.Moves ??
|
||||
(EncounterMatch as List<EncounterStatic>)?.First().Moves ??
|
||||
(EncounterMatch as EncounterTrade)?.Moves ??
|
||||
new int[0];
|
||||
|
||||
CheckResult[] res = parseMoves(Moves, validLevelMoves, RelearnMoves, validTMHM, validTutor, SpecialMoves, new int[0], EggMoves, EventEggMoves);
|
||||
CheckResult[] res = parseMoves(Moves, validLevelMoves, RelearnMoves, validTMHM, validTutor, SpecialMoves, new int[0], EggMoves, new int[0]);
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
if ((pkm.IsEgg || res[i].Flag) && !RelearnMoves.Contains(Moves[i]))
|
||||
|
|
|
@ -866,7 +866,7 @@ namespace PKHeX.Core
|
|||
List<EncounterSlot> s = new List<EncounterSlot>();
|
||||
|
||||
foreach (var area in getEncounterAreas(pkm, gameSource))
|
||||
s.AddRange(getValidEncounterSlots(pkm, area, DexNav: pkm.AO));
|
||||
s.AddRange(getValidEncounterSlots(pkm, area, DexNav: pkm.AO, gameSource: gameSource));
|
||||
|
||||
if (s.Count <= 1 || 3 > pkm.GenNumber || pkm.GenNumber > 4 || pkm.HasOriginalMetLocation)
|
||||
return s.Any() ? s.ToArray() : null;
|
||||
|
@ -894,11 +894,12 @@ namespace PKHeX.Core
|
|||
|
||||
return s.Any() ? s.ToArray() : null;
|
||||
}
|
||||
internal static EncounterStatic getValidStaticEncounter(PKM pkm, GameVersion gameSource = GameVersion.Any)
|
||||
internal static List<EncounterStatic> getValidStaticEncounter(PKM pkm, GameVersion gameSource = GameVersion.Any)
|
||||
{
|
||||
if (gameSource == GameVersion.Any)
|
||||
gameSource = (GameVersion)pkm.Version;
|
||||
|
||||
var enc = new List<EncounterStatic>();
|
||||
// Get possible encounters
|
||||
IEnumerable<EncounterStatic> poss = getStaticEncounters(pkm, gameSource: gameSource);
|
||||
|
||||
|
@ -945,9 +946,9 @@ namespace PKHeX.Core
|
|||
if (!AllowGBCartEra && GameVersion.GBCartEraOnly.Contains(e.Version))
|
||||
continue; // disallow gb cart era encounters (as they aren't obtainable by Main/VC series)
|
||||
|
||||
return e;
|
||||
enc.Add(e);
|
||||
}
|
||||
return null;
|
||||
return enc.Any() ? enc : null;
|
||||
}
|
||||
internal static EncounterTrade getValidIngameTrade(PKM pkm, GameVersion gameSource = GameVersion.Any)
|
||||
{
|
||||
|
@ -1092,6 +1093,9 @@ namespace PKHeX.Core
|
|||
// Since encounter matching is super weak due to limited stored data in the structure
|
||||
// Calculate all 3 at the same time and pick the best result (by species).
|
||||
// Favor special event move gifts as Static Encounters when applicable
|
||||
var maxspeciesorigin = game == GameVersion.GSC ? MaxSpeciesID_2 : MaxSpeciesID_1;
|
||||
DexLevel[] vs = getValidPreEvolutions(pkm, maxspeciesorigin: maxspeciesorigin).ToArray();
|
||||
|
||||
var s = getValidStaticEncounter(pkm, game);
|
||||
var e = getValidWildEncounters(pkm, game);
|
||||
var t = getValidIngameTrade(pkm, game);
|
||||
|
@ -1100,12 +1104,12 @@ namespace PKHeX.Core
|
|||
return null;
|
||||
|
||||
const byte invalid = 255;
|
||||
var sm = s?.Species ?? invalid;
|
||||
var em = e?.Min(slot => slot.Species) ?? invalid;
|
||||
var sm = s != null ? vs.Reverse().First(evo => s.Any(slot => slot.Species == evo.Species)).Species : invalid;
|
||||
var em = e != null ? vs.Reverse().First(evo => e.Any(slot => slot.Species == evo.Species)).Species : invalid;
|
||||
var tm = t?.Species ?? invalid;
|
||||
|
||||
if (s != null && s.Moves[0] != 0 && pkm.Moves.Contains(s.Moves[0]))
|
||||
return new Tuple<object, int, byte>(s, s.Level, 20); // special move
|
||||
if (s != null && (s?.Any(m => m.Moves[0] != 0 && pkm.Moves.Contains(m.Moves[0])) ?? false))
|
||||
return new Tuple<object, int, byte>(s, s.Where(m => m.Moves[0] != 0 && pkm.Moves.Contains(m.Moves[0])).First().Level, 20); // special move
|
||||
if (game == GameVersion.GSC)
|
||||
{
|
||||
if (t != null && t.TID != 0)
|
||||
|
@ -1116,7 +1120,7 @@ namespace PKHeX.Core
|
|||
if (em <= sm && em <= tm)
|
||||
return new Tuple<object, int, byte>(e, e.Where(slot => slot.Species == em).Min(slot => slot.LevelMin), 3);
|
||||
if (sm <= em && sm <= tm)
|
||||
return new Tuple<object, int, byte>(s, s.Level, 2);
|
||||
return new Tuple<object, int, byte>(s, s.Where(slot => slot.Species == em).Min(slot => slot.Level), 2);
|
||||
if (tm <= sm && tm <= em)
|
||||
return new Tuple<object, int, byte>(t, t.Level, 1);
|
||||
return null;
|
||||
|
@ -2095,12 +2099,12 @@ namespace PKHeX.Core
|
|||
case GameVersion.RBY:
|
||||
case GameVersion.RD: case GameVersion.BU:
|
||||
case GameVersion.GN: case GameVersion.YW:
|
||||
return getStatic(pkm, StaticRBY, lvl);
|
||||
return getStatic(pkm, StaticRBY, maxspeciesorigin:MaxSpeciesID_1, lvl: lvl);
|
||||
|
||||
case GameVersion.GSC:
|
||||
case GameVersion.GD: case GameVersion.SV:
|
||||
case GameVersion.C:
|
||||
return getStatic(pkm, getStaticTableGen2(pkm), lvl);
|
||||
return getStatic(pkm, getStaticTableGen2(pkm), maxspeciesorigin: MaxSpeciesID_2, lvl: lvl);
|
||||
|
||||
case GameVersion.R:
|
||||
return getStatic(pkm, StaticR, lvl);
|
||||
|
@ -2159,7 +2163,7 @@ namespace PKHeX.Core
|
|||
bool noMet = !pkm.HasOriginalMetLocation;
|
||||
return noMet ? slots : slots.Where(area => area.Location == pkm.Met_Location);
|
||||
}
|
||||
private static IEnumerable<EncounterSlot> getValidEncounterSlots(PKM pkm, EncounterArea loc, bool DexNav, bool ignoreLevel = false)
|
||||
private static IEnumerable<EncounterSlot> getValidEncounterSlots(PKM pkm, EncounterArea loc, bool DexNav, bool ignoreLevel = false, GameVersion gameSource = GameVersion.Any)
|
||||
{
|
||||
int fluteBoost = pkm.Format < 3 ? 0 : 4;
|
||||
const int dexnavBoost = 30;
|
||||
|
@ -2168,8 +2172,12 @@ namespace PKHeX.Core
|
|||
int dn = DexNav ? fluteBoost + dexnavBoost : 0;
|
||||
List<EncounterSlot> slotdata = new List<EncounterSlot>();
|
||||
|
||||
var maxspeciesorigin = -1;
|
||||
if (gameSource == GameVersion.RBY) maxspeciesorigin = MaxSpeciesID_1;
|
||||
if (gameSource == GameVersion.GSC) maxspeciesorigin = MaxSpeciesID_2;
|
||||
|
||||
// Get Valid levels
|
||||
IEnumerable<DexLevel> vs = getValidPreEvolutions(pkm, ignoreLevel ? 100 : -1, ignoreLevel);
|
||||
IEnumerable<DexLevel> vs = getValidPreEvolutions(pkm, maxspeciesorigin: maxspeciesorigin, lvl: ignoreLevel ? 100 : -1, skipChecks:ignoreLevel);
|
||||
|
||||
// Get slots where pokemon can exist
|
||||
bool ignoreSlotLevel = ignoreLevel;
|
||||
|
@ -2289,7 +2297,7 @@ namespace PKHeX.Core
|
|||
}
|
||||
return slotLocations;
|
||||
}
|
||||
private static IEnumerable<DexLevel> getValidPreEvolutions(PKM pkm, int lvl = -1, bool skipChecks = false)
|
||||
private static IEnumerable<DexLevel> getValidPreEvolutions(PKM pkm, int maxspeciesorigin =-1, int lvl = -1, bool skipChecks = false)
|
||||
{
|
||||
if (lvl < 0)
|
||||
lvl = pkm.CurrentLevel;
|
||||
|
@ -2306,11 +2314,11 @@ namespace PKHeX.Core
|
|||
};
|
||||
|
||||
var et = getEvolutionTable(pkm);
|
||||
return et.getValidPreEvolutions(pkm, lvl, skipChecks: skipChecks);
|
||||
return et.getValidPreEvolutions(pkm, lvl: lvl, maxSpeciesOrigin: maxspeciesorigin, skipChecks: skipChecks);
|
||||
}
|
||||
private static IEnumerable<EncounterStatic> getStatic(PKM pkm, IEnumerable<EncounterStatic> table, int lvl = -1)
|
||||
private static IEnumerable<EncounterStatic> getStatic(PKM pkm, IEnumerable<EncounterStatic> table, int maxspeciesorigin =-1, int lvl = -1)
|
||||
{
|
||||
IEnumerable<DexLevel> dl = getValidPreEvolutions(pkm, lvl);
|
||||
IEnumerable<DexLevel> dl = getValidPreEvolutions(pkm, maxspeciesorigin: maxspeciesorigin, lvl: lvl);
|
||||
return table.Where(e => dl.Any(d => d.Species == e.Species));
|
||||
}
|
||||
private static IEnumerable<int> getValidMoves(PKM pkm, GameVersion Version, IReadOnlyList<DexLevel[]> vs, bool LVL = false, bool Relearn = false, bool Tutor = false, bool Machine = false, bool MoveReminder = true, bool RemoveTransferHM = true)
|
||||
|
|
|
@ -165,10 +165,11 @@ namespace PKHeX.Core
|
|||
|
||||
return Personal.getFormeIndex(evolvesToSpecies, evolvesToForm);
|
||||
}
|
||||
public IEnumerable<DexLevel> getValidPreEvolutions(PKM pkm, int lvl, bool skipChecks = false)
|
||||
public IEnumerable<DexLevel> getValidPreEvolutions(PKM pkm, int lvl, int maxSpeciesOrigin =-1 ,bool skipChecks = false)
|
||||
{
|
||||
int index = getIndex(pkm);
|
||||
int maxSpeciesOrigin = Legal.getMaxSpeciesOrigin(pkm);
|
||||
if(maxSpeciesOrigin <= 0)
|
||||
maxSpeciesOrigin = Legal.getMaxSpeciesOrigin(pkm);
|
||||
return Lineage[index].getExplicitLineage(pkm, lvl, skipChecks, MaxSpeciesTree, maxSpeciesOrigin);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -103,7 +103,7 @@ namespace PKHeX.Core
|
|||
// new EncounterStatic { Species = 007, Level = 10, Version = GameVersion.YW }, // Squirtle (Vermillion City)
|
||||
|
||||
new EncounterStatic { Species = 054, Level = 15, Moves = new [] { 133, 10 }, Version = GameVersion.Stadium }, // Stadium Psyduck (Amnesia)
|
||||
new EncounterStatic { Species = 151, Level = 5, IVs = new [] {15,15,15,15,15,15}, Version = GameVersion.EventsGen1 }, // Event Mew
|
||||
new EncounterStatic { Species = 151, Level = 5, IVs = new [] {15,15,15,15,15,15}, Version = GameVersion.VCEvents }, // Event Mew
|
||||
};
|
||||
internal static readonly EncounterTrade[] TradeGift_RBY =
|
||||
{
|
||||
|
|
|
@ -105,7 +105,7 @@ namespace PKHeX.Core
|
|||
|
||||
new EncounterStatic { Species = 249, Level = 60, Location = 031, Version = GameVersion.C }, // Lugia @ Whirl Islands
|
||||
new EncounterStatic { Species = 250, Level = 60, Location = 023, Version = GameVersion.C }, // Ho-Oh @ Tin Tower
|
||||
new EncounterStatic { Species = 251, Level = 30, Location = 014, Version = GameVersion.EventsGen2 }, // Celebi @ Ilex Forest
|
||||
new EncounterStatic { Species = 251, Level = 30, Location = 014, Version = GameVersion.EventsGBGen2 }, // Celebi @ Ilex Forest
|
||||
};
|
||||
|
||||
internal static readonly EncounterStatic[] Encounter_GS = Encounter_GSC_Common.Concat(Encounter_GS_Exclusive).ToArray();
|
||||
|
|
|
@ -166,7 +166,7 @@ namespace PKHeX.Core
|
|||
private void restoreBackup()
|
||||
{
|
||||
Array.Copy(Data, DirectoryBackup_Block*BLOCK_SIZE, Data, Directory_Block*BLOCK_SIZE, BLOCK_SIZE);
|
||||
Array.Copy(Data, BlockAlloc_Block*BLOCK_SIZE, Data, BlockAllocBackup_Block*BLOCK_SIZE, BLOCK_SIZE);
|
||||
Array.Copy(Data, BlockAllocBackup_Block*BLOCK_SIZE, Data, BlockAlloc_Block*BLOCK_SIZE, BLOCK_SIZE);
|
||||
}
|
||||
|
||||
public GCMemoryCardState LoadMemoryCardFile(byte[] data)
|
||||
|
|
Loading…
Add table
Reference in a new issue