private void B_TinySearch_Click(object sender, EventArgs e)
        {
            var nature = FuncUtil.parseNatureList(NatureList.Text);

            if (nature == null)
            {
                Error("Invalid Input");
                return;
            }
            if (nature.Length != 8)
            {
                Error("Incorrect number of natures");
                return;
            }
            if (tinyfinder == null)
            {
                tinyfinder            = new TinySeedFinder();
                tinyfinder.Update    += UpdateProgressBar7;
                tinyfinder.NewResult += UpdateList7;
            }
            Gen7PBar.Value   = 0;
            Gen7PBar.Maximum = tinyfinder.Max;
            L_Progress7.Text = "0.00%";
            EggSeedList.Items.Clear();
            tinyfinder.Clear();
            tinyfinder.SetFinder(nature, ShinyCharm.Checked);
            tinyfinder.Search();
            B_TinySearch.Visible = false;
            B_Abort7.Visible     = true;
        }
Beispiel #2
0
 public override string ToString()
 {
     string o = "Sync: " + FuncUtil.Bool2Str(Sync) + "  ";
     o += "Encounter Slot: " + Slot.ToString() + "  ";
     o += "Hidden Power Positon: " + (HA == 0 ? "None" : HA.ToString()) + "\n";
     return o;
 }
Beispiel #3
0
 public override string ToString() => string.Join(" / ", new string[]
 {
     Details?Call1.ToString("D2") + "/" + Call2.ToString("D2") : FuncUtil.Bool2Str(Call1 < SOSRNG.Rate1) + FuncUtil.Bool2Str(Call2 < SOSRNG.Rate2),
         FuncUtil.Bool2Str(Sync),
         Slot > 7 ? "W" + (Slot - 7).ToString() : Slot.ToString(),
         Level.ToString(),
         StringItem.helditemStr[Wild7.getHeldItem(HeldItem)],
         string.Join(string.Empty, BumpedIVs.Select(iv => iv ? "V" : "X")),
         HA ? "HA" : "NA",
 });
Beispiel #4
0
        private void Search7_Timeline()
        {
            SFMT sfmt        = new SFMT(Seed.Value);
            int  start_frame = (int)Frame_min.Value;

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

            getsetting(sfmt);
            int totaltime = (int)TimeSpan.Value * 30;
            int frame = (int)Frame_min.Value;
            int frameadvance, Currentframe;

            // Start
            for (int i = 0; i <= totaltime; i++)
            {
                Currentframe = frame;

                RNGPool.CopyStatus(status);

                var result = RNGPool.Generate7() as Result7;

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

                if (!filter.CheckResult(result))
                {
                    continue;
                }

                Frames.Add(new Frame(result, frame: Currentframe, time: i * 2));

                if (Frames.Count > 100000)
                {
                    break;
                }
            }
            if (Frames.FirstOrDefault()?.FrameNum == (int)Frame_min.Value)
            {
                Frames[0].Blink = FuncUtil.blinkflaglist[0];
            }
        }
Beispiel #5
0
 private void Search7()
 {
     Frame_min.Value = Math.Max(Frame_min.Value, FuncUtil.getstartingframe(Gameversion.SelectedIndex, MainRNGEgg.Checked ? 0 : Method));
     // ID
     if (Method == 4)
     {
         Search7_ID();
         return;
     }
     // Eggs
     if (Method == 3 && !MainRNGEgg.Checked)
     {
         if (EggNumber.Checked)
         {
             Search7_EggList();
         }
         else if (RB_EggShortest.Checked)
         {
             Search7_EggShortestPath();
         }
         else
         {
             Search7_Egg();
         }
         return;
     }
     // Method 0-2 & MainRNGEgg
     if (CreateTimeline.Checked)
     {
         Search7_Timeline();
     }
     else if (AroundTarget.Checked)
     {
         Search7_AroundTarget();
     }
     else if (gen7fidgettimeline && MenuMethod.Checked)
     {
         Search7_MenuMethod();
     }
     else if (RB_TimelineLeap.Checked)
     {
         Search7_TimelineLeap();
     }
     else
     {
         Search7_Normal();
     }
 }
