From e772a99341b07767455110a8055f2bd61eea274e Mon Sep 17 00:00:00 2001 From: Kurt Date: Sun, 18 Apr 2021 12:02:30 -0700 Subject: [PATCH] Add index to dumped bcat nests --- .../FlatNest/NestHoleDistributionEncounter8Archive.cs | 9 +++++---- pkNX.WinForms/Dumping/GameDumperSWSH.cs | 6 +++++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/pkNX.Structures/Encounter/Gen8/FlatNest/NestHoleDistributionEncounter8Archive.cs b/pkNX.Structures/Encounter/Gen8/FlatNest/NestHoleDistributionEncounter8Archive.cs index 33530e0b..9e07ad79 100644 --- a/pkNX.Structures/Encounter/Gen8/FlatNest/NestHoleDistributionEncounter8Archive.cs +++ b/pkNX.Structures/Encounter/Gen8/FlatNest/NestHoleDistributionEncounter8Archive.cs @@ -111,20 +111,21 @@ string GetItemName(uint itemID) } } - public IEnumerable GetSummary(IReadOnlyList species) + public IEnumerable GetSummary(IReadOnlyList species, int index) { foreach (var entry in Entries) { if (entry.Exists) - yield return Summary(entry); + yield return Summary(entry, index); } yield return string.Empty; - string Summary(NestHoleDistributionEncounter8 e) + string Summary(NestHoleDistributionEncounter8 e, int index) { var comment = $" // {species[e.Species]}{(e.AltForm == 0 ? string.Empty : "-" + e.AltForm)}"; var gender = e.Gender == 0 ? string.Empty : $", Gender = {e.Gender - 1}"; var altform = e.AltForm == 0 ? string.Empty : $", Form = {e.AltForm}"; + var istr = $", Index = {index}"; var giga = !e.IsGigantamax ? string.Empty : ", CanGigantamax = true"; var moves = $", Moves = new[]{{ {e.Move0:000}, {e.Move1:000}, {e.Move2:000}, {e.Move3:000} }}"; var shiny = e.ShinyLock switch @@ -153,7 +154,7 @@ string Summary(NestHoleDistributionEncounter8 e) throw new Exception(); } var flawless = e.FlawlessIVs; - var line = $" new({e.Level:00},{e.DynamaxLevel:00},{flawless}) {{ Species = {e.Species:000}, Ability = {ability}{moves}{gender}{altform}{giga}{shiny} }},{comment}"; + var line = $" new({e.Level:00},{e.DynamaxLevel:00},{flawless}) {{ Species = {e.Species:000}, Ability = {ability}{moves}{istr}{gender}{altform}{giga}{shiny} }},{comment}"; if (e.Field_13 == 6 && e.Field_14 == 6) line = line.Insert(12, "//").Remove(10, 2); // comment out uncatchable encounters return line; diff --git a/pkNX.WinForms/Dumping/GameDumperSWSH.cs b/pkNX.WinForms/Dumping/GameDumperSWSH.cs index f1bd81db..58d350a8 100644 --- a/pkNX.WinForms/Dumping/GameDumperSWSH.cs +++ b/pkNX.WinForms/Dumping/GameDumperSWSH.cs @@ -541,6 +541,10 @@ public void DumpDistributionNestEntries(string path) var dist_bonus = FlatBufferConverter.DeserializeFrom(bonus_data); var dai_encounts = FlatBufferConverter.DeserializeFrom(dai_data); + int index = dai_data[0]; + + System.Diagnostics.Debug.Assert(dai_data[0] == drop_data[0] && dai_data[0] == bonus_data[0], "BCAT Index should be the same for all files!"); + DumpDistIfExists("normal_encount", ""); DumpDistIfExists("normal_encount_rigel1", "Armor"); DumpDistIfExists("normal_encount_rigel2", "Crown"); @@ -571,7 +575,7 @@ void DumpDistIfExists(string filePath, string dest) foreach (var game in new[] { 1, 2 }) { var tables = encounts.Tables.Where(z => z.GameVersion == game).ToList(); - var encounters = tables.SelectMany(z => z.GetSummary(speciesNames)).ToArray(); + var encounters = tables.SelectMany(z => z.GetSummary(speciesNames, index)).ToArray(); var path1 = GetPath($"nestDistHex{game}.txt"); File.WriteAllLines(path1, encounters);