예제 #1
0
파일: RSTE.cs 프로젝트: jollinshead/pk3DS
        private static void RandomizeTeam(trdata6 t, MoveRandomizer move, LearnsetRandomizer learn, ushort[] itemvals, int type, bool mevo, bool typerand)
        {
            int last = t.Team.Length - 1;

            for (int p = 0; p < t.Team.Length; p++)
            {
                var   pk     = t.Team[p];
                int[] stones = null;
                if (rPKM)
                {
                    // randomize pokemon
                    int species;
                    if (typerand)
                    {
                        species = rSpeciesRand.GetRandomSpeciesType(pk.Species, type);
                        if (p == last && mevo)
                        {
                            int tries = 0;
                            do
                            {
                                stones = GetRandomMega(out species);
                            }while (Main.Config.Personal[species].Types.All(z => z != type) && tries++ < 100);
                        }
                    }
                    else if (p == last && mevo)
                    {
                        stones = GetRandomMega(out species);
                    }
                    else
                    {
                        species = rSpeciesRand.GetRandomSpecies(pk.Species);
                    }

                    pk.Species = (ushort)species;
                    pk.Gender  = 0;                                  // Set Gender to Random
                    bool mega = rRandomMegas & !(mevo && p == last); // except if mega evolution is forced for the last slot
                    pk.Form = (ushort)Randomizer.GetRandomForme(pk.Species, mega, true, Main.SpeciesStat);
                }
                if (rLevel)
                {
                    pk.Level = (ushort)Randomizer.getModifiedLevel(pk.Level, rLevelMultiplier);
                }
                if (rAbility)
                {
                    pk.Ability = (int)(1 + rnd32() % 3);
                }
                if (rDiffIV)
                {
                    pk.IVs = 255;
                }

                if (mevo && p == last && stones != null)
                {
                    pk.Item = (ushort)stones[rnd32() % stones.Length];
                }
                else if (rItem)
                {
                    pk.Item = itemvals[rnd32() % itemvals.Length];
                }

                if (rForceFullyEvolved && pk.Level >= rForceFullyEvolvedLevel && !rFinalEvo.Contains(pk.Species))
                {
                    int randFinalEvo() => (int)(Util.rnd32() % rFinalEvo.Length);

                    pk.Species = (ushort)rFinalEvo[randFinalEvo()];
                    pk.Form    = (ushort)Randomizer.GetRandomForme(pk.Species, rRandomMegas, true, Main.SpeciesStat);
                }

                // random
                if (rMove)
                {
                    var pkMoves = move.GetRandomMoveset(pk.Species, 4);
                    for (int m = 0; m < 4; m++)
                    {
                        pk.Moves[m] = (ushort)pkMoves[m];
                    }
                }

                // levelup
                if (rNoMove)
                {
                    t.Moves = true;
                    var pkMoves = learn.GetCurrentMoves(pk.Species, pk.Form, pk.Level, 4);
                    for (int m = 0; m < 4; m++)
                    {
                        pk.Moves[m] = (ushort)pkMoves[m];
                    }
                }

                // high-power attacks
                if (rForceHighPower && pk.Level >= rForceHighPowerLevel)
                {
                    var pkMoves = learn.GetHighPoweredMoves(pk.Species, pk.Form, 4);
                    for (int m = 0; m < 4; m++)
                    {
                        pk.Moves[m] = (ushort)pkMoves[m];
                    }
                }
            }
        }
