Exemplo n.º 1
0
        private void B_Randomize_Click(object sender, EventArgs e)
        {
            if (WinFormsUtil.Prompt(MessageBoxButtons.YesNo, "Randomize all? Cannot undo.", "Double check Randomization settings in the Enhancements tab.") != DialogResult.Yes)
            {
                return;
            }
            SaveEntry();

            // input settings
            var rnd = new PersonalRandomizer(Main.SpeciesStat, Main.Config)
            {
                TypeCount                = CB_Type1.Items.Count,
                ModifyCatchRate          = CHK_CatchRate.Checked,
                ModifyEggGroup           = CHK_EggGroup.Checked,
                ModifyStats              = CHK_Stats.Checked,
                ShuffleStats             = CHK_Shuffle.Checked,
                StatsToRandomize         = rstat_boxes.Select(g => g.Checked).ToArray(),
                ModifyAbilities          = CHK_Ability.Checked,
                ModifyLearnsetTM         = CHK_TM.Checked,
                ModifyLearnsetHM         = CHK_HM.Checked,
                ModifyLearnsetTypeTutors = CHK_Tutors.Checked,
                ModifyLearnsetMoveTutors = Main.Config.ORAS && CHK_ORASTutors.Checked,
                ModifyTypes              = CHK_Type.Checked,
                ModifyHeldItems          = CHK_Item.Checked,
                SameTypeChance           = NUD_TypePercent.Value,
                SameEggGroupChance       = NUD_Egg.Value,
                StatDeviation            = NUD_StatDev.Value,
                AllowWonderGuard         = CHK_WGuard.Checked,
                MoveIDsTMs               = TMs,
            };

            rnd.Execute();
            Main.SpeciesStat.Select(z => z.Write()).ToArray().CopyTo(files, 0);

            ReadEntry();
            WinFormsUtil.Alert("Randomized all Pokémon Personal data entries according to specification!", "Press the Dump All button to view the new Personal data!");
        }
Exemplo n.º 2
0
        private void ModifyLevels(object sender, EventArgs e)
        {
            if (WinFormsUtil.Prompt(MessageBoxButtons.YesNo, "Modify all current Levels?", "Cannot undo.") != DialogResult.Yes)
            {
                return;
            }

            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);
            }
            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);
            }
            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!");
        }
Exemplo n.º 3
0
        private void B_Randomize_Click(object sender, EventArgs e)
        {
            if (DialogResult.Yes != WinFormsUtil.Prompt(MessageBoxButtons.YesNoCancel, "Randomize mart inventories?"))
            {
                return;
            }

            int[] validItems = Randomizer.getRandomItemList();

            int ctr = 0;

            Util.Shuffle(validItems);

            bool specialOnly = DialogResult.Yes == WinFormsUtil.Prompt(MessageBoxButtons.YesNo, "Randomize only special marts?", "Will leave regular necessities intact.");
            int  start       = specialOnly ? 10 : 0;

            for (int i = start; i < CB_Location.Items.Count; i++)
            {
                CB_Location.SelectedIndex = i;
                for (int r = 0; r < dgv.Rows.Count; r++)
                {
                    int currentItem = Array.IndexOf(itemlist, dgv.Rows[r].Cells[1].Value);
                    if (MartEditor7.BannedItems.Contains(currentItem))
                    {
                        continue;
                    }
                    dgv.Rows[r].Cells[1].Value = itemlist[validItems[ctr++]];
                    if (ctr <= validItems.Length)
                    {
                        continue;
                    }
                    Util.Shuffle(validItems); ctr = 0;
                }
            }
            WinFormsUtil.Alert("Randomized!");
        }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
        private void B_RandAll_Click(object sender, EventArgs e)
        {
            if (DialogResult.Yes != WinFormsUtil.Prompt(MessageBoxButtons.YesNo, "Randomize all resulting species?", "Evolution methods and parameters will stay the same."))
            {
                return;
            }

            SetList();
            // Set up advanced randomization options
            var evos    = files.Select(z => new EvolutionSet7(z)).ToArray();
            var evoRand = new EvolutionRandomizer(Main.Config, evos);

            evoRand.Randomizer.rBST  = CHK_BST.Checked;
            evoRand.Randomizer.rEXP  = CHK_Exp.Checked;
            evoRand.Randomizer.rType = CHK_Type.Checked;
            evoRand.Randomizer.L     = CHK_L.Checked;
            evoRand.Randomizer.E     = CHK_E.Checked;
            evoRand.Randomizer.Initialize();
            evoRand.Execute();
            evos.Select(z => z.Write()).ToArray().CopyTo(files, 0);
            GetList();

            WinFormsUtil.Alert("All Pokémon's Evolutions have been randomized!");
        }
Exemplo n.º 6
0
        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!");
        }
