Beispiel #1
0
        public PersonalTable(byte[] data, GameVersion format)
        {
            int size = 0;
            switch (format)
            {
                case GameVersion.XY: size = PersonalInfoXY.SIZE; break;
                case GameVersion.ORASDEMO:
                case GameVersion.ORAS: size = PersonalInfoORAS.SIZE; break;
                case GameVersion.SMDEMO:
                case GameVersion.SM: size = PersonalInfoSM.SIZE; break;
            }

            if (size == 0)
            { Table = null; return; }

            byte[][] entries = splitBytes(data, size);
            PersonalInfo[] d = new PersonalInfo[data.Length / size];

            switch (format)
            {
                case GameVersion.XY:
                    for (int i = 0; i < d.Length; i++)
                        d[i] = new PersonalInfoXY(entries[i]);
                    break;
                case GameVersion.ORASDEMO:
                case GameVersion.ORAS:
                    for (int i = 0; i < d.Length; i++)
                        d[i] = new PersonalInfoORAS(entries[i]);
                    break;
                case GameVersion.SMDEMO:
                case GameVersion.SM:
                    for (int i = 0; i < d.Length; i++)
                        d[i] = new PersonalInfoSM(entries[i]);
                    break;
            }
            Table = d;
        }
Beispiel #2
0
        private void Randomize()
        {
            int[] banned = { 165, 621 }; // Struggle, Hyperspace Fury
            rImportant = new string[CB_TrainerID.Items.Count];
            rTags      = Main.oras ? GetTagsORAS() : GetTagsXY();
            mEvoTypes  = GetMegaEvolvableTypes();
            List <int> GymE4Types = new List <int>();

            // Fetch Move Stats for more difficult randomization
            var moveData = Moves.getMoves();

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

            Util.Shuffle(moveList);

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

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

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

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

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

                    CB_Trainer_Class.SelectedIndex = rv;
                }

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

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

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

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

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

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

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

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

                            pkMoves[m] = mv;
                        }

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

                        // Assign Moves
                        for (int m = 0; m < 4; m++)
                        {
                            moves[m].SelectedIndex = pkMoves[m];
                        }
                    }
                }
            }
            randomizing = false;
            CB_TrainerID.SelectedIndex = 1;
            Util.Alert("Randomized all trainers according to specification!", "Press the Dump to TXT to view the new trainer information!");
        }
Beispiel #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!");
        }
