public static bool IsValidNature( uint pid1seed, uint nature ) { PokePRNG rand = new PokePRNG( pid1seed ); //PID_LOW (FULL SEED) bool cont = true; do { uint newseed = rand.PrevNum(); //POSSIBLE SEED POINTER uint newhigh = rand.SetPrev().HighBits; //PID2 uint newlow = rand.SetPrev().HighBits; //PID1 uint newpid = ( newhigh << 0x10 ) | newlow; if ( (newseed / 0xA3E) == nature || (newseed >> 15 == 0) ) return true; else if ( (newpid % 25) == nature ) cont = false; } while ( cont ); return false; }
public override bool IsValidAlgorithm( out string message ) { if ( IsEgg && IsValidEggLocation() ) { message = "Valid Egg"; return true; } if ( IsHatched && uint plow = ( PID & 0xFFFF ) << 0x10; uint phigh = (uint)(PID & ~0xFFFF) >> 0x10; bool valid = false; PokePRNG rand = new PokePRNG(); for ( uint j = 0;j < 0x10000; j++ ) { rand.Seed = plow + j; if ( ( rand.NextNum() >> 0x10 ) == phigh ) // A-B { int C = (int)rand.SetNext().HighBits & 0x7FFF; int D = (int)rand.SetNext().HighBits & 0x7FFF; if ( Utility.IsIVMatch( iv1, iv2, C, D ) ) { valid = true; message = "NDS (A-B-C-D)"; if ( RequiresSyncCheck ) { m_ValidSync = IsValidNature( plow + j, PID % 25 ) ); if ( m_ValidSync ) break; } } } } if ( !valid && (HomeTown == 10 || HomeTown == 11) && IsShiny() && IsGrassWild() && Location != 48 ) //Check for chaining! ~ Not in Eterna Forest { PokePRNG rand = new PokePRNG(); uint iv1 = IV1; uint iv2 = IV2; uint highbits = iv1 << 0x10; for ( uint k = 0;k < 2; k++ ) { for( uint i = 0; i < 0x10000; i++ ) { uint seed = ( k << 31 ) + highbits + i; rand.Seed = seed; if ( ( ( rand.Next() >> 0x10 ) & 0x7FFF ) == iv2 ) { for( int j = 0; j < 16; j++ ) rand.PrevNum(); uint natseed = rand.Seed; uint pid = ShinyPID( rand ); if ( realpid == pid ) { valid = true; message = "Chain Shiny"; m_RequiresSyncCheck = false; } } } } } if ( !valid ) message = "Invalid"; return valid; }
public static bool ChainedPID( uint iv1, uint iv2, uint tid, uint sid, uint realpid ) { PokePRNG rand = new PokePRNG(0); uint highbits = iv1 << 0x10; for ( uint k = 0;k < 2; k++ ) { for( uint i = 0; i < 0x10000; i++ ) { uint seed = ( k << 31 ) + highbits + i; rand.Seed = seed; if ( ( ( rand.Next() >> 0x10 ) & 0x7FFF ) == iv2 ) { //Console.WriteLine( "Seed Found: {0:X}", seed ); for( int j = 0; j < 16; j++ ) rand.PrevNum(); uint natseed = rand.Seed; //Console.WriteLine( "Modified Seed: {0:X}", rand.Seed ); uint pid = ShinyPID( tid, sid, rand ); //Console.WriteLine( "Found PID: {0:X}", pid ); if ( realpid == pid ) { bool validnature = ValidNature( natseed, realpid % 25 ); Console.Write( "Chained Sync: " ); if ( validnature ) { PushColor( ConsoleColor.DarkGreen ); Console.WriteLine( "Valid" ); } else { PushColor( ConsoleColor.Red ); Console.WriteLine( "Invalid" ); } PopColor(); return true; } } } } return false; }
public static bool ValidGlitchZig( uint pid, uint tid, int oivs1, int oivs2 ) { PokePRNG rand = new PokePRNG(); for ( uint i = 0; i < 2; ++i ) { for ( uint j = 0; j < 0x10000; j++ ) { rand.Seed = (i << 31) + ((uint)oivs2 << 16) + j; uint iv1 = rand.Seed; uint second = ( rand.SetPrev().Seed >> 0x10 ) & 0x7FFF; uint iv2 = rand.Seed; if ( second == (uint)oivs1 ) { uint afull = rand.PrevNum(); //Variance uint a = rand.HighBits; uint bfull = rand.PrevNum(); //Unknown (Gender Check?) uint b = rand.HighBits; uint cfull = rand.PrevNum(); //High PID uint c = rand.HighBits; uint dfull = rand.PrevNum(); //Seed uint d = rand.HighBits; if ( d == 0 && (dfull & 0xFFFF) <= 0xFF ) { uint calcshiny = c ^ tid ^ 0; uint var = ( ( calcshiny ^ a ) & 0x7 ); uint calclowpid = calcshiny ^ var; if ( ( ( c << 0x10 ) | calclowpid ) == pid ) return true; } } } } return false; }