Exemple #1
0
        public override RNGResult Generate()
        {
            ResultW7 rt = new ResultW7();

            rt.Level = SpecialLevel;

            if (Fishing)
            {
                IsSpecial = rt.IsSpecial = getrand % 100 >= SpecialEnctr;
                time_elapse(12);
                if (IsSpecial) // Predict hooked item
                {
                    int mark = RNGPool.index;
                    time_elapse(34);
                    rt.SpecialVal = (byte)(getrand % 100);
                    RNGPool.Rewind(mark); // Don't need to put modelstatus back
                }
            }
            else if (SpecialEnctr > 0)
            {
                IsSpecial = rt.IsSpecial = getrand % 100 < SpecialEnctr;
            }

            if (SOS)
            {
                SOSRNG.Reset();
                SOSRNG.Advance(2);                                                                    // Call Rate Check
                CheckLeadAbility(getsosrand % 100);
                if (SOSRNG.Weather && (rt.Slot = slot = SOSRNG.getWeatherSlot(getsosrand % 100)) > 7) // No Electric/Steel Type in weather sos slots
                {
                    rt.IsSpecial = true;
                }
                else
                {
                    rt.Slot = StaticMagnetPass ? getsmslot(getsosrand) : getslot((int)(getsosrand % 100));
                }
                rt.Level   = (byte)(getsosrand % (uint)(Levelmax - Levelmin + 1) + Levelmin);
                FluteBoost = getFluteBoost(getsosrand % 100);
                ModifyLevel(rt);
            }
            else if (Crabrawler)
            {
                CheckLeadAbility(getrand % 100);
                rt.Slot  = slot = 1;
                rt.Level = ModifiedLevel;
            }
            else if (NormalSlot) // Normal wild
            {
                CheckLeadAbility(getrand % 100);
                rt.Slot    = StaticMagnetPass ? getsmslot(getrand) : getslot((int)(getrand % 100));
                rt.Level   = (byte)(getrand % (ulong)(Levelmax - Levelmin + 1) + Levelmin);
                FluteBoost = getFluteBoost(getrand % 100);
                ModifyLevel(rt);
                if (IsMinior)
                {
                    rt.Forme = (byte)(getrand % 7);
                }
            }
            else // UB or QR
            {
                slot = 0;
                time_elapse(7);
                CheckLeadAbility(getrand % 100);
                time_elapse(3);
            }
            rt.Species = (short)(SpecForm[slot] & 0x7FF);

            if (DelayTime > 0)
            {
                InlineDelay();
            }

            if (!SOS)
            {
                Advance(60);
            }

            //Encryption Constant
            rt.EC = (uint)getrand;

            //PID
            for (int i = PIDroll_count; i > 0; i--)
            {
                rt.PID = (uint)getrand;
                if (rt.PSV == TSV)
                {
                    if (IsShinyLocked)
                    {
                        rt.PID ^= 0x10000000;
                    }
                    else
                    {
                        rt.Shiny       = true;
                        rt.SquareShiny = rt.PRV == TRV;
                    }
                    break;
                }
            }

            //IV
            rt.IVs = new int[6];
            for (int i = PerfectIVCount; i > 0;)
            {
                int tmp = (int)(getrand % 6);
                if (rt.IVs[tmp] == 0)
                {
                    i--; rt.IVs[tmp] = 31;
                }
            }
            for (int i = 0; i < 6; i++)
            {
                if (rt.IVs[i] == 0)
                {
                    rt.IVs[i] = (int)(getrand & 0x1F);
                }
            }

            //Ability
            rt.Ability = (byte)(IsUB ? 1 : (getrand & 1) + 1);

            //Nature
            rt.Nature = (rt.Synchronize = SynchroPass) && Synchro_Stat < 25 ? Synchro_Stat : (byte)(getrand % 25);

            //Gender
            rt.Gender = RandomGender[slot] ? (CuteCharmPass ? CuteCharmGender : (byte)(getrand % 252 >= Gender[slot] ? 1 : 2)) : Gender[slot];

            //Item
            rt.Item = getHeldItem(SOS ? getsosrand % 100 : NormalSlot ? getrand % 100 : 100, CompoundEye);

            if (Fishing && rt.IsSpecial)
            {
                rt.Slot = getHookedItemSlot(rt.SpecialVal); //Fishing item slots
            }
            else if (SOS)
            {
                SOSRNG.PostGeneration(rt); // IVs and HA
            }
            return(rt);
        }