Exemplo n.º 7
0
        private void B_Save_Click(object sender, EventArgs e)
        {
            if (WinFormsUtil.Prompt(MessageBoxButtons.YesNo, "Randomize all? Cannot undo.", "Double check Randomization settings before continuing.") != DialogResult.Yes)
            {
                return;
            }

            RSTE.rPKM             = CHK_RandomPKM.Checked;
            RSTE.rSmart           = CHK_BST.Checked;
            RSTE.rLevel           = CHK_Level.Checked;
            RSTE.rLevelMultiplier = NUD_Level.Value;
            RSTE.rNoFixedDamage   = CHK_NoFixedDamage.Checked;

            RSTE.rMove      = CB_Moves.SelectedIndex == 1;
            RSTE.rNoMove    = CB_Moves.SelectedIndex == 2;
            RSTE.rMetronome = CB_Moves.SelectedIndex == 3;
            if (RSTE.rMove)
            {
                RSTE.rDMG = CHK_Damage.Checked;
                if (RSTE.rDMG)
                {
                    RSTE.rDMGCount = (int)NUD_Damage.Value;
                }
                RSTE.rSTAB = CHK_STAB.Checked;
                if (RSTE.rSTAB)
                {
                    RSTE.rSTABCount = (int)NUD_STAB.Value;
                }
            }
            RSTE.rItem    = CHK_RandomItems.Checked;
            RSTE.rAbility = CHK_RandomAbilities.Checked;
            RSTE.rDiffIV  = CHK_MaxDiffPKM.Checked;

            RSTE.rClass = CHK_RandomClass.Checked;
            if (RSTE.rClass)
            {
                RSTE.rIgnoreClass = CHK_IgnoreSpecialClass.Checked
                    ? Main.Config.ORAS
                        ? Legal.SpecialClasses_ORAS
                        : Legal.SpecialClasses_XY
                    : new int[] {};
                RSTE.rOnlySingles = CHK_OnlySingles.Checked;
            }
            RSTE.rGift                   = CHK_RandomGift.Checked;
            RSTE.rGiftPercent            = NUD_GiftPercent.Value;
            RSTE.rDiffAI                 = CHK_MaxDiffAI.Checked;
            RSTE.rTypeTheme              = CHK_TypeTheme.Checked;
            RSTE.rTypeGymTrainers        = CHK_GymTrainers.Checked;
            RSTE.rGymE4Only              = CHK_GymE4Only.Checked;
            RSTE.rMinPKM                 = NUD_RMin.Value;
            RSTE.rMaxPKM                 = NUD_RMax.Value;
            RSTE.r6PKM                   = CHK_6PKM.Checked;
            RSTE.rRandomMegas            = CHK_RandomMegaForm.Checked;
            RSTE.rForceFullyEvolved      = CHK_ForceFullyEvolved.Checked;
            RSTE.rForceFullyEvolvedLevel = NUD_ForceFullyEvolved.Value;
            RSTE.rForceHighPower         = CHK_ForceHighPower.Checked;
            RSTE.rForceHighPowerLevel    = NUD_ForceHighPower.Value;

            if (CHK_StoryMEvos.Checked)
            {
                RSTE.rEnsureMEvo = Main.Config.ORAS
                    ? new [] { 178, 235, 557, 583, 687, 698, 699, 700, 701, 713, 906, 907, 908, 909, 910, 911, 912, 913, 942, 944, 946 }
                    : new [] { 188, 263, 276, 277, 519, 520, 521, 526, 599, 600, 601 };
            }
            else
            {
                RSTE.rEnsureMEvo = new int[] { };
            }

            RSTE.rThemedClasses = new bool[trClass.Length];
            RSTE.rSpeciesRand   = 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,

                L        = CHK_L.Checked,
                E        = CHK_E.Checked,
                Shedinja = true,

                rBST = CHK_BST.Checked,
                rEXP = false,
            };
            RSTE.rSpeciesRand.Initialize();

            RSTE.rDoRand = true;
            RandSettings.SetFormSettings(this, Controls);
            Close();
        }
Exemplo n.º 8
0
        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] + "");
                var rand = new SpeciesRandomizer(Main.Config)
                {
                    G1 = !CHK_Gen.Checked || gen == 1,
                    G2 = !CHK_Gen.Checked || gen == 2,
                    G3 = !CHK_Gen.Checked || gen == 3,
                    G4 = !CHK_Gen.Checked || gen == 4,
                    G5 = !CHK_Gen.Checked || gen == 5,
                    G6 = !CHK_Gen.Checked || gen == 6,

                    L        = CHK_L.Checked,
                    E        = CHK_E.Checked,
                    Shedinja = false,
                };
                rand.Initialize();
                // Assign Species
                for (int j = 0; j < 3; j++)
                {
                    // int oldSpecies = BitConverter.ToUInt16(Data, offset + (((i * 3) + j) * 0x54));
                    if (CHK_BasicStarter.Checked)
                    {
                        if (CHK_Gen.Checked)
                        {
                            int basic() => (int)(Util.Random32() % BasicStarterPerGen[gen - 1].Length);

                            Choices[i][j].SelectedIndex = BasicStarterPerGen[gen - 1][basic()];
                        }
                        else
                        {
                            int basic() => (int)(Util.Random32() % BasicStarter.Length);

                            Choices[i][j].SelectedIndex = BasicStarter[basic()];
                        }
                    }
                    else
                    {
                        Choices[i][j].SelectedIndex = rand.GetRandomSpecies(i);
                    }
                }
            }

            if (blind)
            {
                SaveData();
                Close();
            }
        }