Beispiel #6
0
 private void SetAsAfter_Click(object sender, EventArgs e)
 {
     try
     {
         var    seed = (string)DGV.CurrentRow.Cells["dgv_tinystate"].Value;
         int    adv  = (Frames[DGV.CurrentRow.Index].rt as Core.EggResult).FramesUsed;
         uint[] St   = FuncUtil.SeedStr2Array(seed);
         var    tmt  = new RNG.TinyMT(St);
         for (int i = adv; i > 0; i--)
         {
             tmt.Next();
         }
         Status = tmt.status;
     }
     catch
     { }
 }
Beispiel #7
0
 private void SetAsAfter_Click(object sender, EventArgs e)
 {
     try
     {
         var    seed = (string)DGV.CurrentRow.Cells["dgv_tinystate"].Value;
         int    adv  = (Frames[DGV.CurrentRow.Index].rt as Core.EggResult).FramesUsed;
         uint[] St   = FuncUtil.SeedStr2Array(seed);
         var    tmt  = new RNG.TinyMT(St);
         for (int i = adv; i > 0; i--)
         {
             tmt.Next();
         }
         Status = tmt.status;
         var newtarget = TargetFrame.Value - (int)DGV.CurrentRow.Cells["dgv_Frame"].Value - adv;
         TargetFrame.Value = newtarget > 0 ? newtarget : TargetFrame.Value;
     }
     catch (NullReferenceException)
     {
         Error(NOSELECTION_STR[lindex]);
     }
 }
Beispiel #8
0
        public override void Markslots()
        {
            IV3          = new bool[SpecForm.Length];
            RandomGender = new bool[SpecForm.Length];
            Gender       = new byte[SpecForm.Length];
            var smslot = new int[0].ToList();

            if (SpecForm.Distinct().Count(t => t != 0) == 1)
            {
                SpecForm[0] = SpecForm[1];
            }
            for (int i = 0; i < SpecForm.Length; i++)
            {
                if (SpecForm[i] == 0)
                {
                    Gender[i]       = FuncUtil.getGenderRatio(BlankGenderRatio);
                    RandomGender[i] = FuncUtil.IsRandomGender(BlankGenderRatio);
                    continue;
                }
                PersonalInfo info        = PersonalTable.ORAS.getFormeEntry(SpecForm[i] & 0x7FF, SpecForm[i] >> 11);
                byte         genderratio = (byte)info.Gender;
                IV3[i]          = info.EggGroups[0] == 0xF && !(Pokemon.BabyMons.Contains(SpecForm[i] & 0x7FF) && IsORAS);
                Gender[i]       = FuncUtil.getGenderRatio(genderratio);
                RandomGender[i] = FuncUtil.IsRandomGender(genderratio);
                if (Static && info.Types.Contains(Pokemon.electric) || Magnet && info.Types.Contains(Pokemon.steel)) // Collect slots
                {
                    smslot.Add(i);
                }
            }
            StaticMagnetSlot = smslot.Select(s => (byte)s).ToArray();
            if (0 == (NStaticMagnetSlot = (ulong)smslot.Count))
            {
                Static = Magnet = false;
            }
            if (ModifiedLevel != 0)
            {
                ModifiedLevel = SlotLevel.Skip(1).Max();
            }
            _PIDroll_count += ShinyCharm && !IsShinyLocked ? 3 : 1;
        }
Beispiel #9
0
 private void SetAsCurrent_Click(object sender, EventArgs e)
 {
     try
     {
         if (Gen6 && dgv_rand64.Visible)
         {
             ulong key = (ulong)DGV.CurrentRow.Cells["dgv_rand64"].Value;
             Key1.Value = (uint)(key >> 32);
             Key0.Value = (uint)key;
             return;
         }
         var seed = (string)DGV.CurrentRow.Cells["dgv_tinystate"].Value;
         if (Gen7)
         {
             Status = FuncUtil.SeedStr2Array(seed) ?? Status;
         }
     }
     catch (NullReferenceException)
     {
         Error(NOSELECTION_STR[lindex]);
     }
 }