예제 #2
0
파일: SMTE.cs 프로젝트: FullLifeGames/pk3DS
        private void B_Randomize_Click(object sender, EventArgs e)
        {
            Randomizer rnd = new Randomizer(CHK_G1.Checked, CHK_G2.Checked, CHK_G3.Checked, CHK_G4.Checked, CHK_G5.Checked,
                CHK_G6.Checked, CHK_G7.Checked, CHK_L.Checked, CHK_E.Checked, Shedinja: true)
            {
                BST = CHK_BST.Checked,
                Stats = Main.SpeciesStat
            };

            var items = Randomizer.getRandomItemList();
            foreach (var tr in Trainers)
            {
                if (tr.Pokemon.Count == 0)
                    continue;
                // Trainer Properties
                if (CHK_OnlyDoubles.Checked)
                { }
                else if (CHK_OnlySingles.Checked)
                { }

                if (CHK_RandomGift.Checked && Util.rnd32() < NUD_GiftPercent.Value)
                { }

                if (CHK_RandomClass.Checked)
                {
                    if (CHK_IgnoreSpecialClass.Checked)
                    { }
                    else
                    { }
                }

                if (tr.NumPokemon < NUD_RMin.Value)
                {
                    var avgBST = (int)tr.Pokemon.Average(pk => Main.SpeciesStat[pk.Species].BST);
                    var pinfo = Main.SpeciesStat.OrderBy(pk => Math.Abs(avgBST - pk.BST)).First();
                    int avgSpec = Array.IndexOf(Main.SpeciesStat, pinfo);
                    for (int p = tr.NumPokemon; p < NUD_RMin.Value; p++)
                        tr.Pokemon.Add(new trpoke7 {Species = rnd.getRandomSpecies(avgSpec)});
                    tr.NumPokemon = (int)NUD_RMin.Value;
                }
                if (tr.NumPokemon > NUD_RMax.Value)
                {
                    tr.Pokemon.RemoveRange((int)NUD_RMax.Value, (int)(tr.NumPokemon - NUD_RMax.Value));
                    tr.NumPokemon = (int)NUD_RMax.Value;
                }

                // PKM Properties
                foreach (var pk in tr.Pokemon)
                {
                    if (CHK_RandomPKM.Checked)
                    {
                        int Type = CHK_TypeTheme.Checked ? (int)Util.rnd32()%17 : -1;
                        pk.Species = rnd.getRandomSpecies(pk.Species, Type);
                        pk.Form = Randomizer.GetRandomForme(pk.Species, CHK_RandomMegaForm.Checked, true, Main.SpeciesStat);
                    }
                    if (CHK_Level.Checked)
                        pk.Level = (int)(pk.Level*(100 + NUD_LevelBoost.Value))/100;
                    if (CHK_RandomShiny.Checked)
                        pk.Shiny = Util.rand.Next(0, 100 + 1) < NUD_Shiny.Value;
                    if (CHK_RandomItems.Checked)
                        pk.Item = items[Util.rnd32()%items.Length];
                    if (CHK_RandomAbilities.Checked)
                        pk.Ability = (int)Util.rnd32()%4;
                    if (CHK_MaxDiffPKM.Checked)
                        pk.IVs = new[] {31, 31, 31, 31, 31, 31};

                    switch (CB_Moves.SelectedIndex)
                    {
                        case 1: // Random
                            pk.Moves = Randomizer.getRandomMoves(
                                Main.Config.Personal.getFormeEntry(pk.Species, pk.Form).Types,
                                Main.Config.Moves,
                                CHK_Damage.Checked, (int)NUD_Damage.Value,
                                CHK_STAB.Checked, (int)NUD_STAB.Value);
                            break;
                        case 2: // Current LevelUp
                            pk.Moves = getCurrentAttacks(pk);
                            break;
                        case 3: // High Attacks
                            pk.Moves = getHighAttacks(pk);
                            break;
                    }
                }
            }
        }
예제 #3
0
        private static int[] sL; // Random Species List
        private void B_RandAll_Click(object sender, EventArgs e)
        {
            if (DialogResult.Yes != Util.Prompt(MessageBoxButtons.YesNo, "Randomize all resulting species?", "Evolution methods and parameters will stay the same."))
            {
                return;
            }

            // Set up advanced randomization options
            bool rBST  = CHK_BST.Checked;
            bool rEXP  = CHK_Exp.Checked;
            bool rType = CHK_Type.Checked;
            int  ctr   = 0;

            sL = Randomizer.RandomSpeciesList;

            for (int i = 0; i < CB_Species.Items.Count; i++)
            {
                CB_Species.SelectedIndex = i;
                for (int j = 0; j < mb.Length; j++)
                {
                    if (mb[j].SelectedIndex > 0)
                    {
                        // Get a new random species
                        int          oldSpecies     = rb[j].SelectedIndex;
                        PersonalInfo oldpkm         = Main.SpeciesStat[oldSpecies];
                        int          currentSpecies = Array.IndexOf(specieslist, CB_Species.Text);
                        int          loopctr        = 0; // altering calculatiosn to prevent infinite loops
defspecies:
                        int newSpecies = Randomizer.getRandomSpecies(ref sL, ref ctr);
                        PersonalInfo pkm = Main.SpeciesStat[newSpecies];
                        loopctr++;

                        // Verify it meets specifications
                        if (newSpecies == currentSpecies && loopctr < Main.Config.MaxSpeciesID * 10) // no A->A evolutions
                        {
                            goto defspecies;
                        }
                        if (rEXP) // Experience Growth Rate matches
                        {
                            if (oldpkm.EXPGrowth != pkm.EXPGrowth)
                            {
                                goto defspecies;
                            }
                        }
                        if (rType) // Type has to be somewhat similar
                        {
                            if (!oldpkm.Types.Contains(pkm.Types[0]) || !oldpkm.Types.Contains(pkm.Types[1]))
                            {
                                goto defspecies;
                            }
                        }
                        if (rBST)            // Base stat total has to be close
                        {
                            const int l = 5; // tweakable scalars
                            const int h = 6;
                            if (!(pkm.BST * l / (h + loopctr / Main.Config.MaxSpeciesID) < oldpkm.BST && (pkm.BST * h + loopctr / Main.Config.MaxSpeciesID) / l > oldpkm.BST))
                            {
                                goto defspecies;
                            }
                        }
                        // assign random val
                        rb[j].SelectedIndex = newSpecies;
                    }
                }
            }
            setList();
            Util.Alert("All Pokemon's Evolutions have been randomized!");
        }