Exemplo n.º 9
0
        private void B_Randomize_Click(object sender, EventArgs e)
        {
            if (WinFormsUtil.Prompt(MessageBoxButtons.YesNo, "Randomize all? Cannot undo.", "Double check Randomization settings in the Horde tab.") != DialogResult.Yes)
            {
                return;
            }

            Enabled = false;

            // Calculate % diff we will apply to each level
            decimal leveldiff = (100 + NUD_LevelAmp.Value) / 100;

            var rand = 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,

                L        = CHK_L.Checked,
                E        = CHK_E.Checked,
                Shedinja = false,

                rBST = CHK_BST.Checked,
            };

            rand.Initialize();

            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)));
                    }
                }


                // If Distinct Hordes are selected, homogenize
                int hordeslot = 0;
                for (int slot = 0; slot < max.Length; slot++)
                {
                    if (spec[slot].SelectedIndex == 0)
                    {
                        continue;
                    }
                    if (CHK_HomogeneousHordes.Checked && slot >= max.Length - 15)
                    {
                        int shift = hordeslot % 5;
                        hordeslot++;
                        if (shift != 0)
                        {
                            spec[slot].SelectedIndex = spec[slot - shift].SelectedIndex;
                            form[slot].Value         = form[slot - shift].Value;
                            continue;
                        }
                    }

                    int species = rand.GetRandomSpecies(spec[slot].SelectedIndex);
                    spec[slot].SelectedIndex = species;
                    setRandomForm(slot, species);
                }
                B_Save_Click(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!");
        }
Exemplo n.º 10
0
        private void B_RandAll_Click(object sender, EventArgs e)
        {
            if (!CHK_Category.Checked && !CHK_Type.Checked && !CHK_Damage.Checked)
            {
                WinFormsUtil.Alert("Cannot randomize Moves.", "Please check any of the options on the right to randomize Moves.");
                return;
            }

            if (WinFormsUtil.Prompt(MessageBoxButtons.YesNo, "Randomize Moves? Cannot undo.", "Double check options on the right before continuing.") != DialogResult.Yes)
            {
                return;
            }
            Random rnd = Util.rand;

            for (int i = 0; i < CB_Move.Items.Count; i++)
            {
                CB_Move.SelectedIndex = i; // Get new Move
                if (i == 165 || i == 174)
                {
                    continue;                       // Don't change Struggle or Curse
                }
                // Change Damage Category if Not Status
                if (CB_Category.SelectedIndex > 0 && CHK_Category.Checked) // Not Status
                {
                    CB_Category.SelectedIndex = rnd.Next(1, 3);
                }

                // Change Move Type
                if (CHK_Type.Checked)
                {
                    CB_Type.SelectedIndex = rnd.Next(0, 18);
                }

                // Change Move Power
                if (CHK_Damage.Checked && CB_Category.SelectedIndex > 0 && NUD_Power.Value >= 10)
                {
                    if (rnd.Next(0, 3) != 2)
                    {
                        // "Regular" move
                        NUD_Power.Value = rnd.Next(11) * 5 + 50; // 50...100
                    }
                    else
                    {
                        // "Extreme" move
                        NUD_Power.Value = rnd.Next(27) * 5 + 20; // 20...150
                    }

                    // Tiny chance for massive power jumps
                    for (int j = 0; j < 2; j++)
                    {
                        if (rnd.Next(100) == 0)
                        {
                            NUD_Power.Value += 50;
                        }
                    }

                    // Handle Multihit moves
                    if (NUD_HitMax.Value > 0)
                    {
                        NUD_Power.Value = (int)Math.Round(NUD_Power.Value / (NUD_HitMax.Value + NUD_HitMin.Value / 2) / 5) * 5;
                    }
                }
            }
            WinFormsUtil.Alert("All Moves have been randomized!");
        }
Exemplo n.º 11
0
        private void B_RandomTM_Click(object sender, EventArgs e)
        {
            if (WinFormsUtil.Prompt(MessageBoxButtons.YesNo, "Randomize TMs? Cannot undo.", "Move compatibility will be the same as the base TMs.") != DialogResult.Yes)
            {
                return;
            }
            if (WinFormsUtil.Prompt(MessageBoxButtons.YesNo, "Randomizing HMs can halt story progression!", "Continue anyway?") != DialogResult.Yes)
            {
                return;
            }

            int[] randomMoves = Enumerable.Range(1, movelist.Length - 1).Select(i => i).ToArray();
            Util.Shuffle(randomMoves);

            int[] hm_xy  = { 015, 019, 057, 070, 127 };
            int[] hm_ao  = hm_xy.Concat(new int[] { 249, 291 }).ToArray();
            int[] field  = { 148, 249, 290 }; // TMs with field effects
            int[] banned = { 165, 621 };      // Struggle and Hyperspace Fury
            int   ctr    = 0;

            for (int i = 0; i < dgvTM.Rows.Count; i++)
            {
                // randomize all TMs
                if (CHK_RandomizeField.Checked)
                {
                    while (banned.Contains(randomMoves[ctr]))
                    {
                        ctr++;
                    }
                    dgvTM.Rows[i].Cells[1].Value = movelist[randomMoves[ctr++]];
                }

                // randomize all TMs, no Field Moves
                else
                {
                    int val = Array.IndexOf(movelist, dgvTM.Rows[i].Cells[1].Value);
                    if (hm_xy.Contains(val) || hm_ao.Contains(val) || field.Contains(val))
                    {
                        continue;                                                                    // skip banned moves
                    }
                    while (hm_xy.Contains(randomMoves[ctr]) || hm_ao.Contains(randomMoves[ctr]) || field.Contains(randomMoves[ctr]) || banned.Contains(randomMoves[ctr]))
                    {
                        ctr++;
                    }
                    dgvTM.Rows[i].Cells[1].Value = movelist[randomMoves[ctr++]];
                }
            }

            if (CHK_RandomizeHM.Checked)
            {
                for (int j = 0; j < dgvHM.Rows.Count; j++)
                {
                    while (banned.Contains(randomMoves[ctr]))
                    {
                        ctr++;
                    }
                    dgvHM.Rows[j].Cells[1].Value = movelist[randomMoves[ctr++]];
                }
            }
            WinFormsUtil.Alert("Randomized!");
        }