Beispiel #10
0
 public override void Markslots()
 {
     IV3          = new bool[SpecForm.Length];
     RandomGender = new bool[SpecForm.Length];
     Gender       = new byte[SpecForm.Length];
     for (int i = 0; i < SpecForm.Length; i++)
     {
         if (SpecForm[i] == 0)
         {
             continue;
         }
         PersonalInfo info        = PersonalTable.USUM.getFormeEntry(SpecForm[i] & 0x7FF, SpecForm[i] >> 11);
         byte         genderratio = (byte)info.Gender;
         IV3[i]          = info.EggGroups[0] == 0xF && !Pokemon.BabyMons.Contains(SpecForm[i] & 0x7FF);
         Gender[i]       = FuncUtil.getGenderRatio(genderratio);
         RandomGender[i] = FuncUtil.IsRandomGender(genderratio);
     }
     if (UB)
     {
         IV3[0] = true;     // For UB Template
     }
 }
Beispiel #11
0
        public override void Markslots()
        {
            IV3          = new bool[SpecForm.Length];
            RandomGender = new bool[SpecForm.Length];
            Gender       = new byte[SpecForm.Length];
            var smslot = new int[0].ToList();

            for (int i = 0; i < SpecForm.Length; i++)
            {
                if (SpecForm[i] == 0)
                {
                    continue;
                }
                PersonalInfo info        = PersonalTable.USUM.getFormeEntry(SpecForm[i] & 0x7FF, SpecForm[i] >> 11);
                byte         genderratio = (byte)info.Gender;
                IV3[i]          = info.EggGroups[0] == 0xF && !Pokemon.BabyMons.Contains(SpecForm[i] & 0x7FF);
                Gender[i]       = FuncUtil.getGenderRatio(genderratio);
                RandomGender[i] = FuncUtil.IsRandomGender(genderratio);
                if (Static && info.Types.Contains(Pokemon.electric) || Magnet && info.Types.Contains(Pokemon.steel)) // Collect slots
                {
                    smslot.Add(i);
                }
            }
            StaticMagnetSlot = smslot.Select(s => (byte)s).ToArray();
            if (0 == (NStaticMagnetSlot = (ulong)smslot.Count))
            {
                Static = Magnet = false;
            }
            if (ModifiedLevel == 101)
            {
                ModifiedLevel = Levelmax;
            }
            if (UB)
            {
                IV3[0] = true;     // For UB Template
            }
        }
Beispiel #12
0
        private void Search7_AroundTarget()
        {
            SFMT sfmt   = new SFMT(Seed.Value);
            int  start  = (int)Frame_min.Value;
            int  target = (int)TargetFrame.Value;
            int  min    = target - 100;
            int  max    = target + 100;

            if (start > min)
            {
                start = min;
            }

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

            // Prepare
            int  i         = 0;
            byte blinkflag = 0;

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

            status.raining = stmp.raining = Raining.Checked;
            getsetting(sfmt);
            int frameadvance = 0;
            int realtime     = 0;
            int frametime    = 0;

            // Calc frames around target
            for (; i <= max;)
            {
                for (; frameadvance == 0; frameadvance = status.NextState())
                {
                    realtime++;
                }
                for (; frameadvance > 0; frameadvance--, i++)
                {
                    if (min <= i && i <= max)
                    {
                        RNGPool.CopyStatus(stmp);
                        var result = RNGPool.Generate7();
                        blinkflag = FuncUtil.blinkflaglist[i - min];
                        Frames.Add(new Frame(result, frame: i, time: frametime * 2, blink: blinkflag));
                    }
                    RNGPool.AddNext(sfmt);
                }

                // Backup current status
                status.CopyTo(stmp);
                frametime = realtime;
            }

            // Get all possible results by EC matching
            // Can't identify MainRNGEggs by EC
            if (Method < 3)
            {
                Frames = Frames.OrderBy(f => f.FrameNum + (f.rt as Result7).FrameDelayUsed).ToList();

                var EClist = Frames.Select(f => f.rt.EC).ToArray();

                // Another Buffer
                sfmt = new SFMT(Seed.Value);
                int starting = Frames[0].FrameNum + (Frames[0].rt as Result7).FrameDelayUsed;
                for (i = 0; i < starting; i++)
                {
                    sfmt.Next();
                }
                RNGPool.CreateBuffer(sfmt);

                // Skip Delay
                RNGPool.Considerdelay = false;
                if (RNGPool.igenerator is Stationary7 st7)
                {
                    st7.AssumeSynced = Nature.CheckBoxItems[SyncNature.SelectedIndex].Checked;
                }

                uint  EC;
                uint  EClast = EClist.Last();
                int   Nframe = -1;
                ulong rand   = 0;
                do
                {
                    RNGPool.modelnumber = Modelnum;
                    RNGPool.ResetModelStatus();
                    var result = RNGPool.Generate7() as Result7;
                    EC = result.EC;
                    RNGPool.AddNext(sfmt);
                    if (EClist.Contains(EC))
                    {
                        var framenow = Frames.LastOrDefault(f => f.EC == EC);
                        Nframe    = framenow.FrameNum;
                        frametime = framenow.realtime;
                        rand      = framenow.Rand64;
                        continue;
                    }
                    else if (Nframe > -1)
                    {
                        result.RandNum = rand;
                        Frames.Add(new Frame(result, frame: Nframe, time: frametime, blink: 4));
                    }
                }while (EC != EClast);
            }

            // Filters
            RNGResult.IsPokemon = true;
            Frames = Frames.Where(f => filter.CheckResult(f.rt))
                     .OrderBy(f => f.FrameNum)
                     .ToList();
        }
