From f23b1d9348d867ae53e2af72e74b5aca19b7dfde Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Tue, 22 Nov 2016 03:49:57 -0800 Subject: [PATCH] Randomization for SMWE. --- pk3DS/Legality/Randomizer.cs | 6 +- pk3DS/Subforms/Gen6/GiftEditor6.cs | 2 +- pk3DS/Subforms/Gen6/RSWE.cs | 2 +- pk3DS/Subforms/Gen6/RSWE.designer.cs | 24 +- pk3DS/Subforms/Gen6/StaticEncounterEditor6.cs | 2 +- pk3DS/Subforms/Gen6/XYWE.cs | 2 +- pk3DS/Subforms/Gen7/SMWE.Designer.cs | 237 ++++++++++++++++++ pk3DS/Subforms/Gen7/SMWE.cs | 109 +++++++- 8 files changed, 366 insertions(+), 18 deletions(-) diff --git a/pk3DS/Legality/Randomizer.cs b/pk3DS/Legality/Randomizer.cs index 30d75e0..8e0655c 100644 --- a/pk3DS/Legality/Randomizer.cs +++ b/pk3DS/Legality/Randomizer.cs @@ -12,7 +12,7 @@ internal static int getRandomSpecies(ref int[] list, ref int ctr) } internal static readonly int[] RandomSpeciesList = Enumerable.Range(1, 721).ToArray(); - internal static int[] getSpeciesList(bool G1, bool G2, bool G3, bool G4, bool G5, bool G6, bool L, bool E, bool Shedinja = true) + internal static int[] getSpeciesList(bool G1, bool G2, bool G3, bool G4, bool G5, bool G6, bool G7, bool L, bool E, bool Shedinja = true) { int[] sL = new int[0]; @@ -41,6 +41,10 @@ internal static int[] getSpeciesList(bool G1, bool G2, bool G3, bool G4, bool G5 if (G6) sL = sL.Concat(Enumerable.Range(650, 66)).ToArray(); if (G6 && L) sL = sL.Concat(Enumerable.Range(716, 3)).ToArray(); // if (G6 && E) sL = sL.Concat(Enumerable.Range(719, 3)).ToArray(); // + // Gen 7 + if (G7) sL = sL.Concat(Enumerable.Range(722, 67)).ToArray(); + if (G7 && L) sL = sL.Concat(Enumerable.Range(785, 16)).ToArray(); // Tapus, Legends, UBs + if (G7 && E) sL = sL.Concat(Enumerable.Range(801, 2)).ToArray(); // Magearna, Marshadow return sL.Length == 0 ? RandomSpeciesList : sL; } diff --git a/pk3DS/Subforms/Gen6/GiftEditor6.cs b/pk3DS/Subforms/Gen6/GiftEditor6.cs index bf8c4f9..e504005 100644 --- a/pk3DS/Subforms/Gen6/GiftEditor6.cs +++ b/pk3DS/Subforms/Gen6/GiftEditor6.cs @@ -173,7 +173,7 @@ private void B_RandAll_Click(object sender, EventArgs e) } // Randomize by BST - int[] sL = Randomizer.getSpeciesList(G1: true, G2: true, G3: true, G4: true, G5: true, G6: true, L: false, E: false, Shedinja: false); + int[] sL = Randomizer.getSpeciesList(G1: true, G2: true, G3: true, G4: true, G5: true, G6: true, G7: false, L: false, E: false, Shedinja: false); int ctr = 0; for (int i = 0; i < LB_Gifts.Items.Count; i++) { diff --git a/pk3DS/Subforms/Gen6/RSWE.cs b/pk3DS/Subforms/Gen6/RSWE.cs index dceb258..59cf469 100644 --- a/pk3DS/Subforms/Gen6/RSWE.cs +++ b/pk3DS/Subforms/Gen6/RSWE.cs @@ -601,7 +601,7 @@ private void B_Randomize_Click(object sender, EventArgs e) // Nonrepeating List Start int[] sL = Randomizer.getSpeciesList(CHK_G1.Checked, CHK_G2.Checked, CHK_G3.Checked, - CHK_G4.Checked, CHK_G5.Checked, CHK_G6.Checked, CHK_L.Checked, CHK_E.Checked); + CHK_G4.Checked, CHK_G5.Checked, CHK_G6.Checked, false, CHK_L.Checked, CHK_E.Checked); int ctr = 0; int[] slotArray = Enumerable.Range(0, max.Length).Select(a => a).ToArray(); diff --git a/pk3DS/Subforms/Gen6/RSWE.designer.cs b/pk3DS/Subforms/Gen6/RSWE.designer.cs index 82c3b90..9f81ca2 100644 --- a/pk3DS/Subforms/Gen6/RSWE.designer.cs +++ b/pk3DS/Subforms/Gen6/RSWE.designer.cs @@ -35,6 +35,7 @@ private void InitializeComponent() this.CB_FormeList = new System.Windows.Forms.ComboBox(); this.TabPage_Horde = new System.Windows.Forms.TabPage(); this.GB_Tweak = new System.Windows.Forms.GroupBox(); + this.CHK_MegaForm = new System.Windows.Forms.CheckBox(); this.L_RandOpt = new System.Windows.Forms.Label(); this.CHK_BST = new System.Windows.Forms.CheckBox(); this.CHK_E = new System.Windows.Forms.CheckBox(); @@ -387,7 +388,6 @@ private void InitializeComponent() this.TabControl_EncounterData = new System.Windows.Forms.TabControl(); this.B_Dump = new System.Windows.Forms.Button(); this.B_Randomize = new System.Windows.Forms.Button(); - this.CHK_MegaForm = new System.Windows.Forms.CheckBox(); this.TabPage_Horde.SuspendLayout(); this.GB_Tweak.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.NUD_LevelAmp)).BeginInit(); @@ -865,6 +865,16 @@ private void InitializeComponent() this.GB_Tweak.TabStop = false; this.GB_Tweak.Text = "Extra Tweaks"; // + // CHK_MegaForm + // + this.CHK_MegaForm.AutoSize = true; + this.CHK_MegaForm.Location = new System.Drawing.Point(152, 97); + this.CHK_MegaForm.Name = "CHK_MegaForm"; + this.CHK_MegaForm.Size = new System.Drawing.Size(127, 17); + this.CHK_MegaForm.TabIndex = 295; + this.CHK_MegaForm.Text = "Random Mega Forms"; + this.CHK_MegaForm.UseVisualStyleBackColor = true; + // // L_RandOpt // this.L_RandOpt.AutoSize = true; @@ -26167,21 +26177,11 @@ private void InitializeComponent() this.B_Randomize.UseVisualStyleBackColor = true; this.B_Randomize.Click += new System.EventHandler(this.B_Randomize_Click); // - // CHK_MegaForm - // - this.CHK_MegaForm.AutoSize = true; - this.CHK_MegaForm.Location = new System.Drawing.Point(152, 97); - this.CHK_MegaForm.Name = "CHK_MegaForm"; - this.CHK_MegaForm.Size = new System.Drawing.Size(127, 17); - this.CHK_MegaForm.TabIndex = 295; - this.CHK_MegaForm.Text = "Random Mega Forms"; - this.CHK_MegaForm.UseVisualStyleBackColor = true; - // // RSWE // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(948, 416); + this.ClientSize = new System.Drawing.Size(948, 415); this.Controls.Add(this.B_Randomize); this.Controls.Add(this.B_Dump); this.Controls.Add(this.L_FormList); diff --git a/pk3DS/Subforms/Gen6/StaticEncounterEditor6.cs b/pk3DS/Subforms/Gen6/StaticEncounterEditor6.cs index b77738e..c87a513 100644 --- a/pk3DS/Subforms/Gen6/StaticEncounterEditor6.cs +++ b/pk3DS/Subforms/Gen6/StaticEncounterEditor6.cs @@ -134,7 +134,7 @@ private void B_RandAll_Click(object sender, EventArgs e) } // Randomize by BST - int[] sL = Randomizer.getSpeciesList(G1: true, G2: true, G3: true, G4: true, G5: true, G6: true, L: false, E: false, Shedinja: false); + int[] sL = Randomizer.getSpeciesList(G1: true, G2: true, G3: true, G4: true, G5: true, G6: true, G7:false, L: false, E: false, Shedinja: false); int ctr = 0; for (int i = 0; i < LB_Encounters.Items.Count; i++) { diff --git a/pk3DS/Subforms/Gen6/XYWE.cs b/pk3DS/Subforms/Gen6/XYWE.cs index 25e0321..a0f3e95 100644 --- a/pk3DS/Subforms/Gen6/XYWE.cs +++ b/pk3DS/Subforms/Gen6/XYWE.cs @@ -513,7 +513,7 @@ private void B_Randomize_Click(object sender, EventArgs e) // Nonrepeating List Start int[] sL = Randomizer.getSpeciesList(CHK_G1.Checked, CHK_G2.Checked, CHK_G3.Checked, - CHK_G4.Checked, CHK_G5.Checked, CHK_G6.Checked, CHK_L.Checked, CHK_E.Checked); + CHK_G4.Checked, CHK_G5.Checked, CHK_G6.Checked, false, CHK_L.Checked, CHK_E.Checked); int ctr = 0; diff --git a/pk3DS/Subforms/Gen7/SMWE.Designer.cs b/pk3DS/Subforms/Gen7/SMWE.Designer.cs index 8c0d23f..4864661 100644 --- a/pk3DS/Subforms/Gen7/SMWE.Designer.cs +++ b/pk3DS/Subforms/Gen7/SMWE.Designer.cs @@ -39,6 +39,22 @@ private void InitializeComponent() this.L_Max = new System.Windows.Forms.Label(); this.L_Table = new System.Windows.Forms.Label(); this.GB_Encounters = new System.Windows.Forms.GroupBox(); + this.GB_Tweak = new System.Windows.Forms.GroupBox(); + this.CHK_G7 = new System.Windows.Forms.CheckBox(); + this.CHK_MegaForm = new System.Windows.Forms.CheckBox(); + this.L_RandOpt = new System.Windows.Forms.Label(); + this.CHK_BST = new System.Windows.Forms.CheckBox(); + this.CHK_E = new System.Windows.Forms.CheckBox(); + this.CHK_L = new System.Windows.Forms.CheckBox(); + this.CHK_G6 = new System.Windows.Forms.CheckBox(); + this.CHK_G5 = new System.Windows.Forms.CheckBox(); + this.CHK_G4 = new System.Windows.Forms.CheckBox(); + this.CHK_G3 = new System.Windows.Forms.CheckBox(); + this.CHK_G2 = new System.Windows.Forms.CheckBox(); + this.CHK_G1 = new System.Windows.Forms.CheckBox(); + this.B_LevelPlus = new System.Windows.Forms.Button(); + this.NUD_LevelAmp = new System.Windows.Forms.NumericUpDown(); + this.CHK_Level = new System.Windows.Forms.CheckBox(); this.PB_NightIcon = new System.Windows.Forms.PictureBox(); this.PB_DayIcon = new System.Windows.Forms.PictureBox(); this.NUP_WeatherForme6 = new System.Windows.Forms.NumericUpDown(); @@ -240,6 +256,8 @@ private void InitializeComponent() ((System.ComponentModel.ISupportInitialize)(this.NUP_Min)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.NUP_Max)).BeginInit(); this.GB_Encounters.SuspendLayout(); + this.GB_Tweak.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.NUD_LevelAmp)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.PB_NightIcon)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.PB_DayIcon)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.NUP_WeatherForme6)).BeginInit(); @@ -341,6 +359,7 @@ private void InitializeComponent() this.B_Randomize.TabIndex = 421; this.B_Randomize.Text = "Randomize All"; this.B_Randomize.UseVisualStyleBackColor = true; + this.B_Randomize.Click += new System.EventHandler(this.B_Randomize_Click); // // B_Dump // @@ -455,6 +474,7 @@ private void InitializeComponent() // // GB_Encounters // + this.GB_Encounters.Controls.Add(this.GB_Tweak); this.GB_Encounters.Controls.Add(this.PB_NightIcon); this.GB_Encounters.Controls.Add(this.PB_DayIcon); this.GB_Encounters.Controls.Add(this.NUP_WeatherForme6); @@ -659,6 +679,204 @@ private void InitializeComponent() this.GB_Encounters.TabStop = false; this.GB_Encounters.Text = "Encounters"; // + // GB_Tweak + // + this.GB_Tweak.Controls.Add(this.CHK_G7); + this.GB_Tweak.Controls.Add(this.CHK_MegaForm); + this.GB_Tweak.Controls.Add(this.L_RandOpt); + this.GB_Tweak.Controls.Add(this.CHK_BST); + this.GB_Tweak.Controls.Add(this.CHK_E); + this.GB_Tweak.Controls.Add(this.CHK_L); + this.GB_Tweak.Controls.Add(this.CHK_G6); + this.GB_Tweak.Controls.Add(this.CHK_G5); + this.GB_Tweak.Controls.Add(this.CHK_G4); + this.GB_Tweak.Controls.Add(this.CHK_G3); + this.GB_Tweak.Controls.Add(this.CHK_G2); + this.GB_Tweak.Controls.Add(this.CHK_G1); + this.GB_Tweak.Controls.Add(this.B_LevelPlus); + this.GB_Tweak.Controls.Add(this.NUD_LevelAmp); + this.GB_Tweak.Controls.Add(this.CHK_Level); + this.GB_Tweak.Location = new System.Drawing.Point(14, 427); + this.GB_Tweak.Name = "GB_Tweak"; + this.GB_Tweak.Size = new System.Drawing.Size(282, 120); + this.GB_Tweak.TabIndex = 507; + this.GB_Tweak.TabStop = false; + this.GB_Tweak.Text = "Extra Randomization Tweaks"; + // + // CHK_G7 + // + this.CHK_G7.AutoSize = true; + this.CHK_G7.Checked = true; + this.CHK_G7.CheckState = System.Windows.Forms.CheckState.Checked; + this.CHK_G7.Location = new System.Drawing.Point(33, 97); + this.CHK_G7.Name = "CHK_G7"; + this.CHK_G7.Size = new System.Drawing.Size(55, 17); + this.CHK_G7.TabIndex = 296; + this.CHK_G7.Text = "Gen 7"; + this.CHK_G7.UseVisualStyleBackColor = true; + // + // CHK_MegaForm + // + this.CHK_MegaForm.AutoSize = true; + this.CHK_MegaForm.Location = new System.Drawing.Point(152, 97); + this.CHK_MegaForm.Name = "CHK_MegaForm"; + this.CHK_MegaForm.Size = new System.Drawing.Size(127, 17); + this.CHK_MegaForm.TabIndex = 295; + this.CHK_MegaForm.Text = "Random Mega Forms"; + this.CHK_MegaForm.UseVisualStyleBackColor = true; + // + // L_RandOpt + // + this.L_RandOpt.AutoSize = true; + this.L_RandOpt.Location = new System.Drawing.Point(30, 34); + this.L_RandOpt.Name = "L_RandOpt"; + this.L_RandOpt.Size = new System.Drawing.Size(105, 13); + this.L_RandOpt.TabIndex = 294; + this.L_RandOpt.Text = "Randomizer Options:"; + // + // CHK_BST + // + this.CHK_BST.AutoSize = true; + this.CHK_BST.Location = new System.Drawing.Point(152, 82); + this.CHK_BST.Name = "CHK_BST"; + this.CHK_BST.Size = new System.Drawing.Size(117, 17); + this.CHK_BST.TabIndex = 288; + this.CHK_BST.Text = "Randomize by BST"; + this.CHK_BST.UseVisualStyleBackColor = true; + // + // CHK_E + // + this.CHK_E.AutoSize = true; + this.CHK_E.Checked = true; + this.CHK_E.CheckState = System.Windows.Forms.CheckState.Checked; + this.CHK_E.Location = new System.Drawing.Point(152, 67); + this.CHK_E.Name = "CHK_E"; + this.CHK_E.Size = new System.Drawing.Size(98, 17); + this.CHK_E.TabIndex = 287; + this.CHK_E.Text = "Event Legends"; + this.CHK_E.UseVisualStyleBackColor = true; + // + // CHK_L + // + this.CHK_L.AutoSize = true; + this.CHK_L.Checked = true; + this.CHK_L.CheckState = System.Windows.Forms.CheckState.Checked; + this.CHK_L.Location = new System.Drawing.Point(152, 52); + this.CHK_L.Name = "CHK_L"; + this.CHK_L.Size = new System.Drawing.Size(98, 17); + this.CHK_L.TabIndex = 286; + this.CHK_L.Text = "Game Legends"; + this.CHK_L.UseVisualStyleBackColor = true; + // + // CHK_G6 + // + this.CHK_G6.AutoSize = true; + this.CHK_G6.Checked = true; + this.CHK_G6.CheckState = System.Windows.Forms.CheckState.Checked; + this.CHK_G6.Location = new System.Drawing.Point(91, 82); + this.CHK_G6.Name = "CHK_G6"; + this.CHK_G6.Size = new System.Drawing.Size(55, 17); + this.CHK_G6.TabIndex = 285; + this.CHK_G6.Text = "Gen 6"; + this.CHK_G6.UseVisualStyleBackColor = true; + // + // CHK_G5 + // + this.CHK_G5.AutoSize = true; + this.CHK_G5.Checked = true; + this.CHK_G5.CheckState = System.Windows.Forms.CheckState.Checked; + this.CHK_G5.Location = new System.Drawing.Point(91, 67); + this.CHK_G5.Name = "CHK_G5"; + this.CHK_G5.Size = new System.Drawing.Size(55, 17); + this.CHK_G5.TabIndex = 284; + this.CHK_G5.Text = "Gen 5"; + this.CHK_G5.UseVisualStyleBackColor = true; + // + // CHK_G4 + // + this.CHK_G4.AutoSize = true; + this.CHK_G4.Checked = true; + this.CHK_G4.CheckState = System.Windows.Forms.CheckState.Checked; + this.CHK_G4.Location = new System.Drawing.Point(91, 52); + this.CHK_G4.Name = "CHK_G4"; + this.CHK_G4.Size = new System.Drawing.Size(55, 17); + this.CHK_G4.TabIndex = 283; + this.CHK_G4.Text = "Gen 4"; + this.CHK_G4.UseVisualStyleBackColor = true; + // + // CHK_G3 + // + this.CHK_G3.AutoSize = true; + this.CHK_G3.Checked = true; + this.CHK_G3.CheckState = System.Windows.Forms.CheckState.Checked; + this.CHK_G3.Location = new System.Drawing.Point(33, 82); + this.CHK_G3.Name = "CHK_G3"; + this.CHK_G3.Size = new System.Drawing.Size(55, 17); + this.CHK_G3.TabIndex = 282; + this.CHK_G3.Text = "Gen 3"; + this.CHK_G3.UseVisualStyleBackColor = true; + // + // CHK_G2 + // + this.CHK_G2.AutoSize = true; + this.CHK_G2.Checked = true; + this.CHK_G2.CheckState = System.Windows.Forms.CheckState.Checked; + this.CHK_G2.Location = new System.Drawing.Point(33, 67); + this.CHK_G2.Name = "CHK_G2"; + this.CHK_G2.Size = new System.Drawing.Size(55, 17); + this.CHK_G2.TabIndex = 281; + this.CHK_G2.Text = "Gen 2"; + this.CHK_G2.UseVisualStyleBackColor = true; + // + // CHK_G1 + // + this.CHK_G1.AutoSize = true; + this.CHK_G1.Checked = true; + this.CHK_G1.CheckState = System.Windows.Forms.CheckState.Checked; + this.CHK_G1.Location = new System.Drawing.Point(33, 52); + this.CHK_G1.Name = "CHK_G1"; + this.CHK_G1.Size = new System.Drawing.Size(55, 17); + this.CHK_G1.TabIndex = 280; + this.CHK_G1.Text = "Gen 1"; + this.CHK_G1.UseVisualStyleBackColor = true; + // + // B_LevelPlus + // + this.B_LevelPlus.Location = new System.Drawing.Point(199, 14); + this.B_LevelPlus.Name = "B_LevelPlus"; + this.B_LevelPlus.Size = new System.Drawing.Size(70, 23); + this.B_LevelPlus.TabIndex = 277; + this.B_LevelPlus.Text = "+/- Current"; + this.B_LevelPlus.UseVisualStyleBackColor = true; + this.B_LevelPlus.Click += new System.EventHandler(this.modifyLevels); + // + // NUD_LevelAmp + // + this.NUD_LevelAmp.Location = new System.Drawing.Point(152, 16); + this.NUD_LevelAmp.Minimum = new decimal(new int[] { + 75, + 0, + 0, + -2147483648}); + this.NUD_LevelAmp.Name = "NUD_LevelAmp"; + this.NUD_LevelAmp.Size = new System.Drawing.Size(41, 20); + this.NUD_LevelAmp.TabIndex = 276; + this.NUD_LevelAmp.Value = new decimal(new int[] { + 50, + 0, + 0, + 0}); + // + // CHK_Level + // + this.CHK_Level.AutoSize = true; + this.CHK_Level.Location = new System.Drawing.Point(33, 17); + this.CHK_Level.Name = "CHK_Level"; + this.CHK_Level.Size = new System.Drawing.Size(122, 17); + this.CHK_Level.TabIndex = 279; + this.CHK_Level.Text = "Modify All Levels (%)"; + this.CHK_Level.UseVisualStyleBackColor = true; + // // PB_NightIcon // this.PB_NightIcon.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; @@ -2814,6 +3032,9 @@ private void InitializeComponent() ((System.ComponentModel.ISupportInitialize)(this.NUP_Max)).EndInit(); this.GB_Encounters.ResumeLayout(false); this.GB_Encounters.PerformLayout(); + this.GB_Tweak.ResumeLayout(false); + this.GB_Tweak.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.NUD_LevelAmp)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.PB_NightIcon)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.PB_DayIcon)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.NUP_WeatherForme6)).EndInit(); @@ -3120,5 +3341,21 @@ private void InitializeComponent() private System.Windows.Forms.Label L_AddSOS; private System.Windows.Forms.PictureBox PB_NightIcon; private System.Windows.Forms.PictureBox PB_DayIcon; + private System.Windows.Forms.GroupBox GB_Tweak; + private System.Windows.Forms.CheckBox CHK_G7; + private System.Windows.Forms.CheckBox CHK_MegaForm; + private System.Windows.Forms.Label L_RandOpt; + private System.Windows.Forms.CheckBox CHK_BST; + private System.Windows.Forms.CheckBox CHK_E; + private System.Windows.Forms.CheckBox CHK_L; + private System.Windows.Forms.CheckBox CHK_G6; + private System.Windows.Forms.CheckBox CHK_G5; + private System.Windows.Forms.CheckBox CHK_G4; + private System.Windows.Forms.CheckBox CHK_G3; + private System.Windows.Forms.CheckBox CHK_G2; + private System.Windows.Forms.CheckBox CHK_G1; + private System.Windows.Forms.Button B_LevelPlus; + private System.Windows.Forms.NumericUpDown NUD_LevelAmp; + private System.Windows.Forms.CheckBox CHK_Level; } } \ No newline at end of file diff --git a/pk3DS/Subforms/Gen7/SMWE.cs b/pk3DS/Subforms/Gen7/SMWE.cs index b9e5a6d..7f60e25 100644 --- a/pk3DS/Subforms/Gen7/SMWE.cs +++ b/pk3DS/Subforms/Gen7/SMWE.cs @@ -204,7 +204,7 @@ public void LoadData(string dir) { ctrl.Enabled = true; } - B_Randomize.Enabled = false; // TODO: Randomization + B_Randomize.Enabled = true; // Randomization: complete CB_LocationID.SelectedIndex = 0; @@ -562,5 +562,112 @@ public override string ToString() return sb.ToString(); } } + + private void modifyLevels(object sender, EventArgs e) + { + // Disable Interface while modifying + Enabled = false; + + // Calculate % diff we will apply to each level + decimal leveldiff = (100 + NUD_LevelAmp.Value) / 100; + + // Cycle through each location to modify levels + foreach (var Map in Areas) + { + foreach (var Table in Map.Tables) + { + Table.MinLevel = Math.Max(1, Math.Min(100, (int)(leveldiff * Table.MinLevel))); + Table.MaxLevel = Math.Max(1, Math.Min(100, (int)(leveldiff * Table.MaxLevel))); + Table.Write(); + } + } + // Enable Interface... modification complete. + Enabled = true; + + updatePanel(sender, e); + } + + internal static Random rand = new Random(); + internal static uint rnd32() + { + return (uint)rand.Next(1 << 30) << 2 | (uint)rand.Next(1 << 2); + } + + + // Randomization + private void B_Randomize_Click(object sender, EventArgs e) + { + if (Util.Prompt(MessageBoxButtons.YesNo, "Randomize all? Cannot undo.", "Double check Randomization settings @ Horde Tab.") != DialogResult.Yes) return; + + Enabled = false; + + // Calculate % diff we will apply to each level + decimal leveldiff = (100 + NUD_LevelAmp.Value) / 100; + + // Nonrepeating List Start + int[] sL = Randomizer.getSpeciesList(CHK_G1.Checked, CHK_G2.Checked, CHK_G3.Checked, + CHK_G4.Checked, CHK_G5.Checked, CHK_G6.Checked, CHK_G7.Checked, CHK_L.Checked, CHK_E.Checked); + + int ctr = 0; + + foreach (var Map in Areas) + { + foreach (var Table in Map.Tables) + { + if (CHK_Level.Checked) + { + Table.MinLevel = Math.Max(1, Math.Min(100, (int)(leveldiff * Table.MinLevel))); + Table.MaxLevel = Math.Max(1, Math.Min(100, (int)(leveldiff * Table.MaxLevel))); + } + + foreach (var EncounterSet in Table.Encounters) + { + foreach (var encounter in EncounterSet) + { + if (encounter.Species != 0) // Only modify slots that're used. + { + if (!CHK_BST.Checked) + encounter.Species = (uint) Randomizer.getRandomSpecies(ref sL, ref ctr); + else + { + var old_ind = Main.SpeciesStat[encounter.Species].FormeIndex((int)encounter.Species, (int)encounter.Forme); + int oldBST = Main.SpeciesStat[old_ind].BST; + + int species = Randomizer.getRandomSpecies(ref sL, ref ctr); + int newBST = Main.SpeciesStat[species].BST; + while (!(newBST*4/5 < oldBST && newBST*6/5 > oldBST)) + { + species = Randomizer.getRandomSpecies(ref sL, ref ctr); + newBST = Main.SpeciesStat[species].BST;; + } + encounter.Species = (uint)species; + } + encounter.Forme = (uint)GetRandomForme((int)encounter.Species); + } + } + } + + Table.Write(); + } + } + updatePanel(sender, e); + Enabled = true; + Util.Alert("Randomized!"); + } + + public int GetRandomForme(int species) + { + if (Main.SpeciesStat[species].FormeCount > 1) + { + if (Legal.Mega_ORAS.Contains((ushort)species)) + if (CHK_MegaForm.Checked) + return (int) rnd32()%Main.SpeciesStat[species].FormeCount; // Slot-Random + else + return 0; + return (int)rnd32() % Main.SpeciesStat[species].FormeCount; // Slot-Random + + } + return 0; + } } }