Exemplo n.º 12
0
        // Randomization
        private void B_Randomize_Click(object sender, EventArgs e)
        {
            if (WinFormsUtil.Prompt(MessageBoxButtons.YesNo, "Randomize all? Cannot undo.", "Double check Randomization settings in the Horde tab.") != DialogResult.Yes)
            {
                return;
            }

            Enabled = false;

            // Calculate % diff we will apply to each level
            decimal leveldiff = NUD_LevelAmp.Value;

            // Nonrepeating List Start
            var rand = 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,

                L        = CHK_L.Checked,
                E        = CHK_E.Checked,
                Shedinja = false,

                rBST = CHK_BST.Checked,
            };

            rand.Initialize();

            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
                for (int s = 0; s < RandomList.Length; s++)
                {
                    RandomList[s] = rand.GetRandomSpecies(spec[s].SelectedIndex);
                }

                // Assign Slots
                while (used < RandomList.Distinct().Count() || used > 18) // Can just arbitrarily assign slots.
                {
                    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] = RandomList[Util.rand.Next(0, RandomList.Length)];
                        }
                    }
                    used = countUnique(list);
                    if (used != RandomList.Length)
                    {
                        ShuffleSlots(ref list, RandomList.Length);
                    }
                    used = countUnique(list);
                }
                // If Distinct Hordes are selected, homogenize
                int hordeslot = 0;
                if (CHK_HomogeneousHordes.Checked)
                {
                    for (int slot = max.Length - 15; slot < max.Length; slot++)
                    {
                        list[slot] = list[slot - hordeslot % 5];
                        hordeslot++;
                    }
                }

                // 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;
            WinFormsUtil.Alert("Randomized all Wild Encounters according to specification!", "Press the Dump Tables button to view the new Wild Encounter information!");
        }