Beispiel #13
0
        private void Search7_Normal()
        {
            SFMT sfmt = new SFMT(Seed.Value);
            int  min  = (int)Frame_min.Value;
            int  max  = (int)Frame_max.Value;

            if (min > max)
            {
                return;
            }
            // Blinkflag
            FuncUtil.getblinkflaglist(min, max, sfmt, Modelnum);
            // Advance
            for (int i = 0; i < min; i++)
            {
                sfmt.Next();
            }
            // Prepare
            ModelStatus status = new ModelStatus(Modelnum, sfmt);
            ModelStatus stmp   = new ModelStatus(Modelnum, sfmt);

            status.raining = stmp.raining = Raining.Checked;
            getsetting(sfmt);
            int frameadvance;
            int realtime  = 0;
            int frametime = 0;

            // Start
            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
                {
                    RNGPool.CopyStatus(stmp);
                    var result = RNGPool.Generate7();

                    RNGPool.AddNext(sfmt);

                    frameadvance--;
                    i++;
                    if (i > max + 1)
                    {
                        continue;
                    }
                    byte blinkflag = FuncUtil.blinkflaglist[i - min - 1];
                    if (BlinkFOnly.Checked && blinkflag < 4)
                    {
                        continue;
                    }
                    if (SafeFOnly.Checked && blinkflag >= 2)
                    {
                        continue;
                    }
                    if (!filter.CheckResult(result))
                    {
                        continue;
                    }
                    Frames.Add(new Frame(result, frame: i - 1, time: frametime * 2, blink: blinkflag));
                }while (frameadvance > 0);

                if (Frames.Count > MAX_RESULTS_NUM)
                {
                    return;
                }
                // Backup current status
                status.CopyTo(stmp);
                frametime = realtime;
            }
        }
Beispiel #14
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];
            }
        }
Beispiel #15
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;
            }
        }
Beispiel #16
0
 public override string ToString()
 => "Sync: " + FuncUtil.Bool2Str(Sync)
 + "   Encounter Slot: " + Slot.ToString()
 + "   HA Position: " + (HA == 0 ? StringItem.NONE_STR[StringItem.language] : HA.ToString());
Beispiel #17
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]);
            }
        }
