コード例 #1
0
ファイル: EvolutionEditor7.cs プロジェクト: wolfauraz/pk3DS
        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.Initialize();
            evoRand.Execute();
            evos.Select(z => z.Write()).ToArray().CopyTo(files, 0);
            getList();

            WinFormsUtil.Alert("All Pokémon's Evolutions have been randomized!");
        }
コード例 #2
0
        private void B_Metronome_Click(object sender, EventArgs e)
        {
            if (WinFormsUtil.Prompt(MessageBoxButtons.YesNo, "Play using Metronome Mode?", "This will set the Base PP for every other Move to 0!") != DialogResult.Yes)
            {
                return;
            }

            for (int i = 0; i < CB_Move.Items.Count; i++)
            {
                CB_Move.SelectedIndex = i;
                if (CB_Move.SelectedIndex != 117)
                {
                    NUD_PP.Value = 0;
                }
                if (CB_Move.SelectedIndex == 117)
                {
                    NUD_PP.Value = 40;
                }
            }
            CB_Move.SelectedIndex = 0;
            WinFormsUtil.Alert("All Moves have had their Base PP values modified!");
        }
コード例 #3
0
        public void CalcStats() // Debug Function
        {
            Move[] MoveData = Main.Config.Moves;

            int movectr = 0;
            int max     = 0;
            int spec    = 0;
            int stab    = 0;

            for (int i = 0; i < Main.Config.MaxSpeciesID; i++)
            {
                byte[] movedata  = files[i];
                int    movecount = (movedata.Length - 4) / 4;
                if (movecount == 65535)
                {
                    continue;
                }
                movectr += movecount; // Average Moves
                if (max < movecount)
                {
                    max = movecount; spec = i;
                }                                                   // Max Moves (and species)
                for (int m = 0; m < movedata.Length / 4; m++)
                {
                    int move = BitConverter.ToUInt16(movedata, m * 4);
                    if (move == 65535)
                    {
                        movectr--;
                        continue;
                    }
                    if (Main.Config.Personal[i].Types.Contains(MoveData[move].Type))
                    {
                        stab++;
                    }
                }
            }
            WinFormsUtil.Alert($"Moves Learned: {movectr}\r\nMost Learned: {max} @ {spec}\r\nSTAB Count: {stab}");
        }
コード例 #4
0
        private void B_Randomize_Click(object sender, EventArgs e)
        {
            if (WinFormsUtil.Prompt(MessageBoxButtons.YesNo, "Randomize all? This will also randomize Move Power and Acc. 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,
            };

            Move[] newMoves = rnd.Execute2();
            Main.Config.Moves = newMoves;
            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!");
        }
コード例 #5
0
        private void B_DumpMaps_Click(object sender, EventArgs e)
        {
            if (WinFormsUtil.Prompt(MessageBoxButtons.YesNoCancel, "Export all MapImages?") != DialogResult.Yes)
            {
                return;
            }

            debugToolDumping = true;
            const string folder = "MapImages";

            if (!Directory.Exists(folder))
            {
                Directory.CreateDirectory(folder);
            }

            string[] result = new string[CB_LocationID.Items.Count];
            for (int i = 0; i < CB_LocationID.Items.Count; i++)
            {
                mapView.DrawMap = i;
                Image img = mapView.GetMapImage(crop: true);
                using (MemoryStream ms = new MemoryStream())
                {
                    //error will throw from here
                    img.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
                    byte[] data = ms.ToArray();
                    File.WriteAllBytes(Path.Combine(folder, $"{zdLocations[i].Replace('?', '-')} ({i}).png"), data);
                }
                string l = mm.EntryList.Where(t => t != 0xFFFF).Aggregate("", (current, t) => current + t.ToString("000 "));
                result[i] = $"{i:000}\t{CB_LocationID.Items[i]}\t{l}";
            }
            if (WinFormsUtil.Prompt(MessageBoxButtons.YesNoCancel, "Write Map parse output?") == DialogResult.Yes)
            {
                File.WriteAllLines("MapLocations.txt", result);
            }
            CB_LocationID.SelectedIndex = 0;
            WinFormsUtil.Alert("All Map images have been dumped to " + folder + ".");
            debugToolDumping = false;
        }
コード例 #6
0
        private void B_ModifyAll(object sender, EventArgs e)
        {
            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_QuickHatch.Checked)
                {
                    TB_HatchCycles.Text = 1.ToString();
                }
                if (CHK_CallRate.Checked)
                {
                    TB_CallRate.Text = ((int)NUD_CallRate.Value).ToString();
                }
                if (CHK_CatchRateMod.Checked)
                {
                    TB_CatchRate.Text = ((int)NUD_CatchRateMod.Value).ToString();
                }
            }
            CB_Species.SelectedIndex = 1;
            WinFormsUtil.Alert("All species modified according to specification!");
        }
