Add gsc headbutt/rock smash slots

tad bit of rearranging
This commit is contained in:
Kurt 2017-03-02 18:24:50 -08:00
parent e29f7ebd5a
commit 80013b0367
9 changed files with 145 additions and 8 deletions

View File

@ -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
{

View File

@ -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<EncounterSlot1>();
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<EncounterArea> getAreas2(byte[] data, ref int ofs, SlotType t, int slotSets, int slotCount)
{
@ -96,7 +124,7 @@ private static IEnumerable<EncounterArea> getAreas2(byte[] data, ref int ofs, Sl
}
return areas;
}
private static IEnumerable<EncounterArea> getAreas2_F(byte[] data, ref int ofs, SlotType t)
private static IEnumerable<EncounterArea> getAreas2_F(byte[] data, ref int ofs)
{
var areas = new List<EncounterArea>();
var types = new[] {SlotType.Old_Rod, SlotType.Good_Rod, SlotType.Super_Rod};
@ -143,6 +171,57 @@ private static IEnumerable<EncounterArea> getAreas2_F(byte[] data, ref int ofs,
}
return areas;
}
private static IEnumerable<EncounterArea> getAreas2_H(byte[] data, ref int ofs)
{
// Read Location Table
var head = new List<EncounterArea>();
var headID = new List<int>();
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<EncounterArea>();
var rockID = new List<int>();
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);
}
/// <summary>
/// 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)

View File

@ -18,5 +18,6 @@ public enum SlotType
Special,
SOS,
Swarm,
Headbutt,
}
}

View File

@ -265,13 +265,16 @@
<None Include="Resources\byte\eggmove_sm.pkl" />
<None Include="Resources\byte\encounter_blue.pkl" />
<None Include="Resources\byte\encounter_crystal.pkl" />
<None Include="Resources\byte\encounter_crystal_h.pkl" />
<None Include="Resources\byte\encounter_gold.pkl" />
<None Include="Resources\byte\encounter_gold_h.pkl" />
<None Include="Resources\byte\encounter_gsc_f.pkl" />
<None Include="Resources\byte\encounter_mn.pkl" />
<None Include="Resources\byte\encounter_mn_sos.pkl" />
<None Include="Resources\byte\encounter_rb_f.pkl" />
<None Include="Resources\byte\encounter_red.pkl" />
<None Include="Resources\byte\encounter_silver.pkl" />
<None Include="Resources\byte\encounter_silver_h.pkl" />
<None Include="Resources\byte\encounter_sn.pkl" />
<None Include="Resources\byte\encounter_sn_sos.pkl" />
<None Include="Resources\byte\encounter_yellow.pkl" />

View File

@ -12502,6 +12502,16 @@ public class Resources {
}
}
/// <summary>
/// Looks up a localized resource of type System.Byte[].
/// </summary>
public static byte[] encounter_crystal_h {
get {
object obj = ResourceManager.GetObject("encounter_crystal_h", resourceCulture);
return ((byte[])(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Byte[].
/// </summary>
@ -12512,6 +12522,16 @@ public class Resources {
}
}
/// <summary>
/// Looks up a localized resource of type System.Byte[].
/// </summary>
public static byte[] encounter_gold_h {
get {
object obj = ResourceManager.GetObject("encounter_gold_h", resourceCulture);
return ((byte[])(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Byte[].
/// </summary>
@ -12582,6 +12602,16 @@ public class Resources {
}
}
/// <summary>
/// Looks up a localized resource of type System.Byte[].
/// </summary>
public static byte[] encounter_silver_h {
get {
object obj = ResourceManager.GetObject("encounter_silver_h", resourceCulture);
return ((byte[])(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Byte[].
/// </summary>

View File

@ -7438,4 +7438,13 @@
<data name="eggmove_gs" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\byte\eggmove_gs.pkl;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="encounter_crystal_h" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\byte\encounter_crystal_h.pkl;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="encounter_gold_h" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\byte\encounter_gold_h.pkl;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="encounter_silver_h" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\byte\encounter_silver_h.pkl;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
</root>

Binary file not shown.

Binary file not shown.

Binary file not shown.