diff --git a/PKHeX/Legality/Core.cs b/PKHeX/Legality/Core.cs index c18170507..d28952dcd 100644 --- a/PKHeX/Legality/Core.cs +++ b/PKHeX/Legality/Core.cs @@ -167,7 +167,10 @@ namespace PKHeX.Core { Evolves2 = new EvolutionTree(new[] { Resources.evos_gsc }, GameVersion.GSC, PersonalTable.C, MaxSpeciesID_2); - SlotsGSC = new EncounterArea[0]; // todo + var g = EncounterArea.getArray2_GW(Resources.encounter_gold); + var s = EncounterArea.getArray2_GW(Resources.encounter_silver); + var c = EncounterArea.getArray2_GW(Resources.encounter_crystal); + SlotsGSC = addExtraTableSlots(addExtraTableSlots(g, s), c); StaticGSC = getStaticEncounters(GameVersion.GSC); } @@ -1206,7 +1209,11 @@ namespace PKHeX.Core // Pressure Slot EncounterSlot slotMax = encounterSlots.OrderByDescending(slot => slot.LevelMax).FirstOrDefault(); if (slotMax != null) - slotMax = new EncounterSlot(slotMax) { Pressure = true, Form = pkm.AltForm }; + { + slotMax = slotMax.Clone(); + slotMax.Pressure = true; + slotMax.Form = pkm.AltForm; + }; if (gen >= 6 && !DexNav) { @@ -1230,7 +1237,8 @@ namespace PKHeX.Core foreach (EncounterSlot s in eslots) { bool nav = s.AllowDexNav && (pkm.RelearnMove1 != 0 || pkm.AbilityNumber == 4); - EncounterSlot slot = new EncounterSlot(s) { DexNav = nav }; + EncounterSlot slot = s.Clone(); + slot.DexNav = nav; if (slot.LevelMin > lvl) slot.WhiteFlute = true; diff --git a/PKHeX/Legality/Structures/EncounterArea.cs b/PKHeX/Legality/Structures/EncounterArea.cs index 5c7a333ed..bc6444d57 100644 --- a/PKHeX/Legality/Structures/EncounterArea.cs +++ b/PKHeX/Legality/Structures/EncounterArea.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Linq; namespace PKHeX.Core @@ -36,6 +37,40 @@ namespace PKHeX.Core int count = data[ofs++]; return readSlots(data, ref ofs, count, SlotType.Super_Rod, -1); } + + private static EncounterSlot1[] getSlots2_GW(byte[] data, ref int ofs, SlotType t, int slotSets, int slotCount) + { + byte[] rates = new byte[slotSets]; + for (int i = 0; i < rates.Length; i++) + rates[i] = data[ofs++]; + + var slots = readSlots(data, ref ofs, slotSets * slotCount, t, rates[0]); + for (int r = 1; r < slotSets; r++) + { + for (int i = 0; i < slotCount; i++) + { + int index = i + r*slotCount; + slots[index].Rate = rates[r]; + slots[index].SlotNumber = i; + } + } + + return slots; + } + + private static IEnumerable getAreas2(byte[] data, ref int ofs, SlotType t, int slotSets, int slotCount) + { + var areas = new List(); + while (data[ofs] != 0xFF) // end + { + areas.Add(new EncounterArea + { + Location = data[ofs++] << 8 | data[ofs++], + Slots = getSlots2_GW(data, ref ofs, t, slotSets, slotCount), + }); + } + return areas; + } /// /// RBY Format Slot Getter from data. @@ -61,10 +96,17 @@ namespace PKHeX.Core Species = spec, Type = t, Rate = rate, + SlotNumber = i, }; } return slots; } + + /// + /// Gets the encounter areas with information from Generation 1 Grass/Water data. + /// + /// Input raw data. + /// Array of encounter areas. public static EncounterArea[] getArray1_GW(byte[] data) { // RBY Format @@ -93,6 +135,11 @@ namespace PKHeX.Core } return areas.Where(area => area.Slots.Any()).ToArray(); } + /// + /// Gets the encounter areas with information from Pokémon Yellow (Generation 1) Fishing data. + /// + /// Input raw data. + /// Array of encounter areas. public static EncounterArea[] getArray1_FY(byte[] data) { const int size = 9; @@ -109,6 +156,11 @@ namespace PKHeX.Core } return areas; } + /// + /// Gets the encounter areas with information from Generation 1 Fishing data. + /// + /// Input raw data. + /// Array of encounter areas. public static EncounterArea[] getArray1_F(byte[] data) { var ptr = new int[255]; @@ -136,6 +188,25 @@ namespace PKHeX.Core } return areas; } + + /// + /// Gets the encounter areas with information from Generation 2 Grass/Water data. + /// + /// Input raw data. + /// Array of encounter areas. + public static EncounterArea[] getArray2_GW(byte[] data) + { + int ofs = 0; + var areas = new List(); + areas.AddRange(getAreas2(data, ref ofs, SlotType.Grass, 3, 7)); // Johto Grass + areas.AddRange(getAreas2(data, ref ofs, SlotType.Surf, 1, 3)); // Johto Water + areas.AddRange(getAreas2(data, ref ofs, SlotType.Grass, 3, 7)); // Kanto Grass + areas.AddRange(getAreas2(data, ref ofs, SlotType.Surf, 1, 3)); // Kanto Water + areas.AddRange(getAreas2(data, ref ofs, SlotType.Swarm, 3, 7)); // Swarm + areas.AddRange(getAreas2(data, ref ofs, SlotType.Special, 1, 3)); // Union Cave + return areas.ToArray(); + } + public static EncounterArea[] getArray(byte[][] entries) { if (entries == null) diff --git a/PKHeX/Legality/Structures/EncounterSlot.cs b/PKHeX/Legality/Structures/EncounterSlot.cs index 615b08197..7765997fa 100644 --- a/PKHeX/Legality/Structures/EncounterSlot.cs +++ b/PKHeX/Legality/Structures/EncounterSlot.cs @@ -13,16 +13,20 @@ public bool WhiteFlute; public bool BlackFlute; public bool Normal => !(WhiteFlute || BlackFlute || DexNav); + public int SlotNumber; public EncounterSlot() { } - - public EncounterSlot(EncounterSlot template) + public virtual EncounterSlot Clone() { - Species = template.Species; - AllowDexNav = template.AllowDexNav; - LevelMax = template.LevelMax; - LevelMin = template.LevelMin; - Type = template.Type; - Pressure = template.Pressure; + return new EncounterSlot + { + Species = Species, + AllowDexNav = AllowDexNav, + LevelMax = LevelMax, + LevelMin = LevelMin, + Type = Type, + Pressure = Pressure, + SlotNumber = SlotNumber, + }; } public string Name @@ -40,13 +44,17 @@ { public int Rate; public EncounterSlot1() { } - public EncounterSlot1(EncounterSlot1 template) + public override EncounterSlot Clone() { - Species = template.Species; - LevelMax = template.LevelMax; - LevelMin = template.LevelMin; - Type = template.Type; - Rate = template.Rate; + return new EncounterSlot1 + { + Species = Species, + LevelMax = LevelMax, + LevelMin = LevelMin, + Type = Type, + Rate = Rate, + SlotNumber = SlotNumber, + }; } } } diff --git a/PKHeX/Legality/Structures/SlotType.cs b/PKHeX/Legality/Structures/SlotType.cs index 67c0ad50d..e076f725b 100644 --- a/PKHeX/Legality/Structures/SlotType.cs +++ b/PKHeX/Legality/Structures/SlotType.cs @@ -17,5 +17,6 @@ FriendSafari, Special, SOS, + Swarm, } } diff --git a/PKHeX/PKHeX.Core.csproj b/PKHeX/PKHeX.Core.csproj index a1c307766..8ce8ff0af 100644 --- a/PKHeX/PKHeX.Core.csproj +++ b/PKHeX/PKHeX.Core.csproj @@ -262,10 +262,13 @@ + + + diff --git a/PKHeX/Properties/Resources.Designer.cs b/PKHeX/Properties/Resources.Designer.cs index 75ac26f36..17958eb80 100644 --- a/PKHeX/Properties/Resources.Designer.cs +++ b/PKHeX/Properties/Resources.Designer.cs @@ -12472,6 +12472,26 @@ namespace PKHeX.Core.Properties { } } + /// + /// Looks up a localized resource of type System.Byte[]. + /// + public static byte[] encounter_crystal { + get { + object obj = ResourceManager.GetObject("encounter_crystal", resourceCulture); + return ((byte[])(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Byte[]. + /// + public static byte[] encounter_gold { + get { + object obj = ResourceManager.GetObject("encounter_gold", resourceCulture); + return ((byte[])(obj)); + } + } + /// /// Looks up a localized resource of type System.Byte[]. /// @@ -12522,6 +12542,16 @@ namespace PKHeX.Core.Properties { } } + /// + /// Looks up a localized resource of type System.Byte[]. + /// + public static byte[] encounter_silver { + get { + object obj = ResourceManager.GetObject("encounter_silver", resourceCulture); + return ((byte[])(obj)); + } + } + /// /// Looks up a localized resource of type System.Byte[]. /// diff --git a/PKHeX/Properties/Resources.resx b/PKHeX/Properties/Resources.resx index 77081cc35..8cc734d3d 100644 --- a/PKHeX/Properties/Resources.resx +++ b/PKHeX/Properties/Resources.resx @@ -7420,4 +7420,13 @@ ..\Resources\byte\lvlmove_gs.pkl;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + ..\Resources\byte\encounter_crystal.pkl;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + ..\Resources\byte\encounter_gold.pkl;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + ..\Resources\byte\encounter_silver.pkl;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + \ No newline at end of file diff --git a/PKHeX/Resources/byte/encounter_crystal.pkl b/PKHeX/Resources/byte/encounter_crystal.pkl new file mode 100644 index 000000000..4ceebc4fe --- /dev/null +++ b/PKHeX/Resources/byte/encounter_crystal.pkl @@ -0,0 +1,165 @@ +\\\\\\\\\\\\\\\\\\\\ \\\ +\\\ \\\ \\\ + + + m) m) m)mm) mmnmm) mmnmm) mmn   + + + +    + + + + 6  +0 0 0 + + +%J))__J))__J)__&J))_J))_J)_' + + +)*)J__)*)J__)*J__()))O)OO)))O)OO)))O)OO))))O*OO)))O*OO)))O*OO4 + + + +  .. +  ..+0+6..9 )B *J )B *J ) *J: JB)** JB)** J)**;K CJB**K CJB**KJ* * *<))*BJ))*BJ))*J=)****)****)****>)***|)***|)***?)**||)**||)**@)**||)**||)**A)*|||)*|||)*Bb)Vb*VVb)Vb*VVb)bb***Cb)Vb*VVb)Vb*VVb)bb***Db)Vb*VVb)Vb*VVb)bb***Eb)Vb*VVb)Vb*VVb)bb***Fb)Vb*VVb)Vb*VVb)bb***Gb)Vb*VVb)Vb*VVb)bb***Hb)Vb*VVb)Vb*VVb)bb***Ib)Vb*VVb)Vb*VVb)bb***J+K,*_-~-*+K,*_-~-*+K,**_**-7.*.*K0*0C/./0/0*0C/./0/0*07.*./0/--L3*0_0K23*0_0K23*0_0K1*-75*5*M0*.*2*./0/2/4/0*.*2*./0/2/4/-0*2*./0/2/4/N + + +J)JJ)J)JJ))J)JJ))O + + +J)K**J)K**J)K** + +  + + <) +E  +E <E)\\ +EEE)\\JJ)J)  +   +? ' + + +   +? ' + + `  +? ' + + +  : +? ' +  : +? ' + ` 6 +? ' + +E:E:E\\ + :: ::  Q Q 4Q444 QQ4Q444   )*** SS0011rlEFlllrlEFlllr<EF===JKJKJKKKKK JJJJJJ)r*M*,N)T+U+U)r*M*,N)T+U+U)r*=**,=(*,*,*%&' +HI(OO +O)OOP46 +679 +vw;vw<vwD +HtIH +ttII +tIuK#w#7#vN +O +Q + + +HHI<<=<<= +HI HHI + +667HHIHI +vvw  +<<=HHIHHI +<<=HHIHHI <<=  + + + +#=(=#<T +22 223332222333222 2 3 3 3U)J . +J##)J . +J##)J# . +J # #W +h J B )C i i +h J B )C i i ) J J])))X hJ_ )iss hJ_ )iss )J_)]**["K o!_"*##p#p"K o!_"*##p#p"*"K _$K&K(K(KS)*OOO)*OOO)*OOO  +  +  + + + + + + + + + +)##  + + + + + + + + + +)##   ?'??   ?'?? 4 ?'??   Q '  Q ' 4 `Q6 ''??'??45'???:'@@?:'@@4?]'@@ iiii01)di}}di}}0d1)}}  Q Q` 4Qaa!q!q01q!q!q01q!q!q01qXXYYXXYYXXXYYXX !X!Y!YX  !Y!YXXX X!X!Y!YXXYYXXYYXXXXXYYr#rzzzr#rzzzr#rrrrTMTM<< + + + ? +E   + + + ? +E  +0 ++ + ? +E,, + + +  +E  + + +  +E  ++ + +0 +ET MTT MT TT MUUTT MUU 'r(M(N*)T+U+U'r(M(N*)T+U+U'r(=(*(=******S +vOw#HH#I + +vv +w  +66 +7 +v +vw +v +vwHIHI#HH#I#HH#I#HH#I +<< += + +vv +w + +vv +wHHIHHI(<#<(= #HH#I +<< += + +vv +w #HH#IXXY +#HH#IN + + +J)JJ)JJ)J +   + +   + +   + + \ No newline at end of file diff --git a/PKHeX/Resources/byte/encounter_gold.pkl b/PKHeX/Resources/byte/encounter_gold.pkl new file mode 100644 index 000000000..c92b618ee --- /dev/null +++ b/PKHeX/Resources/byte/encounter_gold.pkl @@ -0,0 +1,163 @@ +\\\\\\\\\\\\\\\\\\\\ \\\ +\\\ \\\ \\\ + + + m)m m)m m)mmm)~~mm~)mm)~~ + + + +  + + + +   + + + + + +J))__J))__J))__J)_ )J)_ )J)_ ) + + +)*J__)*J__)*J__ )))O)OO)))O)OO)))O)OO!)))O*OO)))O*OO)))O*OO, + + + +  +.).. + +  )..++).)..1 ))BJ ))BJ ))BJ2 J BJB)) J BJB)) J BJB))3K CJB**K CJB**K CJB**4))BJ))BJ))BJ5*))||*)|||*))||6*))||*)|||*))||7*))||*)|||*))||8*))||*)|||*))||9*))||*)|||*))||:b)bV*VVb)bV*VVb)bV*VV;b)bV*VVb)bV*VVb)bV*VV<b)bV*VVb)bV*VVb)bV*VV=b)bV*VVb)bV*VVb)bV*VV>b)bV*VVb)bV*VVb)bV*VV?b)bV*VVb)bV*VVb)bV*VV@b)bV*VVb)bV*VVb)bV*VVAb)bV*VVb)bV*VVb)bV*VVB*_,+K+K-**_,+K+K-**_,+K+K-*C-07/-0*-07/-0*-07/-0*D3*0_0*2373*0_0*2373*0_0*237E-07/-0*-07/-0*-07/-0*F + + +J)JJ))J)JJ))J)JJ))G + + +J)K**J)K**J)K** + +  +  +   +E  +   +E  +  E +E)EE))))))))  +`  ` +?  + + +`  ` +?  + + +`  ` +?  + + + ` +? + ` +? + ` +? + +   :   : ::  :  + : ::: : QS QS Q  QSQSQ8 8 8 )) 0000rFElFllrFElFllrFElFllJKKKKJKKKKJKKKK JJ''JJ''JJJ'')r*M*,N)T+U+U)r*M*,N)T+U+U)r*M*,N&** +HI OO +O! +OOP,6 +671 +vvw3vvw4vvw< +HtI@ +ttIA +tIuC#w(w#vF +G +I + + +<<=<<= +HI HHI + +667HHIHI +vvw  +<<=HHIHHI +<<=HHIHHI <<=  + + + + +#=(=#<HHIK +222 2333222 2333222 2333L)J . +##)J . +##)J . +##N +h +J B)C h h +h +J B)C h h +h +J B)C h hO h J_ +)iss h J_ +)iss h J_ +)issR K *!"_$_#o#o K *!"_$_#o#o K *!"_$_#o#oJ + + +)*OOO)*OOO)*OOO  +   + ' +' +)' + ' +' +)' +  E ???  E ??? ++ E, ???   EQ ???  EQ ??? ++ EQ ???:::::?:@@?:@@]?:@@  8 99 8 99 8 99d}}d}}}d}} `Q`aaa`Q`aaa`Q`aaa!q!q!q!q!q!q!q!q!qXXYYXXYYXXXYYXX Y YX Y YXXXY Y YXXYYXXYYXXXYYYrr#rrrzzrr#rrzzzrr#rrrzzTMTMME +E ? F0FFE + ? F +EFF0 ++ ? F +E +1 +1 +E0 ? +FF +E + ? FF0 ++ +1 ?F +E +ET MTUT MTUU M TT MTT M M'r(M(*N)T+U+U'r(M(*N)T+U+U'r(M((*N*N*N + +vv +w  +66 +7 +v +vw +v +vwHIHI#HH#I#HH#I#HH#I +<< += + +vv +w + +vv +wHHIHHIJ +vOw(<#<(= #HH#I +<< += + +vv +w #HH#IXXY +#HH#I#HH#I +   + +   + +   + + QS QS Q F + + +J)JJ)JJ)J1 )BJ )BJ )BJ1 +vw \ No newline at end of file diff --git a/PKHeX/Resources/byte/encounter_silver.pkl b/PKHeX/Resources/byte/encounter_silver.pkl new file mode 100644 index 000000000..b80de3d7f --- /dev/null +++ b/PKHeX/Resources/byte/encounter_silver.pkl @@ -0,0 +1,141 @@ +\\\\\\\\\\\\\\\\\\\\ \\\ +\\\ \\\ \\\ + + + m)m m)m m)mmm)~~mm~)mm)~~ + +  + + +   + + + + + +J))__J))__J))__J)_ )J)_ )J)_ ) + + +)*J__)*J__)*J__ )))O)OO)))O)OO)))O)OO!)))O*OO)))O*OO)))O*OO, + + +  .)..  )..++).)..1 ))BJ ))BJ ))BJ2 J BJB)) J BJB)) J BJB))3K CJB**K CJB**K CJB**4))BJ))BJ))BJ5*)||*|||*)||6*)||*|||*)||7*)||*|||*)||8*)||*|||*)||9*)||*|||*)||:b)bV*VVb)bV*VVb)bV*VV;b)bV*VVb)bV*VVb)bV*VV<b)bV*VVb)bV*VVb)bV*VV=b)bV*VVb)bV*VVb)bV*VV>b)bV*VVb)bV*VVb)bV*VV?b)bV*VVb)bV*VVb)bV*VV@b)bV*VVb)bV*VVb)bV*VVAb)bV*VVb)bV*VVb)bV*VVB*_,+K+K-**_,+K+K-**_,+K+K-*C-07/-0*-07/-0*-07/-0*D3*0_0*2373*0_0*2373*0_0*237E-07/-0*-07/-0*-07/-0*F + + +J)JJ))J)JJ))J)JJ))G + + +J)K**J)K**J)K**     E E E +E)EE))))))))  +`  ` +?  + + +`  ` +?  + + +`  ` +?  + + +  ` +? +  ` +? +  ` +? + +   %    % %%  %  + % %%% % 4QS 4QS 4Q4  4QS4QS4Q4   )) 0000rFElFllrFElFllrFElFllJKKKJKKKJKKK JJ''JJ''JJJ'')r*M*,N)T+U+U)r*M*,N)T+U+U)r*M*,N&** +HI OO +O!OOP,6 +671 +vvw3vvw4vvw< +HtI@ +ttIA +tIuC#w(w#vF +G +I + + +<<=<<= +HI HHI + +667HHIHIH +vvw  +<<=HHIHHI +<<=HHIHHI <<=  + + + +#=(=#<HHIK +222 2333222 2333222 2333L)J) . +J##)J) . +J##)J) . +J##N +h +J B)C h h +h +J B)C h h +h +J B)C h hO h J_ +)iss h J_ +)iss h J_ +)issR K *!"_$_#o#o K *!"_$_#o#o K *!"_$_#o#oJ)*OOO)*OOO)*OOO   ' +' +)' + ' +' +)' +  E4 ???  E4 ??? +4 E, ???   E4Q ???  E4Q ??? +4 EQ ???4%54%5%%4%54?%@@4?%@@4]?%@@       d}}d}}}d}} `Q`aaa`Q`aaa`Q`aaa!q!q!q!q!q!q!q!q!qXXYYXXYYXXXYYXX Y YX Y YXXXY Y YXXYYXXYYXXXYYYrr#rrrzzrr#rrzzzrr#rrrzzTMTMME +E ? F0FFE + ? F +EFF0 ++ ? F +E +1 +1 +E0 ? +FF +E + ? FF0 ++ +1 ?F +E +ET MTT MT MTT MUUTT MUU M 'r(M(*N)T+U+U'r(M(*N)T+U+U'r(M((*N*N*N + +vv +w  +66 +7 +v +vw +v +vwHIHI#HH#I#HH#I#HH#I +<< += + +vv +w + +vv +wHHIHHIJ +vOw(<#<(= #HH#I +<< += + +vv +w #HH#IXXY +#HH#I#HH#I +   + +   + +   + + 4QS 4QS 4Q4 F + + +J)JJ)JJ)J1 )BJ )BJ )BJ1 +vw \ No newline at end of file