コード例 #7
0
ファイル: PickupEditor6.cs プロジェクト: tom-overton/pk3DS
 public PickupEditor6()
 {
     InitializeComponent();
     if (Main.ExeFSPath == null)
     {
         WinFormsUtil.Alert("No exeFS code to load."); Close();
     }
     string[] files = Directory.GetFiles(Main.ExeFSPath);
     if (!File.Exists(files[0]) || !Path.GetFileNameWithoutExtension(files[0]).Contains("code"))
     {
         WinFormsUtil.Alert("No .code.bin detected."); Close();
     }
     data = File.ReadAllBytes(files[0]);
     if (data.Length % 0x200 != 0)
     {
         WinFormsUtil.Alert(".code.bin not decompressed. Aborting."); Close();
     }
     offset      = Util.IndexOfBytes(data, new byte[] { 0x1E, 0x28, 0x32, 0x3C, 0x46, 0x50, 0x5A, 0x5E, 0x62, 0x05, 0x0A, 0x0F, 0x14, 0x19, 0x1E, 0x23, 0x28, 0x2D, 0x32 }, 0x400000, 0) - 0x3A;
     codebin     = files[0];
     itemlist[0] = "";
     SetupDGV();
     GetList();
 }
コード例 #8
0
        public TypeChart7()
        {
            InitializeComponent();
            if (Main.ExeFSPath == null)
            {
                WinFormsUtil.Alert("No exeFS code to load."); Close();
            }
            string[] files = Directory.GetFiles(Main.ExeFSPath);
            if (!File.Exists(files[0]) || !Path.GetFileNameWithoutExtension(files[0]).Contains("code"))
            {
                WinFormsUtil.Alert("No .code.bin detected."); Close();
            }
            codebin = files[0];
            exefs   = File.ReadAllBytes(codebin);
            if (exefs.Length % 0x200 != 0)
            {
                WinFormsUtil.Alert(".code.bin not decompressed. Aborting."); Close();
            }
            offset = Util.IndexOfBytes(exefs, Signature, 0x400000, 0) + Signature.Length;

            Array.Copy(exefs, offset, chart, 0, chart.Length);
            populateChart();
        }
コード例 #9
0
        private void B_Randomize_Click(object sender, EventArgs e)
        {
            if (DialogResult.Yes != WinFormsUtil.Prompt(MessageBoxButtons.YesNoCancel, "Randomize pickup lists?"))
            {
                return;
            }

            int[] validItems = Randomizer.getRandomItemList();

            int ctr = 0;

            Util.Shuffle(validItems);
            for (int r = 0; r < dgvCommon.RowCount; r++)
            {
                dgvCommon.Rows[r].Cells[0].Value = items[validItems[ctr++]];
                if (ctr <= validItems.Length)
                {
                    continue;
                }
                Util.Shuffle(validItems); ctr = 0;
            }
            WinFormsUtil.Alert("Randomized!");
        }
コード例 #10
0
ファイル: SMWE.cs プロジェクト: stefan0401/pk3DS
        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);
        }
コード例 #11
0
 public TMHMEditor6()
 {
     InitializeComponent();
     if (Main.ExeFSPath == null)
     {
         WinFormsUtil.Alert("No exeFS code to load."); Close();
     }
     string[] files = Directory.GetFiles(Main.ExeFSPath);
     if (!File.Exists(files[0]) || !Path.GetFileNameWithoutExtension(files[0]).Contains("code"))
     {
         WinFormsUtil.Alert("No .code.bin detected."); Close();
     }
     data = File.ReadAllBytes(files[0]);
     if (data.Length % 0x200 != 0)
     {
         WinFormsUtil.Alert(".code.bin not decompressed. Aborting."); Close();
     }
     offset      = Util.IndexOfBytes(data, Signature, 0x400000, 0) + 8;
     codebin     = files[0];
     movelist[0] = "";
     setupDGV();
     getList();
 }