Beispiel #4
0
        private void ReadInfo()
        {
            pkm = Main.SpeciesStat[entry];

            TB_BaseHP.Text  = pkm.HP.ToString("000");
            TB_BaseATK.Text = pkm.ATK.ToString("000");
            TB_BaseDEF.Text = pkm.DEF.ToString("000");
            TB_BaseSPE.Text = pkm.SPE.ToString("000");
            TB_BaseSPA.Text = pkm.SPA.ToString("000");
            TB_BaseSPD.Text = pkm.SPD.ToString("000");
            TB_HPEVs.Text   = pkm.EV_HP.ToString("0");
            TB_ATKEVs.Text  = pkm.EV_ATK.ToString("0");
            TB_DEFEVs.Text  = pkm.EV_DEF.ToString("0");
            TB_SPEEVs.Text  = pkm.EV_SPE.ToString("0");
            TB_SPAEVs.Text  = pkm.EV_SPA.ToString("0");
            TB_SPDEVs.Text  = pkm.EV_SPD.ToString("0");

            CB_Type1.SelectedIndex = pkm.Types[0];
            CB_Type2.SelectedIndex = pkm.Types[1];

            TB_CatchRate.Text = pkm.CatchRate.ToString("000");
            TB_Stage.Text     = pkm.EvoStage.ToString("0");

            CB_HeldItem1.SelectedIndex = pkm.Items[0];
            CB_HeldItem2.SelectedIndex = pkm.Items[1];
            CB_HeldItem3.SelectedIndex = pkm.Items[2];

            TB_Gender.Text      = pkm.Gender.ToString("000");
            TB_HatchCycles.Text = pkm.HatchCycles.ToString("000");
            TB_Friendship.Text  = pkm.BaseFriendship.ToString("000");

            CB_EXPGroup.SelectedIndex = pkm.EXPGrowth;

            CB_EggGroup1.SelectedIndex = pkm.EggGroups[0];
            CB_EggGroup2.SelectedIndex = pkm.EggGroups[1];

            CB_Ability1.SelectedIndex = pkm.Abilities[0];
            CB_Ability2.SelectedIndex = pkm.Abilities[1];
            CB_Ability3.SelectedIndex = pkm.Abilities[2];

            TB_FormeCount.Text  = pkm.FormeCount.ToString("000");
            TB_FormeSprite.Text = pkm.FormeSprite.ToString("000");

            TB_RawColor.Text       = pkm.Color.ToString("000");
            CB_Color.SelectedIndex = pkm.Color & 0xF;

            TB_BaseExp.Text = pkm.BaseEXP.ToString("000");
            TB_BST.Text     = pkm.BST.ToString("000");

            TB_Height.Text = ((decimal)pkm.Height / 100).ToString("00.00");
            TB_Weight.Text = ((decimal)pkm.Weight / 10).ToString("000.0");

            for (int i = 0; i < CLB_TMHM.Items.Count; i++)
            {
                CLB_TMHM.SetItemChecked(i, pkm.TMHM[i]); // Bitflags for TMHM
            }
            for (int i = 0; i < CLB_MoveTutors.Items.Count; i++)
            {
                CLB_MoveTutors.SetItemChecked(i, pkm.TypeTutors[i]); // Bitflags for Tutors
            }
            if (pkm.SpecialTutors.Length > 0)
            {
                int[] len = { tutor1.Length, tutor2.Length, tutor3.Length, tutor4.Length };
                int   ctr = 0;
                for (int i = 0; i < len.Length; i++)
                {
                    for (int b = 0; b < len[i]; b++)
                    {
                        CLB_ORASTutors.SetItemChecked(ctr++, pkm.SpecialTutors[i][b]);
                    }
                }
            }
        }
        private void readInfo()
        {
            pkm = Main.SpeciesStat[entry];

            TB_BaseHP.Text  = pkm.HP.ToString("000");
            TB_BaseATK.Text = pkm.ATK.ToString("000");
            TB_BaseDEF.Text = pkm.DEF.ToString("000");
            TB_BaseSPE.Text = pkm.SPE.ToString("000");
            TB_BaseSPA.Text = pkm.SPA.ToString("000");
            TB_BaseSPD.Text = pkm.SPD.ToString("000");
            TB_HPEVs.Text   = pkm.EV_HP.ToString("0");
            TB_ATKEVs.Text  = pkm.EV_ATK.ToString("0");
            TB_DEFEVs.Text  = pkm.EV_DEF.ToString("0");
            TB_SPEEVs.Text  = pkm.EV_SPE.ToString("0");
            TB_SPAEVs.Text  = pkm.EV_SPA.ToString("0");
            TB_SPDEVs.Text  = pkm.EV_SPD.ToString("0");

            CB_Type1.SelectedIndex = pkm.Types[0];
            CB_Type2.SelectedIndex = pkm.Types[1];

            TB_CatchRate.Text = pkm.CatchRate.ToString("000");
            TB_Stage.Text     = pkm.EvoStage.ToString("0");

            CB_HeldItem1.SelectedIndex = pkm.Items[0];
            CB_HeldItem2.SelectedIndex = pkm.Items[1];
            CB_HeldItem3.SelectedIndex = pkm.Items[2];

            TB_Gender.Text      = pkm.Gender.ToString("000");
            TB_HatchCycles.Text = pkm.HatchCycles.ToString("000");
            TB_Friendship.Text  = pkm.BaseFriendship.ToString("000");

            CB_EXPGroup.SelectedIndex = pkm.EXPGrowth;

            CB_EggGroup1.SelectedIndex = pkm.EggGroups[0];
            CB_EggGroup2.SelectedIndex = pkm.EggGroups[1];

            CB_Ability1.SelectedIndex = pkm.Abilities[0];
            CB_Ability2.SelectedIndex = pkm.Abilities[1];
            CB_Ability3.SelectedIndex = pkm.Abilities[2];

            TB_FormeCount.Text  = pkm.FormeCount.ToString("000");
            TB_FormeSprite.Text = pkm.FormeSprite.ToString("000");

            TB_RawColor.Text       = pkm.Color.ToString("000");
            CB_Color.SelectedIndex = pkm.Color & 0xF;

            TB_BaseExp.Text = pkm.BaseEXP.ToString("000");
            TB_BST.Text     = pkm.BST.ToString("000");

            TB_Height.Text = ((decimal)pkm.Height / 100).ToString("00.00");
            TB_Weight.Text = ((decimal)pkm.Weight / 10).ToString("000.0");

            for (int i = 0; i < CLB_TM.Items.Count; i++)
            {
                CLB_TM.SetItemChecked(i, pkm.TMHM[i]); // Bitflags for TM
            }
            for (int i = 0; i < CLB_MoveTutors.Items.Count; i++)
            {
                CLB_MoveTutors.SetItemChecked(i, pkm.TypeTutors[i]); // Bitflags for Tutors
            }
            if (Main.Config.SM || Main.Config.USUM)
            {
                PersonalInfoSM sm = (PersonalInfoSM)pkm;
                TB_CallRate.Text           = sm.EscapeRate.ToString("000");
                CB_ZItem.SelectedIndex     = sm.SpecialZ_Item;
                CB_ZBaseMove.SelectedIndex = sm.SpecialZ_BaseMove;
                CB_ZMove.SelectedIndex     = sm.SpecialZ_ZMove;
                CHK_Variant.Checked        = sm.LocalVariant;
            }
            var special = pkm.SpecialTutors;

            if (special.Length > 0)
            {
                for (int b = 0; b < CLB_BeachTutors.Items.Count; b++)
                {
                    CLB_BeachTutors.SetItemChecked(b, special[0][b]);
                }
            }
        }
