private void B_RandAll_Click(object sender, EventArgs e) { if (WinFormsUtil.Prompt(MessageBoxButtons.YesNo, "Randomize all? Cannot undo.", "Double check Randomization settings in the Randomizer Options tab.") != DialogResult.Yes) { return; } // Randomize by BST bool bst = CHK_BST.Checked; int[] sL = Randomizer.getSpeciesList(CHK_G1.Checked, CHK_G2.Checked, CHK_G3.Checked, CHK_G4.Checked, CHK_G5.Checked, CHK_G6.Checked, false, CHK_L.Checked, CHK_E.Checked); int ctr = 0; for (int i = 0; i < LB_Encounters.Items.Count; i++) { LB_Encounters.SelectedIndex = i; int species = CB_Species.SelectedIndex; species = Randomizer.getRandomSpecies(ref sL, ref ctr, species, bst, Main.SpeciesStat); CB_Species.SelectedIndex = species; NUD_Form.Value = Randomizer.GetRandomForme(species, false, true); NUD_Gender.Value = 0; // random if (CHK_Level.Checked) { NUD_Level.Value = Randomizer.getModifiedLevel((int)NUD_Level.Value, NUD_LevelBoost.Value); } } WinFormsUtil.Alert("Randomized all Static Encounters according to specification!"); }
private void B_Starters_Click(object sender, EventArgs e) { if (WinFormsUtil.Prompt(MessageBoxButtons.YesNo, "Randomize Starters? Cannot undo.", "Double check Randomization settings before continuing.") != DialogResult.Yes) { return; } int[] sL = getRandomSpeciesList(); int ctr = 0; setGift(); // Assign Species for (int i = 0; i < 3; i++) { var t = Gifts[i]; t.Species = Randomizer.getRandomSpecies(ref sL, ref ctr, oldStarters[i], CHK_BST.Checked, Main.SpeciesStat); t.Form = Randomizer.GetRandomForme(t.Species, false, true); // no level boosting } getListBoxEntries(); getGift(); WinFormsUtil.Alert("Randomized Starters according to specification!"); }
private void B_RandAll_Click(object sender, EventArgs e) { if (WinFormsUtil.Prompt(MessageBoxButtons.YesNo, "Randomize Static Encounters? Cannot undo.", "Double check Randomization Settings before continuing.") != DialogResult.Yes) { return; } int[] sL = getRandomSpeciesList(); int ctr = 0; setGift(); setEncounter(); setTrade(); for (int i = 3; i < Gifts.Length; i++) // Skip Starters { var t = Gifts[i]; t.Species = Randomizer.getRandomSpecies(ref sL, ref ctr, t.Species, CHK_BST.Checked, Main.SpeciesStat); t.Form = Randomizer.GetRandomForme(t.Species, false, true); if (CHK_Level.Checked) { t.Level = Randomizer.getModifiedLevel(t.Level, NUD_LevelBoost.Value); } } foreach (EncounterStatic7 t in Encounters) { t.Species = Randomizer.getRandomSpecies(ref sL, ref ctr, t.Species, CHK_BST.Checked, Main.SpeciesStat); t.Form = Randomizer.GetRandomForme(t.Species, false, true); int[] moves = Main.Config.Learnsets[t.Species].getCurrentMoves(t.Level); Array.Resize(ref moves, 4); t.RelearnMoves = moves; if (CHK_Level.Checked) { t.Level = Randomizer.getModifiedLevel(t.Level, NUD_LevelBoost.Value); } } foreach (EncounterTrade7 t in Trades) { t.Species = Randomizer.getRandomSpecies(ref sL, ref ctr, t.Species, CHK_BST.Checked, Main.SpeciesStat); t.Form = Randomizer.GetRandomForme(t.Species, false, true); t.TradeRequestSpecies = Randomizer.getRandomSpecies(ref sL, ref ctr, t.TradeRequestSpecies, CHK_BST.Checked, Main.SpeciesStat); if (CHK_Level.Checked) { t.Level = Randomizer.getModifiedLevel(t.Level, NUD_LevelBoost.Value); } } getListBoxEntries(); getGift(); getEncounter(); getTrade(); WinFormsUtil.Alert("Randomized Static Encounters according to specification!"); }
private void B_RandAll_Click(object sender, EventArgs e) { DialogResult ync = Util.Prompt(MessageBoxButtons.YesNoCancel, "Randomize by BST: Yes" + Environment.NewLine + "Randomize Randomly: No" + Environment.NewLine + "Abort: Cancel"); if (ync != DialogResult.Yes && ync != DialogResult.No) { return; } if (ync == DialogResult.No) { for (int i = 0; i < LB_Gifts.Items.Count; i++) { LB_Gifts.SelectedIndex = i; if (CB_Species.SelectedIndex == 448) { continue; // skip Lucario, battle needs to mega evolve } int species = Util.rand.Next(1, 721); CB_Species.SelectedIndex = species; } return; } // Randomize by BST 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++) { LB_Gifts.SelectedIndex = i; int species = CB_Species.SelectedIndex; if (species == 448) { continue; // skip Lucario, battle needs to mega evolve } int bst = Main.SpeciesStat[species].BST; int tries = 0; var pkm = Main.SpeciesStat[species = Randomizer.getRandomSpecies(ref sL, ref ctr)]; while (!((pkm.BST * (5 - ++tries / Main.Config.MaxSpeciesID) / 6 < bst) && pkm.BST * (6 + ++tries / Main.Config.MaxSpeciesID) / 5 > bst)) { pkm = Main.SpeciesStat[species = Randomizer.getRandomSpecies(ref sL, ref ctr)]; } CB_Species.SelectedIndex = species; } }
private void B_RandAll_Click(object sender, EventArgs e) { /* * 3111 Egg Moves Learned by 290 Species (10.73 avg) * 18 is the most * 1000 moves learned were STAB (32.1%) */ Random rnd = new Random(); int[] banned = new[] { 165, 621, 464 }.Concat(Legal.Z_Moves).ToArray(); // Struggle, Hyperspace Fury, Dark Void // Move Stats Move[] moveTypes = Main.Config.Moves; // Set up Randomized Moves int[] randomMoves = Enumerable.Range(1, movelist.Length - 1).Select(i => i).ToArray(); Util.Shuffle(randomMoves); int ctr = 0; for (int i = 0; i < CB_Species.Items.Count; i++) { CB_Species.SelectedIndex = i; // Get new Species int count = dgv.Rows.Count - 1; int species = Util.getIndex(CB_Species); if (CHK_Expand.Checked && (int)NUD_Moves.Value > count) { dgv.Rows.AddCopies(count, (int)NUD_Moves.Value - count); } for (int j = 1; j < dgv.Rows.Count - 1; j++) { // Assign New Moves bool forceSTAB = CHK_STAB.Checked && rnd.Next(0, 99) < NUD_STAB.Value; int move = Randomizer.getRandomSpecies(ref randomMoves, ref ctr); while (banned.Contains(move) || /* Invalid */ (forceSTAB && !Main.SpeciesStat[species].Types.Contains(moveTypes[move].Type))) // STAB is required { move = Randomizer.getRandomSpecies(ref randomMoves, ref ctr); } // Assign Move dgv.Rows[j].Cells[0].Value = movelist[move]; } } CB_Species.SelectedIndex = 0; Util.Alert("All Pokemon's Egg Up Moves have been randomized!"); }
private void B_Randomize_Click(object sender, EventArgs e) { bool blind = DialogResult.Yes == WinFormsUtil.Prompt(MessageBoxButtons.YesNo, "Hide randomization, save, and close?", "If you want the Starters to be a surprise :)"); if (blind) { Hide(); } // Iterate for each group of Starters for (int i = 0; i < Count; i++) { // Get Species List int gen = int.Parse(Labels[i].Text[4] + ""); int[] sL = CHK_Gen.Checked ? Randomizer.getSpeciesList(gen == 1, gen == 2, gen == 3, gen == 4, gen == 5, gen == 6, false, false, false) : Randomizer.getSpeciesList(true, true, true, true, true, true, false, false, false); int ctr = 0; // Assign Species for (int j = 0; j < 3; j++) { int species = Randomizer.getRandomSpecies(ref sL, ref ctr); if (CHK_BST.Checked) // Enforce BST { int oldSpecies = BitConverter.ToUInt16(Data, offset + (i * 3 + j) * 0x54); PersonalInfo oldpkm = Main.SpeciesStat[oldSpecies]; // Use original species cuz why not. PersonalInfo pkm = Main.SpeciesStat[species]; while (!(pkm.BST * 5 / 6 < oldpkm.BST && pkm.BST * 6 / 5 > oldpkm.BST)) { species = Randomizer.getRandomSpecies(ref sL, ref ctr); pkm = Main.SpeciesStat[species]; } } Choices[i][j].SelectedIndex = species; } } if (blind) { saveData(); Close(); } }
private void B_Starters_Click(object sender, EventArgs e) { int[] sL = getRandomSpeciesList(); int ctr = 0; setGift(); // Assign Species for (int i = 0; i < 3; i++) { var t = Gifts[i]; t.Species = Randomizer.getRandomSpecies(ref sL, ref ctr, oldStarters[i], CHK_BST.Checked, Main.SpeciesStat); t.Form = Randomizer.GetRandomForme(t.Species, false, true); } getListBoxEntries(); getGift(); System.Media.SystemSounds.Asterisk.Play(); }
private void B_RandAll_Click(object sender, EventArgs e) { int[] sL = getRandomSpeciesList(); int ctr = 0; setGift(); setEncounter(); setTrade(); for (int i = 3; i < Gifts.Length; i++) // Skip Starters { var t = Gifts[i]; t.Species = Randomizer.getRandomSpecies(ref sL, ref ctr, t.Species, CHK_BST.Checked, Main.SpeciesStat); t.Form = Randomizer.GetRandomForme(t.Species, false, true); } foreach (EncounterStatic7 t in Encounters) { t.Species = Randomizer.getRandomSpecies(ref sL, ref ctr, t.Species, CHK_BST.Checked, Main.SpeciesStat); t.Form = Randomizer.GetRandomForme(t.Species, false, true); int[] moves = Main.Config.Learnsets[t.Species].getCurrentMoves(t.Level); Array.Resize(ref moves, 4); t.RelearnMoves = moves; } foreach (EncounterTrade7 t in Trades) { t.Species = Randomizer.getRandomSpecies(ref sL, ref ctr, t.Species, CHK_BST.Checked, Main.SpeciesStat); t.Form = Randomizer.GetRandomForme(t.Species, false, true); t.TradeRequestSpecies = Randomizer.getRandomSpecies(ref sL, ref ctr, t.TradeRequestSpecies, CHK_BST.Checked, Main.SpeciesStat); } getListBoxEntries(); getGift(); getEncounter(); getTrade(); System.Media.SystemSounds.Asterisk.Play(); }
// 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_L.Checked, CHK_E.Checked); int ctr = 0; int[] slotArray = Enumerable.Range(0, max.Length).Select(a => a).ToArray(); for (int i = 0; i < CB_LocationID.Items.Count; i++) // for every location { CB_LocationID.SelectedIndex = i; if (!hasData()) { continue; // Don't randomize if doesn't have data. } // Assign Levels if (CHK_Level.Checked) { for (int l = 0; l < max.Length; l++) { min[l].Value = max[l].Value = (max[l].Value <= 1) ? max[l].Value : Math.Max(1, Math.Min(100, (int)((leveldiff) * max[l].Value))); } } // Get a new list of Pokemon so that DexNav does not crash. int[] list = new int[max.Length]; int used = 19; // Count up how many slots are active. for (int s = 0; s < max.Length; s++) { if (spec[s].SelectedIndex > 0) { list[s] = spec[s].SelectedIndex; } } // At most 18, but don't chew if there's only a few slots. int cons = list.Count(a => a != 0); int[] RandomList = new int[(cons > 18) ? (18 - (cons / 8)) : cons]; // Fill Location List if (!CHK_BST.Checked) { for (int z = 0; z < RandomList.Length; 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 < RandomList.Length; 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 = sL[rand.Next(1, sL.Length)]; newBST = personal[species].Take(6).Sum(b => (ushort)b); } RandomList[z] = species; } } // Assign Slots while (used < RandomList.Distinct().Count() || used > 18) // Can just arbitrarily assign slots. { int ctrSingle = 0; Util.Shuffle(slotArray); for (int s = 0; s < max.Length; s++) { int slot = slotArray[s]; if (spec[slot].SelectedIndex != 0) // If the slot is in use { list[slot] = Randomizer.getRandomSpecies(ref RandomList, ref ctrSingle); } } used = countUnique(list); if (used != RandomList.Length) { ShuffleSlots(ref list, RandomList.Length); } used = countUnique(list); } // Fill Slots for (int slot = 0; slot < max.Length; slot++) { if (spec[slot].SelectedIndex != 0) { spec[slot].SelectedIndex = list[slot]; setRandomForm(slot, spec[slot].SelectedIndex); } } B_Save_Click(sender, e); } Enabled = true; Util.Alert("Randomized!"); }
private void B_Randomize_Click(object sender, EventArgs e) { Util.Alert("Randomization currently disabled"); return; 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 int[] sL = Randomizer.RandomSpeciesList; int ctr = 0; int[] slotArray = Enumerable.Range(0, max.Length).Select(a => (int)a).ToArray(); for (int i = 0; i < CB_LocationID.Items.Count; i++) // for every location { CB_LocationID.SelectedIndex = i; if (!hasData()) { continue; // Don't randomize if doesn't have data. } // Get a new list of Pokemon so that DexNav does not crash. int[] list = new int[max.Length]; int used = 19; // Count up how many slots are active. for (int s = 0; s < max.Length; s++) { if (spec[s].SelectedIndex > 0) { list[s] = spec[s].SelectedIndex; } } // At most 18, but don't chew if there's only a few slots. int cons = list.Count(a => a != 0); int[] RandomList = new int[(cons > 18) ? (18 - (cons / 8)) : cons]; // Fill Location List if (!smart) { for (int z = 0; z < RandomList.Length; 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 < RandomList.Length; 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; } } // Assign Slots while (used < RandomList.Length || used > 18) // Can just arbitrarily assign slots. { int ctrSingle = 0; Util.Shuffle(slotArray); for (int s = 0; s < max.Length; s++) { int slot = slotArray[s]; if (spec[slot].SelectedIndex != 0) // If the slot is in use { list[slot] = Randomizer.getRandomSpecies(ref RandomList, ref ctrSingle); } } ShuffleSlots(ref list, RandomList.Length); used = countUnique(list); } // Fill Slots for (int slot = 0; slot < max.Length; slot++) { if (spec[slot].SelectedIndex != 0) { spec[slot].SelectedIndex = list[slot]; setRandomForm(slot, spec[slot].SelectedIndex); } } B_Save_Click(sender, e); } this.Enabled = true; Util.Alert("Randomized!"); } }
private void B_RandAll_Click(object sender, EventArgs e) { /* * 3111 Egg Moves Learned by 290 Species (10.73 avg) * 18 is the most * 1000 moves learned were STAB (32.1%) */ Random rnd = new Random(); ushort[] HMs = { 15, 19, 57, 70, 127, 249, 291 }; ushort[] TMs = { }; if (CHK_HMs.Checked && Main.ExeFSPath != null) { TMHM.getTMHMList(Main.oras, ref TMs, ref HMs); } int[] banned = new int[HMs.Length]; for (int i = 0; i < banned.Length; i++) { banned[i] = HMs[i]; } banned = banned.Concat(new[] { 165, 621 }).ToArray(); // Struggle, Hyperspace Fury // Move Stats Move[] moveTypes = Moves.getMoves(); // Personal Stats byte[] personalData = File.ReadAllBytes(Directory.GetFiles("personal").Last()); // Set up Randomized Moves int[] randomMoves = Enumerable.Range(1, movelist.Length - 1).Select(i => i).ToArray(); Util.Shuffle(randomMoves); int ctr = 0; for (int i = 0; i < CB_Species.Items.Count; i++) { CB_Species.SelectedIndex = i; // Get new Species int count = dgv.Rows.Count - 1; int species = Util.getIndex(CB_Species); if (count == 0) { continue; } if (CHK_Expand.Checked && (int)NUD_Moves.Value > count) { dgv.Rows.AddCopies(count, (int)NUD_Moves.Value - count); } for (int j = 0; j < dgv.Rows.Count - 1; j++) { // Assign New Moves bool forceSTAB = CHK_STAB.Checked && rnd.Next(0, 99) < NUD_STAB.Value; int move = Randomizer.getRandomSpecies(ref randomMoves, ref ctr); while ( // Move is invalid (!CHK_HMs.Checked && banned.Contains(move)) || // HM Moves Not Allowed (forceSTAB && // STAB is required !( moveTypes[move].Type == personalData[6 + (Main.oras ? 0x50 : 0x40) * species] // Type 1 || moveTypes[move].Type == personalData[7 + (Main.oras ? 0x50 : 0x40) * species] // Type 2 ) ) ) { move = Randomizer.getRandomSpecies(ref randomMoves, ref ctr); } // Assign Move dgv.Rows[j].Cells[0].Value = movelist[move]; } } CB_Species.SelectedIndex = 0; Util.Alert("All Pokemon's Egg Moves have been randomized!"); }
private void Randomize() { rTags = (Main.oras) ? GetTagsORAS() : GetTagsXY(); mEvoTypes = GetMegaEvolvableTypes(); List <int> GymE4Types = new List <int>(); if (rEnsureMEvo.Length > 0) { if (mEvoTypes.Length < 13 && rTypeTheme) { Util.Alert("There are insufficient types with at least one mega evolution to Guarantee story Mega Evos while keeping Type theming.", "Re-Randomize Personal or don't choose both options."); return; } GymE4Types.AddRange(mEvoTypes); } else { GymE4Types.AddRange(Enumerable.Range(0, types.Length).ToArray()); } foreach (int t1 in rEnsureMEvo.Where(t1 => rTags[t1] != "" && !TagTypes.Keys.Contains(rTags[t1]))) { int t; if (rTags[t1].Contains("GYM") || rTags[t1].Contains("ELITE") || rTags[t1].Contains("CHAMPION")) { t = GymE4Types[(int)(rnd32() % GymE4Types.Count)]; GymE4Types.Remove(t); } else { t = mEvoTypes[rnd32() % mEvoTypes.Length]; } TagTypes[rTags[t1]] = t; } foreach (string t1 in Tags) { if (!TagTypes.Keys.Contains(t1) && t1 != "") { int t; if (t1.Contains("GYM") || t1.Contains("ELITE") || t1.Contains("CHAMPION")) { t = GymE4Types[(int)(rnd32() % GymE4Types.Count)]; GymE4Types.Remove(t); } else { t = (int)(rnd32() % types.Length); } TagTypes[t1] = t; } Console.WriteLine(t1 + ": " + types[TagTypes[t1]]); } for (int i = 1; i < CB_TrainerID.Items.Count; i++) { CB_TrainerID.SelectedIndex = i; // data is loaded // Setup checkBox_Moves.Checked = rMove || checkBox_Moves.Checked; checkBox_Item.Checked = rItem || checkBox_Item.Checked; // Randomize Trainer Stats if (rDiffAI) { if (CB_Battle_Type.SelectedIndex == 0) { CB_AI.SelectedIndex = 7; // Max Single } else if (CB_Battle_Type.SelectedIndex == 1) { CB_AI.SelectedIndex = 135; // Max Double } } if (rClass) { CB_Trainer_Class.SelectedIndex = CB_Battle_Type.SelectedIndex > 0 ? (int)(rnd32() % (CB_Trainer_Class.Items.Count)) : 0; // Change only Single Battles } if (rGift && rnd32() % 100 < rGiftPercent) #region Random Prize Logic { ushort[] items; uint rnd = rnd32() % 10; if (rnd < 2) // held item { items = (Main.oras) ? Legal.Pouch_Items_ORAS : Legal.Pouch_Items_XY; } else if (rnd < 5) // medicine { items = (Main.oras) ? Legal.Pouch_Medicine_ORAS : Legal.Pouch_Medicine_XY; } else // berry { items = Legal.Pouch_Berry_XY; } CB_Prize.SelectedIndex = items[(rnd32() % items.Length)]; } #endregion else if (rGift) { CB_Prize.SelectedIndex = 0; } ushort[] itemvals = (Main.oras) ? Legal.Pouch_Items_ORAS : Legal.Pouch_Items_XY; itemvals = itemvals.Concat(Legal.Pouch_Berry_XY).ToArray(); int moves = trpk_m1[0].Items.Count; int itemC = itemvals.Length; int ctr = 0; int type = GetRandomType(i); bool mevo = rEnsureMEvo.Contains(i); // Randomize Pokemon for (int p = 0; p < CB_numPokemon.SelectedIndex; p++) { if (rPKM) { // randomize pokemon int species = Randomizer.getRandomSpecies(ref sL, ref ctr); if (rTypeTheme) { while (personal[species][6] != type && personal[species][7] != type || (mevo && p == CB_numPokemon.SelectedIndex - 1 && !megaEvos.Contains(species))) { if (p == CB_numPokemon.SelectedIndex - 1 && mevo) { species = GetRandomMegaEvolvablePokemon(type); } else 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 = sL[rand.Next(1, sL.Length)]; newBST = personal[species].Take(6).Sum(b => (ushort)b); } } else { species = Randomizer.getRandomSpecies(ref sL, ref ctr); } } } else if (p == CB_numPokemon.SelectedIndex - 1 && mevo) { species = megaEvos[rnd32() % megaEvos.Length]; } else 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 = sL[rand.Next(1, sL.Length)]; newBST = personal[species].Take(6).Sum(b => (ushort)b); } } trpk_pkm[p].SelectedIndex = species; // Set Gender to Random trpk_gender[p].SelectedIndex = 0; if (trpk_form[p].Items.Count > 0) { trpk_form[p].SelectedIndex = 0; } // Randomize form if (trpk_form[p].Items.Count > 0 && !megaEvos.Contains(species)) { trpk_form[p].SelectedIndex = (int)(rnd32() % trpk_form[p].Items.Count); } } if (rLevel) { trpk_lvl[p].SelectedIndex = Math.Max(1, Math.Min((int)(trpk_lvl[p].SelectedIndex * ((100 + rLevelPercent) / 100)), 100)); } if (rAbility) { trpk_abil[p].SelectedIndex = (int)(1 + rnd32() % 3); } if (rDiffIV) { trpk_IV[p].SelectedIndex = 255; } if (mevo && p == CB_numPokemon.SelectedIndex - 1) { int[] megastones = GetMegaStones(trpk_pkm[p].SelectedIndex); trpk_item[p].SelectedIndex = megastones[rnd32() % megastones.Length]; } else if (rItem) #region RandomItem { trpk_item[p].SelectedIndex = itemvals[(rnd32() % itemC)]; } #endregion if (rMove) { trpk_m1[p].SelectedIndex = (int)(rnd32() % (moves)); trpk_m2[p].SelectedIndex = (int)(rnd32() % (moves)); trpk_m3[p].SelectedIndex = (int)(rnd32() % (moves)); trpk_m4[p].SelectedIndex = (int)(rnd32() % (moves)); } } } CB_TrainerID.SelectedIndex = 1; Util.Alert("Randomized all trainers according to specification!", "Press the Dump to TXT to view the new trainer information!"); }
// Randomization private void B_Randomize_Click(object sender, EventArgs e) { if (Util.Prompt(MessageBoxButtons.YesNo, "Randomize all? Cannot undo.", "Double check Randomization settings.") != DialogResult.Yes) { return; } Enabled = false; int slotStart; int slotStop; bool copy = false; switch (CB_SlotRand.SelectedIndex) { default: // All slotStart = 0; slotStop = -1; break; case 1: // Regular Only slotStart = 0; slotStop = 1; break; case 2: // SOS Only slotStart = 1; slotStop = -1; break; case 3: // Regular Only, Copy to SOS slotStart = 0; slotStop = 1; copy = true; break; } // Calculate % diff we will apply to each level decimal leveldiff = (100 + NUD_LevelAmp.Value) / 100; Randomizer rnd = new Randomizer(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, Shedinja: true) { BST = CHK_BST.Checked, Stats = Main.SpeciesStat }; 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))); } int end = slotStop < 0 ? Table.Encounters.Length : slotStop; for (int s = slotStart; s < end; s++) { var EncounterSet = Table.Encounters[s]; foreach (var enc in EncounterSet.Where(enc => enc.Species != 0)) { enc.Species = (uint)rnd.getRandomSpecies((int)enc.Species); enc.Forme = GetRandomForme((int)enc.Species); } } if (copy) // copy row 0 to rest { var table = Table.Encounters; var s0 = table[0]; for (int r = 1; r < table.Length; r++) { var slots = table[r]; for (int s = 0; s < slots.Length; s++) { slots[s].Species = s0[s].Species; slots[s].Forme = s0[s].Forme; } } } Table.Write(); } encdata[Map.FileNumber] = getMapData(Map.Tables); } updatePanel(sender, e); Enabled = true; Util.Alert("Randomized!"); }
private void B_RandAll_Click(object sender, EventArgs e) { // ORAS: 10682 moves learned on levelup/birth. // 5593 are STAB. 52.3% are STAB. // Steelix learns the most @ 25 (so many level 1)! // Move relearner ingame does not behave properly if the count exceeds 25: // https://twitter.com/Drayano60/status/630044237883666433 Random rnd = new Random(); int[] firstMoves = { 1, 40, 52, 55, 64, 71, 84, 98, 122, 141 }; // Pound, Poison Sting, Ember, Water Gun, Peck, Absorb, Thunder Shock, Quick Attack, Lick, Leech Life ushort[] HMs = { 15, 19, 57, 70, 127, 249, 291 }; ushort[] TMs = {}; if (CHK_HMs.Checked && Main.ExeFSPath != null) { TMHMEditor6.getTMHMList(Main.Config.ORAS, ref TMs, ref HMs); } int[] banned = new int[HMs.Length]; for (int i = 0; i < banned.Length; i++) { banned[i] = HMs[i]; } banned = banned.Concat(new[] { 165, 621 }).ToArray(); // Struggle, Hyperspace Fury // Move Stats Move[] moveTypes = Main.Config.Moves; // Set up Randomized Moves int[] randomMoves = Enumerable.Range(1, movelist.Length - 1).Select(i => i).ToArray(); Util.Shuffle(randomMoves); int ctr = 0; for (int i = 0; i < CB_Species.Items.Count; i++) { CB_Species.SelectedIndex = i; // Get new Species int count = dgv.Rows.Count - 1; int species = WinFormsUtil.getIndex(CB_Species); if (CHK_Expand.Checked && (int)NUD_Moves.Value > count) { dgv.Rows.AddCopies(count, (int)NUD_Moves.Value - count); } // Default First Move dgv.Rows[0].Cells[0].Value = 1; dgv.Rows[0].Cells[1].Value = movelist[firstMoves[rnd.Next(0, firstMoves.Length)]]; for (int j = 1; j < dgv.Rows.Count - 1; j++) { // Assign New Moves bool forceSTAB = CHK_STAB.Checked && rnd.Next(0, 99) < NUD_STAB.Value; int move = Randomizer.getRandomSpecies(ref randomMoves, ref ctr); while ( // Move is invalid !CHK_HMs.Checked && banned.Contains(move) || // HM Moves Not Allowed forceSTAB && // STAB is required !Main.Config.Personal[species].Types.Contains(moveTypes[move].Type)) { move = Randomizer.getRandomSpecies(ref randomMoves, ref ctr); } // Assign Move dgv.Rows[j].Cells[1].Value = movelist[move]; // Assign Level if (j >= count) { string level = (dgv.Rows[count - 1].Cells[0].Value ?? 0).ToString(); ushort lv; ushort.TryParse(level, out lv); if (lv > 100) { lv = 100; } else if (lv == 0) { lv = 1; } dgv.Rows[j].Cells[0].Value = lv + (j - count) + 1; } if (CHK_Spread.Checked) { dgv.Rows[j].Cells[0].Value = ((int)(j * (NUD_Level.Value / (dgv.Rows.Count - 1)))).ToString(); } } } CB_Species.SelectedIndex = 0; WinFormsUtil.Alert("All Pokemon's Level Up Moves have been randomized!"); }
private void B_Randomize_Click(object sender, EventArgs e) { if (Util.Prompt(MessageBoxButtons.YesNo, "Randomize all?", "Cannot undo.") != 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_L.Checked, CHK_E.Checked); int ctr = 0; for (int i = 0; i < CB_LocationID.Items.Count; i++) // for every location { CB_LocationID.SelectedIndex = i; if (!hasData()) { continue; // Don't randomize if doesn't have data. } // Assign Levels if (CHK_Level.Checked) { for (int l = 0; l < max.Length; l++) { min[l].Value = max[l].Value = (max[l].Value <= 1) ? max[l].Value : Math.Max(1, Math.Min(100, (int)((leveldiff) * max[l].Value))); } } for (int slot = 0; slot < max.Length; slot++) { if (spec[slot].SelectedIndex == 0) { continue; } int species = Randomizer.getRandomSpecies(ref sL, ref ctr); if (CHK_BST.Checked) { 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 = sL[rand.Next(1, sL.Length)]; newBST = personal[species].Take(6).Sum(b => (ushort)b); } } spec[slot].SelectedIndex = species; if (species == 666 || species == 665 || species == 664) // Vivillon { form[slot].Value = rnd32() % 20; } else if (species == 386) // Deoxys { form[slot].Value = rnd32() % 4; } else if (species == 201) // Unown { form[slot].Value = rnd32() % 28; } else if (species == 550) // Basculin { form[slot].Value = rnd32() % 2; } else if (species == 412 || species == 413) // Wormadam { form[slot].Value = rnd32() % 3; } else if (species == 422 || species == 423) // Gastrodon { form[slot].Value = rnd32() % 2; } else if (species == 585 || species == 586) // Sawsbuck { form[slot].Value = rnd32() % 4; } else if (species == 669 || species == 671) // Flabebe/Florges { form[slot].Value = rnd32() % 5; } else if (species == 670) // Floette { form[slot].Value = rnd32() % 6; } else if (species == 710 || species == 711) // Pumpkaboo { form[slot].Value = rnd32() % 4; } else { form[slot].Value = 0; } } B_Save_Click(sender, e); } Enabled = true; Util.Alert("Randomized!"); }
private static int[] sL; // Random Species List private void B_RandAll_Click(object sender, EventArgs e) { if (DialogResult.Yes != Util.Prompt(MessageBoxButtons.YesNo, "Randomize all resulting species?", "Evolution methods and parameters will stay the same.")) { return; } // Set up advanced randomization options bool rBST = CHK_BST.Checked; bool rEXP = CHK_Exp.Checked; bool rType = CHK_Type.Checked; int ctr = 0; sL = Randomizer.RandomSpeciesList; for (int i = 0; i < CB_Species.Items.Count; i++) { CB_Species.SelectedIndex = i; for (int j = 0; j < mb.Length; j++) { if (mb[j].SelectedIndex > 0) { // Get a new random species int oldSpecies = rb[j].SelectedIndex; PersonalInfo oldpkm = Main.SpeciesStat[oldSpecies]; int currentSpecies = Array.IndexOf(specieslist, CB_Species.Text); int loopctr = 0; // altering calculatiosn to prevent infinite loops defspecies: int newSpecies = Randomizer.getRandomSpecies(ref sL, ref ctr); PersonalInfo pkm = Main.SpeciesStat[newSpecies]; loopctr++; // Verify it meets specifications if (newSpecies == currentSpecies && loopctr < Main.Config.MaxSpeciesID * 10) // no A->A evolutions { goto defspecies; } if (rEXP) // Experience Growth Rate matches { if (oldpkm.EXPGrowth != pkm.EXPGrowth) { goto defspecies; } } if (rType) // Type has to be somewhat similar { if (!oldpkm.Types.Contains(pkm.Types[0]) || !oldpkm.Types.Contains(pkm.Types[1])) { goto defspecies; } } if (rBST) // Base stat total has to be close { const int l = 5; // tweakable scalars const int h = 6; if (!(pkm.BST * l / (h + loopctr / Main.Config.MaxSpeciesID) < oldpkm.BST && (pkm.BST * h + loopctr / Main.Config.MaxSpeciesID) / l > oldpkm.BST)) { goto defspecies; } } // assign random val rb[j].SelectedIndex = newSpecies; } } } setList(); Util.Alert("All Pokemon's Evolutions have been randomized!"); }
// Randomization private void B_Randomize_Click(object sender, EventArgs e) { if (WinFormsUtil.Prompt(MessageBoxButtons.YesNo, "Randomize all? Cannot undo.", "Double check Randomization settings at the bottom left.") != DialogResult.Yes) { return; } Enabled = false; int slotStart; int slotStop; bool copy = false; switch (CB_SlotRand.SelectedIndex) { default: // All slotStart = 0; slotStop = -1; break; case 1: // Regular Only slotStart = 0; slotStop = 1; break; case 2: // SOS Only slotStart = 1; slotStop = -1; break; case 3: // Regular Only, Copy to SOS slotStart = 0; slotStop = 1; copy = true; break; } Randomizer rnd = new Randomizer(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, Shedinja: true) { BST = CHK_BST.Checked, Stats = Main.SpeciesStat }; foreach (var Map in Areas) { foreach (var Table in Map.Tables) { if (CHK_Level.Checked) { Table.MinLevel = Randomizer.getModifiedLevel(Table.MinLevel, NUD_LevelAmp.Value); Table.MaxLevel = Randomizer.getModifiedLevel(Table.MaxLevel, NUD_LevelAmp.Value); } int end = slotStop < 0 ? Table.Encounters.Length : slotStop; for (int s = slotStart; s < end; s++) { var EncounterSet = Table.Encounters[s]; foreach (var enc in EncounterSet.Where(enc => enc.Species != 0)) { enc.Species = (uint)rnd.getRandomSpecies((int)enc.Species); enc.Forme = GetRandomForme((int)enc.Species); } } if (copy) // copy row 0 to rest { var table = Table.Encounters; var s0 = table[0]; for (int r = 1; r < table.Length; r++) { var slots = table[r]; for (int s = 0; s < slots.Length; s++) { slots[s].Species = s0[s].Species; slots[s].Forme = s0[s].Forme; } } } Table.Write(); } encdata[Map.FileNumber] = getMapData(Map.Tables); } updatePanel(sender, e); Enabled = true; WinFormsUtil.Alert("Randomized all Wild Encounters according to specification!", "Press the Dump Tables button to view the new Wild Encounter information!"); }
// Randomization private void B_Randomize_Click(object sender, EventArgs e) { if (Util.Prompt(MessageBoxButtons.YesNo, "Randomize all? Cannot undo.", "Double check Randomization settings.") != DialogResult.Yes) { return; } Enabled = false; int setSkip = CHK_SOS.Checked ? 1 : 0; // 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.Skip(setSkip)) // Skip regular slots if checked { foreach (var encounter in EncounterSet) { // Only modify slots that're used. if (encounter.Species == 0) { continue; } 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 = GetRandomForme((int)encounter.Species); } } Table.Write(); } encdata[Map.FileNumber] = getMapData(Map.Tables); } updatePanel(sender, e); Enabled = true; Util.Alert("Randomized!"); }
private void B_Randomize_Click(object sender, EventArgs e) { CB_TrainerID.SelectedIndex = 0; Randomizer rnd = new Randomizer(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, Shedinja: true) { BST = CHK_BST.Checked, Stats = Main.SpeciesStat }; var items = Randomizer.getRandomItemList(); for (int i = 0; i < Trainers.Length; i++) { var tr = Trainers[i]; if (tr.Pokemon.Count == 0) { continue; } // Trainer Properties if (CHK_RandomClass.Checked) { int rv; do { rv = (int)(Util.rnd32() % CB_Trainer_Class.Items.Count); } while (/*trClass[rv].StartsWith("[~") || */ (Legal.SpecialClasses_SM.Contains(rv) && !CHK_IgnoreSpecialClass.Checked)); // don't allow disallowed classes tr.TrainerClass = (byte)rv; } if (tr.NumPokemon < NUD_RMin.Value) { var avgBST = (int)tr.Pokemon.Average(pk => Main.SpeciesStat[pk.Species].BST); int avgLevel = (int)tr.Pokemon.Average(pk => pk.Level); var pinfo = Main.SpeciesStat.OrderBy(pk => Math.Abs(avgBST - pk.BST)).First(); int avgSpec = Array.IndexOf(Main.SpeciesStat, pinfo); for (int p = tr.NumPokemon; p < NUD_RMin.Value; p++) { tr.Pokemon.Add(new trpoke7 { Species = rnd.getRandomSpecies(avgSpec), Level = avgLevel, }); } tr.NumPokemon = (int)NUD_RMin.Value; } if (tr.NumPokemon > NUD_RMax.Value) { tr.Pokemon.RemoveRange((int)NUD_RMax.Value, (int)(tr.NumPokemon - NUD_RMax.Value)); tr.NumPokemon = (int)NUD_RMax.Value; } // PKM Properties foreach (var pk in tr.Pokemon) { if (CHK_RandomPKM.Checked) { int Type = CHK_TypeTheme.Checked ? (int)Util.rnd32() % 17 : -1; pk.Species = rnd.getRandomSpecies(pk.Species, Type); pk.Form = Randomizer.GetRandomForme(pk.Species, CHK_RandomMegaForm.Checked, true, Main.SpeciesStat); pk.Gender = 0; // Random Gender } if (CHK_Level.Checked) { pk.Level = (int)(pk.Level * (100 + NUD_LevelBoost.Value)) / 100; } if (CHK_RandomShiny.Checked) { pk.Shiny = Util.rand.Next(0, 100 + 1) < NUD_Shiny.Value; } if (CHK_RandomItems.Checked) { pk.Item = items[Util.rnd32() % items.Length]; } if (CHK_RandomAbilities.Checked) { pk.Ability = (int)Util.rnd32() % 4; } if (CHK_MaxDiffPKM.Checked) { pk.IVs = new[] { 31, 31, 31, 31, 31, 31 } } ; switch (CB_Moves.SelectedIndex) { case 1: // Random pk.Moves = Randomizer.getRandomMoves( Main.Config.Personal.getFormeEntry(pk.Species, pk.Form).Types, Main.Config.Moves, CHK_Damage.Checked, (int)NUD_Damage.Value, CHK_STAB.Checked, (int)NUD_STAB.Value); break; case 2: // Current LevelUp pk.Moves = getCurrentAttacks(pk); break; case 3: // High Attacks pk.Moves = getHighAttacks(pk); break; } } saveData(tr, i); } Util.Alert("Randomized!"); }
private void B_RandAll_Click(object sender, EventArgs e) { // ORAS: 10682 moves learned on levelup/birth. // 5593 are STAB. 52.3% are STAB. // Steelix learns the most @ 25 (so many level 1)! // Move relearner ingame glitch fixed (52 tested), but keep below 75: // https://twitter.com/Drayano60/status/807297858244411397 Random rnd = new Random(); int[] firstMoves = { 1, 40, 52, 55, 64, 71, 84, 98, 122, 141 }; // Pound, Poison Sting, Ember, Water Gun, Peck, Absorb, Thunder Shock, Quick Attack, Lick, Leech Life int[] banned = new[] { 165, 621, 464 }.Concat(Legal.Z_Moves).ToArray(); // Struggle, Hyperspace Fury, Dark Void // Move Stats Move[] moveTypes = Main.Config.Moves; // Set up Randomized Moves int[] randomMoves = Enumerable.Range(1, movelist.Length - 1).Select(i => i).ToArray(); Util.Shuffle(randomMoves); int ctr = 0; for (int i = 0; i < CB_Species.Items.Count; i++) { CB_Species.SelectedIndex = i; // Get new Species int count = dgv.Rows.Count - 1; int species = WinFormsUtil.getIndex(CB_Species); if (CHK_Expand.Checked && (int)NUD_Moves.Value > count) { dgv.Rows.AddCopies(count, (int)NUD_Moves.Value - count); } // Default First Move dgv.Rows[0].Cells[0].Value = 1; dgv.Rows[0].Cells[1].Value = movelist[firstMoves[rnd.Next(0, firstMoves.Length)]]; for (int j = 1; j < dgv.Rows.Count - 1; j++) { // Assign New Moves bool forceSTAB = CHK_STAB.Checked && rnd.Next(0, 99) < NUD_STAB.Value; int move = Randomizer.getRandomSpecies(ref randomMoves, ref ctr); while (banned.Contains(move) || /* Invalid */ forceSTAB && !Main.SpeciesStat[species].Types.Contains(moveTypes[move].Type)) // STAB is required { move = Randomizer.getRandomSpecies(ref randomMoves, ref ctr); } // Assign Move dgv.Rows[j].Cells[1].Value = movelist[move]; // Assign Level if (j >= count) { string level = (dgv.Rows[count - 1].Cells[0].Value ?? 0).ToString(); ushort lv; UInt16.TryParse(level, out lv); if (lv > 100) { lv = 100; } dgv.Rows[j].Cells[0].Value = lv + (j - count) + 1; } if (CHK_Spread.Checked) { dgv.Rows[j].Cells[0].Value = ((int)(j * (NUD_Level.Value / (dgv.Rows.Count - 1)))).ToString(); } } } CB_Species.SelectedIndex = 0; WinFormsUtil.Alert("All Pokemon's Level Up Moves have been randomized!"); }
private void B_RandAll_Click(object sender, EventArgs e) { // ORAS: 10682 moves learned on levelup/birth. // 5593 are STAB. 52.3% are STAB. // Steelix learns the most @ 25 (so many level 1)! Random rnd = new Random(); int[] firstMoves = { 1, 40, 52, 55, 64, 71, 84, 98, 122, 141 }; // Pound, Poison Sting, Ember, Water Gun, Peck, Absorb, Thunder Shock, Quick Attack, Lick, Leech Life ushort[] HMs = { 15, 19, 57, 70, 127, 249, 291 }; ushort[] TMs = {}; if (CHK_HMs.Checked && Main.ExeFS != null) { TMHM.getTMHMList(Main.oras, ref TMs, ref HMs); } int[] banned = new int[HMs.Length]; for (int i = 0; i < banned.Length; i++) { banned[i] = HMs[i]; } // Move Stats int[] moveTypes = Moves.getTypes(); // Personal Stats byte[] personalData = File.ReadAllBytes(Directory.GetFiles("personal").Last()); // Set up Randomized Moves int[] randomMoves = Enumerable.Range(1, movelist.Length - 1).Select(i => i).ToArray(); Util.Shuffle(randomMoves); int ctr = 0; for (int i = 0; i < CB_Species.Items.Count; i++) { CB_Species.SelectedIndex = i; // Get new Species int count = dgv.Rows.Count - 1; if (CHK_Expand.Checked && (int)NUD_Moves.Value > count) { dgv.Rows.AddCopies(count, (int)NUD_Moves.Value - count); } // Default First Move dgv.Rows[0].Cells[0].Value = 1; dgv.Rows[0].Cells[1].Value = movelist[firstMoves[rnd.Next(0, firstMoves.Length)]]; for (int j = 1; j < dgv.Rows.Count - 1; j++) { // Assign New Moves bool forceSTAB = (CHK_STAB.Checked && rnd.Next(0, 99) < NUD_STAB.Value); int move = Randomizer.getRandomSpecies(ref randomMoves, ref ctr); while ( // Move is invalid (!CHK_HMs.Checked && banned.Contains(move)) || // HM Moves Not Allowed (forceSTAB && // STAB is required !( moveTypes[move] == personalData[6 + (Main.oras ? 0x50 : 0x40) * i] // Type 1 || moveTypes[move] == personalData[7 + (Main.oras ? 0x50 : 0x40) * i] // Type 2 ) ) ) { move = Randomizer.getRandomSpecies(ref randomMoves, ref ctr); } // Assign Move dgv.Rows[j].Cells[1].Value = movelist[move]; // Assign Level if (j >= count) { string level = (dgv.Rows[count - 1].Cells[0].Value ?? 0).ToString(); ushort lv; UInt16.TryParse(level, out lv); if (lv > 100) { lv = 100; } else if (lv == 0) { lv = 1; } dgv.Rows[j].Cells[0].Value = lv + (j - count) + 1; } if (CHK_Spread.Checked) { dgv.Rows[j].Cells[0].Value = (j * (NUD_Level.Value / (dgv.Rows.Count - 1))).ToString(); } } } CB_Species.SelectedIndex = 0; Util.Alert("All Pokemon's Level Up Moves have been randomized!"); }
private void B_Randomize_Click(object sender, EventArgs e) { if (Util.Prompt(MessageBoxButtons.YesNo, "Randomize all?", "Cannot undo.") != 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_L.Checked, CHK_E.Checked); int ctr = 0; for (int i = 0; i < CB_LocationID.Items.Count; i++) // for every location { CB_LocationID.SelectedIndex = i; if (!hasData()) { continue; // Don't randomize if doesn't have data. } // Assign Levels if (CHK_Level.Checked) { for (int l = 0; l < max.Length; l++) { min[l].Value = max[l].Value = max[l].Value <= 1 ? max[l].Value : Math.Max(1, Math.Min(100, (int)(leveldiff * max[l].Value))); } } for (int slot = 0; slot < max.Length; slot++) { if (spec[slot].SelectedIndex == 0) { continue; } int species = Randomizer.getRandomSpecies(ref sL, ref ctr); if (CHK_BST.Checked) { 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 = sL[rand.Next(1, sL.Length)]; newBST = personal[species].Take(6).Sum(b => (ushort)b); } } spec[slot].SelectedIndex = species; setRandomForm(slot, spec[slot].SelectedIndex); } B_Save_Click(sender, e); } Enabled = true; Util.Alert("Randomized!"); }
private void B_Randomize_Click(object sender, EventArgs e) { Randomizer rnd = new Randomizer(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, Shedinja: true) { BST = CHK_BST.Checked, Stats = Main.SpeciesStat }; var items = Randomizer.getRandomItemList(); foreach (var tr in Trainers) { if (tr.Pokemon.Count == 0) continue; // Trainer Properties if (CHK_OnlyDoubles.Checked) { } else if (CHK_OnlySingles.Checked) { } if (CHK_RandomGift.Checked && Util.rnd32() < NUD_GiftPercent.Value) { } if (CHK_RandomClass.Checked) { if (CHK_IgnoreSpecialClass.Checked) { } else { } } if (tr.NumPokemon < NUD_RMin.Value) { var avgBST = (int)tr.Pokemon.Average(pk => Main.SpeciesStat[pk.Species].BST); var pinfo = Main.SpeciesStat.OrderBy(pk => Math.Abs(avgBST - pk.BST)).First(); int avgSpec = Array.IndexOf(Main.SpeciesStat, pinfo); for (int p = tr.NumPokemon; p < NUD_RMin.Value; p++) tr.Pokemon.Add(new trpoke7 {Species = rnd.getRandomSpecies(avgSpec)}); tr.NumPokemon = (int)NUD_RMin.Value; } if (tr.NumPokemon > NUD_RMax.Value) { tr.Pokemon.RemoveRange((int)NUD_RMax.Value, (int)(tr.NumPokemon - NUD_RMax.Value)); tr.NumPokemon = (int)NUD_RMax.Value; } // PKM Properties foreach (var pk in tr.Pokemon) { if (CHK_RandomPKM.Checked) { int Type = CHK_TypeTheme.Checked ? (int)Util.rnd32()%17 : -1; pk.Species = rnd.getRandomSpecies(pk.Species, Type); pk.Form = Randomizer.GetRandomForme(pk.Species, CHK_RandomMegaForm.Checked, true, Main.SpeciesStat); } if (CHK_Level.Checked) pk.Level = (int)(pk.Level*(100 + NUD_LevelBoost.Value))/100; if (CHK_RandomShiny.Checked) pk.Shiny = Util.rand.Next(0, 100 + 1) < NUD_Shiny.Value; if (CHK_RandomItems.Checked) pk.Item = items[Util.rnd32()%items.Length]; if (CHK_RandomAbilities.Checked) pk.Ability = (int)Util.rnd32()%4; if (CHK_MaxDiffPKM.Checked) pk.IVs = new[] {31, 31, 31, 31, 31, 31}; switch (CB_Moves.SelectedIndex) { case 1: // Random pk.Moves = Randomizer.getRandomMoves( Main.Config.Personal.getFormeEntry(pk.Species, pk.Form).Types, Main.Config.Moves, CHK_Damage.Checked, (int)NUD_Damage.Value, CHK_STAB.Checked, (int)NUD_STAB.Value); break; case 2: // Current LevelUp pk.Moves = getCurrentAttacks(pk); break; case 3: // High Attacks pk.Moves = getHighAttacks(pk); break; } } } }
private void Randomize() { int[] banned = { 165, 621 }; // Struggle, Hyperspace Fury rImportant = new string[CB_TrainerID.Items.Count]; rTags = Main.oras ? GetTagsORAS() : GetTagsXY(); mEvoTypes = GetMegaEvolvableTypes(); List <int> GymE4Types = new List <int>(); // Fetch Move Stats for more difficult randomization var moveData = Moves.getMoves(); int[] moveList = Enumerable.Range(1, movelist.Count() - 1).ToArray(); int mctr = 0; Util.Shuffle(moveList); if (rEnsureMEvo.Length > 0) { if (mEvoTypes.Length < 13 && rTypeTheme) { Util.Alert("There are insufficient types with at least one mega evolution to Guarantee story Mega Evos while keeping Type theming.", "Re-Randomize Personal or don't choose both options."); return; } GymE4Types.AddRange(mEvoTypes); } else { GymE4Types.AddRange(Enumerable.Range(0, types.Length).ToArray()); } foreach (int t1 in rEnsureMEvo.Where(t1 => rTags[t1] != "" && !TagTypes.Keys.Contains(rTags[t1]))) { int t; if (rTags[t1].Contains("GYM") || rTags[t1].Contains("ELITE") || rTags[t1].Contains("CHAMPION")) { t = GymE4Types[(int)(rnd32() % GymE4Types.Count)]; GymE4Types.Remove(t); } else { t = mEvoTypes[rnd32() % mEvoTypes.Length]; } TagTypes[rTags[t1]] = t; } foreach (string t1 in Tags) { if (!TagTypes.Keys.Contains(t1) && t1 != "") { int t; if (t1.Contains("GYM") || t1.Contains("ELITE") || t1.Contains("CHAMPION")) { t = GymE4Types[(int)(rnd32() % GymE4Types.Count)]; GymE4Types.Remove(t); } else { t = (int)(rnd32() % types.Length); } TagTypes[t1] = t; } Console.WriteLine(t1 + ": " + types[TagTypes[t1]]); } randomizing = true; for (int i = 1; i < CB_TrainerID.Items.Count; i++) { CB_TrainerID.SelectedIndex = i; // data is loaded // Setup checkBox_Moves.Checked = rMove || (!rNoMove && checkBox_Moves.Checked); checkBox_Item.Checked = rItem || checkBox_Item.Checked; if (r6PKM && rImportant[i] != null) // skip the first rival battles { // Copy the last slot to random pokemon int lastPKM = Math.Max(CB_numPokemon.SelectedIndex - 1, 0); // 0,1-6 => 0-5 (never is 0) CB_numPokemon.SelectedIndex = 6; for (int f = lastPKM + 1; f < 6; f++) { trpk_pkm[f].SelectedIndex = trpk_IV[lastPKM].SelectedIndex; trpk_lvl[f].SelectedIndex = Math.Min(trpk_lvl[f - 1].SelectedIndex + 1, 100); } } // Randomize Trainer Stats if (rDiffAI) { if (CB_Battle_Type.SelectedIndex == 0) { CB_AI.SelectedIndex = 7; // Max Single } else if (CB_Battle_Type.SelectedIndex == 1) { CB_AI.SelectedIndex = 135; // Max Double } } if ( rClass && // Classes selected to be randomized (!rOnlySingles || CB_Battle_Type.SelectedIndex == 0) && // Nonsingles only get changed if rOnlySingles !rIgnoreClass.Contains(CB_Trainer_Class.SelectedIndex) // Current class isn't a special class ) { int rv = (int)(rnd32() % CB_Trainer_Class.Items.Count); // Ensure the Random Class isn't an exclusive class while (rIgnoreClass.Contains(rv) && !trClass[rv].StartsWith("[~")) // don't allow disallowed classes { rv = (int)(rnd32() % CB_Trainer_Class.Items.Count); } CB_Trainer_Class.SelectedIndex = rv; } if (rGift && rnd32() % 100 < rGiftPercent) #region Random Prize Logic { ushort[] items; uint rnd = rnd32() % 10; if (rnd < 2) // held item { items = Main.oras ? Legal.Pouch_Items_ORAS : Legal.Pouch_Items_XY; } else if (rnd < 5) // medicine { items = Main.oras ? Legal.Pouch_Medicine_ORAS : Legal.Pouch_Medicine_XY; } else // berry { items = Legal.Pouch_Berry_XY; } CB_Prize.SelectedIndex = items[rnd32() % items.Length]; } #endregion else if (rGift) { CB_Prize.SelectedIndex = 0; } ushort[] itemvals = Main.oras ? Legal.Pouch_Items_ORAS : Legal.Pouch_Items_XY; itemvals = itemvals.Concat(Legal.Pouch_Berry_XY).ToArray(); int itemC = itemvals.Length; int ctr = 0; // Trainer Type/Mega Evo int type = GetRandomType(i); bool mevo = rEnsureMEvo.Contains(i); bool typerand = rTypeTheme && !rGymE4Only || (rTypeTheme && rImportant[i] != null && (rImportant[i].Contains("GYM") || rImportant[i].Contains("ELITE") || rImportant[i].Contains("CHAMPION"))); // Randomize Pokemon for (int p = 0; p < CB_numPokemon.SelectedIndex; p++) { PersonalInfo oldpkm = Main.SpeciesStat[trpk_pkm[p].SelectedIndex]; PersonalInfo pkm = null; if (rPKM) { // randomize pokemon int species; pkm = Main.SpeciesStat[species = Randomizer.getRandomSpecies(ref sL, ref ctr)]; if (typerand) { int tries = 0; while (((pkm.Types[0] != type && pkm.Types[1] != type) || mevo && p == CB_numPokemon.SelectedIndex - 1 && !megaEvos.Contains(species)) && tries < 0x10000) { if (p == CB_numPokemon.SelectedIndex - 1 && mevo) { pkm = Main.SpeciesStat[species = GetRandomMegaEvolvablePokemon(type)]; } else if (rSmart) // Get a new Pokemon with a close BST { pkm = Main.SpeciesStat[species = Randomizer.getRandomSpecies(ref sL, ref ctr)]; while (!((pkm.BST * (5 - ++tries / 722) / 6 < oldpkm.BST) && pkm.BST * (6 + ++tries / 722) / 5 > oldpkm.BST)) { pkm = Main.SpeciesStat[species = Randomizer.getRandomSpecies(ref sL, ref ctr)]; } } else { pkm = Main.SpeciesStat[species = Randomizer.getRandomSpecies(ref sL, ref ctr)]; } } } else if (p == CB_numPokemon.SelectedIndex - 1 && mevo) { pkm = Main.SpeciesStat[species = megaEvos[rnd32() % megaEvos.Length]]; } else if (rSmart) // Get a new Pokemon with a close BST { int tries = 0; while (!((pkm.BST * (5 - ++tries / 722) / 6 < oldpkm.BST) && pkm.BST * (6 + ++tries / 722) / 5 > oldpkm.BST)) { pkm = Main.SpeciesStat[species = Randomizer.getRandomSpecies(ref sL, ref ctr)]; } } trpk_pkm[p].SelectedIndex = species; // Set Gender to Random trpk_gender[p].SelectedIndex = 0; if (trpk_form[p].Items.Count > 0) { trpk_form[p].SelectedIndex = 0; } // Randomize form if (trpk_form[p].Items.Count > 0 && (!megaEvos.Contains(species) || rRandomMegas)) { trpk_form[p].SelectedIndex = (int)(rnd32() % trpk_form[p].Items.Count); } } if (rLevel) { trpk_lvl[p].SelectedIndex = Math.Max(1, Math.Min((int)(trpk_lvl[p].SelectedIndex * ((100 + rLevelPercent) / 100)), 100)); } if (rAbility) { trpk_abil[p].SelectedIndex = (int)(1 + rnd32() % 3); } if (rDiffIV) { trpk_IV[p].SelectedIndex = 255; } if (mevo && p == CB_numPokemon.SelectedIndex - 1) { int[] megastones = GetMegaStones(trpk_pkm[p].SelectedIndex); if (megastones.Length > 0) { trpk_item[p].SelectedIndex = megastones[rnd32() % megastones.Length]; } } else if (rItem) #region RandomItem { trpk_item[p].SelectedIndex = itemvals[rnd32() % itemC]; } #endregion if (rMove) { pkm = pkm ?? Main.SpeciesStat[trpk_pkm[p].SelectedIndex]; int[] pkMoves = new int[4]; var moves = new[] { trpk_m1[p], trpk_m2[p], trpk_m3[p], trpk_m4[p] }; int loopctr = 0; getMoves: // Get list of moves loopctr++; for (int m = 0; m < 4; m++) { int mv = Randomizer.getRandomSpecies(ref moveList, ref mctr); while (banned.Contains(mv) || pkMoves.Contains(mv)) { mv = Randomizer.getRandomSpecies(ref moveList, ref mctr); } pkMoves[m] = mv; } // If a certain amount of damaging moves is required, check. if (rDMG) { int damagingMoves = pkMoves.Count(move => moveData[move].Category != 0); if (damagingMoves < rDMGCount && loopctr < 666) { goto getMoves; } } if (rSTAB) { int STAB = pkMoves.Count(move => pkm.Types.Contains(moveData[move].Type)); if (STAB < rSTABCount && loopctr < 666) { goto getMoves; } } // Assign Moves for (int m = 0; m < 4; m++) { moves[m].SelectedIndex = pkMoves[m]; } } } } randomizing = false; CB_TrainerID.SelectedIndex = 1; Util.Alert("Randomized all trainers according to specification!", "Press the Dump to TXT to view the new trainer information!"); }
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 int[] sL = Randomizer.RandomSpeciesList; int ctr = 0; for (int i = 0; i < CB_LocationID.Items.Count; i++) // for every location { CB_LocationID.SelectedIndex = i; if (!hasData()) { continue; // Don't randomize if doesn't have data. } for (int slot = 0; slot < max.Length; slot++) { 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 { form[slot].Value = rnd32() % 20; } else if (species == 386) // Deoxys { form[slot].Value = rnd32() % 4; } else if (species == 201) // Unown { form[slot].Value = rnd32() % 28; } else if (species == 550) // Basculin { form[slot].Value = rnd32() % 2; } else if (species == 412 || species == 413) // Wormadam { form[slot].Value = rnd32() % 3; } else if (species == 422 || species == 423) // Gastrodon { form[slot].Value = rnd32() % 2; } else if (species == 585 || species == 586) // Sawsbuck { form[slot].Value = rnd32() % 4; } else if (species == 669 || species == 671) // Flabebe/Florges { form[slot].Value = rnd32() % 5; } else if (species == 670) // Floette { form[slot].Value = rnd32() % 6; } else if (species == 710 || species == 711) // Pumpkaboo { form[slot].Value = rnd32() % 4; } else { form[slot].Value = 0; } } } B_Save_Click(sender, e); } this.Enabled = true; Util.Alert("Randomized!"); } }