コード例 #12
0
        private void B_RandAll_Click(object sender, EventArgs e)
        {
            ushort[] HMs = { 15, 19, 57, 70, 127, 249, 291 };
            ushort[] TMs = {};
            if (CHK_HMs.Checked && Main.ExeFSPath != null)
            {
                TMHMEditor6.getTMHMList(Main.Config.ORAS, ref TMs, ref HMs);
            }

            List <int> banned = new List <int> {
                165, 621
            };                                           // Struggle, Hyperspace Fury

            if (!CHK_HMs.Checked)
            {
                banned.AddRange(HMs.Select(z => (int)z));
            }

            setList();
            var sets = files.Select(z => new Learnset6(z)).ToArray();
            var rand = new LearnsetRandomizer(Main.Config, sets)
            {
                Expand       = CHK_Expand.Checked,
                ExpandTo     = (int)NUD_Moves.Value,
                Spread       = CHK_Spread.Checked,
                SpreadTo     = (int)NUD_Level.Value,
                STAB         = CHK_STAB.Checked,
                rSTABPercent = NUD_STAB.Value,
                BannedMoves  = banned.ToArray()
            };

            rand.Execute();
            sets.Select(z => z.Write()).ToArray().CopyTo(files, 0);
            getList();
            WinFormsUtil.Alert("All Pokémon's Level Up Moves have been randomized!");
        }
コード例 #13
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!");
        }
コード例 #14
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!");
        }
コード例 #15
0
ファイル: ShinyRate.cs プロジェクト: nichan200/pk3DS
        private void writeCodePatch()
        {
            // Overwrite the "load input argument value for reroll count" so that it loads a constant value.
            // 23 00 D4 E5 is then replaced with the instruction MOV R0, $value
            // $value is the amount of PID rerolls to iterate for.

            int rerolls = (int)NUD_Rerolls.Value;

            if (rerolls > ushort.MaxValue)
            {
                rerolls = ushort.MaxValue;
            }
            // lazy precomputed table for MOV0 up to 9000, lol
            var instruction = InstructionList.FirstOrDefault(z => z.Value >= rerolls) ?? InstructionList.Last();

            byte[] data = instruction.Bytes;
            data.CopyTo(exefsData, offset);

            if (instruction.Value != rerolls)
            {
                WinFormsUtil.Alert("Specified reroll count increased to the next highest supported value.",
                                   $"{rerolls} -> {instruction.Value}");
            }
        }
コード例 #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 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!");
        }
コード例 #17
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!");
        }
コード例 #18
0
        // Script Handling
        private void B_HLCMD_Click(object sender, EventArgs e)
        {
            int ctr = WinFormsUtil.highlightText(RTB_OSP, "**", Color.Red) + (WinFormsUtil.highlightText(RTB_MSP, "**", Color.Red) / 2);

            WinFormsUtil.Alert($"{ctr} instance{(ctr > 1 ? "s" : "")} of \"*\" present.");
        }
コード例 #19
0
ファイル: XYWE.cs プロジェクト: wolfauraz/pk3DS
        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!");
        }
コード例 #20
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!");
        }
コード例 #21
0
ファイル: MoveEditor6.cs プロジェクト: enfyy/pk3DS
        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!");
        }