Exemplo n.º 13
0
        private void B_Randomize_Click(object sender, EventArgs e)
        {
            if (WinFormsUtil.Prompt(MessageBoxButtons.YesNo, "Randomize all? Cannot undo.", "Double check Randomization settings in the 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, false, 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 = Main.Config.Personal[spec[slot].SelectedIndex].BST;
                        int newBST = Main.Config.Personal[species].BST;
                        while (!(newBST * 4 / 5 < oldBST && newBST * 6 / 5 > oldBST))
                        {
                            species = sL[rand.Next(1, sL.Length)]; newBST = Main.Config.Personal[species].BST;
                        }
                    }

                    spec[slot].SelectedIndex = species;
                    setRandomForm(slot, spec[slot].SelectedIndex);
                }
                B_Save_Click(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!");
        }
Exemplo n.º 14
0
        private void B_RandAll_Click(object sender, EventArgs e)
        {
            Random rnd = Util.rand;

            if (!CHK_Category.Checked && !CHK_Type.Checked)
            {
                if (WinFormsUtil.Prompt(MessageBoxButtons.YesNo, "Will only randomize Move stats.", "Double check options on the right before continuing.") != DialogResult.Yes)
                {
                    return;
                }
                for (int i = 0; i < CB_Move.Items.Count; i++)
                {
                    CB_Move.SelectedIndex = i;
                    if (i == 165 || i == 174)
                    {
                        continue;                       // Don't change Struggle or Curse
                    }
                    else
                    {
                        if (NUD_Power.Value > 10)
                        {
                            if (rnd.Next(3) != 2)
                            {
                                // Regular chance
                                NUD_Power.Value = rnd.Next(11) * 5 + 50; // 50 ... 100
                                NUD_PP.Value    = rnd.Next(3) * 5 + 15;  // PP: 15-25
                            }
                            else
                            {
                                // Extreme chance
                                NUD_Power.Value = rnd.Next(27) * 5 + 20; // 20 ... 150
                                NUD_PP.Value    = rnd.Next(8) * 5 + 5;   // PP: 5-40
                            }
                            // Tiny chance for massive power jumps
                            for (int j = 0; j < 2; j++)
                            {
                                if (rnd.Next(100) == 0)
                                {
                                    NUD_Power.Value += 50;
                                }
                            }
                        }
                        if (NUD_Accuracy.Value >= 5)
                        {
                            // "Sane" accuracy randomization
                            // Broken into three tiers based on original accuracy
                            // Designed to limit the chances of 100% accurate OHKO moves and
                            // keep a decent base of 100% accurate regular moves.
                            if (NUD_Accuracy.Value <= 50)
                            {
                                // lowest tier (acc <= 50)
                                // new accuracy = rand(20...50) inclusive
                                // with a 10% chance to increase by 50%
                                NUD_Accuracy.Value = rnd.Next(7) * 5 + 20;
                                if (rnd.Next(10) == 0)
                                {
                                    NUD_Accuracy.Value = (NUD_Accuracy.Value * 3 / 2) / 5 * 5;
                                }
                            }
                            else if (NUD_Accuracy.Value < 90)
                            {
                                // middle tier (50 < acc < 90)
                                // count down from 100% to 20% in 5% increments with 20%
                                // chance to "stop" and use the current accuracy at each
                                // increment
                                // gives decent-but-not-100% accuracy most of the time
                                NUD_Accuracy.Value = 100;
                                while (NUD_Accuracy.Value > 20)
                                {
                                    if (rnd.Next(10) < 2)
                                    {
                                        break;
                                    }
                                    NUD_Accuracy.Value -= 5;
                                }
                            }
                            else
                            {
                                // highest tier (90 <= acc <= 100)
                                // count down from 100% to 20% in 5% increments with 40%
                                // chance to "stop" and use the current accuracy at each
                                // increment
                                // gives high accuracy most of the time
                                NUD_Accuracy.Value = 100;
                                while (NUD_Accuracy.Value > 20)
                                {
                                    if (rnd.Next(10) < 4)
                                    {
                                        break;
                                    }
                                    NUD_Accuracy.Value -= 5;
                                }
                            }
                        }
                        if (NUD_HitMax.Value > 1)
                        {
                            // Divide randomized power by average hit count, round to
                            // nearest 5
                            NUD_Power.Value = (int)(NUD_Power.Value / NUD_HitMax.Value / 3) * 5;
                            if (NUD_Power.Value == 0)
                            {
                                NUD_Power.Value = 5;
                            }
                        }
                        NUD_PP.Value = 40;
                    }
                }
                CB_Move.SelectedIndex = 0;
                WinFormsUtil.Alert("All Moves have had their Base values modified!");
            }

            if (WinFormsUtil.Prompt(MessageBoxButtons.YesNo, "Randomize Moves? Cannot undo.", "Double check options on the right before continuing.") != DialogResult.Yes)
            {
                return;
            }
            for (int i = 0; i < CB_Move.Items.Count; i++)
            {
                CB_Move.SelectedIndex = i; // Get new Move
                if (i == 165 || i == 174)
                {
                    continue;                       // Don't change Struggle or Curse
                }
                // Change Damage Category if Not Status
                if (CB_Category.SelectedIndex > 0 && CHK_Category.Checked) // Not Status
                {
                    CB_Category.SelectedIndex = rnd.Next(1, 3);
                }

                // Change Move Type
                if (CHK_Type.Checked)
                {
                    int    newType    = rnd.Next(0, 17);              // Randomize new type
                    string newTypeSTR = types[newType];               // Text for new type
                    string oldTypeSTR = types[CB_Type.SelectedIndex]; // Text for old type
                    int    oldIndex   = 0;
                    //Console.WriteLine(types.Any(CB_Move.Text.Contains));
                    //if (CB_Move.Text.Contains(oldTypeSTR))
                    //Console.WriteLine(Array.IndexOf(movelist, CB_Move.Text));
                    oldIndex = Array.IndexOf(movelist, CB_Move.Text); // Where in the list of moves is it?
                    bool finished = false;
                    foreach (string type in types)
                    {
                        if (CB_Move.Text.Contains(type) & type != newTypeSTR & !finished)
                        {
                            Console.WriteLine("Was:");
                            Console.WriteLine(movelist[oldIndex]); // Print the old name

                            /* if (newTypeSTR == "Electric")
                             *  newTypeSTR = "Elec.";
                             * if (newTypeSTR == "Fighting")
                             *  newTypeSTR = "Fight.";
                             * if (newTypeSTR == "Psychic")
                             *  newTypeSTR = "Psy."; */
                            movelist[oldIndex] = CB_Move.Text.Replace(type, newTypeSTR); // Replace old type string with new one
                            Console.WriteLine("Now:");
                            Console.WriteLine(movelist[oldIndex]);                       // print the new name
                            if (type == oldTypeSTR)
                            {
                                finished = true;
                            }
                        }
                    }
                    CB_Type.SelectedIndex = newType;
                }
            }
            WinFormsUtil.Alert("All Moves have been randomized!");
            Setup();
        }
Exemplo n.º 15
0
        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();

            // 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 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.Random32() % helditems.Length];
                    }
                }

                if (CHK_AllowMega.Checked)
                {
                    formrand.AllowMega = true;
                }

                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
                }
                if (CHK_ForceFullyEvolved.Checked && NUD_Level.Value >= NUD_ForceFullyEvolved.Value && !FinalEvo.Contains(species))
                {
Exemplo n.º 16
0
        // 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!");
        }
