diff --git a/Misc/PKX.cs b/Misc/PKX.cs index 044b4f998..f09671bc4 100644 --- a/Misc/PKX.cs +++ b/Misc/PKX.cs @@ -1220,6 +1220,15 @@ internal Personal GetPersonal(int species, int formID) } } + /// + /// Calculate the Hidden Power Type of the entered IVs. + /// + /// HP/ATK/DEF/SPEED/SPA/SPD + /// + internal static int getHPType(int[] ivs) + { + return (15 * ((ivs[0] & 1) + 2 * (ivs[1] & 1) + 4 * (ivs[2] & 1) + 8 * (ivs[5] & 1) + 16 * (ivs[3] & 1) + 32 * (ivs[4] & 1))) / 63; + } internal static int[] setHPIVs(int type, int[] ivs) { for (int i = 0; i < 6; i++) @@ -1248,7 +1257,7 @@ internal static int[] setHPIVs(int type, int[] ivs) new int[] { 1, 0, 0, 1, 1, 1 }, // Ice new int[] { 1, 0, 1, 1, 1, 1 }, // Dragon new int[] { 1, 1, 1, 1, 1, 1 }, // Dark - }; + }; public class Simulator { public struct Set diff --git a/PKX/f1-Main.Designer.cs b/PKX/f1-Main.Designer.cs index 1a2184468..4c8c23849 100644 --- a/PKX/f1-Main.Designer.cs +++ b/PKX/f1-Main.Designer.cs @@ -1627,6 +1627,7 @@ public void InitializeComponent() this.Label_HPTYPE.Size = new System.Drawing.Size(33, 13); this.Label_HPTYPE.TabIndex = 30; this.Label_HPTYPE.Text = "(type)"; + this.Label_HPTYPE.Click += new System.EventHandler(this.clickHPType); // // Label_HiddenPowerPrefix // @@ -2673,7 +2674,7 @@ public void InitializeComponent() this.Menu_Language.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.CB_MainLanguage}); this.Menu_Language.Name = "Menu_Language"; - this.Menu_Language.Size = new System.Drawing.Size(152, 22); + this.Menu_Language.Size = new System.Drawing.Size(139, 22); this.Menu_Language.Text = "Language"; // // CB_MainLanguage @@ -2688,14 +2689,14 @@ public void InitializeComponent() this.Menu_About.Name = "Menu_About"; this.Menu_About.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.B))); this.Menu_About.ShowShortcutKeys = false; - this.Menu_About.Size = new System.Drawing.Size(152, 22); + this.Menu_About.Size = new System.Drawing.Size(139, 22); this.Menu_About.Text = "A&bout PKHeX"; this.Menu_About.Click += new System.EventHandler(this.mainMenuAbout); // // Menu_Unicode // this.Menu_Unicode.Name = "Menu_Unicode"; - this.Menu_Unicode.Size = new System.Drawing.Size(152, 22); + this.Menu_Unicode.Size = new System.Drawing.Size(139, 22); this.Menu_Unicode.Text = "Toggle Font"; this.Menu_Unicode.Click += new System.EventHandler(this.mainMenuUnicode); // @@ -3772,6 +3773,7 @@ public void InitializeComponent() this.RTB_T.ReadOnly = true; this.RTB_T.Size = new System.Drawing.Size(300, 130); this.RTB_T.TabIndex = 1; + this.RTB_T.Text = ""; this.RTB_T.WordWrap = false; // // Tab_SAV @@ -3860,6 +3862,7 @@ public void InitializeComponent() this.RTB_S.ReadOnly = true; this.RTB_S.Size = new System.Drawing.Size(300, 130); this.RTB_S.TabIndex = 0; + this.RTB_S.Text = ""; this.RTB_S.WordWrap = false; // // B_OpenHallofFame diff --git a/PKX/f1-Main.cs b/PKX/f1-Main.cs index 357849ce3..3cf2f1e9f 100644 --- a/PKX/f1-Main.cs +++ b/PKX/f1-Main.cs @@ -1757,6 +1757,22 @@ private void clickTRGender(object sender, EventArgs e) else // set gender label (toggle M/F) lbl.Text = (PKX.getGender(lbl.Text) == 0) ? gendersymbols[1] : gendersymbols[0]; } + private void clickHPType(object sender, EventArgs e) + { + int[] ivs = new int[] { + Util.ToInt32(TB_HPIV.Text), Util.ToInt32(TB_ATKIV.Text), Util.ToInt32(TB_DEFIV.Text), + Util.ToInt32(TB_SPAIV.Text), Util.ToInt32(TB_SPDIV.Text), Util.ToInt32(TB_SPEIV.Text) }; + + // Increment the Current Hidden Power Type by +/- 1 and modulate the IVs to match. + int[] newIVs = PKX.setHPIVs((PKX.getHPType(ivs) + ((ModifierKeys == Keys.Control) ? 15 : 1)) % 0x10, ivs); + TB_HPIV.Text = newIVs[0].ToString(); + TB_ATKIV.Text = newIVs[1].ToString(); + TB_DEFIV.Text = newIVs[2].ToString(); + + TB_SPAIV.Text = newIVs[3].ToString(); + TB_SPDIV.Text = newIVs[4].ToString(); + TB_SPEIV.Text = newIVs[5].ToString(); + } // Prompted Updates of PKX Functions // private bool changingEXPLevel = false; private void updateEXPLevel(object sender, EventArgs e) @@ -1795,20 +1811,14 @@ private void updateIVs(object sender, EventArgs e) if (Util.ToInt32((sender as MaskedTextBox).Text) > 31) (sender as MaskedTextBox).Text = "31"; - int ivtotal, HP_IV, ATK_IV, DEF_IV, SPA_IV, SPD_IV, SPE_IV; - HP_IV = Util.ToInt32(TB_HPIV.Text); - ATK_IV = Util.ToInt32(TB_ATKIV.Text); - DEF_IV = Util.ToInt32(TB_DEFIV.Text); - SPA_IV = Util.ToInt32(TB_SPAIV.Text); - SPD_IV = Util.ToInt32(TB_SPDIV.Text); - SPE_IV = Util.ToInt32(TB_SPEIV.Text); + int[] ivs = new int[] { + Util.ToInt32(TB_HPIV.Text), Util.ToInt32(TB_ATKIV.Text), Util.ToInt32(TB_DEFIV.Text), + Util.ToInt32(TB_SPAIV.Text), Util.ToInt32(TB_SPDIV.Text), Util.ToInt32(TB_SPEIV.Text) }; + + int HPTYPE = PKX.getHPType(ivs); + Label_HPTYPE.Text = types[HPTYPE + 1]; // type array has normal at index 0, so we offset by 1. - int[] iva = new int[] { HP_IV, ATK_IV, DEF_IV, SPE_IV, SPA_IV, SPD_IV }; - - int HPTYPE = (15 * ((HP_IV & 1) + 2 * (ATK_IV & 1) + 4 * (DEF_IV & 1) + 8 * (SPE_IV & 1) + 16 * (SPA_IV & 1) + 32 * (SPD_IV & 1))) / 63; - Label_HPTYPE.Text = types[HPTYPE + 1]; // type array has normal at index 0, so we offset by 1 - - ivtotal = HP_IV + ATK_IV + DEF_IV + SPA_IV + SPD_IV + SPE_IV; + int ivtotal = ivs.Sum(); TB_IVTotal.Text = ivtotal.ToString(); // Potential Reading @@ -1837,13 +1847,13 @@ private void updateIVs(object sender, EventArgs e) // Characteristic with EC%6 int pm6 = (int)(Util.getHEXval(TB_EC) % 6); // EC MOD 6 - int maxIV = iva.Max(); + int maxIV = ivs.Max(); int pm6stat = 0; for (int i = 0; i < 6; i++) { pm6stat = (pm6 + i) % 6; - if (iva[pm6stat] == maxIV) + if (ivs[pm6stat] == maxIV) break; // P%6 is this stat } diff --git a/PKX/f1-Main.resx b/PKX/f1-Main.resx index bd4c222dd..a0ef8fc4c 100644 --- a/PKX/f1-Main.resx +++ b/PKX/f1-Main.resx @@ -243,279 +243,6 @@ True - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - True @@ -672,60 +399,6 @@ True - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - True @@ -798,51 +471,9 @@ True - - True - - - True - - - True - True - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - True @@ -891,75 +522,9 @@ True - - True - - - True - - - True - - - True - - - True - - - True - True - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - True @@ -999,18 +564,12 @@ True - - True - True True - - True - True @@ -1020,27 +579,6 @@ True - - True - - - True - - - True - - - True - - - True - - - True - - - True - True