示例#1
0
        private static void SetValuesFromSeedXDRNG(PKM pk, uint seed)
        {
            var rng = RNG.XDRNG;

            switch (pk.Species)
            {
            case 197:     // Colo Umbreon
            case 133:     // XD Eevee
                pk.TID = (int)((seed = rng.Next(seed)) >> 16);
                pk.SID = (int)((seed = rng.Next(seed)) >> 16);
                seed   = rng.Advance(seed, 2);   // PID calls consumed
                break;

            case 196:     // Colo Espeon
                pk.TID = (int)((seed = rng.Next(seed)) >> 16);
                pk.SID = (int)((seed = rng.Next(seed)) >> 16);
                seed   = rng.Advance(seed, 9);   // PID calls consumed, skip over Umbreon
                break;
            }
            var A = rng.Next(seed); // IV1
            var B = rng.Next(A);    // IV2
            var C = rng.Next(B);    // Ability?
            var D = rng.Next(C);    // PID
            var E = rng.Next(D);    // PID

            pk.PID = (D & 0xFFFF0000) | E >> 16;
            pk.IVs = MethodFinder.GetIVsInt32(A >> 16, B >> 16);
        }
示例#2
0
        private static void SetValuesFromSeedLCRNG(PKM pk, PIDType type, uint seed)
        {
            var rng            = RNG.LCRNG;
            var A              = rng.Next(seed);
            var B              = rng.Next(A);
            var skipBetweenPID = type is PIDType.Method_3 or PIDType.Method_3_Unown;

            if (skipBetweenPID) // VBlank skip between PID rand() [RARE]
            {
                B = rng.Next(B);
            }

            var swappedPIDHalves = type is >= PIDType.Method_1_Unown and <= PIDType.Method_4_Unown;

            if (swappedPIDHalves) // switched order of PID halves, "BA.."
            {
                pk.PID = (A & 0xFFFF0000) | B >> 16;
            }
            else
            {
                pk.PID = (B & 0xFFFF0000) | A >> 16;
            }

            var C            = rng.Next(B);
            var skipIV1Frame = type is PIDType.Method_2 or PIDType.Method_2_Unown;

            if (skipIV1Frame) // VBlank skip after PID
            {
                C = rng.Next(C);
            }

            var D            = rng.Next(C);
            var skipIV2Frame = type is PIDType.Method_4 or PIDType.Method_4_Unown;

            if (skipIV2Frame) // VBlank skip between IVs
            {
                D = rng.Next(D);
            }

            Span <int> IVs = stackalloc int[6];

            MethodFinder.GetIVsInt32(IVs, C >> 16, D >> 16);
            if (type == PIDType.Method_1_Roamer)
            {
                // Only store lowest 8 bits of IV data; zero out the other bits.
                IVs[1] &= 7;
                for (int i = 2; i < 6; i++)
                {
                    IVs[i] = 0;
                }
            }
            pk.SetIVs(IVs);
        }
示例#3
0
        private static void SetValuesFromSeedLCRNG(PKM pk, PIDType type, uint seed)
        {
            var rng = RNG.LCRNG;
            var A   = rng.Next(seed);
            var B   = rng.Next(A);
            var pid = (B & 0xFFFF0000) | A >> 16;

            if (type == PIDType.Method_1_Unown || type == PIDType.Method_2_Unown || type == PIDType.Method_4_Unown)
            {
                pk.PID = (pid >> 16) | (pid << 16); // swap halves
            }
            else
            {
                pk.PID = pid;
            }

            var skipIV1Frame = type == PIDType.Method_2 || type == PIDType.Method_2_Unown;

            if (skipIV1Frame)
            {
                B = rng.Next(B);
            }
            var C = rng.Next(B);
            var D = rng.Next(C);

            var skipIV2Frame = type == PIDType.Method_4 || type == PIDType.Method_4_Unown;

            if (skipIV2Frame)
            {
                D = rng.Next(D);
            }

            var IVs = MethodFinder.GetIVsInt32(C >> 16, D >> 16);

            if (type == PIDType.Method_1_Roamer)
            {
                IVs[1] &= 7;
                for (int i = 2; i < 6; i++)
                {
                    IVs[i] = 0;
                }
            }
            pk.IVs = IVs;
        }
示例#4
0
        public static void SetRandomChainShinyPID(PKM pk, uint seed)
        {
            // 13 rand bits
            // 1 3-bit for upper
            // 1 3-bit for lower

            uint Next() => (seed = RNG.LCRNG.Next(seed)) >> 16;

            uint lower = Next() & 7;
            uint upper = Next() & 7;

            for (int i = 0; i < 13; i++)
            {
                lower |= (Next() & 1) << (3 + i);
            }

            upper  = ((uint)(lower ^ pk.TID ^ pk.SID) & 0xFFF8) | (upper & 0x7);
            pk.PID = upper << 16 | lower;
            pk.IVs = MethodFinder.GetIVsInt32(Next(), Next());
        }
示例#5
0
        private static void SetValuesFromSeedBACD(PKM pk, PIDType type, uint seed)
        {
            var  rng   = RNG.LCRNG;
            bool shiny = type == PIDType.BACD_R_S || type == PIDType.BACD_U_S;
            uint X     = shiny ? rng.Next(seed) : seed;
            var  A     = rng.Next(X);
            var  B     = rng.Next(A);
            var  C     = rng.Next(B);
            var  D     = rng.Next(C);

            if (shiny)
            {
                uint PID = (X & 0xFFFF0000) | ((uint)pk.SID ^ (uint)pk.TID ^ X >> 16);
                PID &= 0xFFFFFFF8;
                PID |= B >> 16 & 0x7; // lowest 3 bits

                pk.PID = PID;
            }
            else if (type == PIDType.BACD_R_AX || type == PIDType.BACD_U_AX)
            {
                uint low = B >> 16;
                pk.PID = ((A & 0xFFFF0000) ^ (((uint)pk.TID ^ (uint)pk.SID ^ low) << 16)) | low;
            }
            else
            {
                pk.PID = (A & 0xFFFF0000) | B >> 16;
            }

            pk.IVs = MethodFinder.GetIVsInt32(C >> 16, D >> 16);

            bool antishiny = type == PIDType.BACD_R_A || type == PIDType.BACD_U_A;

            while (antishiny && pk.IsShiny)
            {
                pk.PID = unchecked (pk.PID + 1);
            }
        }