Exemplo n.º 17
0
        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!");
        }
Exemplo n.º 18
0
        private void B_ModifyAll(object sender, EventArgs e)
        {
            if (WinFormsUtil.Prompt(MessageBoxButtons.YesNo, "Modify all? Cannot undo.", "Double check Modification settings in the Enhancements tab.") != DialogResult.Yes)
            {
                return;
            }

            for (int i = 1; i < CB_Species.Items.Count; i++)
            {
                CB_Species.SelectedIndex = i; // Get new Species

                if (CHK_NoEV.Checked)
                {
                    for (int z = 0; z < 6; z++)
                    {
                        ev_boxes[z].Text = 0.ToString();
                    }
                }

                if (CHK_Growth.Checked)
                {
                    CB_EXPGroup.SelectedIndex = 5;
                }
                if (CHK_EXP.Checked)
                {
                    TB_BaseExp.Text = ((float)NUD_EXP.Value * (Convert.ToUInt16(TB_BaseExp.Text) / 100f)).ToString("000");
                }

                if (CHK_NoTutor.Checked)
                {
                    // preserve HM compatiblity to ensure story progression
                    for (int tm = 0; tm <= 100; tm++)
                    {
                        CLB_TMHM.SetItemCheckState(tm, CheckState.Unchecked);
                    }
                    foreach (int mt in CLB_MoveTutors.CheckedIndices)
                    {
                        CLB_MoveTutors.SetItemCheckState(mt, CheckState.Unchecked);
                    }
                    foreach (int ao in CLB_ORASTutors.CheckedIndices)
                    {
                        CLB_ORASTutors.SetItemCheckState(ao, CheckState.Unchecked);
                    }
                }

                if (CHK_FullTMCompatibility.Checked)
                {
                    for (int t = 0; t < 100; t++)
                    {
                        CLB_TMHM.SetItemCheckState(t, CheckState.Checked);
                    }
                }

                if (CHK_FullHMCompatibility.Checked)
                {
                    for (int h = 100; h < CLB_TMHM.Items.Count; h++)
                    {
                        CLB_TMHM.SetItemCheckState(h, CheckState.Checked);
                    }
                }

                if (CHK_FullMoveTutorCompatibility.Checked)
                {
                    for (int m = 0; m < CLB_MoveTutors.Items.Count; m++)
                    {
                        CLB_MoveTutors.SetItemCheckState(m, CheckState.Checked);
                    }
                }

                if (CHK_QuickHatch.Checked)
                {
                    TB_HatchCycles.Text = 1.ToString();
                }
                if (CHK_CatchRateMod.Checked)
                {
                    TB_CatchRate.Text = ((int)NUD_CatchRateMod.Value).ToString();
                }
            }
            CB_Species.SelectedIndex = 1;
            WinFormsUtil.Alert("Modified all Pokémon Personal data entries according to specification!", "Press the Dump All button to view the new Personal data!");
        }
Exemplo n.º 19
0
        private void B_Randomize_Click(object sender, EventArgs e)
        {
            // gametext can be horribly broken if randomized
            if (Mode == "gametext" && DialogResult.Yes !=
                WinFormsUtil.Prompt(MessageBoxButtons.YesNo, "Randomizing Game Text is dangerous!", "Continue?"))
            {
                return;
            }

            // get if the user wants to randomize current text file or all files
            var dr = WinFormsUtil.Prompt(MessageBoxButtons.YesNoCancel,
                                         $"Yes: Randomize ALL{Environment.NewLine}No: Randomize current textfile{Environment.NewLine}Cancel: Abort");

            if (dr == DialogResult.Cancel)
            {
                return;
            }

            // get if pure shuffle or smart shuffle (no shuffle if variable present)
            var drs = WinFormsUtil.Prompt(MessageBoxButtons.YesNo,
                                          $"Smart shuffle:{Environment.NewLine}Yes: Shuffle if no Variable present{Environment.NewLine}No: Pure random!");

            if (drs == DialogResult.Cancel)
            {
                return;
            }

            bool all   = dr == DialogResult.Yes;
            bool smart = drs == DialogResult.Yes;

            // save current
            if (entry > -1)
            {
                files[entry] = getCurrentDGLines();
            }

            // single-entire looping
            int start = all ? 0 : entry;
            int end   = all ? files.Length - 1 : entry;

            // Gather strings
            List <string> strings = new List <string>();

            for (int i = start; i <= end; i++)
            {
                string[] data = files[i];
                strings.AddRange(smart
                    ? data.Where(line => !line.Contains("["))
                    : data);
            }

            // Shuffle up
            string[] pool = strings.ToArray();
            Util.Shuffle(pool);

            // Apply Text
            int ctr = 0;

            for (int i = start; i <= end; i++)
            {
                string[] data = files[i];

                for (int j = 0; j < data.Length; j++) // apply lines
                {
                    if (!smart || !data[j].Contains("["))
                    {
                        data[j] = pool[ctr++];
                    }
                }

                files[i] = data;
            }

            // Load current text file
            setStringsDataGridView(files[entry]);

            WinFormsUtil.Alert("Strings randomized!");
        }