Beispiel #6
0
        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;
            if (rBST || rEXP || rType)
            {
                // initialize personal data
                string[] personalList = Directory.GetFiles("personal");
                personal = new byte[personalList.Length][];
                for (int i = 0; i < personalList.Length; i++)
                    personal[i] = File.ReadAllBytes("personal" + Path.DirectorySeparatorChar + i.ToString("000") + ".bin");
            }
            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 = new PersonalInfo(personal[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 = new PersonalInfo(personal[newSpecies]);
                        loopctr++;

                        // Verify it meets specifications
                        if (newSpecies == currentSpecies && loopctr < 722*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/722) < oldpkm.BST && (pkm.BST * h + loopctr/722) / l > oldpkm.BST))
                            { goto defspecies; }
                        }
                        // assign random val
                        rb[j].SelectedIndex = newSpecies;
                    }
            }
            setList();
            Util.Alert("All Pokemon's Evolutions have been randomized!");
        }
Beispiel #7
0
        private void readInfo()
        {
            byte[] array = new byte[Main.oras ? 0x50 : 0x40];
            Array.Copy(data, array.Length * entry, array, 0, array.Length);
            pkm = new PersonalInfo(array);

            TB_BaseHP.Text = pkm.HP.ToString("000");
            TB_BaseATK.Text = pkm.ATK.ToString("000");
            TB_BaseDEF.Text = pkm.DEF.ToString("000");
            TB_BaseSPE.Text = pkm.SPE.ToString("000");
            TB_BaseSPA.Text = pkm.SPA.ToString("000");
            TB_BaseSPD.Text = pkm.SPD.ToString("000");
            TB_HPEVs.Text = pkm.EV_HP.ToString("0");
            TB_ATKEVs.Text = pkm.EV_ATK.ToString("0");
            TB_DEFEVs.Text = pkm.EV_DEF.ToString("0");
            TB_SPEEVs.Text = pkm.EV_SPE.ToString("0");
            TB_SPAEVs.Text = pkm.EV_SPA.ToString("0");
            TB_SPDEVs.Text = pkm.EV_SPD.ToString("0");

            CB_Type1.SelectedIndex = pkm.Types[0];
            CB_Type2.SelectedIndex = pkm.Types[1];

            TB_CatchRate.Text = pkm.CatchRate.ToString("000");
            TB_Stage.Text = pkm.EvoStage.ToString("0");

            CB_HeldItem1.SelectedIndex = pkm.Items[0];
            CB_HeldItem2.SelectedIndex = pkm.Items[1];
            CB_HeldItem3.SelectedIndex = pkm.Items[2];

            TB_Gender.Text = pkm.Gender.ToString("000");
            TB_HatchCycles.Text = pkm.HatchCycles.ToString("000");
            TB_Friendship.Text = pkm.BaseFriendship.ToString("000");

            CB_EXPGroup.SelectedIndex = pkm.EXPGrowth;

            CB_EggGroup1.SelectedIndex = pkm.EggGroups[0];
            CB_EggGroup2.SelectedIndex = pkm.EggGroups[1];

            CB_Ability1.SelectedIndex = pkm.Abilities[0];
            CB_Ability2.SelectedIndex = pkm.Abilities[1];
            CB_Ability3.SelectedIndex = pkm.Abilities[2];

            TB_FormeCount.Text = pkm.FormeCount.ToString("000");
            TB_FormeSprite.Text = pkm.FormeSprite.ToString("000");

            TB_RawColor.Text = pkm.Color.ToString("000");
            CB_Color.SelectedIndex = (pkm.Color & 0xF);

            TB_BaseExp.Text = pkm.BaseEXP.ToString("000");

            TB_Height.Text = (pkm.Height / 100).ToString("00.0");
            TB_Weight.Text = (pkm.Weight / 10).ToString("000.0");

            for (int i = 0; i < CLB_TMHM.Items.Count; i++)
                CLB_TMHM.SetItemChecked(i, pkm.TMHM[i]); // Bitflags for TMHM

            for (int i = 0; i < CLB_MoveTutors.Items.Count; i++)
                CLB_MoveTutors.SetItemChecked(i, pkm.Tutors[i]); // Bitflags for Tutors

            if (pkm.ORASTutors[0] != null)
            {
                int[] len = { tutor1.Length, tutor2.Length, tutor3.Length, tutor4.Length };
                int ctr = 0;
                for (int i = 0; i < len.Length; i++)
                    for (int b = 0; b < len[i]; b++)
                        CLB_OrasTutors.SetItemChecked(ctr++, pkm.ORASTutors[i][b]);
            }
        }