コード例 #22
0
ファイル: RSTE.cs プロジェクト: evraiterrule/pk3DS
        private void Randomize()
        {
            List <int> banned = new List <int> {
                165, 621
            };                                             // Struggle, Hyperspace Fury

            if (rNoFixedDamage)
            {
                banned.AddRange(MoveRandomizer.FixedDamageMoves);
            }
            var move = new MoveRandomizer(Main.Config)
            {
                rDMG        = rDMG,
                rSTAB       = rSTAB,
                rSTABCount  = rSTABCount,
                rDMGCount   = rDMGCount,
                BannedMoves = banned,
            };

            rImportant = new string[CB_TrainerID.Items.Count];
            rTags      = Main.Config.ORAS ? GetTagsORAS() : GetTagsXY();
            mEvoTypes  = GetMegaEvolvableTypes();
            List <int> GymE4Types = new List <int>();

            // Fetch Move Stats for more difficult randomization

            if (rEnsureMEvo.Length > 0)
            {
                if (mEvoTypes.Length < 13 && rTypeTheme)
                {
                    WinFormsUtil.Alert("There are insufficient Types with at least one mega evolution to Guarantee story Mega Evos while keeping Type theming.",
                                       "Re-Randomize Personal or don't choose both options."); return;
                }
                GymE4Types.AddRange(mEvoTypes);
            }
            else
            {
                GymE4Types.AddRange(Enumerable.Range(0, types.Length).ToArray());
            }
            foreach (int t1 in rEnsureMEvo.Where(t1 => rTags[t1] != "" && !TagTypes.Keys.Contains(rTags[t1])))
            {
                int t;
                if (rTags[t1].Contains("GYM") || rTags[t1].Contains("ELITE") || rTags[t1].Contains("CHAMPION"))
                {
                    t = GymE4Types[(int)(rnd32() % GymE4Types.Count)];
                    GymE4Types.Remove(t);
                }
                else
                {
                    t = mEvoTypes[rnd32() % mEvoTypes.Length];
                }
                TagTypes[rTags[t1]] = t;
            }
            foreach (string t1 in Tags)
            {
                if (!TagTypes.Keys.Contains(t1) && t1 != "")
                {
                    int t;
                    if (t1.Contains("GYM") || t1.Contains("ELITE") || t1.Contains("CHAMPION"))
                    {
                        t = GymE4Types[(int)(rnd32() % GymE4Types.Count)];
                        GymE4Types.Remove(t);
                    }
                    else
                    {
                        t = (int)(rnd32() % types.Length);
                    }

                    TagTypes[t1] = t;
                }
                Console.WriteLine(t1 + ": " + types[TagTypes[t1]]);
            }

            CB_TrainerID.SelectedIndex = 0; // fake a writeback
            ushort[] itemvals = Main.Config.ORAS ? Legal.Pouch_Items_AO : Legal.Pouch_Items_XY;
            itemvals = itemvals.Concat(Legal.Pouch_Berry_XY).ToArray();

            string[] ImportantClasses = { "GYM", "ELITE", "CHAMPION" };
            for (int i = 1; i < CB_TrainerID.Items.Count; i++)
            {
                // Trainer Type/Mega Evo
                int  type     = GetRandomType(i);
                bool mevo     = rEnsureMEvo.Contains(i);
                bool typerand = rTypeTheme && !rGymE4Only ||
                                rTypeTheme && rImportant[i] != null && ImportantClasses.Contains(rImportant[i]);
                rSpeciesRand.rType = typerand;

                byte[] trd = trdata[i];
                byte[] trp = trpoke[i];
                var    t   = new trdata6(trd, trp, Main.Config.ORAS)
                {
                    Moves = rMove || !rNoMove && checkBox_Moves.Checked,
                    Item  = rItem || checkBox_Item.Checked
                };

                InitializeTrainerTeamInfo(t, rImportant[i] == null);
                RandomizeTrainerAIClass(t, trClass);
                RandomizeTrainerPrizeItem(t);
                RandomizeTeam(t, move, learn, itemvals, type, mevo, typerand);

                trdata[i] = t.Write();
                trpoke[i] = t.WriteTeam();
            }
            CB_TrainerID.SelectedIndex = 1;
            WinFormsUtil.Alert("Randomized all Trainers according to specification!", "Press the Dump to .TXT button to view the new Trainer information!");
        }
コード例 #23
0
ファイル: ToolsUI.cs プロジェクト: tom-overton/pk3DS
 private void DecompressLZSS_BLZ(string path)
 {
     try
     {
         LZSS.Decompress(path, Path.Combine(Path.GetDirectoryName(path), "dec_" + Path.GetFileName(path)));
         File.Delete(path);
     }
     catch
     {
         try
         {
             if (threads < 1)
             {
                 new Thread(() => { Interlocked.Increment(ref threads); new BLZCoder(new[] { "-d", path }, pBar1); Interlocked.Decrement(ref threads); WinFormsUtil.Alert("Decompressed!"); }).Start();
             }
         }
         catch { WinFormsUtil.Error("Unable to process file."); threads = 0; }
     }
 }
コード例 #24
0
ファイル: ToolsUI.cs プロジェクト: tom-overton/pk3DS
        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();
        }
