Esempio n. 1
0
        private void Search6()
        {
            MersenneTwister MT        = new MersenneTwister(Seed.Value);
            int             frame     = (int)StartingFrame.Value;
            int             loopcount = (int)MaxResults.Value;
            int             delay     = (int)Delay.Value;
            ulong           N         = (ulong)Range.Value;

            for (int i = 0; i < frame; i++)
            {
                MT.Next();
            }

            RNGPool.CreateBuffer(MT);

            for (int i = 0; i < loopcount; i++, RNGPool.AddNext(MT))
            {
                var f = new Frame_Misc();
                f.Frame    = frame++;
                f.Rand32   = RNGPool.getcurrent;
                f.realtime = i;
                f.st       = RNGPool.getcurrentstate;

                RNGPool.Rewind(0);
                RNGPool.Advance(delay);
                if (filter.Random)
                {
                    f.RandN = (int)((RNGPool.getrand * N) >> 32);
                }
                else if (filter.Pokerus)
                {
                    f.Pokerus = Pokerus6.getStrain();
                }

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

                Frames.Add(f);
            }
        }
Esempio n. 2
0
        private void Search7_TimelineLeap()
        {
            int start      = (int)Frame_min.Value;
            int target     = (int)TargetFrame.Value;
            int Totaldelay = FuncUtil.CalcFrame(Seed.Value, start, target, Modelnum)[0];
            int mindelay   = (int)Math.Round(DelayMin.Value * 30);
            int maxdelay   = (int)Math.Round(DelayMax.Value * 30);
            int starttime  = Totaldelay - maxdelay;
            int endtime    = Totaldelay - mindelay;

            // Intialize
            SFMT sfmt = new SFMT(Seed.Value);

            for (int i = 0; i < start; i++)
            {
                sfmt.Next();
            }
            ModelStatus status = new ModelStatus(Modelnum, sfmt)
            {
                IsBoy = Boy.Checked
            };

            // Advance
            int frame = start;

            for (int i = 0; i < starttime; i++)
            {
                frame += status.NextState();
            }
            for (int i = start; i < frame; i++)
            {
                sfmt.Next();
            }

            getsetting(sfmt);

            List <int>         Framelist  = new List <int>();
            List <ModelStatus> statuslist = new List <ModelStatus>();
            List <int>         timelist   = new List <int>();

            // Search
            int         LeapType = getLeapType();
            int         frameadvance;
            int         Tmpframe, bakframe1, bakframe2 = 0;
            ModelStatus stmp, bak1, bak2 = null;

            for (int i = Math.Max(0, starttime); i < endtime; i++)
            {
                Tmpframe = frame;
                stmp     = status.Clone();

                // Leap!
                switch (LeapType)
                {
                case 0:     // WC7
                    for (int j = 0; j < 19; j++)
                    {
                        Tmpframe += stmp.NextState();
                    }
                    RNGPool.Rewind(Tmpframe - frame);
                    RNGPool.CopyStatus(stmp);
                    RNGPool.igenerator.Generate();
                    frameadvance = RNGPool.index - (Tmpframe - frame);
                    Tmpframe    += stmp.frameshift(frameadvance);
                    Tmpframe    += stmp.NextState();
                    break;

                case 1:     // Menu
                    stmp.fidget_cd = 3;
                    break;

                case 2:     // Dialogue
                    Tmpframe += stmp.NextState();
                    Tmpframe += stmp.NextState();
                    Tmpframe += stmp.frameshift(1);
                    Tmpframe += stmp.NextState();
                    break;
                }

                bak1      = stmp.Clone();
                bakframe1 = Tmpframe;

                // Check if hit
                while (Tmpframe < target)
                {
                    Tmpframe += stmp.NextState();
                }
                if (Tmpframe == target)
                {
                    Framelist.Add(frame);
                    timelist.Add(i);
                    bak2      = bak1.Clone();
                    bakframe2 = bakframe1;
                    statuslist.Add(stmp.Clone());
                }

                // Move to next state
                frameadvance = status.NextState();
                frame       += frameadvance;
                for (int j = 0; j < frameadvance; j++)
                {
                    RNGPool.AddNext(sfmt);
                }
            }

            if (Framelist.Count > 0)
            {
                int frame0 = Framelist.Last();
                Frame_max.Value = frame0;
                if (!IsEvent)
                {
                    JumpFrame.Value = frame0;
                }
                if (FormUtil.Prompt(MessageBoxButtons.YesNo, string.Format("Hit A at {0} (Frame1) and then at {1} (Frame2).\n\nYes: Check new timeline / No: Check the spread", frame0, target)) == DialogResult.Yes)
                {
                    Search7_TimelineLeap1(bakframe2, target, bak2, maxdelay);
                    foreach (var f in Frames)
                    {
                        f.Frame0 = frame0;
                    }
                }
                else
                {
                    Search7_TimelineLeap2(Framelist, statuslist, target, timelist);
                }
            }
            else
            {
                FormUtil.Error(StringItem.NORESULT_STR[StringItem.language]);
            }
        }