Beispiel #8
0
        private void Randomize()
        {
            int[] banned = { 165, 621 }; // Struggle, Hyperspace Fury
            rTags = (Main.oras) ? GetTagsORAS() : GetTagsXY();
            mEvoTypes = GetMegaEvolvableTypes();
            List<int> GymE4Types = new List<int>();

            // Fetch Move Stats for more difficult randomization
            var moveData = Moves.getMoves();
            int[] moveList = Enumerable.Range(1, movelist.Count() - 1).ToArray();
            int mctr = 0;
            Util.Shuffle(moveList);

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

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

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

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

                    CB_Trainer_Class.SelectedIndex = rv;
                }

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

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

                int type = GetRandomType(i);
                bool mevo = rEnsureMEvo.Contains(i);

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

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

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

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

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

                            pkMoves[m] = mv;
                        }

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

                        // Assign Moves
                        for (int m = 0; m < 4; m++)
                            moves[m].SelectedIndex = pkMoves[m];
                    }
                }
            }
            randomizing = false;
            CB_TrainerID.SelectedIndex = 1;
            Util.Alert("Randomized all trainers according to specification!", "Press the Dump to TXT to view the new trainer information!");
        }
Beispiel #9
0
        private void readInfo()
        {
            byte[] array = new byte[Main.oras ? 0x50 : 0x40];
            Array.Copy(data, array.Length * entry, array, 0, array.Length);
            pkm = new PersonalInfo(array);

            TB_BaseHP.Text  = pkm.HP.ToString("000");
            TB_BaseATK.Text = pkm.ATK.ToString("000");
            TB_BaseDEF.Text = pkm.DEF.ToString("000");
            TB_BaseSPE.Text = pkm.SPE.ToString("000");
            TB_BaseSPA.Text = pkm.SPA.ToString("000");
            TB_BaseSPD.Text = pkm.SPD.ToString("000");
            TB_HPEVs.Text   = pkm.EV_HP.ToString("0");
            TB_ATKEVs.Text  = pkm.EV_ATK.ToString("0");
            TB_DEFEVs.Text  = pkm.EV_DEF.ToString("0");
            TB_SPEEVs.Text  = pkm.EV_SPE.ToString("0");
            TB_SPAEVs.Text  = pkm.EV_SPA.ToString("0");
            TB_SPDEVs.Text  = pkm.EV_SPD.ToString("0");

            CB_Type1.SelectedIndex = pkm.Types[0];
            CB_Type2.SelectedIndex = pkm.Types[1];

            TB_CatchRate.Text = pkm.CatchRate.ToString("000");
            TB_Stage.Text     = pkm.EvoStage.ToString("0");

            CB_HeldItem1.SelectedIndex = pkm.Items[0];
            CB_HeldItem2.SelectedIndex = pkm.Items[1];
            CB_HeldItem3.SelectedIndex = pkm.Items[2];

            TB_Gender.Text      = pkm.Gender.ToString("000");
            TB_HatchCycles.Text = pkm.HatchCycles.ToString("000");
            TB_Friendship.Text  = pkm.BaseFriendship.ToString("000");

            CB_EXPGroup.SelectedIndex = pkm.EXPGrowth;

            CB_EggGroup1.SelectedIndex = pkm.EggGroups[0];
            CB_EggGroup2.SelectedIndex = pkm.EggGroups[1];

            CB_Ability1.SelectedIndex = pkm.Abilities[0];
            CB_Ability2.SelectedIndex = pkm.Abilities[1];
            CB_Ability3.SelectedIndex = pkm.Abilities[2];

            TB_FormeCount.Text  = pkm.FormeCount.ToString("000");
            TB_FormeSprite.Text = pkm.FormeSprite.ToString("000");

            TB_RawColor.Text       = pkm.Color.ToString("000");
            CB_Color.SelectedIndex = pkm.Color & 0xF;

            TB_BaseExp.Text = pkm.BaseEXP.ToString("000");

            TB_Height.Text = (pkm.Height / 100).ToString("00.0");
            TB_Weight.Text = (pkm.Weight / 10).ToString("000.0");

            for (int i = 0; i < CLB_TMHM.Items.Count; i++)
            {
                CLB_TMHM.SetItemChecked(i, pkm.TMHM[i]); // Bitflags for TMHM
            }
            for (int i = 0; i < CLB_MoveTutors.Items.Count; i++)
            {
                CLB_MoveTutors.SetItemChecked(i, pkm.Tutors[i]); // Bitflags for Tutors
            }
            if (pkm.ORASTutors[0] != null)
            {
                int[] len = { tutor1.Length, tutor2.Length, tutor3.Length, tutor4.Length };
                int   ctr = 0;
                for (int i = 0; i < len.Length; i++)
                {
                    for (int b = 0; b < len[i]; b++)
                    {
                        CLB_OrasTutors.SetItemChecked(ctr++, pkm.ORASTutors[i][b]);
                    }
                }
            }
        }