コード例 #25
0
ファイル: ToolsUI.cs プロジェクト: tom-overton/pk3DS
        internal static void OpenARC(string path, ProgressBar pBar1, bool recursing = false)
        {
            string newFolder = "";

            try
            {
                // Pre-check file length to see if it is at least valid.
                FileInfo fi = new FileInfo(path);
                if (fi.Length > (long)2 * (1 << 30))
                {
                    WinFormsUtil.Error("File is too big!"); return;
                }                                                                                      // 2 GB
                string folderPath = Path.Combine(Path.GetDirectoryName(path), Path.GetFileNameWithoutExtension(path));

                byte[] first4 = new byte[4];
                try
                {
                    using var fs = new FileStream(path, FileMode.Open);
                    using var bw = new BinaryReader(fs);
                    first4       = bw.ReadBytes(4);
                }
                catch (Exception e)
                {
                    WinFormsUtil.Error("Cannot open file!", e.ToString());
                }

                // Determine if it is a DARC or a Mini
                // Check if Mini first
                string fx = fi.Length > 10 * (1 << 20) ? null : Mini.GetIsMini(path); // no mini is above 10MB
                if (fx != null)                                                       // Is Mini Packed File
                {
                    newFolder = folderPath + "_" + fx;
                    // Fetch Mini File Contents
                    Mini.UnpackMini(path, fx, newFolder, false);
                    // Recurse throught the extracted contents if they extract successfully
                    if (Directory.Exists(newFolder))
                    {
                        foreach (string file in Directory.GetFiles(newFolder))
                        {
                            OpenARC(file, pBar1, true);
                        }
                        BatchRenameExtension(newFolder);
                    }
                }
                else if (first4.SequenceEqual(BitConverter.GetBytes(0x54594C41))) // ALYT
                {
                    if (threads > 0)
                    {
                        WinFormsUtil.Alert("Please wait for all operations to finish first."); return;
                    }
                    new Thread(() =>
                    {
                        Interlocked.Increment(ref threads);
                        var alyt = new ALYT(File.ReadAllBytes(path));
                        var sarc = new SARC(alyt.Data) // rip out sarc
                        {
                            FileName = Path.GetFileNameWithoutExtension(path) + "_sarc",
                            FilePath = Path.GetDirectoryName(path)
                        };
                        if (!sarc.Valid)
                        {
                            return;
                        }
                        var files = sarc.Dump();
                        foreach (var _ in files)
                        {
                            // openARC(file, pBar1, true);
                        }
                        Interlocked.Decrement(ref threads);
                    }).Start();
                }
                else if (first4.SequenceEqual(BitConverter.GetBytes(0x47415243))) // GARC
                {
                    if (threads > 0)
                    {
                        WinFormsUtil.Alert("Please wait for all operations to finish first."); return;
                    }
                    bool SkipDecompression = ModifierKeys == Keys.Control;
                    new Thread(() =>
                    {
                        Interlocked.Increment(ref threads);
                        bool r = GarcUtil.UnpackGARC(path, folderPath + "_g", SkipDecompression, pBar1);
                        Interlocked.Decrement(ref threads);
                        if (r)
                        {
                            BatchRenameExtension(newFolder);
                        }
                        else
                        {
                            WinFormsUtil.Alert("Unpacking failed."); return;
                        }
                        System.Media.SystemSounds.Asterisk.Play();
                    }).Start();
                }
                else if (ARC.Analyze(path).valid) // DARC
                {
                    var data = File.ReadAllBytes(path);
                    int pos  = 0;
                    while (BitConverter.ToUInt32(data, pos) != 0x63726164)
                    {
                        pos += 4;
                        if (pos >= data.Length)
                        {
                            return;
                        }
                    }
                    var darcData = data.Skip(pos).ToArray();
                    newFolder = folderPath + "_d";
                    bool r = Core.CTR.DARC.Darc2files(darcData, newFolder);
                    if (!r)
                    {
                        WinFormsUtil.Alert("Unpacking failed.");
                    }
                }
                else if (ARC.AnalyzeSARC(path).Valid)
                {
                    var sarc = ARC.AnalyzeSARC(path);
                    Console.WriteLine($"New SARC with {sarc.SFAT.EntryCount} files.");
                    foreach (var _ in sarc.Dump(path))
                    {
                    }
                }
                else if (!recursing)
                {
                    WinFormsUtil.Alert("File is not a darc or a mini packed file:" + Environment.NewLine + path);
                }
            }
            catch (Exception e)
            {
                if (!recursing)
                {
                    WinFormsUtil.Error("File error:" + Environment.NewLine + path, e.ToString());
                }
                threads = 0;
            }
        }
コード例 #26
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!");
        }
