From ed34f245db6ab0001d3edbaa6231eced7dc05c04 Mon Sep 17 00:00:00 2001 From: sora10pls Date: Wed, 23 Sep 2020 12:26:35 -0400 Subject: [PATCH] =?UTF-8?q?Add=20every=20level=20evolution=20randomizer=20?= =?UTF-8?q?Every=20new=20level=20up=20grants=20an=20evolution=20to=20the?= =?UTF-8?q?=20Pok=C3=A9mon.=20Makes=20for=20an=20incredibly=20varied=20pla?= =?UTF-8?q?ythrough!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Randomizers/EvolutionRandomizer.cs | 34 +++++ pkNX.Structures/Evolution/EvolutionMethod.cs | 2 +- pkNX.WinForms/Subforms/PokeDataUI.Designer.cs | 141 ++++++++++-------- pkNX.WinForms/Subforms/PokeDataUI.cs | 24 +++ 4 files changed, 136 insertions(+), 65 deletions(-) diff --git a/pkNX.Randomization/Randomizers/EvolutionRandomizer.cs b/pkNX.Randomization/Randomizers/EvolutionRandomizer.cs index 4bfa88b7..40faf496 100644 --- a/pkNX.Randomization/Randomizers/EvolutionRandomizer.cs +++ b/pkNX.Randomization/Randomizers/EvolutionRandomizer.cs @@ -27,6 +27,8 @@ public override void Execute() for (var i = 0; i < Evolutions.Length; i++) { var evo = Evolutions[i]; + if (Personal[i].HP == 0) + continue; Randomize(evo, i); } } @@ -40,6 +42,17 @@ public void ExecuteTrade() } } + public void ExecuteEvolveEveryLevel() + { + for (var i = 0; i < Evolutions.Length; i++) + { + var evo = Evolutions[i]; + if (Personal[i].HP == 0) + continue; + MakeEvolveEveryLevel(evo, i); + } + } + private void Randomize(EvolutionSet evos, int species) { foreach (var evo in evos.PossibleEvolutions) @@ -98,5 +111,26 @@ private void ReplaceTradeMethod(EvolutionMethod evo, int species, int evoIndex) return; } } + + private void MakeEvolveEveryLevel(EvolutionSet evos, int species) + { + var evoSet = evos.PossibleEvolutions; + var evoNew = new EvolutionMethod() + { + Argument = 0, // clear + Form = 0, // randomized later + Level = 1, + Method = EvolutionType.LevelUp, + Species = species, // randomized later + }; + + evoSet[0] = evoNew; + + if (evoSet[1].HasData) // has other branched evolutions; remove them + { + for (int i = 1; i < evoSet.Length; i++) + evoSet[i] = new EvolutionMethod(); + } + } } } \ No newline at end of file diff --git a/pkNX.Structures/Evolution/EvolutionMethod.cs b/pkNX.Structures/Evolution/EvolutionMethod.cs index 64fc6863..6cc3cc82 100644 --- a/pkNX.Structures/Evolution/EvolutionMethod.cs +++ b/pkNX.Structures/Evolution/EvolutionMethod.cs @@ -8,7 +8,7 @@ public class EvolutionMethod public EvolutionType Method; public int Species; public int Argument; - public int Form = -1; + public int Form; public int Level; public EvolutionMethod Copy(int species = -1) diff --git a/pkNX.WinForms/Subforms/PokeDataUI.Designer.cs b/pkNX.WinForms/Subforms/PokeDataUI.Designer.cs index dc2630b5..947128d4 100644 --- a/pkNX.WinForms/Subforms/PokeDataUI.Designer.cs +++ b/pkNX.WinForms/Subforms/PokeDataUI.Designer.cs @@ -31,6 +31,12 @@ private void InitializeComponent() this.B_Save = new System.Windows.Forms.Button(); this.tabControl1 = new System.Windows.Forms.TabControl(); this.Tab_Personal = new System.Windows.Forms.TabPage(); + this.TB_CrownDex = new System.Windows.Forms.TextBox(); + this.L_CrownDex = new System.Windows.Forms.Label(); + this.TB_RegionalDex = new System.Windows.Forms.TextBox(); + this.TB_ArmorDex = new System.Windows.Forms.TextBox(); + this.L_ArmorDex = new System.Windows.Forms.Label(); + this.L_RegionalDex = new System.Windows.Forms.Label(); this.GB_ZMove = new System.Windows.Forms.GroupBox(); this.L_ZCrystal = new System.Windows.Forms.Label(); this.L_BaseMove = new System.Windows.Forms.Label(); @@ -140,16 +146,11 @@ private void InitializeComponent() this.B_LearnExpand = new System.Windows.Forms.Button(); this.B_RandLearn = new System.Windows.Forms.Button(); this.Tab_REvo = new System.Windows.Forms.TabPage(); + this.B_EveryLevel = new System.Windows.Forms.Button(); this.B_TradeEvo = new System.Windows.Forms.Button(); this.B_RandEvo = new System.Windows.Forms.Button(); this.PG_Evolution = new System.Windows.Forms.PropertyGrid(); this.CB_Species = new System.Windows.Forms.ComboBox(); - this.L_ArmorDex = new System.Windows.Forms.Label(); - this.L_RegionalDex = new System.Windows.Forms.Label(); - this.TB_RegionalDex = new System.Windows.Forms.TextBox(); - this.TB_ArmorDex = new System.Windows.Forms.TextBox(); - this.TB_CrownDex = new System.Windows.Forms.TextBox(); - this.L_CrownDex = new System.Windows.Forms.Label(); this.tabControl1.SuspendLayout(); this.Tab_Personal.SuspendLayout(); this.GB_ZMove.SuspendLayout(); @@ -287,6 +288,63 @@ private void InitializeComponent() this.Tab_Personal.Text = "Personal"; this.Tab_Personal.UseVisualStyleBackColor = true; // + // TB_CrownDex + // + this.TB_CrownDex.Location = new System.Drawing.Point(405, 552); + this.TB_CrownDex.Name = "TB_CrownDex"; + this.TB_CrownDex.ReadOnly = true; + this.TB_CrownDex.Size = new System.Drawing.Size(32, 20); + this.TB_CrownDex.TabIndex = 511; + this.TB_CrownDex.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; + // + // L_CrownDex + // + this.L_CrownDex.AutoSize = true; + this.L_CrownDex.Location = new System.Drawing.Point(343, 556); + this.L_CrownDex.Name = "L_CrownDex"; + this.L_CrownDex.Size = new System.Drawing.Size(62, 13); + this.L_CrownDex.TabIndex = 510; + this.L_CrownDex.Text = "Crown Dex:"; + this.L_CrownDex.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + // + // TB_RegionalDex + // + this.TB_RegionalDex.Location = new System.Drawing.Point(405, 510); + this.TB_RegionalDex.Name = "TB_RegionalDex"; + this.TB_RegionalDex.ReadOnly = true; + this.TB_RegionalDex.Size = new System.Drawing.Size(32, 20); + this.TB_RegionalDex.TabIndex = 509; + this.TB_RegionalDex.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; + // + // TB_ArmorDex + // + this.TB_ArmorDex.Location = new System.Drawing.Point(405, 531); + this.TB_ArmorDex.Name = "TB_ArmorDex"; + this.TB_ArmorDex.ReadOnly = true; + this.TB_ArmorDex.Size = new System.Drawing.Size(32, 20); + this.TB_ArmorDex.TabIndex = 508; + this.TB_ArmorDex.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; + // + // L_ArmorDex + // + this.L_ArmorDex.AutoSize = true; + this.L_ArmorDex.Location = new System.Drawing.Point(346, 535); + this.L_ArmorDex.Name = "L_ArmorDex"; + this.L_ArmorDex.Size = new System.Drawing.Size(59, 13); + this.L_ArmorDex.TabIndex = 507; + this.L_ArmorDex.Text = "Armor Dex:"; + this.L_ArmorDex.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + // + // L_RegionalDex + // + this.L_RegionalDex.AutoSize = true; + this.L_RegionalDex.Location = new System.Drawing.Point(331, 513); + this.L_RegionalDex.Name = "L_RegionalDex"; + this.L_RegionalDex.Size = new System.Drawing.Size(74, 13); + this.L_RegionalDex.TabIndex = 506; + this.L_RegionalDex.Text = "Regional Dex:"; + this.L_RegionalDex.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + // // GB_ZMove // this.GB_ZMove.Controls.Add(this.L_ZCrystal); @@ -1376,6 +1434,7 @@ private void InitializeComponent() // // Tab_REvo // + this.Tab_REvo.Controls.Add(this.B_EveryLevel); this.Tab_REvo.Controls.Add(this.B_TradeEvo); this.Tab_REvo.Controls.Add(this.B_RandEvo); this.Tab_REvo.Controls.Add(this.PG_Evolution); @@ -1386,11 +1445,21 @@ private void InitializeComponent() this.Tab_REvo.Text = "Randomize Evo"; this.Tab_REvo.UseVisualStyleBackColor = true; // + // B_EveryLevel + // + this.B_EveryLevel.Location = new System.Drawing.Point(241, 3); + this.B_EveryLevel.Name = "B_EveryLevel"; + this.B_EveryLevel.Size = new System.Drawing.Size(168, 23); + this.B_EveryLevel.TabIndex = 5; + this.B_EveryLevel.Text = "Random Evolution Every Level"; + this.B_EveryLevel.UseVisualStyleBackColor = true; + this.B_EveryLevel.Click += new System.EventHandler(this.B_EvolveEveryLevel_Click); + // // B_TradeEvo // this.B_TradeEvo.Location = new System.Drawing.Point(87, 3); this.B_TradeEvo.Name = "B_TradeEvo"; - this.B_TradeEvo.Size = new System.Drawing.Size(180, 23); + this.B_TradeEvo.Size = new System.Drawing.Size(148, 23); this.B_TradeEvo.TabIndex = 4; this.B_TradeEvo.Text = "Replace Trade Evolutions"; this.B_TradeEvo.UseVisualStyleBackColor = true; @@ -1428,63 +1497,6 @@ private void InitializeComponent() this.CB_Species.TabIndex = 2; this.CB_Species.SelectedIndexChanged += new System.EventHandler(this.UpdateIndex); // - // L_ArmorDex - // - this.L_ArmorDex.AutoSize = true; - this.L_ArmorDex.Location = new System.Drawing.Point(346, 535); - this.L_ArmorDex.Name = "L_ArmorDex"; - this.L_ArmorDex.Size = new System.Drawing.Size(59, 13); - this.L_ArmorDex.TabIndex = 507; - this.L_ArmorDex.Text = "Armor Dex:"; - this.L_ArmorDex.TextAlign = System.Drawing.ContentAlignment.MiddleRight; - // - // L_RegionalDex - // - this.L_RegionalDex.AutoSize = true; - this.L_RegionalDex.Location = new System.Drawing.Point(331, 513); - this.L_RegionalDex.Name = "L_RegionalDex"; - this.L_RegionalDex.Size = new System.Drawing.Size(74, 13); - this.L_RegionalDex.TabIndex = 506; - this.L_RegionalDex.Text = "Regional Dex:"; - this.L_RegionalDex.TextAlign = System.Drawing.ContentAlignment.MiddleRight; - // - // TB_RegionalDex - // - this.TB_RegionalDex.Location = new System.Drawing.Point(405, 510); - this.TB_RegionalDex.Name = "TB_RegionalDex"; - this.TB_RegionalDex.ReadOnly = true; - this.TB_RegionalDex.Size = new System.Drawing.Size(32, 20); - this.TB_RegionalDex.TabIndex = 509; - this.TB_RegionalDex.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; - // - // TB_ArmorDex - // - this.TB_ArmorDex.Location = new System.Drawing.Point(405, 531); - this.TB_ArmorDex.Name = "TB_ArmorDex"; - this.TB_ArmorDex.ReadOnly = true; - this.TB_ArmorDex.Size = new System.Drawing.Size(32, 20); - this.TB_ArmorDex.TabIndex = 508; - this.TB_ArmorDex.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; - // - // TB_CrownDex - // - this.TB_CrownDex.Location = new System.Drawing.Point(405, 552); - this.TB_CrownDex.Name = "TB_CrownDex"; - this.TB_CrownDex.ReadOnly = true; - this.TB_CrownDex.Size = new System.Drawing.Size(32, 20); - this.TB_CrownDex.TabIndex = 511; - this.TB_CrownDex.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; - // - // L_CrownDex - // - this.L_CrownDex.AutoSize = true; - this.L_CrownDex.Location = new System.Drawing.Point(343, 556); - this.L_CrownDex.Name = "L_CrownDex"; - this.L_CrownDex.Size = new System.Drawing.Size(62, 13); - this.L_CrownDex.TabIndex = 510; - this.L_CrownDex.Text = "Crown Dex:"; - this.L_CrownDex.TextAlign = System.Drawing.ContentAlignment.MiddleRight; - // // PokeDataUI // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -1645,5 +1657,6 @@ private void InitializeComponent() private System.Windows.Forms.TextBox TB_ArmorDex; private System.Windows.Forms.TextBox TB_CrownDex; private System.Windows.Forms.Label L_CrownDex; + private System.Windows.Forms.Button B_EveryLevel; } } \ No newline at end of file diff --git a/pkNX.WinForms/Subforms/PokeDataUI.cs b/pkNX.WinForms/Subforms/PokeDataUI.cs index 0fea5ed7..708fb239 100644 --- a/pkNX.WinForms/Subforms/PokeDataUI.cs +++ b/pkNX.WinForms/Subforms/PokeDataUI.cs @@ -527,6 +527,30 @@ private void B_TradeEvo_Click(object sender, EventArgs e) System.Media.SystemSounds.Asterisk.Play(); } + private void B_EvolveEveryLevel_Click(object sender, EventArgs e) + { + SaveCurrent(); + var settings = (SpeciesSettings)PG_Evolution.SelectedObject; + if (ROM.Info.GG) + settings.Gen2 = settings.Gen3 = settings.Gen4 = settings.Gen5 = settings.Gen6 = settings.Gen7 = settings.Gen8 = false; + var rand = new EvolutionRandomizer(ROM.Info, Editor.Evolve.LoadAll(), Editor.Personal); + int[] ban = Array.Empty(); + + if (ROM.Info.SWSH) + { + var pt = ROM.Data.PersonalData; + ban = pt.Table.Take(ROM.Info.MaxSpeciesID + 1) + .Select((z, i) => new {Species = i, Present = ((PersonalInfoSWSH)z).IsPresentInGame}) + .Where(z => !z.Present).Select(z => z.Species).ToArray(); + } + + rand.RandSpec.Initialize(settings, ban); + rand.ExecuteEvolveEveryLevel(); + rand.Execute(); // randomize right after + LoadIndex(CB_Species.SelectedIndex); + System.Media.SystemSounds.Asterisk.Play(); + } + private void B_RandLearn_Click(object sender, EventArgs e) { SaveCurrent();