Пример #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            dataGridView1.Rows.Clear();
            uint        pidi    = uint.Parse(PIDTextBox.Text, System.Globalization.NumberStyles.HexNumber);
            List <uint> origin  = recoverLower16BitsPID(pidi);
            List <uint> origin2 = new List <uint>()
            {
            };

            foreach (uint seed in origin)
            {
                PokeRNGR rng = new PokeRNGR(seed);

                uint seed1 = rng.nextUInt();

                PokeRNGR testRNG = new PokeRNGR(seed1);
                uint     testPID;
                uint     slot;
                uint     nextRNG  = seed >> 16;
                uint     nextRNG2 = testRNG.nextUShort();

                do
                {
                    if ((nextRNG % 25) == (pidi % 25))
                    {
                        slot  = testRNG.seed * 0xeeb9eb65 + 0xa3561a1;
                        seed1 = slot * 0xdc6c95d9 + 0x4d3cb126;
                        origin2.Add(seed1);
                    }
                    testPID  = (nextRNG << 16) | nextRNG2;
                    nextRNG  = testRNG.nextUShort();
                    nextRNG2 = testRNG.nextUShort();
                } while ((testPID % 25) != (pidi % 25));
            }

            foreach (uint seed in origin2)
            {
                PokeRNG go = new PokeRNG(seed);
                go.nextUInt();

                uint slot = comparetoslot(go.nextUShort() % 100);

                go.nextUInt();

                uint nature = go.nextUShort() % 25;

                uint pid;

                do
                {
                    uint low  = go.nextUShort();
                    uint high = go.nextUShort();
                    pid = (high << 16) | low;
                } while (pid % 25 != nature);

                if (MethodComboBox.Text == "H2")
                {
                    go.nextUInt();
                }
                uint iv1 = go.nextUShort();
                if (MethodComboBox.Text == "H4")
                {
                    go.nextUInt();
                }
                uint        iv2 = go.nextUShort();
                List <uint> ivs = GetIVs(iv1, iv2);

                string naturestr = natures[(int)nature];

                dataGridView1.Rows.Add(seed.ToString("X8"), slot.ToString(), slottolevel(slot).ToString(), pid.ToString("X"), correctslots.Contains(slot), pidtospinda(pid, ShinyCheck.Checked ? "Yes" : "No"), naturestr, ivs[0], ivs[1], ivs[2], ivs[3], ivs[4], ivs[5]);
            }
        }