コード例 #27
0
        private void B_RandAll_Click(object sender, EventArgs e)
        {
            // ORAS: 10682 moves learned on levelup/birth.
            // 5593 are STAB. 52.3% are STAB.
            // Steelix learns the most @ 25 (so many level 1)!
            // Move relearner ingame glitch fixed (52 tested), but keep below 75:
            // https://twitter.com/Drayano60/status/807297858244411397
            Random rnd = new Random();

            int[] firstMoves = { 1, 40, 52, 55, 64, 71, 84, 98, 122, 141 };
            // Pound, Poison Sting, Ember, Water Gun, Peck, Absorb, Thunder Shock, Quick Attack, Lick, Leech Life

            int[] banned = new[] { 165, 621, 464 }.Concat(Legal.Z_Moves).ToArray(); // Struggle, Hyperspace Fury, Dark Void

            // Move Stats
            Move[] moveTypes = Main.Config.Moves;

            // Set up Randomized Moves
            int[] randomMoves = Enumerable.Range(1, movelist.Length - 1).Select(i => i).ToArray();
            Util.Shuffle(randomMoves);
            int ctr = 0;

            for (int i = 0; i < CB_Species.Items.Count; i++)
            {
                CB_Species.SelectedIndex = i; // Get new Species
                int count   = dgv.Rows.Count - 1;
                int species = WinFormsUtil.getIndex(CB_Species);
                if (CHK_Expand.Checked && (int)NUD_Moves.Value > count)
                {
                    dgv.Rows.AddCopies(count, (int)NUD_Moves.Value - count);
                }

                // Default First Move
                dgv.Rows[0].Cells[0].Value = 1;
                dgv.Rows[0].Cells[1].Value = movelist[firstMoves[rnd.Next(0, firstMoves.Length)]];
                for (int j = 1; j < dgv.Rows.Count - 1; j++)
                {
                    // Assign New Moves
                    bool forceSTAB = CHK_STAB.Checked && rnd.Next(0, 99) < NUD_STAB.Value;
                    int  move      = Randomizer.getRandomSpecies(ref randomMoves, ref ctr);

                    while (banned.Contains(move) || /* Invalid */
                           forceSTAB && !Main.SpeciesStat[species].Types.Contains(moveTypes[move].Type)) // STAB is required
                    {
                        move = Randomizer.getRandomSpecies(ref randomMoves, ref ctr);
                    }

                    // Assign Move
                    dgv.Rows[j].Cells[1].Value = movelist[move];
                    // Assign Level
                    if (j >= count)
                    {
                        string level = (dgv.Rows[count - 1].Cells[0].Value ?? 0).ToString();
                        ushort lv;
                        UInt16.TryParse(level, out lv);
                        if (lv > 100)
                        {
                            lv = 100;
                        }
                        dgv.Rows[j].Cells[0].Value = lv + (j - count) + 1;
                    }
                    if (CHK_Spread.Checked)
                    {
                        dgv.Rows[j].Cells[0].Value = ((int)(j * (NUD_Level.Value / (dgv.Rows.Count - 1)))).ToString();
                    }
                }
            }
            CB_Species.SelectedIndex = 0;
            WinFormsUtil.Alert("All Pokemon's Level Up Moves have been randomized!");
        }
