mirror of
https://github.com/kwsch/pkNX.git
synced 2026-09-08 02:25:15 -05:00
Update dumper, recognize NHO spawns
This commit is contained in:
@@ -21,46 +21,11 @@ public class NewHugeOutbreakGroupLotteryArchive8a : IFlatBufferArchive<NewHugeOu
|
||||
public bool IsAreaGroup(PlacementSpawner8a spawner, NewHugeOutbreakGroupArchive8a groups, ulong tableID)
|
||||
{
|
||||
var hash = spawner.Field_20_Value.EncounterTableID;
|
||||
foreach (var t in Table)
|
||||
{
|
||||
if (t.LotteryGroup != hash)
|
||||
continue;
|
||||
var group = Array.Find(Table, z => z.LotteryGroup == hash);
|
||||
if (group == null)
|
||||
return false;
|
||||
|
||||
foreach (var lotteryChoice in t.Table1)
|
||||
{
|
||||
var group = lotteryChoice.Group;
|
||||
var lottery = Array.Find(groups.Table, z => z.Group == group);
|
||||
if (lottery is null)
|
||||
continue;
|
||||
var tables = lottery.Table;
|
||||
var matches = Array.Find(tables, z => z.EncounterTableID == tableID);
|
||||
if (matches is not null)
|
||||
return true;
|
||||
}
|
||||
foreach (var lotteryChoice in t.Table2)
|
||||
{
|
||||
var group = lotteryChoice.Group;
|
||||
var lottery = Array.Find(groups.Table, z => z.Group == group);
|
||||
if (lottery is null)
|
||||
continue;
|
||||
var tables = lottery.Table;
|
||||
var matches = Array.Find(tables, z => z.EncounterTableID == tableID);
|
||||
if (matches is not null)
|
||||
return true;
|
||||
}
|
||||
foreach (var lotteryChoice in t.Table3)
|
||||
{
|
||||
var group = lotteryChoice.Group;
|
||||
var lottery = Array.Find(groups.Table, z => z.Group == group);
|
||||
if (lottery is null)
|
||||
continue;
|
||||
var tables = lottery.Table;
|
||||
var matches = Array.Find(tables, z => z.EncounterTableID == tableID);
|
||||
if (matches is not null)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return group.IsUseTable(groups, tableID);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,6 +36,26 @@ public class NewHugeOutbreakGroupLottery8a
|
||||
[FlatBufferItem(01)] public NewHugeOutbreakGroupLotteryDetail8a[] Table1 { get; set; } = Array.Empty<NewHugeOutbreakGroupLotteryDetail8a>();
|
||||
[FlatBufferItem(02)] public NewHugeOutbreakGroupLotteryDetail8a[] Table2 { get; set; } = Array.Empty<NewHugeOutbreakGroupLotteryDetail8a>();
|
||||
[FlatBufferItem(03)] public NewHugeOutbreakGroupLotteryDetail8a[] Table3 { get; set; } = Array.Empty<NewHugeOutbreakGroupLotteryDetail8a>();
|
||||
|
||||
public bool IsUseTable(NewHugeOutbreakGroupArchive8a groups, ulong tableID)
|
||||
{
|
||||
foreach (var lotteryChoice in Table1)
|
||||
{
|
||||
if (lotteryChoice.UsesTable(groups, tableID))
|
||||
return true;
|
||||
}
|
||||
foreach (var lotteryChoice in Table2)
|
||||
{
|
||||
if (lotteryChoice.UsesTable(groups, tableID))
|
||||
return true;
|
||||
}
|
||||
foreach (var lotteryChoice in Table3)
|
||||
{
|
||||
if (lotteryChoice.UsesTable(groups, tableID))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
[FlatBufferTable, TypeConverter(typeof(ExpandableObjectConverter))]
|
||||
@@ -78,4 +63,14 @@ public class NewHugeOutbreakGroupLotteryDetail8a
|
||||
{
|
||||
[FlatBufferItem(00)] public ulong Group { get; set; }
|
||||
[FlatBufferItem(01)] public int Rate { get; set; }
|
||||
|
||||
public override string ToString() => $"{Group:X16}|{Rate}";
|
||||
|
||||
public bool UsesTable(NewHugeOutbreakGroupArchive8a groups, ulong tableID)
|
||||
{
|
||||
var lottery = Array.Find(groups.Table, z => z.Group == Group);
|
||||
if (lottery is null)
|
||||
return false;
|
||||
return lottery.UsesTable(tableID);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,15 @@ public class NewHugeOutbreakGroup8a : IFlatBufferArchive<NewHugeOutbreakDetail8a
|
||||
{
|
||||
[FlatBufferItem(00)] public ulong Group { get; set; }
|
||||
[FlatBufferItem(01)] public NewHugeOutbreakDetail8a[] Table { get; set; } = Array.Empty<NewHugeOutbreakDetail8a>();
|
||||
[FlatBufferItem(02)] public ulong Field_02 { get; set; }
|
||||
[FlatBufferItem(02)] public ulong EncounterTableID { get; set; }
|
||||
|
||||
public bool UsesTable(ulong tableID)
|
||||
{
|
||||
if (EncounterTableID == tableID)
|
||||
return true;
|
||||
var matches = Array.Find(Table, z => z.EncounterTableID == tableID);
|
||||
return matches is not null;
|
||||
}
|
||||
}
|
||||
|
||||
[FlatBufferTable, TypeConverter(typeof(ExpandableObjectConverter))]
|
||||
@@ -39,4 +47,5 @@ public class NewHugeOutbreakDetail8a : IHasCondition8a
|
||||
[FlatBufferItem(6)] public string ConditionArg5 { get; set; } = string.Empty;
|
||||
[FlatBufferItem(7)] public ulong EncounterTableID { get; set; }
|
||||
[FlatBufferItem(8)] public int Rate { get; set; }
|
||||
public override string ToString() => $"PlacementParameters(/* ConditionTypeID = */ {this.GetConditionTypeSummary()}, /* Condition = */ {this.GetConditionSummary()}, {EncounterTableID:X16}, {Rate})";
|
||||
}
|
||||
|
||||
@@ -25,8 +25,8 @@ public class NewHugeOutbreakLottery8a
|
||||
[FlatBufferItem(00)] public ulong Hash { get; set; }
|
||||
[FlatBufferItem(01)] public string Field_01 { get; set; } = string.Empty;
|
||||
[FlatBufferItem(02)] public int OutbreakChance { get; set; }
|
||||
[FlatBufferItem(03)] public int Field_03 { get; set; }
|
||||
[FlatBufferItem(04)] public int Field_04 { get; set; }
|
||||
[FlatBufferItem(03)] public int OutbreakTotalMin { get; set; }
|
||||
[FlatBufferItem(04)] public int OutbreakTotalMax { get; set; }
|
||||
[FlatBufferItem(05)] public int Field_05 { get; set; }
|
||||
[FlatBufferItem(06)] public int Field_06 { get; set; }
|
||||
[FlatBufferItem(07)] public int MinCountFirst { get; set; }
|
||||
@@ -35,9 +35,13 @@ public class NewHugeOutbreakLottery8a
|
||||
[FlatBufferItem(10)] public int MaxCountSecond { get; set; }
|
||||
[FlatBufferItem(11)] public int Field_11 { get; set; }
|
||||
[FlatBufferItem(12)] public int Field_12 { get; set; }
|
||||
[FlatBufferItem(13)] public int Field_13 { get; set; }
|
||||
[FlatBufferItem(14)] public int Field_14 { get; set; }
|
||||
[FlatBufferItem(13)] public int BerryChance { get; set; }
|
||||
[FlatBufferItem(14)] public int RollBonus { get; set; }
|
||||
[FlatBufferItem(15)] public string[] Field_15 { get; set; } = Array.Empty<string>();
|
||||
[FlatBufferItem(16)] public int[] Field_16 { get; set; } = Array.Empty<int>();
|
||||
[FlatBufferItem(17)] public int[] Field_17 { get; set; } = Array.Empty<int>();
|
||||
[FlatBufferItem(17)] public int[] StarChanceParams { get; set; } = Array.Empty<int>();
|
||||
|
||||
// Stars are checked before berries
|
||||
public int StarMin => StarChanceParams[0];
|
||||
public int StarMax => StarChanceParams[1];
|
||||
}
|
||||
|
||||
@@ -12,7 +12,9 @@ public static class EncounterTable8aUtil
|
||||
private const float LandmarkBias = 15;
|
||||
|
||||
public static IEnumerable<byte[]> GetEncounterDump(AreaInstance8a area,
|
||||
IReadOnlyDictionary<string, (string Name, int Index)> map, PokeMiscTable8a misc)
|
||||
IReadOnlyDictionary<string, (string Name, int Index)> map, PokeMiscTable8a misc,
|
||||
NewHugeOutbreakGroupArchive8a nhoGroup,
|
||||
NewHugeOutbreakGroupLotteryArchive8a nhoLottery)
|
||||
{
|
||||
if (area.Locations.Length == 0)
|
||||
yield break;
|
||||
@@ -23,17 +25,20 @@ public static class EncounterTable8aUtil
|
||||
if (slots.Count == 0)
|
||||
continue;
|
||||
|
||||
foreach (var p in GetAreas(area, slots, table, map, misc))
|
||||
foreach (var p in GetAreas(area, slots, table, map, misc, nhoGroup, nhoLottery))
|
||||
yield return p;
|
||||
foreach (var x in area.SubAreas)
|
||||
{
|
||||
foreach (var p in GetAreas(x, slots, table, map, misc))
|
||||
foreach (var p in GetAreas(x, slots, table, map, misc, nhoGroup, nhoLottery))
|
||||
yield return p;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static IEnumerable<byte[]> GetAreas(AreaInstance8a area, IReadOnlyCollection<EncounterSlot8a> slots, EncounterTable8a table, IReadOnlyDictionary<string, (string Name, int Index)> map, PokeMiscTable8a misc)
|
||||
private static IEnumerable<byte[]> GetAreas(AreaInstance8a area, IReadOnlyCollection<EncounterSlot8a> slots, EncounterTable8a table,
|
||||
IReadOnlyDictionary<string, (string Name, int Index)> map, PokeMiscTable8a misc,
|
||||
NewHugeOutbreakGroupArchive8a nhoGroup,
|
||||
NewHugeOutbreakGroupLotteryArchive8a nhoLottery)
|
||||
{
|
||||
if (area.Locations.Length == 0)
|
||||
yield break;
|
||||
@@ -47,6 +52,13 @@ private static IEnumerable<byte[]> GetAreas(AreaInstance8a area, IReadOnlyCollec
|
||||
foreach (var a in GetAll(sl, SpawnerType.Spawner))
|
||||
yield return a;
|
||||
}
|
||||
{
|
||||
var s = area.Spawners;
|
||||
var spawners = s.Where(z => nhoLottery.IsAreaGroup(z, nhoGroup, table.TableID));
|
||||
var sl = spawners.SelectMany(z => z.GetIntersectingLocations(area.Locations, SpawnerBias));
|
||||
foreach (var a in GetAll(sl, SpawnerType.Spawner))
|
||||
yield return a;
|
||||
}
|
||||
|
||||
// Wormholes
|
||||
{
|
||||
|
||||
@@ -413,7 +413,7 @@ public void DumpWilds()
|
||||
allUnownLines.AddRange(unown);
|
||||
allUnownLinesBias.AddRange(unownBias);
|
||||
|
||||
var slices = EncounterTable8aUtil.GetEncounterDump(instance, map, misc);
|
||||
var slices = EncounterTable8aUtil.GetEncounterDump(instance, map, misc, nhoGroup, nhoGroupL);
|
||||
foreach (var s in slices)
|
||||
{
|
||||
if (!hexBin.Any(z => z.SequenceEqual(s)))
|
||||
|
||||
Reference in New Issue
Block a user