Gen 2 filter encounter location when pokemon have crystal met location to found only in crystal encounters

If the pokemon does not have met location but cant be tradeback to gen 1 games then search only in gold and silver encounters
This commit is contained in:
javierhimura
2017-03-21 01:50:35 +01:00
parent 89a2546773
commit d7927d80b4
4 changed files with 119 additions and 47 deletions

View File

@@ -26,8 +26,8 @@ public static partial class Legal
private static readonly EggMoves[] EggMovesC = EggMoves2.getArray(Resources.eggmove_c, MaxSpeciesID_2);
private static readonly Learnset[] LevelUpC = Learnset1.getArray(Resources.lvlmove_c, MaxSpeciesID_2);
private static readonly EvolutionTree Evolves2;
private static readonly EncounterArea[] SlotsGSC;
private static readonly EncounterStatic[] StaticGSC;
private static readonly EncounterArea[] SlotsGSC, SlotsGS, SlotsC;
private static readonly EncounterStatic[] StaticGSC, StaticGS, StaticC;
// Gen 3
private static readonly Learnset[] LevelUpE = Learnset6.getArray(Data.unpackMini(Resources.lvlmove_e, "em"));
@@ -81,6 +81,10 @@ private static EncounterStatic[] getStaticEncounters(GameVersion Game)
{
case GameVersion.RBY:
return Encounter_RBY; // GameVersion filtering not possible, return immediately
case GameVersion.GS:
return Encounter_GS;
case GameVersion.C:
return Encounter_C;
case GameVersion.GSC:
return Encounter_GSC;
@@ -294,22 +298,39 @@ private static EncounterArea[] getTables1()
return table;
}
private static EncounterArea[] getTables2()
private static EncounterArea[] getTables2(GameVersion Version)
{
// Grass/Water
var g = EncounterArea.getArray2_GW(Resources.encounter_gold);
var s = EncounterArea.getArray2_GW(Resources.encounter_silver);
var c = EncounterArea.getArray2_GW(Resources.encounter_crystal);
EncounterArea[] Slots = null;
// Fishing
var f = EncounterArea.getArray2_F(Resources.encounter_gsc_f);
// Headbutt/Rock Smash
var h_c = EncounterArea.getArray2_H(Resources.encounter_crystal_h);
var h_g = EncounterArea.getArray2_H(Resources.encounter_gold_h);
var h_s = EncounterArea.getArray2_H(Resources.encounter_silver_h);
var h = h_c.Concat(h_g).Concat(h_s);
if(Version == GameVersion.GS || Version == GameVersion.GSC)
{
// Grass/Water
var g = EncounterArea.getArray2_GW(Resources.encounter_gold);
var s = EncounterArea.getArray2_GW(Resources.encounter_silver);
// Headbutt/Rock Smash
var h_g = EncounterArea.getArray2_H(Resources.encounter_gold_h);
var h_s = EncounterArea.getArray2_H(Resources.encounter_silver_h);
return addExtraTableSlots(g, s).Concat(c).Concat(f).Concat(h).ToArray();
Slots = addExtraTableSlots(addExtraTableSlots(addExtraTableSlots(addExtraTableSlots(g, s), h_g), h_s),f);
}
if (Version == GameVersion.C || Version == GameVersion.GSC)
{
// Grass/Water
var c = EncounterArea.getArray2_GW(Resources.encounter_crystal);
// Headbutt/Rock Smash
var h_c = EncounterArea.getArray2_H(Resources.encounter_crystal_h);
var SlotsC = addExtraTableSlots(addExtraTableSlots(c, h_c),f);
if (Version == GameVersion.C)
Slots = SlotsC;
else
Slots = addExtraTableSlots(Slots, SlotsC);
}
return Slots;
}
static Legal() // Setup
{
// Gen 1
@@ -320,8 +341,12 @@ private static EncounterArea[] getTables2()
}
// Gen 2
{
StaticGS = getStaticEncounters(GameVersion.GS);
StaticC = getStaticEncounters(GameVersion.C);
StaticGSC = getStaticEncounters(GameVersion.GSC);
SlotsGSC = getTables2();
SlotsGS = getTables2(GameVersion.GS);
SlotsC = getTables2(GameVersion.C);
SlotsGSC = getTables2(GameVersion.GSC);
Evolves2 = new EvolutionTree(new[] { Resources.evos_gsc }, GameVersion.GSC, PersonalTable.C, MaxSpeciesID_2);
}
// Gen3
@@ -1648,7 +1673,7 @@ private static IEnumerable<EncounterArea> getEncounterSlots(PKM pkm, int lvl = -
case GameVersion.GSC:
case GameVersion.GD: case GameVersion.SV:
case GameVersion.C:
return getSlots(pkm, SlotsGSC, lvl);
return getSlots(pkm, getSlotsTableGen2(pkm), lvl);
case GameVersion.R:
return getSlots(pkm, SlotsR, lvl);
@@ -1712,7 +1737,7 @@ private static IEnumerable<EncounterStatic> getStaticEncounters(PKM pkm, int lvl
case GameVersion.GSC:
case GameVersion.GD: case GameVersion.SV:
case GameVersion.C:
return getStatic(pkm, StaticGSC, lvl);
return getStatic(pkm, getStaticTableGen2(pkm), lvl);
case GameVersion.R:
return getStatic(pkm, StaticR, lvl);
@@ -1855,6 +1880,41 @@ private static IEnumerable<EncounterSlot> getValidEncounterSlots(PKM pkm, Encoun
}
return slotdata;
}
private static IEnumerable<EncounterArea> getSlotsTableGen2(PKM pkm)
{
if (pkm.Format != 2)
// Gen 2 met location is lost outside gen 2 games
return SlotsGSC;
else
{
if (pkm.HasOriginalMetLocation)
// Format 2 with met location, encounter should be from crystal
return SlotsC;
else if (pkm.Species > 151 && !FutureEvolutionsGen1.Contains(pkm.Species))
// Format 2 without met location but pokemon could not be tradeback to gen 1,
// encounter should be from gold or silver
return SlotsGS;
else
// Encounter could be any gen 2 game, it can have empty met location for have a g/s origin
// or it can be a crystal pokemon that lost met location after being tradeback to gen 1 games
return SlotsGSC;
}
}
private static IEnumerable<EncounterStatic> getStaticTableGen2(PKM pkm)
{
if (pkm.Format != 2)
return StaticGSC;
else
{
if (pkm.HasOriginalMetLocation)
return StaticC;
else if (pkm.Species > 151 && !FutureEvolutionsGen1.Contains(pkm.Species))
return StaticGS;
else
return StaticGSC;
}
}
private static IEnumerable<EncounterArea> getSlots(PKM pkm, IEnumerable<EncounterArea> tables, int lvl = -1)
{
IEnumerable<DexLevel> vs = getValidPreEvolutions(pkm, lvl);

View File

@@ -52,30 +52,43 @@ public static partial class Legal
{
424,429,430,461,462,463,464,465,466,467,468,469,470,471,472,473,474,700
};
internal static readonly EncounterStatic[] Encounter_GSC =
internal static readonly EncounterStatic[] Encounter_GSC_Common =
{
new EncounterStatic { Species = 152, Level = 05, Version = GameVersion.GSC }, // Chikorita @ New Bark Town
new EncounterStatic { Species = 155, Level = 05, Version = GameVersion.GSC }, // Cyndaquil @ New Bark Town
new EncounterStatic { Species = 158, Level = 05, Version = GameVersion.GSC }, // Totodile @ New Bark Town
new EncounterStatic { Species = 152, Level = 05, Location = 001, Version = GameVersion.GSC }, // Chikorita @ New Bark Town
new EncounterStatic { Species = 155, Level = 05, Location = 001, Version = GameVersion.GSC }, // Cyndaquil @ New Bark Town
new EncounterStatic { Species = 158, Level = 05, Location = 001, Version = GameVersion.GSC }, // Totodile @ New Bark Town
new EncounterStatic { Species = 175, Level = 05, Version = GameVersion.GSC }, // Togepi
new EncounterStatic { Species = 131, Level = 20, Version = GameVersion.GSC }, // Lapras @ Union Cave
new EncounterStatic { Species = 133, Level = 20, Version = GameVersion.GSC }, // Eevee @ Goldenrod City
new EncounterStatic { Species = 131, Level = 20, Location = 010, Version = GameVersion.GSC }, // Lapras @ Union Cave
new EncounterStatic { Species = 133, Level = 20, Location = 016, Version = GameVersion.GSC }, // Eevee @ Goldenrod City
new EncounterStatic { Species = 185, Level = 20, Version = GameVersion.GSC }, // Sudowoodo @ Route 36
new EncounterStatic { Species = 213, Level = 15, Version = GameVersion.GSC }, // Shuckle @ Cianwood City
new EncounterStatic { Species = 236, Level = 10, Version = GameVersion.GSC }, // Tyrogue @ Mt. Mortar
new EncounterStatic { Species = 185, Level = 20, Location = 020, Version = GameVersion.GSC }, // Sudowoodo @ Route 36
new EncounterStatic { Species = 213, Level = 15, Location = 033, Version = GameVersion.GSC }, // Shuckle @ Cianwood City
new EncounterStatic { Species = 236, Level = 10, Location = 035, Version = GameVersion.GSC }, // Tyrogue @ Mt. Mortar
new EncounterStatic { Species = 130, Level = 30, Version = GameVersion.GSC, Shiny = true, }, // Gyarados @ Lake of Rage
new EncounterStatic { Species = 074, Level = 21, Version = GameVersion.GSC }, // Geodude @ Rocket Hideout
new EncounterStatic { Species = 109, Level = 21, Version = GameVersion.GSC }, // Koffing @ Rocket Hideout
new EncounterStatic { Species = 100, Level = 23, Version = GameVersion.GSC }, // Voltorb @ Rocket Hideout
new EncounterStatic { Species = 101, Level = 23, Version = GameVersion.GSC }, // Electrode @ Rocket Hideout
new EncounterStatic { Species = 143, Level = 50, Version = GameVersion.GSC }, // Snorlax @ Vermillion City
new EncounterStatic { Species = 243, Level = 40, Version = GameVersion.GSC }, // Raikou
new EncounterStatic { Species = 244, Level = 40, Version = GameVersion.GSC }, // Entei
new EncounterStatic { Species = 130, Level = 30, Location = 038, Version = GameVersion.GSC, Shiny = true, }, // Gyarados @ Lake of Rage
new EncounterStatic { Species = 074, Level = 21, Location = 036, Version = GameVersion.GSC }, // Geodude @ Rocket Hideout (Mahogany Town)
new EncounterStatic { Species = 109, Level = 21, Location = 036, Version = GameVersion.GSC }, // Koffing @ Rocket Hideout (Mahogany Town)
new EncounterStatic { Species = 100, Level = 23, Location = 036, Version = GameVersion.GSC }, // Voltorb @ Rocket Hideout (Mahogany Town)
new EncounterStatic { Species = 101, Level = 23, Location = 036, Version = GameVersion.GSC }, // Electrode @ Rocket Hideout (Mahogany Town)
new EncounterStatic { Species = 143, Level = 50, Location = 061, Version = GameVersion.GSC }, // Snorlax @ Vermillion City
};
internal static readonly EncounterStatic[] Encounter_GS_Exclusive =
{
new EncounterStatic { Species = 245, Level = 40, Version = GameVersion.GS }, // Suicune
new EncounterStatic { Species = 245, Level = 40, Version = GameVersion.C }, // Suicune @ Tin Tower
new EncounterStatic { Species = 249, Level = 70, Version = GameVersion.GD }, // Lugia @ Whirl Islands
new EncounterStatic { Species = 249, Level = 40, Version = GameVersion.SV }, // Lugia @ Whirl Islands
new EncounterStatic { Species = 250, Level = 40, Version = GameVersion.GD }, // Ho-Oh @ Tin Tower
new EncounterStatic { Species = 250, Level = 70, Version = GameVersion.SV }, // Ho-Oh @ Tin Tower
};
internal static readonly EncounterStatic[] Encounter_C_Exclusive =
{
new EncounterStatic { Species = 245, Level = 40, Location = 023, Version = GameVersion.C }, // Suicune @ Tin Tower
new EncounterStatic { Species = 172, Level = 05, Version = GameVersion.C, Moves = new [] {146} }, // Pichu Dizzy Punch
new EncounterStatic { Species = 173, Level = 05, Version = GameVersion.C, Moves = new [] {146} }, // Cleffa Dizzy Punch
@@ -85,18 +98,17 @@ public static partial class Legal
new EncounterStatic { Species = 239, Level = 05, Version = GameVersion.C, Moves = new [] {146} }, // Elekid Dizzy Punch
new EncounterStatic { Species = 240, Level = 05, Version = GameVersion.C, Moves = new [] {146} }, // Magby Dizzy Punch
new EncounterStatic { Species = 147, Level = 40, Version = GameVersion.C, Moves = new [] {245} }, // Dratini ExtremeSpeed
new EncounterStatic { Species = 249, Level = 70, Version = GameVersion.GD }, // Lugia @ Whirl Islands
new EncounterStatic { Species = 249, Level = 40, Version = GameVersion.SV }, // Lugia @ Whirl Islands
new EncounterStatic { Species = 249, Level = 60, Version = GameVersion.C }, // Lugia @ Whirl Islands
new EncounterStatic { Species = 147, Level = 40, Location = 042, Version = GameVersion.C, Moves = new [] {245} }, // Dratini ExtremeSpeed
new EncounterStatic { Species = 250, Level = 40, Version = GameVersion.GD }, // Ho-Oh @ Tin Tower
new EncounterStatic { Species = 250, Level = 70, Version = GameVersion.SV }, // Ho-Oh @ Tin Tower
new EncounterStatic { Species = 250, Level = 60, Version = GameVersion.C }, // Ho-Oh @ Tin Tower
new EncounterStatic { Species = 251, Level = 30, Version = GameVersion.SPECIAL }, // Celebi @ Ilex Forest
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.SPECIAL }, // Celebi @ Ilex Forest
};
internal static readonly EncounterStatic[] Encounter_GS = Encounter_GSC_Common.Concat(Encounter_GS_Exclusive).ToArray();
internal static readonly EncounterStatic[] Encounter_C = Encounter_GSC_Common.Concat(Encounter_C_Exclusive).ToArray();
internal static readonly EncounterStatic[] Encounter_GSC = Encounter_GSC_Common.Concat(Encounter_GS_Exclusive).Concat(Encounter_C_Exclusive).ToArray();
internal static readonly EncounterTrade[] TradeGift_GSC =
{
new EncounterTrade { Species = 095, Level = 03, Gender = 0, Location = 06, TID = 48926, IVs = new[] {08, 09, 06, 06, 06} }, // Onix @ Violet City for Bellsprout [wild]

View File

@@ -278,8 +278,8 @@ public override int Gender
}
set { }
}
public bool hasMetData => CaughtData != 0;
public override bool HasOriginalMetLocation => CaughtData != 0;
#region Future, Unused Attributes
public override uint EncryptionConstant { get { return 0; } set { } }

View File

@@ -506,7 +506,7 @@ public bool InhabitedGeneration(int Generation, int species = -1)
/// Checks if the PKM has its original met location.
/// </summary>
/// <returns>Returns false if the Met Location has been overwritten via generational transfer.</returns>
public bool HasOriginalMetLocation => !(Format < 3 || VC || GenNumber <= 4 && Format != GenNumber);
public virtual bool HasOriginalMetLocation => !(Format < 3 || VC || GenNumber <= 4 && Format != GenNumber);
/// <summary>
/// Checks if the current <see cref="Gender"/> is valid.