예제 #4
0
파일: RSTE.cs 프로젝트: wolfauraz/pk3DS
        private static void RandomizeTeam(trdata6 t, MoveRandomizer move, ushort[] itemvals, int type, bool mevo, bool typerand)
        {
            int last = t.Team.Length - 1;

            for (int p = 0; p < t.Team.Length; p++)
            {
                var   pk     = t.Team[p];
                int[] stones = null;
                if (rPKM)
                {
                    // randomize pokemon
                    int species;
                    if (typerand)
                    {
                        species = rSpeciesRand.GetRandomSpeciesType(pk.Species, type);
                        if (p == last && mevo)
                        {
                            int tries = 0;
                            do
                            {
                                stones = GetRandomMega(out species);
                            }while (Main.Config.Personal[species].Types.All(z => z != type) && tries++ < 100);
                        }
                    }
                    else if (p == last && mevo)
                    {
                        stones = GetRandomMega(out species);
                    }
                    else
                    {
                        species = rSpeciesRand.GetRandomSpecies(pk.Species);
                    }

                    pk.Species = (ushort)species;
                    pk.Gender  = 0;                                  // Set Gender to Random
                    bool mega = rRandomMegas & !(mevo && p == last); // except if mega evolution is forced for the last slot
                    pk.Form = (ushort)Randomizer.GetRandomForme(pk.Species, mega, true, Main.SpeciesStat);
                }
                if (rLevel)
                {
                    pk.Level = (ushort)Randomizer.getModifiedLevel(pk.Level, rLevelMultiplier);
                }
                if (rAbility)
                {
                    pk.Ability = (int)(1 + rnd32() % 3);
                }
                if (rDiffIV)
                {
                    pk.IVs = 255;
                }

                if (mevo && p == last && stones != null)
                {
                    pk.Item = (ushort)stones[rnd32() % stones.Length];
                }
                else if (rItem)
                {
                    pk.Item = itemvals[rnd32() % itemvals.Length];
                }

                if (rMove)
                {
                    var pkMoves = move.GetRandomMoveset(pk.Species, 4);
                    for (int m = 0; m < 4; m++)
                    {
                        pk.Moves[m] = (ushort)pkMoves[m];
                    }
                }
            }
        }
예제 #5
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, 464, 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)
                {
                    if (CHK_Metronome.Checked)
                    {
                        t.SpecialMove = 0; // remove Surf Pikachu's special move
                    }
                    else
                    {
                        int rv;
                        do
                        {
                            rv = Util.rand.Next(1, CB_SpecialMove.Items.Count);
                        }while (banned.Contains(rv));
                        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()];
                }

                if (t.IV3)
                {
                    t.IVs = new[] { -4, -1, -1, -1, -1, -1 }
                }
                ;                                             // random with IV3 flag
                else
                {
                    t.IVs = new[] { -1, -1, -1, -1, -1, -1 }
                };                                  // random

                t.EVs = new[] { 0, 0, 0, 0, 0, 0 }; // reset EVs

                t.Form   = Randomizer.GetRandomForme(t.Species, CHK_AllowMega.Checked, true, Main.SpeciesStat);
                t.Gender = 0; // random
                t.Nature = 0; // random

                if (CHK_Metronome.Checked)
                {
                    t.RelearnMoves = new[] { 118, 0, 0, 0 }
                }
                ;
                else
                {
                    t.RelearnMoves = move.GetCurrentMoves(t.Species, t.Form, t.Level, 4);
                }
            }
            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
                t.IVs    = new[] { -1, -1, -1, -1, -1, -1 };             // random
            }

            GetListBoxEntries();
            GetGift();
            GetEncounter();
            GetTrade();

            WinFormsUtil.Alert("Randomized Static Encounters according to specification!");

            B_Starters_Click(sender, e);
        }
