private RNGSearch getRNGSettings() { int gender_threshold = 0; switch (GenderRatio.SelectedIndex) { case 1: gender_threshold = 126; break; case 2: gender_threshold = 30; break; case 3: gender_threshold = 63; break; case 4: gender_threshold = 189; break; } RNGSearch.createtimeline = CreateTimeline.Checked; RNGSearch.Considerdelay = ShowResultsAfterDelay.Checked; RNGSearch.PreDelayCorrection = (int)Correction.Value; RNGSearch.delaytime = (int)Timedelay.Value / 2; RNGSearch.ConsiderBlink = ConsiderBlink.Checked; RNGSearch.npcnumber = (int)NPC.Value + 1; RNGSearch.IsSolgaleo = Poke.SelectedIndex == SearchSetting.Solgaleo_index; RNGSearch.IsLunala = Poke.SelectedIndex == SearchSetting.Lunala_index; var rng = new RNGSearch { Synchro_Stat = SyncNature.SelectedIndex - 1, TSV = (int)TSV.Value, AlwaysSynchro = AlwaysSynced.Checked, Honey = Honey.Checked, UB = UB.Checked, ShinyCharm = ShinyCharm.Checked, Wild = Wild.Checked, Fix3v = Fix3v.Checked, gender_ratio = gender_threshold, nogender = GenderRatio.SelectedIndex == 0, PokeLv = (Poke.SelectedIndex == 0) ? -1 : SearchSetting.PokeLevel[Poke.SelectedIndex - 1], Lv_min = (int)Lv_min.Value, Lv_max = (int)Lv_max.Value, UB_th = (int)UB_th.Value, ShinyLocked = SearchSetting.ShinyLocked(Poke.SelectedIndex), }; return(rng); }
private void createtimeline() { SFMT sfmt = new SFMT((uint)Seed.Value); bool Isevent = Poke.SelectedIndex == 1; for (int i = 0; i < (int)Frame_min.Value; i++) { sfmt.NextUInt64(); } List <DataGridViewRow> list = new List <DataGridViewRow>(); DGV.Rows.Clear(); var st = CreateNPCStatus(sfmt); var setting = getSettings(); var rng = getRNGSettings(); RNGSearch.ResetNPCStatus(); RNGSearch.CreateBuffer(sfmt); if (Isevent) { e = geteventsetting(); } int totaltime = (int)TimeSpan.Value * 30; int frame = (int)Frame_min.Value; int frameadvance = 0; for (int i = 0; i <= totaltime; i++) { RNGSearch.remain_frame = (int[])st.remain_frame.Clone(); RNGSearch.blink_flag = (bool[])st.blink_flag.Clone(); RNGSearch.RNGResult result = Isevent ? rng.GenerateEvent(e) : rng.Generate(); result.realtime = i; frameadvance = st.NextState(); frame += frameadvance; for (int j = 0; j < frameadvance; j++) { RNGSearch.Rand.RemoveAt(0); RNGSearch.Rand.Add(sfmt.NextUInt64()); } if (!frameMatch(result, setting)) { continue; } list.Add(getRow_Sta(frame - frameadvance, rng, result, DGV)); if (list.Count > 100000) { break; } } DGV.Rows.AddRange(list.ToArray()); DGV.CurrentCell = null; }
private void StationarySearch() { int max, min; if (AroundTarget.Checked) { min = (int)Time_max.Value - 100; max = (int)Time_max.Value + 100; } else { min = (int)Frame_min.Value; max = (int)Frame_max.Value; } bool Isevent = Poke.SelectedIndex == 1; SFMT sfmt = new SFMT((uint)Seed.Value); List <DataGridViewRow> list = new List <DataGridViewRow>(); DGV.Rows.Clear(); var setting = getSettings(); var rng = getRNGSettings(); //Blink flag history int blink_flag = 0; int UnsafeRange = 41 * (int)NPC.Value; if (UnsafeRange == 0) { for (int i = 0; i < min - 2; i++) { sfmt.NextUInt64(); } for (int i = 0; i < 2; i++) { switch (blink_flag) { case 0: if ((sfmt.NextUInt64() & 0x7F) == 0) { blink_flag = 1; } break; case 1: blink_flag = (sfmt.NextUInt64() % 3) == 0 ? 36 : 30; break; } } } else if (!Honey.Checked) { for (int i = 0; i < Math.Max(418, min - UnsafeRange); i++) { sfmt.NextUInt64(); } for (int i = Math.Max(418, min - UnsafeRange); i < min; i++) { if ((sfmt.NextUInt64() & 0x7F) == 0) { blink_flag = UnsafeRange; } else if (blink_flag > 0) { blink_flag--; } } } else { for (int i = 0; i < min; i++) { sfmt.NextUInt64(); } } RNGSearch.CreateBuffer(sfmt); if (Isevent) { e = geteventsetting(); } for (int i = min; i <= max; i++, RNGSearch.Rand.RemoveAt(0), RNGSearch.Rand.Add(sfmt.NextUInt64())) { RNGSearch.RNGResult result = Isevent ? rng.GenerateEvent(e) : rng.Generate(); if (NPC.Value == 0) { switch (blink_flag) { case 0: if (result.Blink == 1) { blink_flag = 1; } break; case 1: blink_flag = (result.row_r % 3) == 0 ? 36 : 30; result.Blink = 5; break; default: result.Blink = blink_flag; blink_flag = 0; break; } } else if (!Honey.Checked) { if (result.Blink == 1) { if (blink_flag > 0) { result.Blink = -2; } blink_flag = UnsafeRange; } else if (blink_flag > 0) { blink_flag--; result.Blink = -1; } } if (!frameMatch(result, setting)) { continue; } list.Add(getRow_Sta(i, rng, result, DGV)); if (list.Count > 100000) { break; } } DGV.Rows.AddRange(list.ToArray()); DGV.CurrentCell = null; }
private DataGridViewRow getRow_Sta(int i, RNGSearch rng, RNGSearch.RNGResult result, DataGridView dgv) { int d = i - (int)Time_max.Value; string true_nature = SearchSetting.naturestr[result.Nature]; string SynchronizeFlag = (result.Synchronize ? "O" : "X"); if ((result.UbValue < UB_th.Value) && (ConsiderDelay.Checked) && (!ShowResultsAfterDelay.Checked)) { result.Blink = -1; } string BlinkFlag = ""; switch (result.Blink) { case -2: BlinkFlag = "★+?"; break; case -1: BlinkFlag = "?"; break; case 0: BlinkFlag = "-"; break; case 1: BlinkFlag = "★"; break; default: BlinkFlag = result.Blink.ToString(); break; } string PSV = result.PSV.ToString("D4"); string Ability = result.Ability.ToString(); string Encounter = (result.Encounter == -1) ? "-" : result.Encounter.ToString(); string Slot = (result.Slot == -1) ? "-" : result.Slot.ToString(); string Lv = (result.Lv == -1) ? "-" : result.Lv.ToString(); string Item = (result.Item == -1) ? "-" : result.Item.ToString(); string UbValue = (result.UbValue == 100) ? "-" : result.UbValue.ToString(); string randstr = result.row_r.ToString("X16"); string PID = result.PID.ToString("X8"); string EC = result.EC.ToString("X8"); string time = (CreateTimeline.Checked) ? (2 * result.realtime).ToString() + "F" : "-"; if (!Advanced.Checked) { if (Encounter != "-") { Encounter = (result.Encounter < Encounter_th.Value) ? "O" : "X"; } if (UbValue != "-") { UbValue = (result.UbValue < UB_th.Value) ? "O" : "X"; } if (UbValue == "O") { Slot = "UB"; } if (result.Item < 50) { Item = "50%"; } else if (result.Item < 55) { Item = "5%"; } else { Item = "-"; } time = (CreateTimeline.Checked) ? ((float)result.realtime / 30).ToString("F") + "s" : "-"; } if (Poke.SelectedIndex == 1) { if (e.AbilityLocked) { Ability = "-"; } if (e.NatureLocked) { true_nature = "-"; } if (e.PIDType != 0) { PID = "-"; PSV = "-"; EC = "-"; } } string frameadvance = result.frameshift.ToString("+#;-#;0"); if (ConsiderDelay.Checked && !ShowResultsAfterDelay.Checked) { RNGSearch.Resetindex(); RNGSearch.ResetNPCStatus(); frameadvance = (Poke.SelectedIndex == 1) ? rng.getframeshift(e).ToString("+#;-#;0") : rng.getframeshift().ToString("+#;-#;0"); } int[] Status = new int[6] { 0, 0, 0, 0, 0, 0 }; if (ShowStats.Checked) { Status = result.p_Status; } else { Status = result.IVs; } DataGridViewRow row = new DataGridViewRow(); row.CreateCells(dgv); row.SetValues( i, d.ToString("+#;-#;0"), BlinkFlag, Status[0], Status[1], Status[2], Status[3], Status[4], Status[5], true_nature, SynchronizeFlag, result.Clock, PSV, frameadvance, UbValue, Slot, Lv, SearchSetting.genderstr[result.Gender], Ability, Item, Encounter, randstr, PID, EC, time ); if (result.Shiny) { row.DefaultCellStyle.BackColor = Color.LightCyan; } return(row); }