Beispiel #10
0
        private void readInfo()
        {
            pkm = Main.SpeciesStat[entry];

            TB_BaseHP.Text = pkm.HP.ToString("000");
            TB_BaseATK.Text = pkm.ATK.ToString("000");
            TB_BaseDEF.Text = pkm.DEF.ToString("000");
            TB_BaseSPE.Text = pkm.SPE.ToString("000");
            TB_BaseSPA.Text = pkm.SPA.ToString("000");
            TB_BaseSPD.Text = pkm.SPD.ToString("000");
            TB_HPEVs.Text = pkm.EV_HP.ToString("0");
            TB_ATKEVs.Text = pkm.EV_ATK.ToString("0");
            TB_DEFEVs.Text = pkm.EV_DEF.ToString("0");
            TB_SPEEVs.Text = pkm.EV_SPE.ToString("0");
            TB_SPAEVs.Text = pkm.EV_SPA.ToString("0");
            TB_SPDEVs.Text = pkm.EV_SPD.ToString("0");

            CB_Type1.SelectedIndex = pkm.Types[0];
            CB_Type2.SelectedIndex = pkm.Types[1];

            TB_CatchRate.Text = pkm.CatchRate.ToString("000");
            TB_Stage.Text = pkm.EvoStage.ToString("0");

            CB_HeldItem1.SelectedIndex = pkm.Items[0];
            CB_HeldItem2.SelectedIndex = pkm.Items[1];
            CB_HeldItem3.SelectedIndex = pkm.Items[2];

            TB_Gender.Text = pkm.Gender.ToString("000");
            TB_HatchCycles.Text = pkm.HatchCycles.ToString("000");
            TB_Friendship.Text = pkm.BaseFriendship.ToString("000");

            CB_EXPGroup.SelectedIndex = pkm.EXPGrowth;

            CB_EggGroup1.SelectedIndex = pkm.EggGroups[0];
            CB_EggGroup2.SelectedIndex = pkm.EggGroups[1];

            CB_Ability1.SelectedIndex = pkm.Abilities[0];
            CB_Ability2.SelectedIndex = pkm.Abilities[1];
            CB_Ability3.SelectedIndex = pkm.Abilities[2];

            TB_FormeCount.Text = pkm.FormeCount.ToString("000");
            TB_FormeSprite.Text = pkm.FormeSprite.ToString("000");

            TB_RawColor.Text = pkm.Color.ToString("000");
            CB_Color.SelectedIndex = pkm.Color & 0xF;

            TB_BaseExp.Text = pkm.BaseEXP.ToString("000");
            TB_BST.Text = pkm.BST.ToString("000");

            TB_Height.Text = ((decimal)pkm.Height / 100).ToString("00.00");
            TB_Weight.Text = ((decimal)pkm.Weight / 10).ToString("000.0");

            for (int i = 0; i < CLB_TMHM.Items.Count; i++)
                CLB_TMHM.SetItemChecked(i, pkm.TMHM[i]); // Bitflags for TMHM

            for (int i = 0; i < CLB_MoveTutors.Items.Count; i++)
                CLB_MoveTutors.SetItemChecked(i, pkm.TypeTutors[i]); // Bitflags for Tutors

            if (pkm.SpecialTutors.Length > 0)
            {
                int[] len = { tutor1.Length, tutor2.Length, tutor3.Length, tutor4.Length };
                int ctr = 0;
                for (int i = 0; i < len.Length; i++)
                    for (int b = 0; b < len[i]; b++)
                        CLB_OrasTutors.SetItemChecked(ctr++, pkm.SpecialTutors[i][b]);
            }
        }