예제 #6
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;
                }

                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))
                {
                    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
                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 gifts to be form 1
                }
            }
            WinFormsUtil.Alert("Randomized all Gift Pokémon according to specification!");
        }
예제 #7
0
파일: RSWE.cs 프로젝트: bailie1912/pk3DS
        // Randomization
        private void B_Randomize_Click(object sender, EventArgs e)
        {
            if (Util.Prompt(MessageBoxButtons.YesNo, "Randomize all? Cannot undo.", "Double check Randomization settings @ Horde Tab.") != DialogResult.Yes)
            {
                return;
            }

            Enabled = false;

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

            // Nonrepeating List Start
            int[] sL = Randomizer.getSpeciesList(CHK_G1.Checked, CHK_G2.Checked, CHK_G3.Checked,
                                                 CHK_G4.Checked, CHK_G5.Checked, CHK_G6.Checked, CHK_L.Checked, CHK_E.Checked);

            int ctr = 0;

            int[] slotArray = Enumerable.Range(0, max.Length).Select(a => a).ToArray();

            for (int i = 0; i < CB_LocationID.Items.Count; i++) // for every location
            {
                CB_LocationID.SelectedIndex = i;
                if (!hasData())
                {
                    continue;             // Don't randomize if doesn't have data.
                }
                // Assign Levels
                if (CHK_Level.Checked)
                {
                    for (int l = 0; l < max.Length; l++)
                    {
                        min[l].Value = max[l].Value = max[l].Value <= 1 ? max[l].Value : Math.Max(1, Math.Min(100, (int)(leveldiff * max[l].Value)));
                    }
                }

                // Get a new list of Pokemon so that DexNav does not crash.
                int[] list = new int[max.Length];
                int   used = 19;

                // Count up how many slots are active.
                for (int s = 0; s < max.Length; s++)
                {
                    if (spec[s].SelectedIndex > 0)
                    {
                        list[s] = spec[s].SelectedIndex;
                    }
                }

                // At most 18, but don't chew if there's only a few slots.
                int   cons       = list.Count(a => a != 0);
                int[] RandomList = new int[cons > 18 ? 18 - cons / 8 : cons];

                // Fill Location List
                if (!CHK_BST.Checked)
                {
                    for (int z = 0; z < RandomList.Length; z++)
                    {
                        RandomList[z] = Randomizer.getRandomSpecies(ref sL, ref ctr);
                    }
                }
                else
                {
                    int oldBST = 0;
                    for (int s = 0; s < max.Length; s++)
                    {
                        if (spec[s].SelectedIndex > 0)
                        {
                            oldBST = personal[spec[s + 2].SelectedIndex].Take(6).Sum(b => (ushort)b); break;
                        }
                    }

                    for (int z = 0; z < RandomList.Length; z++)
                    {
                        int species = Randomizer.getRandomSpecies(ref sL, ref ctr);
                        int newBST  = personal[species].Take(6).Sum(b => (ushort)b);
                        while (!(newBST * 4 / 5 < oldBST && newBST * 6 / 5 > oldBST))
                        {
                            species = sL[rand.Next(1, sL.Length)]; newBST = personal[species].Take(6).Sum(b => (ushort)b);
                        }
                        RandomList[z] = species;
                    }
                }

                // Assign Slots
                while (used < RandomList.Distinct().Count() || used > 18) // Can just arbitrarily assign slots.
                {
                    int ctrSingle = 0;
                    Util.Shuffle(slotArray);
                    for (int s = 0; s < max.Length; s++)
                    {
                        int slot = slotArray[s];
                        if (spec[slot].SelectedIndex != 0) // If the slot is in use
                        {
                            list[slot] = Randomizer.getRandomSpecies(ref RandomList, ref ctrSingle);
                        }
                    }
                    used = countUnique(list);
                    if (used != RandomList.Length)
                    {
                        ShuffleSlots(ref list, RandomList.Length);
                    }
                    used = countUnique(list);
                }

                // Fill Slots
                for (int slot = 0; slot < max.Length; slot++)
                {
                    if (spec[slot].SelectedIndex != 0)
                    {
                        spec[slot].SelectedIndex = list[slot];
                        setRandomForm(slot, spec[slot].SelectedIndex);
                    }
                }

                B_Save_Click(sender, e);
            }
            Enabled = true;
            Util.Alert("Randomized!");
        }