Exemplo n.º 20
0
        private static int[] sL; // Random Species List
        private void B_RandAll_Click(object sender, EventArgs e)
        {
            if (DialogResult.Yes != WinFormsUtil.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();
            WinFormsUtil.Alert("All Pokemon's Evolutions have been randomized!");
        }
Exemplo n.º 21
0
        // Randomization
        private void B_Randomize_Click(object sender, EventArgs e)
        {
            if (WinFormsUtil.Prompt(MessageBoxButtons.YesNo, "Randomize all? Cannot undo.", "Double check Randomization settings in the Horde tab.") != DialogResult.Yes)
            {
                return;
            }

            Enabled = false;

            // Calculate % diff we will apply to each level
            decimal leveldiff = NUD_LevelAmp.Value;

            // 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, false, 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 = Main.Config.Personal[spec[s + 2].SelectedIndex].BST; break;
                        }
                    }

                    for (int z = 0; z < RandomList.Length; z++)
                    {
                        int species = Randomizer.getRandomSpecies(ref sL, ref ctr);
                        int newBST  = Main.Config.Personal[species].BST;
                        while (!(newBST * 4 / 5 < oldBST && newBST * 6 / 5 > oldBST))
                        {
                            species = sL[rand.Next(1, sL.Length)]; newBST = Main.Config.Personal[species].BST;
                        }
                        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;
            WinFormsUtil.Alert("Randomized all Wild Encounters according to specification!", "Press the Dump Tables button to view the new Wild Encounter information!");
        }
Exemplo n.º 22
0
        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!");
        }
Exemplo n.º 23
0
        private void SaveARC(string path)
        {
            if (!Directory.Exists(path))
            {
                WinFormsUtil.Error("Input path is not a Folder", path); return;
            }
            string folderName = Path.GetFileName(path);
            string parentName = Directory.GetParent(path).FullName;
            int    type       = CB_Repack.SelectedIndex;

            switch (type)
            {
            case 0:     // AutoDetect
            {
                if (!folderName.Contains("_"))
                {
                    WinFormsUtil.Alert("Unable to autodetect pack type."); return;
                }

                if (folderName.Contains("_g"))
                {
                    goto case 1;
                }
                if (folderName.Contains("_d"))
                {
                    goto case 2;
                }
                // else
                goto case 3;
            }

            case 1:     // GARC Pack
            {
                if (threads > 0)
                {
                    WinFormsUtil.Alert("Please wait for all operations to finish first."); return;
                }
                DialogResult dr = WinFormsUtil.Prompt(MessageBoxButtons.YesNoCancel, "Format Selection:",
                                                      "Yes: Sun/Moon (Version 6)\nNo: XY/ORAS (Version 4)");
                if (dr == DialogResult.Cancel)
                {
                    return;
                }

                var version = dr == DialogResult.Yes ? GARC.VER_6 : GARC.VER_4;
                int padding = (int)NUD_Padding.Value;
                if (version == GARC.VER_4)
                {
                    padding = 4;
                }

                string outfolder = Directory.GetParent(path).FullName;
                new Thread(() =>
                    {
                        bool r = GarcUtil.PackGARC(path, Path.Combine(outfolder, folderName + ".garc"), version, padding, pBar1);
                        if (!r)
                        {
                            WinFormsUtil.Alert("Packing failed."); return;
                        }
                        // Delete path after repacking
                        if (CHK_Delete.Checked && Directory.Exists(path))
                        {
                            Directory.Delete(path, true);
                        }

                        System.Media.SystemSounds.Asterisk.Play();
                    }).Start();
                return;
            }

            case 2:     // DARC Pack (from existing if exists)
            {
                string oldFile = path.Replace("_d", "");
                if (File.Exists(Path.Combine(parentName, oldFile)))
                {
                    oldFile = Path.Combine(parentName, oldFile);
                }
                else if (File.Exists(Path.Combine(parentName, oldFile + ".bin")))
                {
                    oldFile = Path.Combine(parentName, oldFile + ".bin");
                }
                else if (File.Exists(Path.Combine(parentName, oldFile + ".darc")))
                {
                    oldFile = Path.Combine(parentName, oldFile + ".darc");
                }
                else
                {
                    oldFile = null;
                }

                bool r = Core.CTR.DARC.Files2darc(path, false, oldFile);
                if (!r)
                {
                    WinFormsUtil.Alert("Packing failed.");
                }
                break;
            }

            case 3:     // Mini Pack
            {
                // Get Folder Name
                string fileName = Path.GetFileName(path);
                if (fileName.Length < 3)
                {
                    WinFormsUtil.Error("Mini Folder name not valid:", path); return;
                }

                int    index   = fileName.LastIndexOf('_');
                string fileNum = fileName.Substring(0, index);
                string fileExt = fileName.Substring(index + 1);

                // Find old file for reference...
                string file;
                if (File.Exists(Path.Combine(parentName, fileNum + ".bin")))
                {
                    file = Path.Combine(parentName, fileNum + ".bin");
                }
                else if (File.Exists(Path.Combine(parentName, fileNum + "." + fileExt)))
                {
                    file = Path.Combine(parentName, fileNum + "." + fileExt);
                }
                else
                {
                    file = null;
                }

                byte[] oldData = file != null?File.ReadAllBytes(file) : null;

                bool r = Mini.PackMini2(path, fileExt, Path.Combine(parentName, fileNum + "." + fileExt));
                if (!r)
                {
                    WinFormsUtil.Alert("Packing failed.");
                    break;
                }

                // Check to see if the header size is different...
                if (oldData == null)     // No data to compare to.
                {
                    break;
                }

                byte[] newData = File.ReadAllBytes(Path.Combine(parentName, fileNum + "." + fileExt));
                if (newData[2] == oldData[2])
                {
                    int newPtr = BitConverter.ToInt32(newData, 4);
                    int oldPtr = BitConverter.ToInt32(oldData, 4);
                    if (newPtr != oldPtr)     // Header size is different. Prompt repointing.
                    {
                        if (DialogResult.Yes != WinFormsUtil.Prompt(MessageBoxButtons.YesNo, "Header size of existing file is nonstandard.", "Adjust newly packed file to have the same header size as old file? Data pointers will be updated accordingly."))
                        {
                            break;
                        }

                        // Fix pointers
                        byte[] update = Mini.AdjustMiniHeader(newData, oldPtr);
                        File.WriteAllBytes(Path.Combine(parentName, fileNum + "." + fileExt), update);
                    }
                }

                break;
            }

            default:
                WinFormsUtil.Alert("Repacking not implemented." + Environment.NewLine + path);
                return;
            }
            // Delete path after repacking
            if (CHK_Delete.Checked && Directory.Exists(path))
            {
                Directory.Delete(path, true);
            }
            System.Media.SystemSounds.Asterisk.Play();
        }