Esempio n. 3
0
        private void Search7_FishyTimeline()
        {
            SFMT sfmt        = new SFMT(Seed.Value);
            int  start_frame = (int)Frame_min.Value;
            int  targetframe = (int)TargetFrame.Value;

            // Advance
            for (int i = 0; i < start_frame; i++)
            {
                sfmt.Next();
            }
            // Prepare
            ModelStatus status = new ModelStatus(Modelnum, sfmt)
            {
                raining = Raining.Checked
            };

            getsetting(sfmt);
            int totaltime = (int)TimeSpan.Value * 30;
            int frameinput1 = (int)Frame_min.Value;         // Input 1: Cast the rod
            int frameadvance, fishingdelay, frameinput2;    // Input 2: Pull the rod off water
            var fsetting   = getFishingSetting;
            int Timewindow = 2;

            // Start
            for (int i = 0; i <= totaltime; i++)
            {
                RNGPool.Save();

                // 2 Frames for delay calc
                // USUM v1.1 sub_39E2F0
                RNGPool.Rewind(0); RNGPool.CopyStatus(status);
                fishingdelay = (int)(RNGPool.getrand64 % 60) + fsetting.basedelay;
                if (Overview.Checked)
                {
                    RNGPool.Advance(1); // Keep timewindow at 2 to avoid calculation
                }
                else
                {
                    Timewindow = (int)(RNGPool.getrand64 % 15) + fsetting.platdelay + 14;
                }

                // Fishing Delay
                RNGPool.time_elapse7(fishingdelay);

                // Bitechance
                if (fsetting.suctioncups || (int)(RNGPool.getrand64 % 100) < 50)
                {
                    RNGPool.time_elapse7(1);
                    frameinput2 = RNGPool.index + frameinput1;
                    RNGPool.SaveStatus();

                    for (int j = 2; j <= Timewindow; j++)
                    {
                        RNGPool.LoadStatus();
                        RNGPool.time_elapse7(1);
                        frameinput2 += RNGPool.index;
                        RNGPool.SaveStatus();
                        RNGPool.DelayTime = fsetting.pkmdelay + Math.Max(0, fsetting.platdelay - j); //  Duplicates

                        var result = RNGPool.Generate7() as ResultW7;

                        if (!filter.CheckResult(result))
                        {
                            continue;
                        }
                        if (Overview.Checked)
                        {
                            result.RandNum = RNGPool.getsavepoint;
                        }
                        result.FrameDelayUsed += frameinput2 - frameinput1;
                        Frames.Add(new Frame(result, frame: frameinput2, time: (i + j + fishingdelay) * 2)
                        {
                            Frame0 = frameinput1
                        });
                    }
                }

                RNGPool.Load();

                if (Frames.Count > MAX_RESULTS_NUM)
                {
                    break;
                }

                // Move to next Frame, Update RNGPool
                frameadvance = status.NextState();
                frameinput1 += frameadvance;
                for (int j = 0; j < frameadvance; j++)
                {
                    RNGPool.AddNext(sfmt);
                }
            }
        }
Esempio n. 4
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);
        }