예제 #8
0
파일: SMTE.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 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 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)
                {
                    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 = move.GetRandomMoveset(pk.Species, 4);
                        break;

                    case 2:     // Current LevelUp
                        pk.Moves = learn.GetCurrentMoves(pk.Species, pk.Form, pk.Level, 4);
                        break;

                    case 3:     // High Attacks
                        pk.Moves = learn.GetHighPoweredMoves(pk.Species, pk.Form, 4);
                        break;
                    }
                    // 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!");
        }
예제 #9
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)!
            Random rnd = new Random();

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

            ushort[] HMs = { 15, 19, 57, 70, 127, 249, 291 };
            ushort[] TMs = {};
            if (CHK_HMs.Checked && Main.ExeFS != null)
            {
                TMHM.getTMHMList(Main.oras, ref TMs, ref HMs);
            }

            int[] banned = new int[HMs.Length];
            for (int i = 0; i < banned.Length; i++)
            {
                banned[i] = HMs[i];
            }

            // Move Stats
            int[] moveTypes = Moves.getTypes();

            // Personal Stats
            byte[] personalData = File.ReadAllBytes(Directory.GetFiles("personal").Last());

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

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

                if (CHK_Expand.Checked && (int)NUD_Moves.Value > count)
                {
                    dgv.Rows.AddCopies(count, (int)NUD_Moves.Value - count);
                }

                // Default First Move
                dgv.Rows[0].Cells[0].Value = 1;
                dgv.Rows[0].Cells[1].Value = movelist[firstMoves[rnd.Next(0, firstMoves.Length)]];
                for (int j = 1; j < dgv.Rows.Count - 1; j++)
                {
                    // Assign New Moves
                    bool forceSTAB = (CHK_STAB.Checked && rnd.Next(0, 99) < NUD_STAB.Value);
                    int  move      = Randomizer.getRandomSpecies(ref randomMoves, ref ctr);
                    while (                                                                     // Move is invalid
                        (!CHK_HMs.Checked && banned.Contains(move)) || // HM Moves Not Allowed
                        (forceSTAB &&                                                           // STAB is required
                         !(
                             moveTypes[move] == personalData[6 + (Main.oras ? 0x50 : 0x40) * i] // Type 1
                             ||
                             moveTypes[move] == personalData[7 + (Main.oras ? 0x50 : 0x40) * i] // Type 2
                             )
                        )
                        )
                    {
                        move = Randomizer.getRandomSpecies(ref randomMoves, ref ctr);
                    }

                    // Assign Move
                    dgv.Rows[j].Cells[1].Value = movelist[move];
                    // Assign Level
                    if (j >= count)
                    {
                        string level = (dgv.Rows[count - 1].Cells[0].Value ?? 0).ToString();
                        ushort lv;
                        UInt16.TryParse(level, out lv);
                        if (lv > 100)
                        {
                            lv = 100;
                        }
                        else if (lv == 0)
                        {
                            lv = 1;
                        }
                        dgv.Rows[j].Cells[0].Value = lv + (j - count) + 1;
                    }
                    if (CHK_Spread.Checked)
                    {
                        dgv.Rows[j].Cells[0].Value = (j * (NUD_Level.Value / (dgv.Rows.Count - 1))).ToString();
                    }
                }
            }
            CB_Species.SelectedIndex = 0;
            Util.Alert("All Pokemon's Level Up Moves have been randomized!");
        }