Exemplo n.º 24
0
        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!");
        }
Exemplo n.º 25
0
        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!");
        }
Exemplo n.º 26
0
        private void B_Save_Click(object sender, EventArgs e)
        {
            RSTE.rPKM             = CHK_RandomPKM.Checked;
            RSTE.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, ModifierKeys == Keys.Control);
            RSTE.rSmart           = CHK_BST.Checked;
            RSTE.rLevel           = CHK_Level.Checked;
            RSTE.rLevelMultiplier = NUD_Level.Value;

            RSTE.rMove   = CB_Moves.SelectedIndex == 1;
            RSTE.rNoMove = CB_Moves.SelectedIndex == 2;
            if (RSTE.rMove)
            {
                RSTE.rDMG = CHK_Damage.Checked;
                if (RSTE.rDMG)
                {
                    RSTE.rDMGCount = (int)NUD_Damage.Value;
                }
                RSTE.rSTAB = CHK_STAB.Checked;
                if (RSTE.rSTAB)
                {
                    RSTE.rSTABCount = (int)NUD_STAB.Value;
                }
            }
            RSTE.rItem    = CHK_RandomItems.Checked;
            RSTE.rAbility = CHK_RandomAbilities.Checked;
            RSTE.rDiffIV  = CHK_MaxDiffPKM.Checked;

            RSTE.rClass = CHK_RandomClass.Checked;
            if (RSTE.rClass)
            {
                RSTE.rIgnoreClass = CHK_IgnoreSpecialClass.Checked
                    ? Main.Config.ORAS
                        ? Legal.SpecialClasses_ORAS
                        : Legal.SpecialClasses_XY
                    : new int[] {};
                RSTE.rOnlySingles = CHK_OnlySingles.Checked;
            }
            RSTE.rGift            = CHK_RandomGift.Checked;
            RSTE.rGiftPercent     = NUD_GiftPercent.Value;
            RSTE.rDiffAI          = CHK_MaxDiffAI.Checked;
            RSTE.rTypeTheme       = CHK_TypeTheme.Checked;
            RSTE.rTypeGymTrainers = CHK_GymTrainers.Checked;
            RSTE.rGymE4Only       = CHK_GymE4Only.Checked;
            RSTE.r6PKM            = CHK_6PKM.Checked;
            RSTE.rRandomMegas     = CHK_RandomMegaForm.Checked;

            if (CHK_StoryMEvos.Checked)
            {
                RSTE.rEnsureMEvo = Main.Config.ORAS
                    ? new [] { 178, 235, 557, 583, 687, 698, 699, 700, 701, 713, 906, 907, 908, 909, 910, 911, 912, 913, 942, 944, 946 }
                    : new [] { 188, 263, 276, 277, 519, 520, 521, 526, 599, 600, 601 };
            }
            else
            {
                RSTE.rEnsureMEvo = new int[] { };
            }

            RSTE.rThemedClasses = new bool[trClass.Length];

            if (WinFormsUtil.Prompt(MessageBoxButtons.YesNo, "Randomize all? Cannot undo.", "Double check Randomization settings before continuing.") != DialogResult.Yes)
            {
                return;
            }
            if (!CHK_IgnoreSpecialClass.Checked)
            {
                if (WinFormsUtil.Prompt(MessageBoxButtons.YesNo, "Ignoring Special Trainer Classes has the chance of crashing your game in some battles!", "Continue anyway?") != DialogResult.Yes)
                {
                    return;
                }
            }
            RSTE.rDoRand = true;
            Close();
        }
Exemplo n.º 27
0
        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!");
        }
Exemplo n.º 28
0
        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!");
        }