diff --git a/pk3DS/Main.cs b/pk3DS/Main.cs index 6dbccb3..1ecacb6 100644 --- a/pk3DS/Main.cs +++ b/pk3DS/Main.cs @@ -269,6 +269,12 @@ private void B_Wild_Click(object sender, EventArgs e) if (threads > 0) { Util.Alert("Please wait for all operations to finish first."); return; } new Thread(() => { + string personal = "personal"; + string personalGARC = getGARCFileName(personal); + threadGet(RomFS + personalGARC, personal, true, true); + while (threads > 0) // Let threads complete + Thread.Sleep(50); + string encdata = "encdata"; string encdataGARC = getGARCFileName(encdata); threadGet(RomFS + encdataGARC, encdata, true, false); @@ -566,6 +572,15 @@ private void formClosing(object sender, FormClosingEventArgs e) } private void L_About_Click(object sender, EventArgs e) { + if (ModifierKeys == Keys.Control && RomFS != null) + { + string s = "Game Type: " + ((oras) ? "ORAS" : "XY") + Environment.NewLine ; + for (int i = 0; i < allGARCs.Length; i++) + s += String.Format(Environment.NewLine + "{0} - {1}", allGARCs[i], getGARCFileName(allGARCs[i])); + if (DialogResult.Yes == Util.Prompt(MessageBoxButtons.YesNo, s, "Copy to Clipboard?")) + try { Clipboard.SetText(s); } catch { Util.Alert("Unable to copy to Clipboard."); } + } + else Util.Alert( "pk3DS: A package of Pokémon X/Y/OR/AS tools by various contributors.", "GARCTool (Backbone): Kaphotics" + Environment.NewLine + @@ -574,8 +589,7 @@ private void L_About_Click(object sender, EventArgs e) "Trainer Editor (**TE): SciresM, Kaphotics, and KazoWAR" + Environment.NewLine + "Personal Editor: SciresM" + Environment.NewLine + "Mega Evolution Editor (MEE): Huntereb & SciresM" + Environment.NewLine + - "Evolutions, Moves, and Maison Editor: Kaphotics" + Environment.NewLine + - "Item Editor and more have yet to be implemented.", + "Evolutions, Moves, Items, ExeFS, and Maison Editor: Kaphotics" + Environment.NewLine + "Big thanks to the ProjectPokemon community!"); } diff --git a/pk3DS/Subforms/Personal.cs b/pk3DS/Subforms/Personal.cs index e71dd8b..eefa192 100644 --- a/pk3DS/Subforms/Personal.cs +++ b/pk3DS/Subforms/Personal.cs @@ -26,7 +26,6 @@ public Personal() L_Mode.Text = "Mode: " + mode; Setup(); //Turn string resources into arrays CB_Species.SelectedIndex = 1; - // debugScan(); } #region Global Variables private string[] paths = Directory.GetFiles("personal", "*.*", SearchOption.TopDirectoryOnly); @@ -151,20 +150,6 @@ private void Setup() foreach (string eg in EXPGroups) CB_EXPGroup.Items.Add(eg); } - private void debugScan() - { - // Scan for TM usage - int TMs = 0; - int Species = 721; - for (int i = 1; i < 722; i++) - { - // Check Each for TMs - CB_Species.SelectedIndex = i; - for (int t = 0; t < CLB_TMHM.Items.Count; t++) - TMs += (CLB_TMHM.GetItemChecked(t)) ? 1 : 0; - } - float avg = (float)TMs / (float)Species; - } private void CB_Species_SelectedIndexChanged(object sender, EventArgs e) { @@ -440,24 +425,40 @@ private void B_Randomize_Click(object sender, EventArgs e) for (int t = 0; t < CLB_TMHM.Items.Count; t++) CLB_TMHM.SetItemChecked(t, rnd.Next(0, 100) < TMPercent); - // Fiddle with Base Stats - for (int z = 0; z < 6; z++) - byte_boxes[z].Text = (Math.Min(rnd.Next(1, 2 * Convert.ToByte(byte_boxes[z].Text)),255)).ToString("000"); - - // EV yield stays the same... // Abilities: + int[] abils = new int[3]; + for (int a = 0; a < 3; a++) // Get 3 New Abilities, none being Wonder Guard (25) + { int newabil = rnd.Next(1, abillen); while (newabil == 25) newabil = rnd.Next(1, abillen); abils[a] = newabil; } CB_Ability1.SelectedIndex = rnd.Next(1, abillen); CB_Ability2.SelectedIndex = rnd.Next(1, abillen); CB_Ability3.SelectedIndex = rnd.Next(1, abillen); + + // Fiddle with Base Stats, don't muck with Shedinja. + if (Convert.ToByte(byte_boxes[0].Text) == 1) + CB_Ability1.SelectedIndex = CB_Ability2.SelectedIndex = CB_Ability3.SelectedIndex = 25; + else + for (int z = 0; z < 6; z++) + byte_boxes[z].Text = + Math.Max( + 5, + rnd.Next + ( + Convert.ToByte(byte_boxes[z].Text) * 3 / 4, + (byte)Convert.ToByte(byte_boxes[z].Text) * 5 / 4) + ) + .ToString("000"); + + // EV yield stays the same... + // Items CB_HeldItem1.SelectedIndex = (CB_HeldItem1.SelectedIndex > 0) ? itemlist[rnd.Next(1, itemlen)] : 0; CB_HeldItem2.SelectedIndex = (CB_HeldItem2.SelectedIndex > 0) ? itemlist[rnd.Next(1, itemlen)] : 0; CB_HeldItem3.SelectedIndex = (CB_HeldItem3.SelectedIndex > 0) ? itemlist[rnd.Next(1, itemlen)] : 0; // Type - if (CB_Type1.SelectedIndex == CB_Type2.SelectedIndex) + if (rnd.Next(0,100) < 50) // 50% chance to have either Single or Dual Typing CB_Type1.SelectedIndex = CB_Type2.SelectedIndex = rnd.Next(0, typelen); else { diff --git a/pk3DS/Subforms/RSTE.cs b/pk3DS/Subforms/RSTE.cs index 1e3ad21..65cef88 100644 --- a/pk3DS/Subforms/RSTE.cs +++ b/pk3DS/Subforms/RSTE.cs @@ -515,7 +515,7 @@ private void Setup() System.Media.SystemSounds.Asterisk.Play(); } - public static bool rPKM, rMove, rAbility, rDiffAI, rDiffIV, rClass, rGift, rItem, rDoRand; + public static bool rPKM, rSmart, rMove, rAbility, rDiffAI, rDiffIV, rClass, rGift, rItem, rDoRand; public static decimal rGiftPercent; private void B_Randomize_Click(object sender, EventArgs e) { @@ -573,12 +573,19 @@ private void Randomize() if (rPKM) { // randomize pokemon - int species = (int)(rnd32() % 722); + int species = (int)(rand.Next(1, 722)); + if (rSmart) // Get a new Pokemon with a close BST + { + int oldBST = personal[trpk_pkm[p].SelectedIndex].Take(6).Sum(b => (ushort)b); + int newBST = personal[species].Take(6).Sum(b => (ushort)b); + while (!(newBST * 5 / 6 < oldBST && newBST * 6 / 5 > oldBST)) + { species = rand.Next(1, 722); newBST = personal[species].Take(6).Sum(b => (ushort)b); } + } trpk_pkm[p].SelectedIndex = species; // Set Gender to Random trpk_gender[p].SelectedIndex = 0; - // randomize form + // Randomize form trpk_form[p].SelectedIndex = (int)(rnd32() % trpk_form[p].Items.Count); } if (rAbility) diff --git a/pk3DS/Subforms/RSWE.cs b/pk3DS/Subforms/RSWE.cs index 186bf41..baa476c 100644 --- a/pk3DS/Subforms/RSWE.cs +++ b/pk3DS/Subforms/RSWE.cs @@ -270,6 +270,13 @@ public RSWE() }; RSWE_Load(null, null); openQuick(Directory.GetFiles("encdata")); + + string[] personalList = Directory.GetFiles("personal"); + personalData = File.ReadAllBytes(personalList[personalList.Length - 1]); + indexList = Personal.getPersonalIndexList(personalData, Main.oras); + personal = new byte[personalList.Length][]; + for (int i = 0; i < personalList.Length; i++) + personal[i] = File.ReadAllBytes("personal" + Path.DirectorySeparatorChar + i.ToString("000") + ".bin"); } private ComboBox[] spec; private NumericUpDown[] min; @@ -284,6 +291,10 @@ public RSWE() private string[] encdatapaths; private string[] filepaths; + byte[] personalData; + ushort[] indexList; + byte[][] personal; + private void RSWE_Load(object sender, EventArgs e) { specieslist = Main.getText((Main.oras) ? 98 : 80); @@ -573,6 +584,7 @@ private void B_Randomize_Click(object sender, EventArgs e) { if (Util.Prompt(MessageBoxButtons.YesNo, "Randomize all?", "Cannot undo.") == DialogResult.Yes) { + bool smart = Util.Prompt(MessageBoxButtons.YesNo, "Smart Randomize by Base Stat Total?", "Pokemon strength variance will attempt to match ingame.") == DialogResult.Yes; this.Enabled = false; // Nonrepeating List Start @@ -587,8 +599,25 @@ private void B_Randomize_Click(object sender, EventArgs e) // Get a new list of Pokemon so that DexNav does not crash. int[] RandomList = new int[18]; // Fill Location List - for (int z = 0; z < 18; z++) - RandomList[z] = Randomizer.getRandomSpecies(ref sL, ref ctr); + if (!smart) + for (int z = 0; z < 18; z++) + RandomList[z] = Randomizer.getRandomSpecies(ref sL, ref ctr); + else + { + int oldBST = 0; + for (int s = 0; s < max.Length; s++) + if (spec[s].SelectedIndex > 0) + { oldBST = personal[spec[s + 2].SelectedIndex].Take(6).Sum(b => (ushort)b); break; } + + for (int z = 0; z < 18; z++) + { + int species = Randomizer.getRandomSpecies(ref sL, ref ctr); + int newBST = personal[species].Take(6).Sum(b => (ushort)b); + while (!(newBST * 4 / 5 < oldBST && newBST * 6 / 5 > oldBST)) + { species = rand.Next(1, 722); newBST = personal[species].Take(6).Sum(b => (ushort)b); } + RandomList[z] = species; + } + } int ctrSingle = 0; for (int slot = 0; slot < max.Length; slot++) @@ -611,7 +640,7 @@ private void B_Randomize_Click(object sender, EventArgs e) else if (species == 422 || species == 423) // Gastrodon form[slot].Value = rnd32() % 2; else if (species == 585 || species == 586) // Sawsbuck - form[slot].Value = rnd32() % 28; + form[slot].Value = rnd32() % 4; else if (species == 669 || species == 671) // Flabebe/Florges form[slot].Value = rnd32() % 5; else if (species == 670) // Floette diff --git a/pk3DS/Subforms/TrainerRand.Designer.cs b/pk3DS/Subforms/TrainerRand.Designer.cs index 251e44c..bcbd9af 100644 --- a/pk3DS/Subforms/TrainerRand.Designer.cs +++ b/pk3DS/Subforms/TrainerRand.Designer.cs @@ -40,6 +40,7 @@ private void InitializeComponent() this.button2 = new System.Windows.Forms.Button(); this.NUD_GiftPercent = new System.Windows.Forms.NumericUpDown(); this.label1 = new System.Windows.Forms.Label(); + this.CHK_Smart = new System.Windows.Forms.CheckBox(); ((System.ComponentModel.ISupportInitialize)(this.NUD_GiftPercent)).BeginInit(); this.SuspendLayout(); // @@ -54,10 +55,13 @@ private void InitializeComponent() this.CHK_RandomPKM.TabIndex = 0; this.CHK_RandomPKM.Text = "Random Pokemon"; this.CHK_RandomPKM.UseVisualStyleBackColor = true; + this.CHK_RandomPKM.CheckedChanged += new System.EventHandler(this.CHK_RandomPKM_CheckedChanged); // // CHK_RandomItems // this.CHK_RandomItems.AutoSize = true; + this.CHK_RandomItems.Checked = true; + this.CHK_RandomItems.CheckState = System.Windows.Forms.CheckState.Checked; this.CHK_RandomItems.Location = new System.Drawing.Point(12, 193); this.CHK_RandomItems.Name = "CHK_RandomItems"; this.CHK_RandomItems.Size = new System.Drawing.Size(119, 17); @@ -70,7 +74,7 @@ private void InitializeComponent() this.CHK_RandomMoves.AutoSize = true; this.CHK_RandomMoves.Checked = true; this.CHK_RandomMoves.CheckState = System.Windows.Forms.CheckState.Checked; - this.CHK_RandomMoves.Location = new System.Drawing.Point(12, 35); + this.CHK_RandomMoves.Location = new System.Drawing.Point(12, 55); this.CHK_RandomMoves.Name = "CHK_RandomMoves"; this.CHK_RandomMoves.Size = new System.Drawing.Size(101, 17); this.CHK_RandomMoves.TabIndex = 2; @@ -82,7 +86,7 @@ private void InitializeComponent() this.CHK_RandomAbilities.AutoSize = true; this.CHK_RandomAbilities.Checked = true; this.CHK_RandomAbilities.CheckState = System.Windows.Forms.CheckState.Checked; - this.CHK_RandomAbilities.Location = new System.Drawing.Point(12, 58); + this.CHK_RandomAbilities.Location = new System.Drawing.Point(12, 78); this.CHK_RandomAbilities.Name = "CHK_RandomAbilities"; this.CHK_RandomAbilities.Size = new System.Drawing.Size(193, 17); this.CHK_RandomAbilities.TabIndex = 3; @@ -92,6 +96,8 @@ private void InitializeComponent() // CHK_RandomGift // this.CHK_RandomGift.AutoSize = true; + this.CHK_RandomGift.Checked = true; + this.CHK_RandomGift.CheckState = System.Windows.Forms.CheckState.Checked; this.CHK_RandomGift.Location = new System.Drawing.Point(12, 170); this.CHK_RandomGift.Name = "CHK_RandomGift"; this.CHK_RandomGift.Size = new System.Drawing.Size(145, 17); @@ -103,6 +109,8 @@ private void InitializeComponent() // CHK_RandomClass // this.CHK_RandomClass.AutoSize = true; + this.CHK_RandomClass.Checked = true; + this.CHK_RandomClass.CheckState = System.Windows.Forms.CheckState.Checked; this.CHK_RandomClass.Location = new System.Drawing.Point(12, 147); this.CHK_RandomClass.Name = "CHK_RandomClass"; this.CHK_RandomClass.Size = new System.Drawing.Size(141, 17); @@ -113,20 +121,21 @@ private void InitializeComponent() // CHK_MaxDiffAI // this.CHK_MaxDiffAI.AutoSize = true; - this.CHK_MaxDiffAI.Location = new System.Drawing.Point(12, 104); + this.CHK_MaxDiffAI.Checked = true; + this.CHK_MaxDiffAI.CheckState = System.Windows.Forms.CheckState.Checked; + this.CHK_MaxDiffAI.Location = new System.Drawing.Point(12, 124); this.CHK_MaxDiffAI.Name = "CHK_MaxDiffAI"; - this.CHK_MaxDiffAI.Size = new System.Drawing.Size(219, 17); + this.CHK_MaxDiffAI.Size = new System.Drawing.Size(226, 17); this.CHK_MaxDiffAI.TabIndex = 6; - this.CHK_MaxDiffAI.Text = "[NOT VISIBLE] Max Difficulty (Trainer AI)"; + this.CHK_MaxDiffAI.Text = "Max Difficulty (Trainer AI) [Single/Doubles]"; this.CHK_MaxDiffAI.UseVisualStyleBackColor = true; - this.CHK_MaxDiffAI.Visible = false; // // CHK_MaxDiffPKM // this.CHK_MaxDiffPKM.AutoSize = true; this.CHK_MaxDiffPKM.Checked = true; this.CHK_MaxDiffPKM.CheckState = System.Windows.Forms.CheckState.Checked; - this.CHK_MaxDiffPKM.Location = new System.Drawing.Point(12, 81); + this.CHK_MaxDiffPKM.Location = new System.Drawing.Point(12, 101); this.CHK_MaxDiffPKM.Name = "CHK_MaxDiffPKM"; this.CHK_MaxDiffPKM.Size = new System.Drawing.Size(161, 17); this.CHK_MaxDiffPKM.TabIndex = 7; @@ -155,11 +164,15 @@ private void InitializeComponent() // // NUD_GiftPercent // - this.NUD_GiftPercent.Enabled = false; this.NUD_GiftPercent.Location = new System.Drawing.Point(163, 167); this.NUD_GiftPercent.Name = "NUD_GiftPercent"; this.NUD_GiftPercent.Size = new System.Drawing.Size(43, 20); this.NUD_GiftPercent.TabIndex = 10; + this.NUD_GiftPercent.Value = new decimal(new int[] { + 15, + 0, + 0, + 0}); this.NUD_GiftPercent.ValueChanged += new System.EventHandler(this.changePercent); // // label1 @@ -171,11 +184,24 @@ private void InitializeComponent() this.label1.TabIndex = 11; this.label1.Text = "%"; // + // CHK_Smart + // + this.CHK_Smart.AutoSize = true; + this.CHK_Smart.Checked = true; + this.CHK_Smart.CheckState = System.Windows.Forms.CheckState.Checked; + this.CHK_Smart.Location = new System.Drawing.Point(132, 12); + this.CHK_Smart.Name = "CHK_Smart"; + this.CHK_Smart.Size = new System.Drawing.Size(112, 17); + this.CHK_Smart.TabIndex = 12; + this.CHK_Smart.Text = "Smart Rand (BST)"; + this.CHK_Smart.UseVisualStyleBackColor = true; + // // TrainerRand // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(284, 222); + this.Controls.Add(this.CHK_Smart); this.Controls.Add(this.label1); this.Controls.Add(this.NUD_GiftPercent); this.Controls.Add(this.button2); @@ -212,5 +238,6 @@ private void InitializeComponent() private System.Windows.Forms.Button button2; private System.Windows.Forms.NumericUpDown NUD_GiftPercent; private System.Windows.Forms.Label label1; + private System.Windows.Forms.CheckBox CHK_Smart; } } \ No newline at end of file diff --git a/pk3DS/Subforms/TrainerRand.cs b/pk3DS/Subforms/TrainerRand.cs index f63db62..8a5eaa6 100644 --- a/pk3DS/Subforms/TrainerRand.cs +++ b/pk3DS/Subforms/TrainerRand.cs @@ -23,6 +23,7 @@ private void B_Close_Click(object sender, EventArgs e) private void B_Save_Click(object sender, EventArgs e) { RSTE.rPKM = CHK_RandomPKM.Checked; + RSTE.rSmart = CHK_Smart.Checked; RSTE.rMove = CHK_RandomMoves.Checked; RSTE.rAbility = CHK_RandomAbilities.Checked; @@ -48,5 +49,10 @@ private void changePercent(object sender, EventArgs e) { CHK_RandomGift.Checked = (NUD_GiftPercent.Value != 0); } + + private void CHK_RandomPKM_CheckedChanged(object sender, EventArgs e) + { + CHK_Smart.Enabled = CHK_Smart.Checked = CHK_RandomPKM.Checked; + } } } \ No newline at end of file diff --git a/pk3DS/Subforms/XYWE.cs b/pk3DS/Subforms/XYWE.cs index 0a1e32e..2d1f8dc 100644 --- a/pk3DS/Subforms/XYWE.cs +++ b/pk3DS/Subforms/XYWE.cs @@ -275,6 +275,13 @@ public XYWE() }; Load_XYWE(null, null); openQuick(Directory.GetFiles("encdata")); + + string[] personalList = Directory.GetFiles("personal"); + personalData = File.ReadAllBytes(personalList[personalList.Length - 1]); + indexList = Personal.getPersonalIndexList(personalData, Main.oras); + personal = new byte[personalList.Length][]; + for (int i = 0; i < personalList.Length; i++) + personal[i] = File.ReadAllBytes("personal" + Path.DirectorySeparatorChar + i.ToString("000") + ".bin"); } private ComboBox[] spec; private NumericUpDown[] min; @@ -288,6 +295,10 @@ public XYWE() private string[] encdatapaths; private string[] filepaths; + byte[] personalData; + ushort[] indexList; + byte[][] personal; + private void Load_XYWE(object sender, EventArgs e) { specieslist = Main.getText((Main.oras) ? 98 : 80); @@ -500,6 +511,7 @@ private void B_Randomize_Click(object sender, EventArgs e) { if (Util.Prompt(MessageBoxButtons.YesNo, "Randomize all?", "Cannot undo.") == DialogResult.Yes) { + bool smart = Util.Prompt(MessageBoxButtons.YesNo, "Smart Randomize by Base Stat Total?", "Pokemon strength variance will attempt to match ingame.") == DialogResult.Yes; this.Enabled = false; // Nonrepeating List Start @@ -516,6 +528,15 @@ private void B_Randomize_Click(object sender, EventArgs e) if (spec[slot].SelectedIndex != 0) { int species = Randomizer.getRandomSpecies(ref sL, ref ctr); + + if (smart) + { + int oldBST = personal[spec[slot].SelectedIndex].Take(6).Sum(b => (ushort)b); + int newBST = personal[species].Take(6).Sum(b => (ushort)b); + while (!(newBST * 4 / 5 < oldBST && newBST * 6 / 5 > oldBST)) + { species = rand.Next(1, 722); newBST = personal[species].Take(6).Sum(b => (ushort)b); } + } + spec[slot].SelectedIndex = species; if (species == 666 || species == 665 || species == 664) // Vivillon @@ -531,7 +552,7 @@ private void B_Randomize_Click(object sender, EventArgs e) else if (species == 422 || species == 423) // Gastrodon form[slot].Value = rnd32() % 2; else if (species == 585 || species == 586) // Sawsbuck - form[slot].Value = rnd32() % 28; + form[slot].Value = rnd32() % 4; else if (species == 669 || species == 671) // Flabebe/Florges form[slot].Value = rnd32() % 5; else if (species == 670) // Floette