예제 #10
0
        private void B_Randomize_Click(object sender, EventArgs e)
        {
            if (Util.Prompt(MessageBoxButtons.YesNo, "Randomize all?", "Cannot undo.") != DialogResult.Yes)
            {
                return;
            }

            Enabled = false;

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

            // Nonrepeating List Start
            int[] sL = Randomizer.getSpeciesList(CHK_G1.Checked, CHK_G2.Checked, CHK_G3.Checked,
                                                 CHK_G4.Checked, CHK_G5.Checked, CHK_G6.Checked, CHK_L.Checked, CHK_E.Checked);

            int ctr = 0;

            for (int i = 0; i < CB_LocationID.Items.Count; i++) // for every location
            {
                CB_LocationID.SelectedIndex = i;
                if (!hasData())
                {
                    continue;             // Don't randomize if doesn't have data.
                }
                // Assign Levels
                if (CHK_Level.Checked)
                {
                    for (int l = 0; l < max.Length; l++)
                    {
                        min[l].Value = max[l].Value = (max[l].Value <= 1) ? max[l].Value : Math.Max(1, Math.Min(100, (int)((leveldiff) * max[l].Value)));
                    }
                }

                for (int slot = 0; slot < max.Length; slot++)
                {
                    if (spec[slot].SelectedIndex == 0)
                    {
                        continue;
                    }

                    int species = Randomizer.getRandomSpecies(ref sL, ref ctr);

                    if (CHK_BST.Checked)
                    {
                        int oldBST = personal[spec[slot].SelectedIndex].Take(6).Sum(b => (ushort)b);
                        int newBST = personal[species].Take(6).Sum(b => (ushort)b);
                        while (!(newBST * 4 / 5 < oldBST && newBST * 6 / 5 > oldBST))
                        {
                            species = sL[rand.Next(1, sL.Length)]; newBST = personal[species].Take(6).Sum(b => (ushort)b);
                        }
                    }

                    spec[slot].SelectedIndex = species;

                    if (species == 666 || species == 665 || species == 664) // Vivillon
                    {
                        form[slot].Value = rnd32() % 20;
                    }
                    else if (species == 386) // Deoxys
                    {
                        form[slot].Value = rnd32() % 4;
                    }
                    else if (species == 201) // Unown
                    {
                        form[slot].Value = rnd32() % 28;
                    }
                    else if (species == 550) // Basculin
                    {
                        form[slot].Value = rnd32() % 2;
                    }
                    else if (species == 412 || species == 413) // Wormadam
                    {
                        form[slot].Value = rnd32() % 3;
                    }
                    else if (species == 422 || species == 423) // Gastrodon
                    {
                        form[slot].Value = rnd32() % 2;
                    }
                    else if (species == 585 || species == 586) // Sawsbuck
                    {
                        form[slot].Value = rnd32() % 4;
                    }
                    else if (species == 669 || species == 671) // Flabebe/Florges
                    {
                        form[slot].Value = rnd32() % 5;
                    }
                    else if (species == 670) // Floette
                    {
                        form[slot].Value = rnd32() % 6;
                    }
                    else if (species == 710 || species == 711) // Pumpkaboo
                    {
                        form[slot].Value = rnd32() % 4;
                    }
                    else
                    {
                        form[slot].Value = 0;
                    }
                }
                B_Save_Click(sender, e);
            }
            Enabled = true;
            Util.Alert("Randomized!");
        }
예제 #11
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;
                species = specrand.GetRandomSpecies(species);
                CB_Species.SelectedIndex = species;
                NUD_Form.Value           = formrand.GetRandomForme(species);
                CB_Gender.SelectedIndex  = 0; // random

                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
                }
            }
            WinFormsUtil.Alert("Randomized all Static Encounters according to specification!");
        }
예제 #12
0
 // Randomization
 private int[] getRandomSpeciesList()
 {
     return(Randomizer.getSpeciesList(CHK_G1.Checked, CHK_G2.Checked, CHK_G3.Checked, CHK_G4.Checked, CHK_G5.Checked, CHK_G6.Checked, CHK_G7.Checked,
                                      CHK_L.Checked, CHK_E.Checked));
 }
        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 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!");
        }
예제 #14
0
파일: XYWE.cs 프로젝트: mjnzy12/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;

            // 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!");
        }
예제 #15
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, 464, 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 && !CHK_Metronome.Checked)
                {
                    int rv;
                    do
                    {
                        rv = Util.rand.Next(1, CB_SpecialMove.Items.Count);
                    }while (banned.Contains(rv));
                    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!");
        }
