Esempio n. 1
0
        /// <summary>
        /// Sets the <see cref="PKM.IVs"/> to match a provided <see cref="hiddenPowerType"/>.
        /// </summary>
        /// <param name="pk">Pokémon to modify.</param>
        /// <param name="hiddenPowerType">Desired Hidden Power typing.</param>
        public static void SetHiddenPower(this PKM pk, int hiddenPowerType)
        {
            Span <int> IVs = stackalloc int[6];

            pk.GetIVs(IVs);
            HiddenPower.SetIVsForType(hiddenPowerType, IVs, pk.Format);
            pk.SetIVs(IVs);
        }
Esempio n. 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);
        }