コード例 #28
0
ファイル: RSTE.cs プロジェクト: mjnzy12/pk3DS
        private void Randomize()
        {
            int[] banned = { 165, 621 }; // Struggle, Hyperspace Fury
            rImportant = new string[CB_TrainerID.Items.Count];
            rTags      = Main.Config.ORAS ? GetTagsORAS() : GetTagsXY();
            mEvoTypes  = GetMegaEvolvableTypes();
            List <int> GymE4Types = new List <int>();

            // Fetch Move Stats for more difficult randomization
            var moveData = Main.Config.Moves;

            int[] moveList = Enumerable.Range(1, movelist.Length - 1).ToArray();
            int   mctr     = 0;

            Util.Shuffle(moveList);

            if (rEnsureMEvo.Length > 0)
            {
                if (mEvoTypes.Length < 13 && rTypeTheme)
                {
                    WinFormsUtil.Alert("There are insufficient Types with at least one mega evolution to Guarantee story Mega Evos while keeping Type theming.",
                                       "Re-Randomize Personal or don't choose both options."); return;
                }
                GymE4Types.AddRange(mEvoTypes);
            }
            else
            {
                GymE4Types.AddRange(Enumerable.Range(0, types.Length).ToArray());
            }
            foreach (int t1 in rEnsureMEvo.Where(t1 => rTags[t1] != "" && !TagTypes.Keys.Contains(rTags[t1])))
            {
                int t;
                if (rTags[t1].Contains("GYM") || rTags[t1].Contains("ELITE") || rTags[t1].Contains("CHAMPION"))
                {
                    t = GymE4Types[(int)(rnd32() % GymE4Types.Count)];
                    GymE4Types.Remove(t);
                }
                else
                {
                    t = mEvoTypes[rnd32() % mEvoTypes.Length];
                }
                TagTypes[rTags[t1]] = t;
            }
            foreach (string t1 in Tags)
            {
                if (!TagTypes.Keys.Contains(t1) && t1 != "")
                {
                    int t;
                    if (t1.Contains("GYM") || t1.Contains("ELITE") || t1.Contains("CHAMPION"))
                    {
                        t = GymE4Types[(int)(rnd32() % GymE4Types.Count)];
                        GymE4Types.Remove(t);
                    }
                    else
                    {
                        t = (int)(rnd32() % types.Length);
                    }

                    TagTypes[t1] = t;
                }
                Console.WriteLine(t1 + ": " + types[TagTypes[t1]]);
            }
            randomizing = true;
            for (int i = 1; i < CB_TrainerID.Items.Count; i++)
            {
                CB_TrainerID.SelectedIndex = i; // data is loaded

                // Setup
                checkBox_Moves.Checked = rMove || !rNoMove && checkBox_Moves.Checked;
                checkBox_Item.Checked  = rItem || checkBox_Item.Checked;

                if (r6PKM && rImportant[i] != null) // skip the first rival battles
                {
                    // Copy the last slot to random pokemon
                    int lastPKM = Math.Max(CB_numPokemon.SelectedIndex - 1, 0); // 0,1-6 => 0-5 (never is 0)
                    CB_numPokemon.SelectedIndex = 6;
                    for (int f = lastPKM + 1; f < 6; f++)
                    {
                        trpk_pkm[f].SelectedIndex = trpk_IV[lastPKM].SelectedIndex;
                        trpk_lvl[f].SelectedIndex = Math.Min(trpk_lvl[f - 1].SelectedIndex + 1, 100);
                    }
                }

                // Randomize Trainer Stats
                if (rDiffAI)
                {
                    if (CB_Battle_Type.SelectedIndex == 0)
                    {
                        CB_AI.SelectedIndex = 7; // Max Single
                    }
                    else if (CB_Battle_Type.SelectedIndex == 1)
                    {
                        CB_AI.SelectedIndex = 135; // Max Double
                    }
                }
                if (
                    rClass && // Classes selected to be randomized
                    (!rOnlySingles || CB_Battle_Type.SelectedIndex == 0) && //  Nonsingles only get changed if rOnlySingles
                    !rIgnoreClass.Contains(CB_Trainer_Class.SelectedIndex)    // Current class isn't a special class
                    )
                {
                    int rv = (int)(rnd32() % CB_Trainer_Class.Items.Count);
                    // Ensure the Random Class isn't an exclusive class
                    while (rIgnoreClass.Contains(rv) && !trClass[rv].StartsWith("[~")) // don't allow disallowed classes
                    {
                        rv = (int)(rnd32() % CB_Trainer_Class.Items.Count);
                    }

                    CB_Trainer_Class.SelectedIndex = rv;
                }

                if (rGift && rnd32() % 100 < rGiftPercent)
                #region Random Prize Logic
                {
                    ushort[] items;
                    uint     rnd = rnd32() % 10;
                    if (rnd < 2) // held item
                    {
                        items = Main.Config.ORAS ? Legal.Pouch_Items_ORAS : Legal.Pouch_Items_XY;
                    }
                    else if (rnd < 5) // medicine
                    {
                        items = Main.Config.ORAS ? Legal.Pouch_Medicine_ORAS : Legal.Pouch_Medicine_XY;
                    }
                    else // berry
                    {
                        items = Legal.Pouch_Berry_XY;
                    }
                    CB_Prize.SelectedIndex = items[rnd32() % items.Length];
                }
                #endregion
                else if (rGift)
                {
                    CB_Prize.SelectedIndex = 0;
                }

                ushort[] itemvals = Main.Config.ORAS ? Legal.Pouch_Items_ORAS : Legal.Pouch_Items_XY;
                itemvals = itemvals.Concat(Legal.Pouch_Berry_XY).ToArray();
                int itemC = itemvals.Length;
                int ctr   = 0;

                // Trainer Type/Mega Evo
                int  type     = GetRandomType(i);
                bool mevo     = rEnsureMEvo.Contains(i);
                bool typerand = rTypeTheme && !rGymE4Only ||
                                rTypeTheme && rImportant[i] != null && (rImportant[i].Contains("GYM") || rImportant[i].Contains("ELITE") || rImportant[i].Contains("CHAMPION"));

                // Randomize Pokemon
                for (int p = 0; p < CB_numPokemon.SelectedIndex; p++)
                {
                    PersonalInfo oldpkm = Main.SpeciesStat[trpk_pkm[p].SelectedIndex];
                    PersonalInfo pkm    = null;
                    if (rPKM)
                    {
                        // randomize pokemon
                        int species;
                        pkm = Main.SpeciesStat[species = Randomizer.getRandomSpecies(ref sL, ref ctr)];
                        if (typerand)
                        {
                            int tries = 0;
                            while ((pkm.Types[0] != type && pkm.Types[1] != type || mevo && p == CB_numPokemon.SelectedIndex - 1 && !megaEvos.Contains(species)) && tries < 0x10000)
                            {
                                if (p == CB_numPokemon.SelectedIndex - 1 && mevo)
                                {
                                    pkm = Main.SpeciesStat[species = GetRandomMegaEvolvablePokemon(type)];
                                }
                                else if (rSmart) // Get a new Pokemon with a close BST
                                {
                                    pkm = Main.SpeciesStat[species = Randomizer.getRandomSpecies(ref sL, ref ctr)];
                                    while (!(pkm.BST * (5 - ++tries / Main.Config.MaxSpeciesID) / 6 < oldpkm.BST && pkm.BST * (6 + ++tries / Main.Config.MaxSpeciesID) / 5 > oldpkm.BST))
                                    {
                                        pkm = Main.SpeciesStat[species = Randomizer.getRandomSpecies(ref sL, ref ctr)];
                                    }
                                }
                                else
                                {
                                    pkm = Main.SpeciesStat[species = Randomizer.getRandomSpecies(ref sL, ref ctr)];
                                }
                            }
                        }
                        else if (p == CB_numPokemon.SelectedIndex - 1 && mevo)
                        {
                            pkm = Main.SpeciesStat[species = megaEvos[rnd32() % megaEvos.Length]];
                        }
                        else if (rSmart) // Get a new Pokemon with a close BST
                        {
                            int tries = 0;
                            while (!(pkm.BST * (5 - ++tries / Main.Config.MaxSpeciesID) / 6 < oldpkm.BST && pkm.BST * (6 + ++tries / Main.Config.MaxSpeciesID) / 5 > oldpkm.BST))
                            {
                                pkm = Main.SpeciesStat[species = Randomizer.getRandomSpecies(ref sL, ref ctr)];
                            }
                        }

                        trpk_pkm[p].SelectedIndex = species;
                        // Set Gender to Random
                        trpk_gender[p].SelectedIndex = 0;

                        if (trpk_form[p].Items.Count > 0)
                        {
                            trpk_form[p].SelectedIndex = 0;
                        }
                        // Randomize form
                        if (trpk_form[p].Items.Count > 0 && (!megaEvos.Contains(species) || rRandomMegas))
                        {
                            trpk_form[p].SelectedIndex = (int)(rnd32() % trpk_form[p].Items.Count);
                        }
                    }
                    if (rLevel)
                    {
                        trpk_lvl[p].SelectedIndex = Randomizer.getModifiedLevel(trpk_lvl[p].SelectedIndex, rLevelMultiplier);
                    }
                    if (rAbility)
                    {
                        trpk_abil[p].SelectedIndex = (int)(1 + rnd32() % 3);
                    }
                    if (rDiffIV)
                    {
                        trpk_IV[p].SelectedIndex = 255;
                    }
                    if (mevo && p == CB_numPokemon.SelectedIndex - 1)
                    {
                        int[] megastones = GetMegaStones(trpk_pkm[p].SelectedIndex);
                        if (megastones.Length > 0)
                        {
                            trpk_item[p].SelectedIndex = megastones[rnd32() % megastones.Length];
                        }
                    }
                    else if (rItem)
                    #region RandomItem
                    {
                        trpk_item[p].SelectedIndex = itemvals[rnd32() % itemC];
                    }
                    #endregion

                    if (rMove)
                    {
                        pkm = pkm ?? Main.SpeciesStat[trpk_pkm[p].SelectedIndex];
                        int[] pkMoves = new int[4];
                        var   moves   = new[] { trpk_m1[p], trpk_m2[p], trpk_m3[p], trpk_m4[p] };

                        int loopctr = 0;
getMoves:               // Get list of moves
                        loopctr++;
                        for (int m = 0; m < 4; m++)
                        {
                            int mv = Randomizer.getRandomSpecies(ref moveList, ref mctr);
                            while (banned.Contains(mv) || pkMoves.Contains(mv))
                            {
                                mv = Randomizer.getRandomSpecies(ref moveList, ref mctr);
                            }

                            pkMoves[m] = mv;
                        }

                        // If a certain amount of damaging moves is required, check.
                        if (rDMG)
                        {
                            int damagingMoves = pkMoves.Count(move => moveData[move].Category != 0);
                            if (damagingMoves < rDMGCount && loopctr < 666)
                            {
                                goto getMoves;
                            }
                        }
                        if (rSTAB)
                        {
                            int STAB = pkMoves.Count(move => pkm.Types.Contains(moveData[move].Type));
                            if (STAB < rSTABCount && loopctr < 666)
                            {
                                goto getMoves;
                            }
                        }

                        // Assign Moves
                        for (int m = 0; m < 4; m++)
                        {
                            moves[m].SelectedIndex = pkMoves[m];
                        }
                    }
                }
            }
            randomizing = false;
            CB_TrainerID.SelectedIndex = 1;
            WinFormsUtil.Alert("Randomized all Trainers according to specification!", "Press the Dump to .TXT button to view the new Trainer information!");
        }
コード例 #29
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!");
        }
コード例 #30
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!");
        }