예제 #16
0
        private void B_Randomize_Click(object sender, EventArgs e)
        {
            CB_TrainerID.SelectedIndex = 0;
            Randomizer rnd = new Randomizer(CHK_G1.Checked, CHK_G2.Checked, CHK_G3.Checked, CHK_G4.Checked, CHK_G5.Checked,
                                            CHK_G6.Checked, CHK_G7.Checked, CHK_L.Checked, CHK_E.Checked, Shedinja: true)
            {
                BST   = CHK_BST.Checked,
                Stats = Main.SpeciesStat
            };

            var items = Randomizer.getRandomItemList();

            for (int i = 0; i < Trainers.Length; i++)
            {
                var tr = Trainers[i];
                if (tr.Pokemon.Count == 0)
                {
                    continue;
                }
                // Trainer Properties
                if (CHK_RandomClass.Checked)
                {
                    int rv;
                    do
                    {
                        rv = (int)(Util.rnd32() % CB_Trainer_Class.Items.Count);
                    } while (/*trClass[rv].StartsWith("[~") || */ (Legal.SpecialClasses_SM.Contains(rv) && !CHK_IgnoreSpecialClass.Checked));
                    // don't allow disallowed classes
                    tr.TrainerClass = (byte)rv;
                }

                if (tr.NumPokemon < NUD_RMin.Value)
                {
                    var avgBST   = (int)tr.Pokemon.Average(pk => Main.SpeciesStat[pk.Species].BST);
                    int avgLevel = (int)tr.Pokemon.Average(pk => pk.Level);
                    var pinfo    = Main.SpeciesStat.OrderBy(pk => Math.Abs(avgBST - pk.BST)).First();
                    int avgSpec  = Array.IndexOf(Main.SpeciesStat, pinfo);
                    for (int p = tr.NumPokemon; p < NUD_RMin.Value; p++)
                    {
                        tr.Pokemon.Add(new trpoke7
                        {
                            Species = rnd.getRandomSpecies(avgSpec),
                            Level   = avgLevel,
                        });
                    }
                    tr.NumPokemon = (int)NUD_RMin.Value;
                }
                if (tr.NumPokemon > NUD_RMax.Value)
                {
                    tr.Pokemon.RemoveRange((int)NUD_RMax.Value, (int)(tr.NumPokemon - NUD_RMax.Value));
                    tr.NumPokemon = (int)NUD_RMax.Value;
                }

                // PKM Properties
                foreach (var pk in tr.Pokemon)
                {
                    if (CHK_RandomPKM.Checked)
                    {
                        int Type = CHK_TypeTheme.Checked ? (int)Util.rnd32() % 17 : -1;
                        pk.Species = rnd.getRandomSpecies(pk.Species, Type);
                        pk.Form    = Randomizer.GetRandomForme(pk.Species, CHK_RandomMegaForm.Checked, true, Main.SpeciesStat);
                        pk.Gender  = 0; // Random Gender
                    }
                    if (CHK_Level.Checked)
                    {
                        pk.Level = (int)(pk.Level * (100 + NUD_LevelBoost.Value)) / 100;
                    }
                    if (CHK_RandomShiny.Checked)
                    {
                        pk.Shiny = Util.rand.Next(0, 100 + 1) < NUD_Shiny.Value;
                    }
                    if (CHK_RandomItems.Checked)
                    {
                        pk.Item = items[Util.rnd32() % items.Length];
                    }
                    if (CHK_RandomAbilities.Checked)
                    {
                        pk.Ability = (int)Util.rnd32() % 4;
                    }
                    if (CHK_MaxDiffPKM.Checked)
                    {
                        pk.IVs = new[] { 31, 31, 31, 31, 31, 31 }
                    }
                    ;

                    switch (CB_Moves.SelectedIndex)
                    {
                    case 1:     // Random
                        pk.Moves = Randomizer.getRandomMoves(
                            Main.Config.Personal.getFormeEntry(pk.Species, pk.Form).Types,
                            Main.Config.Moves,
                            CHK_Damage.Checked, (int)NUD_Damage.Value,
                            CHK_STAB.Checked, (int)NUD_STAB.Value);
                        break;

                    case 2:     // Current LevelUp
                        pk.Moves = getCurrentAttacks(pk);
                        break;

                    case 3:     // High Attacks
                        pk.Moves = getHighAttacks(pk);
                        break;
                    }
                }
                saveData(tr, i);
            }
            Util.Alert("Randomized!");
        }
예제 #17
0
파일: SMTE.cs 프로젝트: XIuminArmpit/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 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 |= 7;
                    }

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