public void Execute(IEnumerable <Area7> Areas, lzGARCFile encdata) { GetTableRandSettings((RandOption)TableRandomizationOption, out int slotStart, out int slotStop, out bool copy); foreach (var Map in Areas) { foreach (var Table in Map.Tables) { if (ModifyLevel) { Table.MinLevel = Randomizer.getModifiedLevel(Table.MinLevel, LevelAmplifier); Table.MaxLevel = Randomizer.getModifiedLevel(Table.MaxLevel, LevelAmplifier); } RandomizeTable7(Table, slotStart, slotStop); if (copy) // copy row 0 to rest { Table.CopySlotsToSOS(); } Table.Write(); } encdata[Map.FileNumber] = Area7.GetDayNightTableBinary(Map.Tables); } }
private void modifyLevels(object sender, EventArgs e) { if (WinFormsUtil.Prompt(MessageBoxButtons.YesNo, "Modify all current Level ranges?", "Cannot undo.") != DialogResult.Yes) { return; } // Disable Interface while modifying Enabled = false; // Calculate % diff we will apply to each level decimal leveldiff = NUD_LevelAmp.Value; // Cycle through each location to modify levels for (int i = 0; i < CB_LocationID.Items.Count; i++) // for every location { // Load location CB_LocationID.SelectedIndex = i; // Amp Levels for (int l = 0; l < max.Length; l++) { if (min[l].Value > 1) { min[l].Value = max[l].Value = Randomizer.getModifiedLevel((int)max[l].Value, leveldiff); } } // Save Changes B_Save_Click(sender, e); } // Enable Interface... modification complete. Enabled = true; WinFormsUtil.Alert("Modified all Level ranges according to specification!", "Press the Dump Tables button to view the new Level ranges!"); }
private void ModifyLevels(object sender, EventArgs e) { if (WinFormsUtil.Prompt(MessageBoxButtons.YesNo, "Modify all current Levels?", "Cannot undo.") != DialogResult.Yes) { return; } // encounter for (int i = 0; i < LB_Encounter.Items.Count; i++) { LB_Encounter.SelectedIndex = i; NUD_ELevel.Value = Randomizer.getModifiedLevel((int)NUD_ELevel.Value, NUD_LevelBoost.Value); } // gift for (int i = 0; i < LB_Gift.Items.Count; i++) { LB_Gift.SelectedIndex = i; NUD_GLevel.Value = Randomizer.getModifiedLevel((int)NUD_GLevel.Value, NUD_LevelBoost.Value); } // trade for (int i = 0; i < LB_Trade.Items.Count; i++) { LB_Trade.SelectedIndex = i; NUD_TLevel.Value = Randomizer.getModifiedLevel((int)NUD_TLevel.Value, NUD_LevelBoost.Value); } WinFormsUtil.Alert("Modified all Levels according to specification!"); }
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_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; } setGift(); setEncounter(); setTrade(); var specrand = getRandomizer(); var formrand = new FormRandomizer(Main.Config) { AllowMega = false, AllowAlolanForm = true }; var move = new LearnsetRandomizer(Main.Config, Main.Config.Learnsets); for (int i = 3; i < Gifts.Length; i++) // Skip Starters { var t = Gifts[i]; t.Species = specrand.GetRandomSpecies(t.Species); t.Form = formrand.GetRandomForme(t.Species); if (CHK_Level.Checked) { t.Level = Randomizer.getModifiedLevel(t.Level, NUD_LevelBoost.Value); } } foreach (EncounterStatic7 t in Encounters) { t.Species = specrand.GetRandomSpecies(t.Species); t.Form = formrand.GetRandomForme(t.Species); t.RelearnMoves = move.GetCurrentMoves(t.Species, t.Form, t.Level, 4); if (CHK_Level.Checked) { t.Level = Randomizer.getModifiedLevel(t.Level, NUD_LevelBoost.Value); } } foreach (EncounterTrade7 t in Trades) { t.Species = specrand.GetRandomSpecies(t.Species); t.Form = formrand.GetRandomForme(t.Species); t.TradeRequestSpecies = specrand.GetRandomSpecies(t.TradeRequestSpecies); 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_Starters_Click(object sender, EventArgs e) { if (WinFormsUtil.Prompt(MessageBoxButtons.YesNo, "Randomize Starters? Cannot undo.", "Double check Randomization settings before continuing.") != DialogResult.Yes) { return; } setGift(); var specrand = getRandomizer(); var formrand = new FormRandomizer(Main.Config) { AllowMega = false, AllowAlolanForm = true }; var items = Randomizer.getRandomItemList(); // Assign Species for (int i = 0; i < 3; i++) { var t = Gifts[i]; t.Species = specrand.GetRandomSpecies(oldStarters[i]); t.Form = formrand.GetRandomForme(t.Species); t.Nature = -1; // random if (CHK_AllowMega.Checked) { formrand.AllowMega = true; } if (CHK_Item.Checked) { t.HeldItem = items[Util.rnd32() % items.Length]; } if (CHK_Level.Checked) { t.Level = Randomizer.getModifiedLevel(t.Level, NUD_LevelBoost.Value); } if (CHK_RemoveShinyLock.Checked) { t.ShinyLock = false; // in case any user modifications locked the starters } if (CHK_SpecialMove.Checked) { t.SpecialMove = Util.rand.Next(1, CB_SpecialMove.Items.Count); // don't allow none } if (CHK_RandomAbility.Checked) { t.Ability = (sbyte)(Util.rand.Next(0, 3)); // 1, 2, or H } } getListBoxEntries(); getGift(); WinFormsUtil.Alert("Randomized Starters according to specification!"); }
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; } var formrand = new FormRandomizer(Main.Config) { AllowMega = false, AllowAlolanForm = false }; var specrand = new SpeciesRandomizer(Main.Config) { G1 = CHK_G1.Checked, G2 = CHK_G2.Checked, G3 = CHK_G3.Checked, G4 = CHK_G4.Checked, G5 = CHK_G5.Checked, G6 = CHK_G6.Checked, G7 = false, E = CHK_E.Checked, L = CHK_L.Checked, rBST = CHK_BST.Checked, }; specrand.Initialize(); for (int i = 0; i < LB_Gifts.Items.Count; i++) { LB_Gifts.SelectedIndex = i; int species = CB_Species.SelectedIndex; if (MegaDictionary.Values.Any(z => z.Contains(CB_HeldItem.SelectedIndex))) // mega stone gift pkm (only lucario?) { if (!CHK_Mega.Checked) { continue; // skip Lucario, battle needs to mega evolve } int[] items = GetRandomMega(out species); CB_HeldItem.SelectedIndex = items[Util.rand.Next(0, items.Length)]; } else { species = specrand.GetRandomSpecies(species); } CB_Species.SelectedIndex = species; NUD_Form.Value = formrand.GetRandomForme(species); 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 Gift Pokémon 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) { if (WinFormsUtil.Prompt(MessageBoxButtons.YesNo, "Randomize all? Cannot undo.", "Double check Randomization settings in the Randomizer Options tab.") != DialogResult.Yes) { return; } var formrand = new FormRandomizer(Main.Config) { AllowMega = false, AllowAlolanForm = false }; var specrand = new SpeciesRandomizer(Main.Config) { G1 = CHK_G1.Checked, G2 = CHK_G2.Checked, G3 = CHK_G3.Checked, G4 = CHK_G4.Checked, G5 = CHK_G5.Checked, G6 = CHK_G6.Checked, G7 = false, E = CHK_E.Checked, L = CHK_L.Checked, rBST = CHK_BST.Checked, }; specrand.Initialize(); for (int i = 0; i < LB_Encounters.Items.Count; i++) { LB_Encounters.SelectedIndex = i; int species = CB_Species.SelectedIndex; species = specrand.GetRandomSpecies(species); CB_Species.SelectedIndex = species; NUD_Form.Value = formrand.GetRandomForme(species); 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 ModifyAllLevelRanges(object sender, EventArgs e) { if (DialogResult.Yes != WinFormsUtil.Prompt(MessageBoxButtons.YesNo, "Modify all current Level ranges?", "Cannot undo.")) { return; } // Disable Interface while modifying Enabled = false; // Cycle through each location to modify levels foreach (var Table in Areas.SelectMany(Map => Map.Tables)) { Table.MinLevel = Randomizer.getModifiedLevel(Table.MinLevel, NUD_LevelAmp.Value); Table.MaxLevel = Randomizer.getModifiedLevel(Table.MaxLevel, NUD_LevelAmp.Value); Table.Write(); } // Enable Interface... modification complete. Enabled = true; WinFormsUtil.Alert("Modified all Level ranges according to specification!", "Press the Dump Tables button to view the new Level ranges!"); UpdatePanel(sender, e); }
private void B_Randomize_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; } CB_TrainerID.SelectedIndex = 0; var rnd = new SpeciesRandomizer(Main.Config) { G1 = CHK_G1.Checked, G2 = CHK_G2.Checked, G3 = CHK_G3.Checked, G4 = CHK_G4.Checked, G5 = CHK_G5.Checked, G6 = CHK_G6.Checked, G7 = CHK_G7.Checked, E = CHK_E.Checked, L = CHK_L.Checked, rBST = CHK_BST.Checked, }; rnd.Initialize(); // add Legendary/Mythical to final evolutions if checked if (CHK_L.Checked) { FinalEvo = FinalEvo.Concat(Legendary).ToArray(); } if (CHK_E.Checked) { FinalEvo = FinalEvo.Concat(Mythical).ToArray(); } var banned = new List <int>(new[] { 165, 621, 464 }.Concat(Legal.Z_Moves)); // Struggle, Hyperspace Fury, Dark Void if (CHK_NoFixedDamage.Checked) { banned.AddRange(MoveRandomizer.FixedDamageMoves); } var move = new MoveRandomizer(Main.Config) { BannedMoves = banned, rSTABCount = (int)NUD_STAB.Value, rDMG = CHK_Damage.Checked, rDMGCount = (int)NUD_Damage.Value, rSTAB = CHK_STAB.Checked }; 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) { // ignore special classes if (CHK_IgnoreSpecialClass.Checked && !SpecialClasses.Contains(tr.TrainerClass)) { int randClass() => (int)(Util.rnd32() % CB_Trainer_Class.Items.Count); int rv; do { rv = randClass(); }while (SpecialClasses.Contains(rv)); // don't allow disallowed classes tr.TrainerClass = (byte)rv; } // all classes else if (!CHK_IgnoreSpecialClass.Checked) { int randClass() => (int)(Util.rnd32() % CB_Trainer_Class.Items.Count); int rv; do { rv = randClass(); }while (rv == 082); // Lusamine 2 can crash multi battles, skip tr.TrainerClass = (byte)rv; } } 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); int[] royal = { 081, 082, 083, 084, 185 }; if (tr.NumPokemon < NUD_RMin.Value) { 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; } if (CHK_6PKM.Checked && ImportantTrainers.Contains(tr.ID)) { for (int g = tr.NumPokemon; g < 6; g++) { tr.Pokemon.Add(new trpoke7 { Species = rnd.GetRandomSpecies(avgSpec), Level = avgLevel, }); } tr.NumPokemon = 6; } // force 1 pkm to keep forced Battle Royal fair if (royal.Contains(tr.ID)) { tr.NumPokemon = 1; } // PKM Properties foreach (var pk in tr.Pokemon) { if (CHK_RandomPKM.Checked) { int Type = CHK_TypeTheme.Checked ? (int)Util.rnd32() % 17 : -1; // replaces Megas with another Mega (Dexio and Lysandre in USUM) if (MegaDictionary.Values.Any(z => z.Contains(pk.Item))) { int[] mega = GetRandomMega(out int species); pk.Species = species; pk.Item = mega[Util.rand.Next(0, mega.Length)]; pk.Form = 0; // allow it to Mega Evolve naturally } // every other pkm else { pk.Species = rnd.GetRandomSpeciesType(pk.Species, Type); pk.Item = items[Util.rnd32() % items.Length]; pk.Form = Randomizer.GetRandomForme(pk.Species, CHK_RandomMegaForm.Checked, true, Main.SpeciesStat); } pk.Gender = 0; // random pk.Nature = (int)(Util.rnd32() % CB_Nature.Items.Count); // random } if (CHK_Level.Checked) { pk.Level = Randomizer.getModifiedLevel(pk.Level, NUD_LevelBoost.Value); } if (CHK_RandomShiny.Checked) { pk.Shiny = Util.rand.Next(0, 100 + 1) < NUD_Shiny.Value; } if (CHK_RandomAbilities.Checked) { pk.Ability = (int)Util.rnd32() % 4; } if (CHK_MaxDiffPKM.Checked) { pk.IVs = new[] { 31, 31, 31, 31, 31, 31 } } ; if (CHK_MaxAI.Checked) { tr.AI |= (int)(TrainerAI.Basic | TrainerAI.Strong | TrainerAI.Expert | TrainerAI.PokeChange); } if (CHK_ForceFullyEvolved.Checked && pk.Level >= NUD_ForceFullyEvolved.Value && !FinalEvo.Contains(pk.Species)) { int randFinalEvo() => (int)(Util.rnd32() % FinalEvo.Length); pk.Species = FinalEvo[randFinalEvo()]; pk.Form = Randomizer.GetRandomForme(pk.Species, CHK_RandomMegaForm.Checked, true, Main.SpeciesStat); } switch (CB_Moves.SelectedIndex) { case 1: // Random pk.Moves = move.GetRandomMoveset(pk.Species, 4); break; case 2: // Current LevelUp pk.Moves = learn.GetCurrentMoves(pk.Species, pk.Form, pk.Level, 4); break; case 3: // Metronome pk.Moves = new[] { 118, 0, 0, 0 }; break; } // high-power attacks if (CHK_ForceHighPower.Checked && pk.Level >= NUD_ForceHighPower.Value) { pk.Moves = learn.GetHighPoweredMoves(pk.Species, pk.Form, 4); } // sanitize moves if (CB_Moves.SelectedIndex > 1) // learn source { var moves = pk.Moves; if (move.SanitizeMovesetForBannedMoves(moves, pk.Species)) { pk.Moves = moves; } } } SaveData(tr, i); } WinFormsUtil.Alert("Randomized all Trainers according to specification!", "Press the Dump to .TXT button to view the new Trainer information!"); }
private void B_Randomize_Click(object sender, EventArgs e) { if (WinFormsUtil.Prompt(MessageBoxButtons.YesNo, "Randomize all? Cannot undo.", "Double check Randomization settings in the Misc/Rand tab.") != DialogResult.Yes) { return; } CB_TrainerID.SelectedIndex = 0; var rnd = new SpeciesRandomizer(Main.Config) { G1 = CHK_G1.Checked, G2 = CHK_G2.Checked, G3 = CHK_G3.Checked, G4 = CHK_G4.Checked, G5 = CHK_G5.Checked, G6 = CHK_G6.Checked, G7 = CHK_G7.Checked, E = CHK_E.Checked, L = CHK_L.Checked, rBST = CHK_BST.Checked, }; rnd.Initialize(); 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.GetRandomSpeciesType(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 = Randomizer.getModifiedLevel(pk.Level, NUD_LevelBoost.Value); } 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 = move.GetCurrentMoves(pk.Species, pk.Form, pk.Level, 4); break; case 3: // High Attacks pk.Moves = move.GetHighPoweredMoves(pk.Species, pk.Form, 4); break; } } saveData(tr, i); } WinFormsUtil.Alert("Randomized all Trainers according to specification!", "Press the Dump to .TXT button to view the new Trainer information!"); }
private static void RandomizeTeam(trdata6 t, MoveRandomizer move, LearnsetRandomizer learn, ushort[] itemvals, int type, bool mevo, bool typerand) { int last = t.Team.Length - 1; for (int p = 0; p < t.Team.Length; p++) { var pk = t.Team[p]; int[] stones = null; if (rPKM) { // randomize pokemon int species; if (typerand) { species = rSpeciesRand.GetRandomSpeciesType(pk.Species, type); if (p == last && mevo) { int tries = 0; do { stones = GetRandomMega(out species); }while (Main.Config.Personal[species].Types.All(z => z != type) && tries++ < 100); } } else if (p == last && mevo) { stones = GetRandomMega(out species); } else { species = rSpeciesRand.GetRandomSpecies(pk.Species); } pk.Species = (ushort)species; pk.Gender = 0; // Set Gender to Random bool mega = rRandomMegas & !(mevo && p == last); // except if mega evolution is forced for the last slot pk.Form = (ushort)Randomizer.GetRandomForme(pk.Species, mega, true, Main.SpeciesStat); } if (rLevel) { pk.Level = (ushort)Randomizer.getModifiedLevel(pk.Level, rLevelMultiplier); } if (rAbility) { pk.Ability = (int)(1 + rnd32() % 3); } if (rDiffIV) { pk.IVs = 255; } if (mevo && p == last && stones != null) { pk.Item = (ushort)stones[rnd32() % stones.Length]; } else if (rItem) { pk.Item = itemvals[rnd32() % itemvals.Length]; } if (rForceFullyEvolved && pk.Level >= rForceFullyEvolvedLevel && !rFinalEvo.Contains(pk.Species)) { int randFinalEvo() => (int)(Util.rnd32() % rFinalEvo.Length); pk.Species = (ushort)rFinalEvo[randFinalEvo()]; pk.Form = (ushort)Randomizer.GetRandomForme(pk.Species, rRandomMegas, true, Main.SpeciesStat); } // random if (rMove) { var pkMoves = move.GetRandomMoveset(pk.Species, 4); for (int m = 0; m < 4; m++) { pk.Moves[m] = (ushort)pkMoves[m]; } } // levelup if (rNoMove) { t.Moves = true; var pkMoves = learn.GetCurrentMoves(pk.Species, pk.Form, pk.Level, 4); for (int m = 0; m < 4; m++) { pk.Moves[m] = (ushort)pkMoves[m]; } } // high-power attacks if (rForceHighPower && pk.Level >= rForceHighPowerLevel) { var pkMoves = learn.GetHighPoweredMoves(pk.Species, pk.Form, 4); for (int m = 0; m < 4; m++) { pk.Moves[m] = (ushort)pkMoves[m]; } } } }
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; } setGift(); setEncounter(); setTrade(); var specrand = getRandomizer(); var formrand = new FormRandomizer(Main.Config) { AllowMega = false, AllowAlolanForm = true }; var move = new LearnsetRandomizer(Main.Config, Main.Config.Learnsets); var items = Randomizer.getRandomItemList(); int[] banned = Legal.Z_Moves.Concat(new int[] { 165, 621 }).ToArray(); int randFinalEvo() => (int)(Util.rnd32() % FinalEvo.Length); int randLegend() => (int)(Util.rnd32() % ReplaceLegend.Length); for (int i = 3; i < Gifts.Length; i++) // Skip Starters { var t = Gifts[i]; // Legendary-for-Legendary if (CHK_ReplaceLegend.Checked && ReplaceLegend.Contains(t.Species) || UnevolvedLegend.Contains(t.Species)) { t.Species = ReplaceLegend[randLegend()]; } // every other entry else { t.Species = specrand.GetRandomSpecies(t.Species); } if (CHK_AllowMega.Checked) { formrand.AllowMega = true; } if (CHK_Item.Checked) { t.HeldItem = items[Util.rnd32() % items.Length]; } if (CHK_Level.Checked) { t.Level = Randomizer.getModifiedLevel(t.Level, NUD_LevelBoost.Value); } if (CHK_RemoveShinyLock.Checked) { t.ShinyLock = false; } if (CHK_SpecialMove.Checked) { int rv = Util.rand.Next(1, CB_SpecialMove.Items.Count); if (banned.Contains(rv)) { continue; // disallow banned moves } t.SpecialMove = rv; } if (CHK_RandomAbility.Checked) { t.Ability = (sbyte)(Util.rand.Next(0, 3)); // 1, 2, or H } if (CHK_ForceFullyEvolved.Checked && t.Level >= NUD_ForceFullyEvolved.Value && !FinalEvo.Contains(t.Species)) { t.Species = FinalEvo[randFinalEvo()]; } t.Form = Randomizer.GetRandomForme(t.Species, CHK_AllowMega.Checked, true, Main.SpeciesStat); t.Nature = -1; // random } foreach (EncounterStatic7 t in Encounters) { // Legendary-for-Legendary if (CHK_ReplaceLegend.Checked && ReplaceLegend.Contains(t.Species)) { t.Species = ReplaceLegend[randLegend()]; } // fully evolved Totems else if (CHK_ForceTotem.Checked && Totem.Contains(t.Species)) { t.Species = FinalEvo[randFinalEvo()]; } // every other entry else { t.Species = specrand.GetRandomSpecies(t.Species); } if (CHK_AllowMega.Checked) { formrand.AllowMega = true; } if (CHK_Item.Checked) { t.HeldItem = items[Util.rnd32() % items.Length]; } if (CHK_Level.Checked) { t.Level = Randomizer.getModifiedLevel(t.Level, NUD_LevelBoost.Value); } if (CHK_RemoveShinyLock.Checked) { t.ShinyLock = false; } if (CHK_RandomAura.Checked && t.Aura != 0) // don't apply aura to a pkm without it { t.Aura = Util.rand.Next(1, CB_Aura.Items.Count); // don't allow none } if (CHK_RandomAbility.Checked) { t.Ability = (sbyte)(Util.rand.Next(1, 4)); // 1, 2, or H } if (CHK_ForceFullyEvolved.Checked && t.Level >= NUD_ForceFullyEvolved.Value && !FinalEvo.Contains(t.Species)) { t.Species = FinalEvo[randFinalEvo()]; } t.Form = Randomizer.GetRandomForme(t.Species, CHK_AllowMega.Checked, true, Main.SpeciesStat); t.RelearnMoves = move.GetCurrentMoves(t.Species, t.Form, t.Level, 4); t.Gender = 0; // random t.Nature = 0; // random } foreach (EncounterTrade7 t in Trades) { t.Species = specrand.GetRandomSpecies(t.Species); t.TradeRequestSpecies = specrand.GetRandomSpecies(t.TradeRequestSpecies); if (CHK_AllowMega.Checked) { formrand.AllowMega = true; } if (CHK_Item.Checked) { t.HeldItem = items[Util.rnd32() % items.Length]; } if (CHK_Level.Checked) { t.Level = Randomizer.getModifiedLevel(t.Level, NUD_LevelBoost.Value); } if (CHK_RandomAbility.Checked) { t.Ability = (sbyte)(Util.rand.Next(0, 3)); // 1, 2, or H } if (CHK_ForceFullyEvolved.Checked && t.Level >= NUD_ForceFullyEvolved.Value && !FinalEvo.Contains(t.Species)) { t.Species = FinalEvo[randFinalEvo()]; // only do offered species to be fair } t.Form = Randomizer.GetRandomForme(t.Species, CHK_AllowMega.Checked, true, Main.SpeciesStat); t.Nature = (int)(Util.rnd32() % CB_TNature.Items.Count); // randomly selected } getListBoxEntries(); getGift(); getEncounter(); getTrade(); WinFormsUtil.Alert("Randomized 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; } setGift(); var specrand = getRandomizer(); var formrand = new FormRandomizer(Main.Config) { AllowMega = false, AllowAlolanForm = true }; var items = Randomizer.getRandomItemList(); int[] banned = Legal.Z_Moves.Concat(new int[] { 165, 621 }).ToArray(); // Assign Species for (int i = 0; i < 3; i++) { var t = Gifts[i]; // Pokemon with 2 evolutions if (CHK_BasicStarter.Checked) { int basic() => (int)(Util.rnd32() % BasicStarter.Length); t.Species = BasicStarter[basic()]; } else { t.Species = specrand.GetRandomSpecies(oldStarters[i]); } if (CHK_AllowMega.Checked) { formrand.AllowMega = true; } if (CHK_Item.Checked) { t.HeldItem = items[Util.rnd32() % items.Length]; } if (CHK_Level.Checked) { t.Level = Randomizer.getModifiedLevel(t.Level, NUD_LevelBoost.Value); } if (CHK_RemoveShinyLock.Checked) { t.ShinyLock = false; } if (CHK_SpecialMove.Checked) { int rv = Util.rand.Next(1, CB_SpecialMove.Items.Count); if (banned.Contains(rv)) { continue; // disallow banned moves } t.SpecialMove = rv; } if (CHK_RandomAbility.Checked) { t.Ability = (sbyte)(Util.rand.Next(0, 3)); // 1, 2, or H } t.Form = Randomizer.GetRandomForme(t.Species, CHK_AllowMega.Checked, true, Main.SpeciesStat); t.Nature = -1; // random } getListBoxEntries(); getGift(); WinFormsUtil.Alert("Randomized Starters according to specification!"); }
private void Randomize() { int[] banned = { 165, 621 }; // Struggle, Hyperspace Fury rImportant = new string[CB_TrainerID.Items.Count]; rTags = Main.Config.ORAS ? GetTagsORAS() : GetTagsXY(); mEvoTypes = GetMegaEvolvableTypes(); List <int> GymE4Types = new List <int>(); // Fetch Move Stats for more difficult randomization var moveData = Main.Config.Moves; int[] moveList = Enumerable.Range(1, movelist.Length - 1).ToArray(); int mctr = 0; Util.Shuffle(moveList); if (rEnsureMEvo.Length > 0) { if (mEvoTypes.Length < 13 && rTypeTheme) { WinFormsUtil.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.Config.ORAS ? Legal.Pouch_Items_ORAS : Legal.Pouch_Items_XY; } else if (rnd < 5) // medicine { items = Main.Config.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.Config.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 / Main.Config.MaxSpeciesID) / 6 < oldpkm.BST && pkm.BST * (6 + ++tries / Main.Config.MaxSpeciesID) / 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 / Main.Config.MaxSpeciesID) / 6 < oldpkm.BST && pkm.BST * (6 + ++tries / Main.Config.MaxSpeciesID) / 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 = Randomizer.getModifiedLevel(trpk_lvl[p].SelectedIndex, rLevelMultiplier); } 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; WinFormsUtil.Alert("Randomized all Trainers according to specification!", "Press the Dump to .TXT button to view the new Trainer information!"); }
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; } var formrand = new FormRandomizer(Main.Config) { AllowMega = false, AllowAlolanForm = false }; var specrand = new SpeciesRandomizer(Main.Config) { G1 = CHK_G1.Checked, G2 = CHK_G2.Checked, G3 = CHK_G3.Checked, G4 = CHK_G4.Checked, G5 = CHK_G5.Checked, G6 = CHK_G6.Checked, G7 = false, E = CHK_E.Checked, L = CHK_L.Checked, rBST = CHK_BST.Checked, }; specrand.Initialize(); var items = Randomizer.getRandomItemList(); for (int i = 0; i < LB_Encounters.Items.Count; i++) { LB_Encounters.SelectedIndex = i; int species = CB_Species.SelectedIndex; // replace Legendaries with another Legendary if (CHK_ReplaceLegend.Checked && ReplaceLegend.Contains(species)) { int randLegend() => (int)(Util.rnd32() % ReplaceLegend.Length); species = ReplaceLegend[randLegend()]; } // every other entry else { species = specrand.GetRandomSpecies(species); } if (CHK_AllowMega.Checked) { formrand.AllowMega = true; } if (CHK_Item.Checked) { CB_HeldItem.SelectedIndex = items[Util.rnd32() % items.Length]; } if (CHK_Level.Checked) { NUD_Level.Value = Randomizer.getModifiedLevel((int)NUD_Level.Value, NUD_LevelBoost.Value); } if (CHK_RemoveShinyLock.Checked) { CHK_ShinyLock.Checked = false; } if (CHK_RandomAbility.Checked) { CB_Ability.SelectedIndex = (Util.rand.Next(1, 4)); // 1, 2 , or H } if (CHK_ForceFullyEvolved.Checked && NUD_Level.Value >= NUD_ForceFullyEvolved.Value && !FinalEvo.Contains(species)) { int randFinalEvo() => (int)(Util.rnd32() % FinalEvo.Length); species = FinalEvo[randFinalEvo()]; } CB_Species.SelectedIndex = species; NUD_Form.Value = formrand.GetRandomForme(species); CB_Gender.SelectedIndex = 0; // random } WinFormsUtil.Alert("Randomized all Static Encounters according to specification!"); }
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; } var formrand = new FormRandomizer(Main.Config) { AllowMega = false, AllowAlolanForm = false }; var specrand = new SpeciesRandomizer(Main.Config) { G1 = CHK_G1.Checked, G2 = CHK_G2.Checked, G3 = CHK_G3.Checked, G4 = CHK_G4.Checked, G5 = CHK_G5.Checked, G6 = CHK_G6.Checked, G7 = false, E = CHK_E.Checked, L = CHK_L.Checked, rBST = CHK_BST.Checked, }; specrand.Initialize(); var helditems = Randomizer.getRandomItemList(); for (int i = 0; i < LB_Gifts.Items.Count; i++) { LB_Gifts.SelectedIndex = i; int species = CB_Species.SelectedIndex; if (MegaDictionary.Values.Any(z => z.Contains(CB_HeldItem.SelectedIndex))) // Mega Stone Gifts (Lucario, Latias/Latios) { if (!CHK_ReplaceMega.Checked) { continue; // skip Lucario, battle needs to Mega Evolve } int[] items = GetRandomMega(out species); CB_HeldItem.SelectedIndex = items[Util.rand.Next(0, items.Length)]; } else { species = specrand.GetRandomSpecies(species); if (CHK_Item.Checked) { CB_HeldItem.SelectedIndex = helditems[Util.rnd32() % helditems.Length]; } } if (CHK_AllowMega.Checked) { formrand.AllowMega = true; } CB_Species.SelectedIndex = species; NUD_Form.Value = formrand.GetRandomForme(species); CB_Gender.SelectedIndex = 0; // random CB_Nature.SelectedIndex = 0; // random if (MegaDictionary.Values.Any(z => z.Contains(CB_HeldItem.SelectedIndex)) && NUD_Form.Value > 0) { NUD_Form.Value = 0; // don't allow Mega Stone Gifts to be form 1 } if (CHK_RemoveShinyLock.Checked) { CHK_ShinyLock.Checked = false; } if (CHK_Level.Checked) { NUD_Level.Value = Randomizer.getModifiedLevel((int)NUD_Level.Value, NUD_LevelBoost.Value); } if (CHK_RandomAbility.Checked) { CB_Ability.SelectedIndex = (Util.rand.Next(1, 4)); // 1, 2 , or H } } WinFormsUtil.Alert("Randomized all Gift Pokémon 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; } setGift(); setEncounter(); setTrade(); var specrand = getRandomizer(); var formrand = new FormRandomizer(Main.Config) { AllowMega = false, AllowAlolanForm = true }; var move = new LearnsetRandomizer(Main.Config, Main.Config.Learnsets); var items = Randomizer.getRandomItemList(); for (int i = 3; i < Gifts.Length; i++) // Skip Starters { var t = Gifts[i]; t.Species = specrand.GetRandomSpecies(t.Species); t.Form = formrand.GetRandomForme(t.Species); t.Nature = -1; // random if (CHK_AllowMega.Checked) { formrand.AllowMega = true; } if (CHK_Item.Checked) { t.HeldItem = items[Util.rnd32() % items.Length]; } if (CHK_Level.Checked) { t.Level = Randomizer.getModifiedLevel(t.Level, NUD_LevelBoost.Value); } if (CHK_RemoveShinyLock.Checked) { t.ShinyLock = false; } if (CHK_SpecialMove.Checked) { t.SpecialMove = Util.rand.Next(1, CB_SpecialMove.Items.Count); // don't allow none } if (CHK_RandomAbility.Checked) { t.Ability = (sbyte)(Util.rand.Next(0, 3)); // 1, 2, or H } } foreach (EncounterStatic7 t in Encounters) { t.Species = specrand.GetRandomSpecies(t.Species); t.Form = formrand.GetRandomForme(t.Species); t.RelearnMoves = move.GetCurrentMoves(t.Species, t.Form, t.Level, 4); t.Gender = 0; // random t.Nature = 0; // random if (CHK_AllowMega.Checked) { formrand.AllowMega = true; } if (CHK_Item.Checked) { t.HeldItem = items[Util.rnd32() % items.Length]; } if (CHK_Level.Checked) { t.Level = Randomizer.getModifiedLevel(t.Level, NUD_LevelBoost.Value); } if (CHK_RemoveShinyLock.Checked) { t.ShinyLock = false; } if (CHK_RandomAura.Checked && t.Aura != 0) // don't apply aura to a pkm without it { t.Aura = Util.rand.Next(1, CB_Aura.Items.Count); // don't allow none } if (CHK_RandomAbility.Checked) { t.Ability = (sbyte)(Util.rand.Next(1, 4)); // 1, 2, or H } } foreach (EncounterTrade7 t in Trades) { t.Species = specrand.GetRandomSpecies(t.Species); t.Form = formrand.GetRandomForme(t.Species); t.TradeRequestSpecies = specrand.GetRandomSpecies(t.TradeRequestSpecies); t.Nature = (int)(Util.rnd32() % CB_TNature.Items.Count); // randomly selected if (CHK_AllowMega.Checked) { formrand.AllowMega = true; } if (CHK_Item.Checked) { t.HeldItem = items[Util.rnd32() % items.Length]; } if (CHK_Level.Checked) { t.Level = Randomizer.getModifiedLevel(t.Level, NUD_LevelBoost.Value); } if (CHK_RandomAbility.Checked) { t.Ability = (sbyte)(Util.rand.Next(0, 3)); // 1, 2, or H } } getListBoxEntries(); getGift(); getEncounter(); getTrade(); WinFormsUtil.Alert("Randomized Static Encounters according to specification!"); }
private static void RandomizeTeam(trdata6 t, MoveRandomizer move, ushort[] itemvals, int type, bool mevo, bool typerand) { int last = t.Team.Length - 1; for (int p = 0; p < t.Team.Length; p++) { var pk = t.Team[p]; int[] stones = null; if (rPKM) { // randomize pokemon int species; if (typerand) { species = rSpeciesRand.GetRandomSpeciesType(pk.Species, type); if (p == last && mevo) { int tries = 0; do { stones = GetRandomMega(out species); }while (Main.Config.Personal[species].Types.All(z => z != type) && tries++ < 100); } } else if (p == last && mevo) { stones = GetRandomMega(out species); } else { species = rSpeciesRand.GetRandomSpecies(pk.Species); } pk.Species = (ushort)species; pk.Gender = 0; // Set Gender to Random bool mega = rRandomMegas & !(mevo && p == last); // except if mega evolution is forced for the last slot pk.Form = (ushort)Randomizer.GetRandomForme(pk.Species, mega, true, Main.SpeciesStat); } if (rLevel) { pk.Level = (ushort)Randomizer.getModifiedLevel(pk.Level, rLevelMultiplier); } if (rAbility) { pk.Ability = (int)(1 + rnd32() % 3); } if (rDiffIV) { pk.IVs = 255; } if (mevo && p == last && stones != null) { pk.Item = (ushort)stones[rnd32() % stones.Length]; } else if (rItem) { pk.Item = itemvals[rnd32() % itemvals.Length]; } if (rMove) { var pkMoves = move.GetRandomMoveset(pk.Species, 4); for (int m = 0; m < 4; m++) { pk.Moves[m] = (ushort)pkMoves[m]; } } } }
// 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; } var rnd = new SpeciesRandomizer(Main.Config) { G1 = CHK_G1.Checked, G2 = CHK_G2.Checked, G3 = CHK_G3.Checked, G4 = CHK_G4.Checked, G5 = CHK_G5.Checked, G6 = CHK_G6.Checked, G7 = CHK_G7.Checked, E = CHK_E.Checked, L = CHK_L.Checked, rBST = CHK_BST.Checked, }; rnd.Initialize(); 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!"); }