diff --git a/PKHeX.Core/Legality/Tables7.cs b/PKHeX.Core/Legality/Tables7.cs index a5523e271..8cb122baa 100644 --- a/PKHeX.Core/Legality/Tables7.cs +++ b/PKHeX.Core/Legality/Tables7.cs @@ -418,6 +418,39 @@ public static partial class Legal 687, // Core Enforcer }; + internal static readonly HashSet Totem_Alolan = new HashSet + { + 020, // Raticate (Normal, Alolan, Totem) + 105, // Marowak (Normal, Alolan, Totem) + 778, // Mimikyu (Normal, Busted, Totem, Totem_Busted) + }; + internal static readonly HashSet Totem_SM = new HashSet + { + 020, // Raticate + 735, // Gumshoos + 746, // Wishiwashi + 758, // Salazzle + 754, // Lurantis + 738, // Vikavolt + 778, // Mimikyu + 784, // Kommo-o + }; + internal static readonly HashSet Totem_USUM = new HashSet + { + 020, // Raticate + 735, // Gumshoos + 746, // Wishiwashi + 758, // Salazzle + 754, // Lurantis + 738, // Vikavolt + 778, // Mimikyu + 784, // Kommo-o + 105, // Marowak + 752, // Araquanid + 777, // Togedemaru + 743, // Ribombee + }; + internal static readonly int[] EggLocations7 = {60002, 30002}; internal static readonly HashSet ValidMet_SM = new HashSet { diff --git a/PKHeX.Core/PKM/FormConverter.cs b/PKHeX.Core/PKM/FormConverter.cs index f5da804b6..9bf4bc47c 100644 --- a/PKHeX.Core/PKM/FormConverter.cs +++ b/PKHeX.Core/PKM/FormConverter.cs @@ -2,7 +2,7 @@ namespace PKHeX.Core { - internal static class FormConverter + public static class FormConverter { /// /// Gets a list of formes that the species can have. @@ -22,6 +22,8 @@ internal static string[] GetFormList(int species, IReadOnlyList types, I types[000], // Normal forms[804], // Mega }; + if (generation == 7 && Legal.Totem_USUM.Contains(species)) + return GetFormsTotem(species, types, forms); if (species <= Legal.MaxSpeciesID_1) return GetFormsGen1(species, types, forms, generation); @@ -39,6 +41,27 @@ internal static string[] GetFormList(int species, IReadOnlyList types, I return GetFormsGen7(species, types, forms); } + public static bool IsTotemForm(int species, int form, int generation = 7) + { + if (generation != 7) + return false; + if (form == 0) + return false; + if (!Legal.Totem_USUM.Contains(species)) + return false; + if (species == 778) // Mimikyu + return form == 2 || form == 3; + if (Legal.Totem_Alolan.Contains(species)) + return form == 2; + return form == 1; + } + public static int GetTotemBaseForm(int species, int form) + { + if (species == 778) // Mimikyu + return form -2; + return form - 1; + } + private static string[] GetFormsGen1(int species, IReadOnlyList types, IReadOnlyList forms, int generation) { switch (species) @@ -419,13 +442,6 @@ private static string[] GetFormsGen7(int species, IReadOnlyList types, I forms[1057], // "V-Core", // Core Violet }; - case 778: // Mimikyu - return new[] - { - forms[778], // Disguised - forms[1058], // Busted - }; - case 800: return new[] { @@ -444,7 +460,7 @@ private static string[] GetFormsGen7(int species, IReadOnlyList types, I } } - private static string[] GetFormsAlolan(int generation, IReadOnlyList types, IReadOnlyList forms, int species) + private static string[] GetFormsAlolan (int generation, IReadOnlyList types, IReadOnlyList forms, int species) { if (generation < 7) return new[] { "" }; @@ -455,7 +471,6 @@ private static string[] GetFormsAlolan(int generation, IReadOnlyList typ return new[] { "" }; case 19: // Rattata - case 20: // Raticate case 26: // Raichu case 27: // Sandshrew case 28: // Sandslash @@ -470,7 +485,6 @@ private static string[] GetFormsAlolan(int generation, IReadOnlyList typ case 76: // Golem case 88: // Grimer case 89: // Muk - case 105: // Marowak case 103: // Exeggutor return new[] { @@ -592,6 +606,29 @@ private static string[] GetFormsArceus (int generation, IReadOnlyList ty }; } } + private static string[] GetFormsTotem (int species, IReadOnlyList types, IReadOnlyList forms) + { + if (species == 778) // Mimikyu + return new[] + { + forms[778], // Disguised + forms[1058], // Busted + forms[1007], // Large + "*" + forms[1058], // Busted + }; + if (Legal.Totem_Alolan.Contains(species)) + return new[] + { + types[0], // Normal + forms[810], // Alolan + forms[1007], // Large + }; + return new[] + { + types[0], // Normal + forms[1007], // Large + }; + } private static string[] GetFormsUnown(int generation) { switch (generation) diff --git a/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs b/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs index cf27d9dfb..de98555cd 100644 --- a/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs +++ b/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs @@ -343,7 +343,8 @@ private void SetForms() if (!hasForms) return; - var ds = PKX.GetFormList(species, GameInfo.Strings.types, GameInfo.Strings.forms, gendersymbols, pkm.Format).ToList(); + var ds = PKX.GetFormList(species, GameInfo.Strings.types, GameInfo.Strings.forms, gendersymbols, pkm.Format) + .Take(RequestSaveFile?.Personal[species]?.FormeCount ?? 0).ToList(); if (ds.Count == 1 && string.IsNullOrEmpty(ds[0])) // empty (Alolan Totems) CB_Form.Enabled = CB_Form.Visible = Label_Form.Visible = false; else CB_Form.DataSource = ds; diff --git a/PKHeX.WinForms/Subforms/Save Editors/Gen7/SAV_PokedexSM.cs b/PKHeX.WinForms/Subforms/Save Editors/Gen7/SAV_PokedexSM.cs index dec905429..8329d275e 100644 --- a/PKHeX.WinForms/Subforms/Save Editors/Gen7/SAV_PokedexSM.cs +++ b/PKHeX.WinForms/Subforms/Save Editors/Gen7/SAV_PokedexSM.cs @@ -139,7 +139,7 @@ private bool FillLBForms() bool hasForms = SAV.Personal[bspecies].HasFormes || new[] { 201, 664, 665, 414 }.Contains(bspecies); LB_Forms.Enabled = hasForms; if (!hasForms) return false; - var ds = PKX.GetFormList(bspecies, GameInfo.Strings.types, GameInfo.Strings.forms, Main.GenderSymbols, SAV.Generation).ToList(); + var ds = PKX.GetFormList(bspecies, GameInfo.Strings.types, GameInfo.Strings.forms, Main.GenderSymbols, SAV.Generation).Take(SAV.Personal[bspecies].FormeCount).ToList(); if (ds.Count == 1 && string.IsNullOrEmpty(ds[0])) { // empty (Alolan Totems) diff --git a/PKHeX.WinForms/Util/PKMUtil.cs b/PKHeX.WinForms/Util/PKMUtil.cs index 742994e87..f8cfbcbf2 100644 --- a/PKHeX.WinForms/Util/PKMUtil.cs +++ b/PKHeX.WinForms/Util/PKMUtil.cs @@ -49,6 +49,13 @@ public static Image GetSprite(int species, int form, int gender, int item, bool // Redrawing logic Image baseImage = (Image)Resources.ResourceManager.GetObject(file); + if (baseImage == null && FormConverter.IsTotemForm(species, form)) + { + form = FormConverter.GetTotemBaseForm(species, form); + file = PKX.GetResourceStringSprite(species, form, gender, generation); + baseImage = (Image)Resources.ResourceManager.GetObject(file); + baseImage = ImageUtil.ToGrayscale(baseImage); + } if (baseImage == null) { baseImage = (Image) Resources.ResourceManager.GetObject($"_{species}");