Exemple #2
0
        private void Search7_Battle()
        {
            SFMT  sfmt      = new SFMT(Seed.Value);
            int   frame     = (int)StartingFrame.Value;
            int   loopcount = (int)MaxResults.Value;
            int   delay     = (int)Delay.Value;
            ulong N         = (ulong)Range.Value;

            CaptureResult.Details = SOSResult.Details = CB_Detail.Checked || Filters.SelectedTab == TP_Misc;
            var capture7 = new Capture();

            if (Filters.SelectedTab == TP_Capture)
            {
                capture7.HPCurr      = (uint)HPCurr.Value;
                capture7.HPMax       = (uint)HPMax.Value;
                capture7.CatchRate   = (byte)CatchRate.Value;
                capture7.StatusBonus = (uint)(int)Status.SelectedValue;
                capture7.BallBonus   = (uint)(int)BallBonus.SelectedValue;
                capture7.DexBonus    = (uint)(int)DexBonus.SelectedValue;
                capture7.OPowerBonus = RotoCatch.Checked ? 2.5f : 1.0f;
                capture7.Calc();
                var criticalchance = capture7.CriticalRate / 256.0;
                var shakechance    = capture7.ShakeRate / 65536.0;
                var capturechance  = criticalchance * shakechance + (1 - criticalchance) * Math.Pow(shakechance, 4);
                L_output.Text = CB_Detail.Checked ? string.Format("Critical {0:P}  \tShake {1:P}", criticalchance, shakechance)
                    : string.Format("Critical {0:P}  \tSuccess {1:P}", criticalchance, capturechance);
            }
            else if (SOS)
            {
                SOSRNG.ChainLength = (int)ChainLength.Value;
                SOSRNG.Weather     = L_Weather.Checked;

                int Rate1 = (int)CB_CallRate.SelectedValue * (int)HPBarColor.SelectedValue;
                if (AO.Checked)
                {
                    Rate1 *= 2;
                }
                if (Rate1 > 100)
                {
                    Rate1 = 100;
                }
                SOSRNG.Rate1 = (byte)Rate1;

                double Rate2 = (int)CB_CallRate.SelectedValue * (Intimidate.Checked ? 0x4CCC : 0x4000) / 4096.0;
                if (SameCaller.Checked)
                {
                    Rate2 *= 1.5;
                }
                if (SupperEffective.Checked)
                {
                    Rate2 *= 2;
                }
                if (LastCallFail.Checked)
                {
                    Rate2 *= 3;
                }
                if (Rate2 > 100)
                {
                    Rate2 = 100.0;
                }
                SOSRNG.Rate2 = (byte)Math.Round(Rate2);
            }

            for (int i = 0; i < frame; i++)
            {
                sfmt.Nextuint();
            }

            RNGPool.CreateBuffer(sfmt, AutoCheck: false); // Force 32bit

            for (int i = 0; i < loopcount; i++, RNGPool.AddNext(sfmt, AutoCheck: false))
            {
                var f = new Frame_Misc();
                f.Frame  = frame++;
                f.Rand32 = RNGPool.getcurrent;

                RNGPool.Rewind(0);
                RNGPool.Advance(delay);
                if (filter.Random)
                {
                    f.RandN = (int)(RNGPool.getrand % N);
                }
                if (ShowCapture)
                {
                    RNGPool.Rewind(0);
                    f.Crt = capture7.Catch();
                }
                if (ShowSOS)
                {
                    RNGPool.Rewind(0);
                    f.Srt = SOSRNG.Generate();
                }

                if (!filter.check(f))
                {
                    continue;
                }

                Frames.Add(f);
            }
        }