From 2f209a215c3b03ecdb6aba7a3d09a8d2d38d6dcf Mon Sep 17 00:00:00 2001 From: sora10pls <17801814+sora10pls@users.noreply.github.com> Date: Sat, 7 Oct 2023 16:42:30 -0400 Subject: [PATCH] Raid pretty dump: print proper materials/shards Move switch expression outside of loop, add form string handling for Meteor Form Minior and Scatterbug/Spewpa --- pkNX.WinForms/Dumping/TeraRaidRipper.cs | 69 +++++++++++++++++-------- 1 file changed, 48 insertions(+), 21 deletions(-) diff --git a/pkNX.WinForms/Dumping/TeraRaidRipper.cs b/pkNX.WinForms/Dumping/TeraRaidRipper.cs index f5df8cab..d92d77c4 100644 --- a/pkNX.WinForms/Dumping/TeraRaidRipper.cs +++ b/pkNX.WinForms/Dumping/TeraRaidRipper.cs @@ -569,10 +569,10 @@ private static void DumpPretty(IFileInternal ROM, DeliveryRaidEnemyTableArray ta }; if (drop.Category == RaidRewardItemCategoryType.POKE) // Material - lines.Add($"\t\t\t{drop.Num,2} × TM Material{limitation}"); + lines.Add($"\t\t\t{drop.Num,2} × {GetNameMaterial(ROM, boss.DevId, items)}{limitation}"); if (drop.Category == RaidRewardItemCategoryType.GEM) // Tera Shard - lines.Add($"\t\t\t{drop.Num,2} × Tera Shard{limitation}"); + lines.Add($"\t\t\t{drop.Num,2} × {GetNameShard(boss.GemType, types)}{limitation}"); if (drop.ItemID != 0) lines.Add($"\t\t\t{drop.Num,2} × {GetItemName((ushort)drop.ItemID, items, moves)}{limitation}"); @@ -597,10 +597,10 @@ private static void DumpPretty(IFileInternal ROM, DeliveryRaidEnemyTableArray ta float rate = (float)(Math.Round((item.GetRewardItem(i).Rate / totalRate) * 100f, 2)); if (drop.Category == RaidRewardItemCategoryType.POKE) // Material - lines.Add($"\t\t\t{rate,5}% {drop.Num,2} × TM Material"); + lines.Add($"\t\t\t{rate,5}% {drop.Num,2} × {GetNameMaterial(ROM, boss.DevId, items)}"); if (drop.Category == RaidRewardItemCategoryType.GEM) // Tera Shard - lines.Add($"\t\t\t{rate,5}% {drop.Num,2} × Tera Shard"); + lines.Add($"\t\t\t{rate,5}% {drop.Num,2} × {GetNameShard(boss.GemType, types)}"); if (drop.ItemID != 0) lines.Add($"\t\t\t{rate,5}% {drop.Num,2} × {GetItemName((ushort)drop.ItemID, items, moves)}"); @@ -622,34 +622,41 @@ public static string GetFormName(IFileInternal ROM, ushort species, byte form) var path = ROM.GetPackedFile("message/dat/English/common/zkn_form.tbl"); var ahtb = new AHTB(path); - var GenericFormNames = new HashSet { Tauros, Unown, Kyogre, Groudon, Rotom, Arceus, Kyurem, Greninja, Rockruff }; + var GenericFormNames = new HashSet { Tauros, Unown, Kyogre, Groudon, Rotom, Arceus, Kyurem, Greninja, Rockruff, Minior }; string[] TaurosForms = { "", "Combat Breed", "Blaze Breed", "Aqua Breed" }; ReadOnlySpan UnownForms = "ABCDEFGHIJKLMNOPQRSTUVWXYZ!?"; + string[] MiniorForms = { "Red", "Orange", "Yellow", "Green", "Blue", "Indigo", "Violet" }; + + // some species have form strings that are just the species name (Rotom), or are not descriptive (e.g. Unown "One form"), or no form string at all! + if (GenericFormNames.Contains((Species)species)) + { + return (Species)species switch + { + Tauros when form is not 0 => $"Paldean Form / {TaurosForms[form]}", + Unown => $"Unown {UnownForms[form]}", // A-Z!? + Kyogre or Groudon when form is 0 => "", // Kyogre-0 / Groudon-0 + Rotom when form is 0 => "", // Rotom-0 + Arceus => $"Type: {type[form]}", // Types + Kyurem when form is 0 => "", // Kyurem-0 + Greninja when form is 1 => "", // Battle Bond Greninja + Rockruff when form is 1 => "", // Own Tempo Rockruff + Minior when form is <= 6 => $"{MiniorForms[form]} Meteor Form", // Meteor Forms + _ => "", + }; + } + for (int i = 0; i < text.Length; i++) { var entry = ahtb.Entries[i]; var name = entry.Name; var line = text[i]; - // some species have form strings that are just the species name (Rotom), or are not descriptive (e.g. Unown "One form"), or no form string at all! - if (GenericFormNames.Contains((Species)species)) - { - return (Species)species switch - { - Tauros when form is not 0 => $"Paldean Form / {TaurosForms[form]}", - Unown => $"Unown {UnownForms[form]}", // A-Z!? - Kyogre or Groudon when form is 0 => "", // Kyogre-0 / Groudon-0 - Rotom when form is 0 => "", // Rotom-0 - Arceus => $"{type[form]}", // Types - Kyurem when form is 0 => "", // Kyurem-0 - Greninja when form is 1 => "", // Battle Bond Greninja - Rockruff when form is 1 => "", // Own Tempo Rockruff - _ => "", - }; - } + if (species is (int)Scatterbug or (int)Spewpa) // workaround to get Vivillon form strings + species = (int)Vivillon; if (name == $"ZKN_FORM_{species:000}_{form:000}") return line; } + return ""; } @@ -680,6 +687,26 @@ private static string GetItemName(ushort item, ReadOnlySpan items, ReadO _ => $"{items[item]} {moves[tm[100 + item - 2160]]}", // TM100 to TM229 }; + private static string GetNameMaterial(IFileInternal ROM, DevID species, ReadOnlySpan items) + { + var data = ROM.GetPackedFile("world/data/item/dropitemdata/dropitemdata_array.bin"); + var obj = FlatBufferConverter.DeserializeFrom(data); + foreach (var t in obj.Table) + { + var item = t.Item1.ItemId; + if (t.DevId == species && item != 0) + return $"{items[(int)t.Item1.ItemId]}"; + } + + return "TM Material"; // no material, but the raid data may have it in the drop table anyway + } + + private static string GetNameShard(GemType gem, ReadOnlySpan types) => gem switch + { + GemType.DEFAULT or GemType.RANDOM => "Tera Shard", // variable, matches boss gemtype + _ => $"{types[(int)gem - 2]} Tera Shard", + }; + private static string GetExtraActionInfo(RaidBossExtraData action, string[] moves) { var type = action.Timing == RaidBossExtraTimingType.TIME ? "Time" : "HP";