Esempio n. 5
0
        private void Search6_Battle()
        {
            TinyMT tiny      = TTT.Checked ? new TinyMT(Program.mainform.TinySeeds) : new TinyMT(Seed.Value);
            int    frame     = (int)StartingFrame.Value;
            int    loopcount = (int)MaxResults.Value;
            int    delay     = (int)Delay.Value;
            ulong  N         = (ulong)Range.Value;

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

            if (Filters.SelectedTab == TP_Capture)
            {
                capture6.Gen6        = true;
                capture6.HPCurr      = (uint)HPCurr.Value;
                capture6.HPMax       = (uint)HPMax.Value;
                capture6.CatchRate   = (byte)CatchRate.Value;
                capture6.StatusBonus = (uint)(int)Status.SelectedValue;
                capture6.BallBonus   = (uint)(int)BallBonus.SelectedValue;
                capture6.DexBonus    = (uint)(int)DexBonus.SelectedValue;
                capture6.OPowerBonus = OPowerList[OPower.SelectedIndex];
                capture6.Calc();
                var criticalchance = capture6.CriticalRate / 256.0;
                var shakechance    = capture6.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);
            }

            for (int i = 0; i < frame; i++)
            {
                tiny.Next();
            }

            RNGPool.CreateBuffer(tiny);

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

                RNGPool.Rewind(0);
                RNGPool.Advance(delay);
                if (filter.Random)
                {
                    f.RandN = (int)((RNGPool.getrand * N) >> 32);
                }
                if (ShowCapture)
                {
                    RNGPool.Rewind(0);
                    f.Crt = capture6.Catch();
                }

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

                Frames.Add(f);
            }
        }
Esempio n. 6
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);
            }
        }
Esempio n. 7
0
        private void Search7_Timeline()
        {
            SFMT sfmt      = new SFMT(Seed.Value);
            int  frame     = (int)StartingFrame.Value;
            int  loopcount = (int)MaxResults.Value;
            int  frameadvance;
            int  FirstJumpFrame = (int)JumpFrame.Value;

            FirstJumpFrame = FirstJumpFrame >= frame && Fidget.Checked ? FirstJumpFrame : int.MaxValue;
            setupgenerator();

            FuncUtil.getblinkflaglist(frame, frame, sfmt, (byte)(NPC.Value + 1));

            for (int i = 0; i < frame; i++)
            {
                sfmt.Next();
            }
            ModelStatus status = new ModelStatus((byte)(NPC.Value + 1), sfmt);

            status.raining = Raining.Checked;
            status.IsBoy   = Boy.Checked;

            RNGPool.CreateBuffer(sfmt);

            for (int i = 0; i <= loopcount; i++)
            {
                var f = new Frame_Misc();
                f.Frame    = frame;
                f.Rand64   = RNGPool.getcurrent64;
                f.realtime = 2 * i;
                f.status   = (int[])status.remain_frame.Clone();

                if (frame >= FirstJumpFrame) // Find the first call
                {
                    status.fidget_cd = 1;
                    FirstJumpFrame   = int.MaxValue; // Disable this part
                }
                if (status.fidget_cd == 1)
                {
                    f.Blink = 1;
                }

                // USUM v1.1 sub_421E4C eyes closed
                if (status.remain_frame[0] == -3 || status.remain_frame[0] == 33)
                {
                    f.Blink = 4;
                }

                RNGPool.Rewind(0); RNGPool.CopyStatus(status);
                getspecialinfo(f);

                frameadvance = status.NextState();
                frame       += frameadvance;
                for (int j = frameadvance; j > 0; j--)
                {
                    RNGPool.AddNext(sfmt);
                }

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

                Frames.Add(f);
            }
            if (Frames.FirstOrDefault()?.Frame == (int)StartingFrame.Value)
            {
                Frames[0].Blink = FuncUtil.blinkflaglist[0];
            }
        }