Beispiel #11
0
        private void B_Randomize_Click(object sender, EventArgs e)
        {
            bool blind = DialogResult.Yes ==
                         Util.Prompt(MessageBoxButtons.YesNo, "Hide randomization, save, and close?",
                             "If you want the Starters to be a surprise :)");
            if (blind)
                Hide();

            // Iterate for each group of Starters
            for (int i = 0; i < Count; i++)
            {
                // Get Species List
                int gen = Int32.Parse(Labels[i].Text[4]+"");
                int[] sL = CHK_Gen.Checked
                    ? Randomizer.getSpeciesList(gen==1, gen==2, gen==3, gen==4, gen==5, gen==6, false, false, false)
                    : Randomizer.getSpeciesList(true, true, true, true, true, true, false, false, false);
                int ctr = 0;
                // Assign Species
                for (int j = 0; j < 3; j++)
                {
                    int species = Randomizer.getRandomSpecies(ref sL, ref ctr);

                    if (CHK_BST.Checked) // Enforce BST
                    {
                        PersonalInfo oldpkm = new PersonalInfo(personal[BitConverter.ToUInt16(Data, offset + (i * 3 + j) * 0x54)]); // Use original species cuz why not.
                        PersonalInfo pkm = new PersonalInfo(personal[species]);

                        while (!(pkm.BST * 5 / 6 < oldpkm.BST && pkm.BST * 6 / 5 > oldpkm.BST))
                        { species = Randomizer.getRandomSpecies(ref sL, ref ctr); pkm = new PersonalInfo(personal[species]); }
                    }

                    Choices[i][j].SelectedIndex = species;
                }
            }

            if (blind)
            {
                saveData();
                Close();
            }
        }
Beispiel #12
0
        internal static int getRandomSpecies(ref int[] sL, ref int ctr, int oldSpecies, bool BST, PersonalInfo[] stats = null, int Type = -1)
        {
            int species = getRandomSpecies(ref sL, ref ctr);
            if (!BST || stats == null)
                return species;

            PersonalInfo oldpkm = stats[oldSpecies];
            PersonalInfo pkm = stats[species];

            // Stat Deviation: increasing 10% increments if no suitable match found in entire list
            int a = 11;
            const int c = 10;

            int iter = 1;
            bool valid = pkm.BST*c/a < oldpkm.BST && pkm.BST*a/c > oldpkm.BST;
            if (Type > -1) valid &= pkm.Types.Any(type => type == Type);

            while (!valid)
            {
                species = getRandomSpecies(ref sL, ref ctr);
                pkm = Main.SpeciesStat[species];
                if (++iter % sL.Length == 0)
                    a++;

                // Check Satisfaction
                valid = pkm.BST*c/a < oldpkm.BST && pkm.BST*a/c > oldpkm.BST;
                if (Type > -1) valid &= pkm.Types.Any(type => type == Type);
            }
            return species;
        }
Beispiel #13
0
 internal static int GetRandomForme(int species, bool mega, bool alola, PersonalInfo[] stats = null)
 {
     if (stats == null)
         return 0;
     if (stats[species].FormeCount <= 1)
         return 0;
     if (alola && Legal.EvolveToAlolanForms.Contains(species))
         return (int)(Util.rnd32()%2);
     if (!Legal.Mega_ORAS.Contains((ushort)species) || mega)
         return (int)(Util.rnd32() % stats[species].FormeCount); // Slot-Random
     return 0;
 }