Beispiel #18
0
        private void Search7_Timeline()
        {
            if (gen7fishing)
            {
                Search7_FishyTimeline();
                return;
            }
            SFMT sfmt        = new SFMT(Seed.Value);
            int  start_frame = (int)Frame_min.Value;
            int  targetframe = (int)TargetFrame.Value;

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

            getsetting(sfmt);
            int totaltime = (int)TimeSpan.Value * 30;
            int frame = (int)Frame_min.Value;
            int frameadvance, Currentframe;
            int FirstJumpFrame = (int)JumpFrame.Value;

            FirstJumpFrame = FirstJumpFrame >= start_frame && gen7fidgettimeline ? FirstJumpFrame : int.MaxValue;
            // Start
            for (int i = 0; i <= totaltime; i++)
            {
                Currentframe = frame;

                RNGPool.CopyStatus(status);

                var result = RNGPool.Generate7();

                if (frame >= FirstJumpFrame) // Find the first call
                {
                    status.fidget_cd = XMenu.Checked ? 3 : 1;
                    FirstJumpFrame   = int.MaxValue; // Disable this part
                }
                byte Jumpflag = (byte)(status.fidget_cd == 1 ? 1 : 0);
                frameadvance = status.NextState();
                frame       += frameadvance;
                for (int j = 0; j < frameadvance; j++)
                {
                    RNGPool.AddNext(sfmt);
                }
                if (Currentframe <= targetframe && targetframe < frame)
                {
                    Frame.standard = i * 2;
                }

                if (!filter.CheckResult(result))
                {
                    continue;
                }

                Frames.Add(new Frame(result, frame: Currentframe, time: i * 2, blink: Jumpflag));

                if (Frames.Count > MAX_RESULTS_NUM)
                {
                    break;
                }
            }
            if (Frames.FirstOrDefault()?.FrameNum == (int)Frame_min.Value)
            {
                Frames[0].Blink = FuncUtil.blinkflaglist[0];
            }
        }
        private void B_MTSearch_Click(object sender, EventArgs e)
        {
            if (mtfinder == null)
            {
                mtfinder            = new MTSeedFinder();
                mtfinder.Update    += UpdateProgressBar6;
                mtfinder.NewResult += UpdateDGV6;
            }
            var seedmin = Seed_min.Value;
            var seedmax = Seed_max.Value;

            if (RB_2Wild.Checked)
            {
                var IV1  = FuncUtil.parseIVs(WildIV1.Text);
                var IV2  = FuncUtil.parseIVs(WildIV2.Text);
                var min1 = (int)Wild1_Fmin.Value;
                var max1 = (int)Wild1_Fmax.Value;
                var min2 = (int)Wild2_Fmin.Value;
                var max2 = (int)Wild2_Fmax.Value;
                if (IV1 == null || IV2 == null || min1 > max1 || max1 > min2 || min2 > max2 || seedmin > seedmax)
                {
                    Error("Invalid Input");
                    return;
                }
                mtfinder.setFinder(IV1, min1, max1, IV2, min2, max2);
            }
            else if (RB_1Wild.Checked)
            {
                var IVupper = FuncUtil.parseIVs(Wild_upper.Text);
                var IVlower = FuncUtil.parseIVs(Wild_lower.Text);
                var min     = (int)Wild_min.Value;
                var max     = (int)Wild_max.Value;
                var nature  = (byte)Wild_Nature.SelectedIndex;
                if (IVupper == null || IVlower == null || min > max || seedmin > seedmax)
                {
                    Error("Invalid Input");
                    return;
                }
                for (int i = 0; i < 6; i++)
                {
                    if (IVupper[i] < IVlower[i] || IVupper[i] > IVlower[i] + 2)
                    {
                        Error("Improper IVs Range");
                        return;
                    }
                }
                if (seedmax > seedmin + 0x10000000ul)
                {
                    Error("Seed Range too large");
                    return;
                }
                mtfinder.setFinder2(IVlower, IVupper, min, max, nature);
            }
            else
            {
                return;
            }
            Gen6PBar.Value   = 0;
            L_Progress6.Text = "0.00%";
            mtfinder.Clear();
            mtfinder.Search(seedmin, seedmax, RB_2Wild.Checked);
            Gen6PBar.Maximum = mtfinder.Max;
            AdjustDGVSeedColumn();
            DGV_Seed.CurrentCell = null;
            DGV_Seed.DataSource  = new BindingSource(new List <Frame_Seed>(), null);
            B_MTSearch.Visible   = false;
            B_Abort6.Visible     = true;
            RB_1Wild.Enabled     = RB_2Wild.Enabled = false;
        }
Beispiel #20
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]);
            }
        }
Beispiel #21
0
        private void Search7_MenuMethod()
        {
            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;

            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);

            status.IsBoy = Boy.Checked;

            // Advance
            int frame = start;

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

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

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

                // Leap!
                stmp.fidget_cd = 3;

                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());
                }
            }

            if (Framelist.Count > 0)
            {
                JumpFrame.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, maxdelay + 10);
                }
                else
                {
                    Search7_TimelineLeap2(Framelist, statuslist, target);
                }
            }
            else
            {
                Error(StringItem.NORESULT_STR[StringItem.language]);
            }
        }