Last active
September 24, 2022 01:06
-
-
Save Lusamine/c3a86d26e025ccce0a0b6a5e30ccdb05 to your computer and use it in GitHub Desktop.
Go anywhere where the advances go +1 at a time. Delay is 0 on this script, or you can figure it out for yourself.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int FlawlessIVs = 0; | |
void Main() | |
{ | |
// Initial state | |
// s0 should be s1, s0 from CS | |
// s1 should be s3, s2 from CS | |
ulong s0 = 0x0123456789ABCDEF; | |
ulong s1 = 0x0123456789ABCDEF; | |
// Set this for how far you want to search. | |
int maxAdvance = 150000; | |
var rng = new XorShift128(s0, s1); | |
for (int advances = 0; advances < maxAdvance; advances++) | |
{ | |
GetStateMysteryGift(advances, rng); | |
rng.Next(); | |
} | |
Console.WriteLine("Search completed."); | |
} | |
// You can define other methods, fields, classes and namespaces here | |
private void GetStateMysteryGift(int advance, XorShift128 rng) | |
{ | |
var (s0, s1) = rng.GetState64(); | |
var output = $"{advance} | {s0:x16} | {s1:x16} |"; | |
rng.Next(); // need this roll, but we don't care what it is. | |
var ec = rng.NextUInt(); | |
output = output + $" {ec:x8} |"; | |
var pid = rng.NextUInt(); | |
output = output + $" {pid:x8} |"; | |
Span<int> ivs = stackalloc[] { -1, -1, -1, -1, -1, -1 }; | |
var i = 0; | |
while (i < FlawlessIVs) | |
{ | |
var next = (int)rng.Next(); | |
next = next - (next / 6) * 6; | |
if (ivs[next] == -1) | |
{ | |
ivs[next] = 31; | |
i++; | |
} | |
} | |
var ivstring = ""; | |
for (i = 0; i < 6; i++) | |
{ | |
if (ivs[i] == -1) | |
ivs[i] = rng.NextInt(0, 32); | |
ivstring += ivs[i]; | |
if (i < 5) | |
ivstring += "/"; | |
} | |
output = output + $" {ivstring} |"; | |
var nature = rng.NextUInt(25); | |
output = output + $" {GameInfo.GetStrings(1).Natures[(int)nature]}"; | |
// Add your filters here. | |
if (!(ivs[0] == 31 && ivs[1] == 0 && ivs[2] == 31 && ivs[3] == 31 && ivs[4] == 31 && ivs[5] == 31)) | |
return; | |
Console.WriteLine(output); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Setup is:
PKHeX.Core
to second tab,