From 80013b0367199a89c5f43982d4f899b04cb213d3 Mon Sep 17 00:00:00 2001 From: Kurt Date: Thu, 2 Mar 2017 18:24:50 -0800 Subject: [PATCH] Add gsc headbutt/rock smash slots tad bit of rearranging --- PKHeX/Legality/Core.cs | 22 +++-- PKHeX/Legality/Structures/EncounterArea.cs | 88 ++++++++++++++++++- PKHeX/Legality/Structures/SlotType.cs | 1 + PKHeX/PKHeX.Core.csproj | 3 + PKHeX/Properties/Resources.Designer.cs | 30 +++++++ PKHeX/Properties/Resources.resx | 9 ++ PKHeX/Resources/byte/encounter_crystal_h.pkl | Bin 0 -> 391 bytes PKHeX/Resources/byte/encounter_gold_h.pkl | Bin 0 -> 265 bytes PKHeX/Resources/byte/encounter_silver_h.pkl | Bin 0 -> 265 bytes 9 files changed, 145 insertions(+), 8 deletions(-) create mode 100644 PKHeX/Resources/byte/encounter_crystal_h.pkl create mode 100644 PKHeX/Resources/byte/encounter_gold_h.pkl create mode 100644 PKHeX/Resources/byte/encounter_silver_h.pkl diff --git a/PKHeX/Legality/Core.cs b/PKHeX/Legality/Core.cs index f6a08b9c9..0ad400761 100644 --- a/PKHeX/Legality/Core.cs +++ b/PKHeX/Legality/Core.cs @@ -149,7 +149,8 @@ private static void MarkG7SMSlots(ref EncounterArea[] Areas) { // Gen 1 { - Evolves1 = new EvolutionTree(new[] { Resources.evos_rby }, GameVersion.RBY, PersonalTable.Y, MaxSpeciesID_1); + StaticRBY = getStaticEncounters(GameVersion.RBY); + var red = EncounterArea.getArray1_GW(Resources.encounter_red); var blu = EncounterArea.getArray1_GW(Resources.encounter_blue); var ylw = EncounterArea.getArray1_GW(Resources.encounter_yellow); @@ -163,19 +164,28 @@ private static void MarkG7SMSlots(ref EncounterArea[] Areas) SlotsRBY = addExtraTableSlots(addExtraTableSlots(red, blu), ylw); Array.Resize(ref SlotsRBY, SlotsRBY.Length + 1); SlotsRBY[SlotsRBY.Length - 1] = FishOldGood_RBY; - StaticRBY = getStaticEncounters(GameVersion.RBY); + + Evolves1 = new EvolutionTree(new[] { Resources.evos_rby }, GameVersion.RBY, PersonalTable.Y, MaxSpeciesID_1); } // Gen 2 { - Evolves2 = new EvolutionTree(new[] { Resources.evos_gsc }, GameVersion.GSC, PersonalTable.C, MaxSpeciesID_2); + StaticGSC = getStaticEncounters(GameVersion.GSC); + // 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); + // Fishing var f = EncounterArea.getArray2_F(Resources.encounter_gsc_f); - SlotsGSC = addExtraTableSlots(g, s).Concat(c).Concat(f).ToArray(); - - StaticGSC = getStaticEncounters(GameVersion.GSC); + // 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); + + SlotsGSC = addExtraTableSlots(g, s).Concat(c).Concat(f).Concat(h).ToArray(); + + Evolves2 = new EvolutionTree(new[] { Resources.evos_gsc }, GameVersion.GSC, PersonalTable.C, MaxSpeciesID_2); } // Gen 6 { diff --git a/PKHeX/Legality/Structures/EncounterArea.cs b/PKHeX/Legality/Structures/EncounterArea.cs index c0b552a7b..9fd58b873 100644 --- a/PKHeX/Legality/Structures/EncounterArea.cs +++ b/PKHeX/Legality/Structures/EncounterArea.cs @@ -82,6 +82,34 @@ private static EncounterSlot1[] getSlots2_F(byte[] data, ref int ofs, SlotType t } return slots.ToArray(); } + private static EncounterSlot1[] getSlots2_H(byte[] data, ref int ofs, SlotType t) + { + // slot set ends in 0xFF + var slots = new List(); + int tableCount = t == SlotType.Headbutt ? 2 : 1; + while (tableCount != 0) + { + int rate = data[ofs++]; + if (rate == 0xFF) // end of table + { + tableCount--; + continue; + } + + int species = data[ofs++]; + int level = data[ofs++]; + + slots.Add(new EncounterSlot1 + { + Rate = rate, + Species = species, + LevelMin = level, + LevelMax = level, + Type = t + }); + } + return slots.ToArray(); + } private static IEnumerable getAreas2(byte[] data, ref int ofs, SlotType t, int slotSets, int slotCount) { @@ -96,7 +124,7 @@ private static IEnumerable getAreas2(byte[] data, ref int ofs, Sl } return areas; } - private static IEnumerable getAreas2_F(byte[] data, ref int ofs, SlotType t) + private static IEnumerable getAreas2_F(byte[] data, ref int ofs) { var areas = new List(); var types = new[] {SlotType.Old_Rod, SlotType.Good_Rod, SlotType.Super_Rod}; @@ -143,6 +171,57 @@ private static IEnumerable getAreas2_F(byte[] data, ref int ofs, } return areas; } + private static IEnumerable getAreas2_H(byte[] data, ref int ofs) + { + // Read Location Table + var head = new List(); + var headID = new List(); + while (data[ofs] != 0xFF) + { + head.Add(new EncounterArea + { + Location = (data[ofs++] << 8) | data[ofs++], + Slots = null, // later + }); + headID.Add(data[ofs++]); + } + ofs++; + + var rock = new List(); + var rockID = new List(); + while (data[ofs] != 0xFF) + { + rock.Add(new EncounterArea + { + Location = (data[ofs++] << 8) | data[ofs++], + Slots = null, // later + }); + rockID.Add(data[ofs++]); + } + ofs++; + ofs += 0x16; // jump over GetTreeMons + + // Read ptr table + int[] ptr = new int[data.Length == 0x109 ? 6 : 9]; // GS : C + for (int i = 0; i < ptr.Length; i++) + ptr[i] = data[ofs++] | (data[ofs++] << 8); + + int baseOffset = ptr.Min() - ofs; + + // Read Tables + for (int i = 0; i < head.Count; i++) + { + int o = ptr[headID[i]] - baseOffset; + head[i].Slots = getSlots2_H(data, ref o, SlotType.Headbutt); + } + for (int i = 0; i < rock.Count; i++) + { + int o = ptr[rockID[i]] - baseOffset; + rock[i].Slots = getSlots2_H(data, ref o, SlotType.Rock_Smash); + } + + return head.Concat(rock); + } /// /// RBY Format Slot Getter from data. @@ -287,7 +366,12 @@ public static EncounterArea[] getArray2_GW(byte[] data) public static EncounterArea[] getArray2_F(byte[] data) { int ofs = 0; - return getAreas2_F(data, ref ofs, SlotType.Any).ToArray(); + return getAreas2_F(data, ref ofs).ToArray(); + } + public static EncounterArea[] getArray2_H(byte[] data) + { + int ofs = 0; + return getAreas2_H(data, ref ofs).ToArray(); } public static EncounterArea[] getArray(byte[][] entries) diff --git a/PKHeX/Legality/Structures/SlotType.cs b/PKHeX/Legality/Structures/SlotType.cs index e076f725b..e96316d77 100644 --- a/PKHeX/Legality/Structures/SlotType.cs +++ b/PKHeX/Legality/Structures/SlotType.cs @@ -18,5 +18,6 @@ public enum SlotType Special, SOS, Swarm, + Headbutt, } } diff --git a/PKHeX/PKHeX.Core.csproj b/PKHeX/PKHeX.Core.csproj index c9793f10c..2cbc189ee 100644 --- a/PKHeX/PKHeX.Core.csproj +++ b/PKHeX/PKHeX.Core.csproj @@ -265,13 +265,16 @@ + + + diff --git a/PKHeX/Properties/Resources.Designer.cs b/PKHeX/Properties/Resources.Designer.cs index 04c1abe16..f9f979fbb 100644 --- a/PKHeX/Properties/Resources.Designer.cs +++ b/PKHeX/Properties/Resources.Designer.cs @@ -12502,6 +12502,16 @@ public class Resources { } } + /// + /// Looks up a localized resource of type System.Byte[]. + /// + public static byte[] encounter_crystal_h { + get { + object obj = ResourceManager.GetObject("encounter_crystal_h", resourceCulture); + return ((byte[])(obj)); + } + } + /// /// Looks up a localized resource of type System.Byte[]. /// @@ -12512,6 +12522,16 @@ public class Resources { } } + /// + /// Looks up a localized resource of type System.Byte[]. + /// + public static byte[] encounter_gold_h { + get { + object obj = ResourceManager.GetObject("encounter_gold_h", resourceCulture); + return ((byte[])(obj)); + } + } + /// /// Looks up a localized resource of type System.Byte[]. /// @@ -12582,6 +12602,16 @@ public class Resources { } } + /// + /// Looks up a localized resource of type System.Byte[]. + /// + public static byte[] encounter_silver_h { + get { + object obj = ResourceManager.GetObject("encounter_silver_h", 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 9f4621852..c7dbc73fd 100644 --- a/PKHeX/Properties/Resources.resx +++ b/PKHeX/Properties/Resources.resx @@ -7438,4 +7438,13 @@ ..\Resources\byte\eggmove_gs.pkl;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + ..\Resources\byte\encounter_crystal_h.pkl;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + ..\Resources\byte\encounter_gold_h.pkl;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + ..\Resources\byte\encounter_silver_h.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_h.pkl b/PKHeX/Resources/byte/encounter_crystal_h.pkl new file mode 100644 index 0000000000000000000000000000000000000000..311dba042aa0788e624f702d6dda68016f8ae927 GIT binary patch literal 391 zcma)#u}Z{15Qb-VcCyKz%dK!2bE&jDtd2vtJ`0vUfQ?{rmEgPh3Q?}KwX#33)zaE$ zNa1>kRSpZ`D~6A6W-7Lou`{Mhq-Lp&fNh$XoCW(?1Xg$=Tu8}O8Zv4!RgYMqD%k)=n7|5P3d|7T0v(mLk|njG)@%#y#F=U}K@iu_ z;mj5JW1@8lHC@ojEm9B(5P1-}l=NHl^VjRyQ*c+ixLn?BwyVS2VIN=ONBoKVd_(Uq wdT;k$vpb*0UZ1v^&lz>% literal 0 HcmV?d00001 diff --git a/PKHeX/Resources/byte/encounter_silver_h.pkl b/PKHeX/Resources/byte/encounter_silver_h.pkl new file mode 100644 index 0000000000000000000000000000000000000000..07a7d561f3ea6b660c2130728dd262afc4b83e6e GIT binary patch literal 265 zcmYkyF;2rk5QX7+GakpD;7p{5mE!_IhY*Evlah`;Ee#S{rA-cyqtH`w0}8rGv~UJa z!Lm+6G+*;SO$)S)1*jG7z#X%JtCFXHF-%|ua0WC8puoh+wKA8i6>H6Hp`DPaRucrF zDHCQ?p?Dc6k=Gn|_W16|8A@}F#WI8uLvUk&?H01ss{ZEh2ZeO1M05P5`Qvd(} literal 0 HcmV?d00001