Пример #2
0
        private void GenerateFrames(object sender, EventArgs e)
        {
            dataGridView1.Rows.Clear();
            List <uint> correctslots = new List <uint> {
                0, 1, 3, 4, 6, 8, 10
            };

            uint seed;

            try
            {
                seed = uint.Parse(SeedTextBox.Text, System.Globalization.NumberStyles.HexNumber);
            }
            catch
            {
                MessageBox.Show("Error: Seed has not been entered properly, please fix this if you want results.");
                return;
            }
            PokeRNG rng = new PokeRNG(seed);
            uint    startingFrame, maxFrames;

            try
            {
                startingFrame = uint.Parse(StartingFrameTextBox.Text);
                maxFrames     = uint.Parse(FrameAmountTextBox.Text);
            }
            catch
            {
                MessageBox.Show("Error: Starting Frame and/or Frame Amount have not been entered properly, please fix this if you want results.");
                return;
            }
            List <decimal> minIVs = new List <decimal> {
                MinHPUD.Value, MinATKUD.Value, MinDEFUD.Value, MinSPAUD.Value, MinSPDUD.Value, MinSPEUD.Value
            };
            List <decimal> maxIVs = new List <decimal> {
                MaxHPUD.Value, MaxATKUD.Value, MaxDEFUD.Value, MaxSPAUD.Value, MaxSPDUD.Value, MaxSPEUD.Value
            };

            int delay = 0;

            if (DelayCheckBox.Checked)
            {
                try
                {
                    delay = int.Parse(DelayTextBox.Text);
                }
                catch
                {
                    MessageBox.Show("Error: Delay has not been entered properly, please fix this if you want it to impact the frames or uncheck the Delay box.");
                }
            }

            uint f = 1;

            while (f < startingFrame + delay)
            {
                rng.nextUInt();
                f += 1;
            }
            uint tid, sid, tsv;

            try
            {
                tid = uint.Parse(TIDTextBox.Text);
                sid = uint.Parse(SIDTextBox.Text);
                tsv = (tid ^ sid) / 8;
            }
            catch
            {
                tsv = 8193;
                MessageBox.Show("Error: TID/SID have not been entered properly, please fix this if you want shinies to be marked correctly.");
            }

            string selectedNature = "None";

            if (NatureCheckBox.Checked)
            {
                try
                {
                    selectedNature = NatureComboBox.Text;
                }
                catch
                {
                    MessageBox.Show("Error: Chosen Nature has not been entered properly, please fix this or uncheck the Nature box if you want results.");
                    return;
                }
            }

            uint selectedPID = 0;

            if (PIDCheck.Checked)
            {
                try
                {
                    selectedPID = uint.Parse(PIDTextBox.Text, System.Globalization.NumberStyles.HexNumber);
                    if (Recover(selectedPID).Count == 0)
                    {
                        MessageBox.Show("Selected PID is not possible");
                        return;
                    }
                }
                catch
                {
                    MessageBox.Show("Error: Chosen PID has not been entered properly, please fix this or uncheck the PID box if you want results");
                    return;
                }
            }

            int j = 0;

            while (j < 6)
            {
                if (maxIVs[j] < minIVs[j] | minIVs[j] > maxIVs[j])
                {
                    MessageBox.Show("Error: IV Range has not been entered properly.");
                    break;
                }
                j += 1;
            }

            uint cnt = 0;

            while (cnt < maxFrames + delay)
            {
                bool    flag = true;
                PokeRNG go   = new PokeRNG(rng.seed);
                go.nextUInt();

                uint slot = comparetoslot(go.nextUShort() % 100);

                go.nextUInt();

                uint nature = go.nextUShort() % 25;

                uint pid;

                do
                {
                    uint low  = go.nextUShort();
                    uint high = go.nextUShort();
                    pid = (high << 16) | low;
                } while (pid % 25 != nature);

                if (MethodComboBox.Text == "H2")
                {
                    go.nextUInt();
                }
                uint iv1 = go.nextUShort();
                if (MethodComboBox.Text == "H4")
                {
                    go.nextUInt();
                }
                uint        iv2   = go.nextUShort();
                List <uint> ivs   = GetIVs(iv1, iv2);
                string      shiny = "No";


                uint   psv       = (uint)(((pid & 0xFFFF) ^ (pid >> 16)) / 8);
                string naturestr = natures[(int)nature];


                if (tsv == psv)
                {
                    shiny = "Yes";
                }
                if (ShinyCheckBox.Checked)
                {
                    if (!(tsv == psv))
                    {
                        flag = false;
                    }
                }



                if (NatureCheckBox.Checked & !(selectedNature == naturestr))
                {
                    flag = false;
                }

                if (SpindaCheck.Checked & !(correctslots.Contains(slot)))
                {
                    flag = false;
                }

                if (PIDCheck.Checked & !(selectedPID == pid))
                {
                    flag = false;
                }

                int i = 0;

                while (i < 6)
                {
                    if (ivs[i] < minIVs[i] | ivs[i] > maxIVs[i])
                    {
                        flag = false;
                        break;
                    }
                    i += 1;
                }

                if (flag)
                {
                    dataGridView1.Rows.Add(cnt + startingFrame, slot.ToString(), slottolevel(slot).ToString(), pid.ToString("X"), shiny, pidtospinda(pid, shiny), naturestr, ivs[0], ivs[1], ivs[2], ivs[3], ivs[4], ivs[5]);
                }
                cnt += 1;
                rng.nextUInt();
            }
        }