Esempio n. 8
0
        private void Search7()
        {
            SFMT sfmt     = new SFMT(Seed.Value);
            int  min      = (int)StartingFrame.Value;
            int  max      = min + (int)MaxResults.Value;
            byte Modelnum = (byte)(NPC.Value + 1);

            setupgenerator();

            FuncUtil.getblinkflaglist(min, max, sfmt, Modelnum);

            for (int i = 0; i < min; i++)
            {
                sfmt.Next();
            }

            ModelStatus status = new ModelStatus(Modelnum, sfmt);
            ModelStatus stmp   = new ModelStatus(Modelnum, sfmt);

            RNGPool.CreateBuffer(sfmt);

            int frameadvance;
            int realtime  = 0;
            int frametime = 0;

            for (int i = min; i <= max;)
            {
                do
                {
                    frameadvance = status.NextState();
                    realtime++;
                }while (frameadvance == 0); // Keep the starting status of a longlife frame(for npc=0 case)
                do
                {
                    var f = new Frame_Misc();
                    f.Frame    = i;
                    f.Rand64   = RNGPool.getcurrent64;
                    f.Blink    = FuncUtil.blinkflaglist[i - min];
                    f.realtime = 2 * frametime;
                    f.status   = (int[])stmp.remain_frame.Clone();

                    RNGPool.Rewind(0); RNGPool.CopyStatus(stmp);
                    getspecialinfo(f);

                    RNGPool.AddNext(sfmt);
                    frameadvance--;
                    if (i++ > max)
                    {
                        return;
                    }
                    if (!filter.check(f))
                    {
                        continue;
                    }

                    Frames.Add(f);
                }while (frameadvance > 0);

                // Backup current status
                status.CopyTo(stmp);
                frametime = realtime;
            }
        }
Esempio n. 9
0
        private void Search7_TimelineLeap()
        {
            int start      = (int)Frame_min.Value;
            int target     = (int)TargetFrame.Value;
            int frame      = start;
            int Totaldelay = FuncUtil.CalcFrame(Seed.Value, start, target, Modelnum)[0] - 300; // 10 seconds ahead

            if (Totaldelay > 20000)
            {
                Error("Too away from target!");
                return;
            }

            List <int>         Framelist  = new List <int>();
            List <ModelStatus> statuslist = new List <ModelStatus>();

            // Intialize
            SFMT sfmt = new SFMT(Seed.Value);

            for (int i = 0; i < start; i++)
            {
                sfmt.Next();
            }
            ModelStatus status = new ModelStatus(Modelnum, sfmt);

            getsetting(sfmt);

            // Search
            int         frameadvance;
            int         Tmpframe, bakframe1, bakframe2 = 0;
            ModelStatus stmp, bak1, bak2 = null;

            for (int i = 0; i < Totaldelay; i++)
            {
                Tmpframe = frame;
                stmp     = status.Clone();

                // Leap!
                for (int j = 0; j < 19; j++)
                {
                    Tmpframe += stmp.NextState();
                }
                RNGPool.Rewind(Tmpframe - frame);
                RNGPool.CopyStatus(stmp);
                RNGPool.igenerator.Generate();
                frameadvance = RNGPool.index - (Tmpframe - frame);
                Tmpframe    += frameadvance; stmp.frameshift(frameadvance);
                Tmpframe    += stmp.NextState();

                bak1      = stmp.Clone();
                bakframe1 = Tmpframe;

                // Check if hit
                while (Tmpframe < target)
                {
                    Tmpframe += stmp.NextState();
                }
                if (Tmpframe == target)
                {
                    Framelist.Add(frame);
                    bak2      = bak1.Clone();
                    bakframe2 = bakframe1;
                    statuslist.Add(stmp.Clone());
                }

                // Move to next state
                frameadvance = status.NextState();
                frame       += frameadvance;
                for (int j = 0; j < frameadvance; j++)
                {
                    RNGPool.AddNext(sfmt);
                }
            }

            if (Framelist.Count > 0)
            {
                Frame_max.Value = Framelist.Last();
                if (Prompt(MessageBoxButtons.YesNo, string.Format("Hit A at {0}. Yes: Check new timeline / No: Check the spread", Framelist.Last())) == DialogResult.Yes)
                {
                    Search7_TimelineLeap1(bakframe2, target, bak2, Totaldelay);
                }
                else
                {
                    Search7_TimelineLeap2(Framelist, statuslist, target);
                }
            }
            else
            {
                Error(StringItem.NORESULT_STR[StringItem.language]);
            }
        }