private List <uint> generateUpper(uint seed, uint lower, List <List <uint> > parents) { PokeRNG go = new PokeRNG(seed); uint pid = go.nextUShort(); go.nextUInt(); uint iv1 = go.nextUShort(); uint iv2 = go.nextUShort(); List <uint> ivs = getIVs(iv1, iv2); go.nextUInt(); uint inh1 = go.nextUShort(); uint inh2 = go.nextUShort(); uint inh3 = go.nextUShort(); List <uint> inh = new List <uint>() { inh1, inh2, inh3 }; uint par1 = go.nextUShort(); uint par2 = go.nextUShort(); uint par3 = go.nextUShort(); List <uint> par = new List <uint>() { par1, par2, par3 }; ivs = setInheritance(ivs, inh, par, parents); return(ivs); }
private uint generateLower(uint seed, uint compatability) { PokeRNG go = new PokeRNG(seed); if ((go.nextUShort() * 100 / 0xFFFF) < compatability) { uint pid = (ushort)((go.nextUShort() % 0xFFFE) + 1); return(pid); } return(0x10000); }
private void backgroundWorker1_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e) { source.Rows.Clear(); uint pid1_high = ((egg_pid - 1 & 0xFFFF) << 16); uint pid2_low = (egg_pid >> 16); if (pid1_high != (((egg_pid - 1 & 0xFFFF) % 0xFFFE) << 16)) { MessageBox.Show("PID is not possible by egg"); return; } uint og_pid_high = pid1_high; uint og_pid_low = pid2_low; List <uint> seeds1 = new List <uint>(); List <uint> seeds2 = new List <uint>(); List <uint> pids1 = new List <uint>(); List <uint> pids2 = new List <uint>(); List <List <uint> > ivss = new List <List <uint> >(); List <List <uint> > parents = new List <List <uint> >() { parentaivs, parentbivs }; MessageBox.Show("Seed generation begun, do not click the search button again until the second set of seeds are generated or the program will crash."); while (seeds1.Count == 0) { List <uint> origin = recoverLower16BitsPID(pid1_high); foreach (uint seed in origin) { PokeRNG go = new PokeRNG(seed); if ((go.nextUShort() * 100 / 0xFFFF) < c) { seeds1.Add(seed); pids1.Add(pid1_high); } } if (seeds1.Count == 0) { pid1_high = ((pid1_high) + 0x1); if (pid1_high == og_pid_high) { MessageBox.Show("PID is not possible by egg"); return; } } } MessageBox.Show("First set of seeds done. (PIDLow)"); bool scondition = true; bool fcheck = true; while (scondition) { List <uint> origin = recoverLower16BitsPID(pid2_low); foreach (uint seed in origin) { List <uint> ivs = generateUpper(seed, 0, parents); bool check = true; for (int i = 0; i < 6; i++) { if (ivs[i] > maxivs[i] || ivs[i] < minivs[i]) { check = false; } } if (hiddenpowercheck != "Any") { if (GetHPowerType(ivs) != hiddenpowercheck) { check = false; } } if (check) { seeds2.Add(seed); pids2.Add(pid2_low); ivss.Add(ivs); } } if (!all) { scondition = seeds2.Count == 0; } else { scondition = !(pid2_low == og_pid_low); } if (scondition | fcheck) { fcheck = false; pid2_low = pid2_low + 0x10000; if (pid2_low == og_pid_low & seeds2.Count == 0) { MessageBox.Show("PID/IVs are not possible by egg"); return; } } if (!all) { scondition = seeds2.Count == 0; } else { scondition = !(pid2_low == og_pid_low); } } MessageBox.Show("Second set of seeds done. (PIDHigh and IVs)"); int y = 0; foreach (uint seed1 in seeds1) { int x = 0; foreach (uint seed2 in seeds2) { List <uint> a = getInitial(seed1); List <uint> b = getInitial(seed2); List <uint> c = ivss[x]; source.Rows.Add(a[0].ToString("X4"), a[1], pids1[y].ToString("X8"), b[0].ToString("X4"), b[1], pids2[x].ToString("X8"), egg_pid.ToString("X8"), "", natures[(int)(egg_pid % 25)], egg_pid & 1, c[0], c[1], c[2], c[3], c[4], c[5], GetHPowerType(c), GetHPowerDamage(c)); x++; } y += 1; } }