Beispiel #1
0
        /// <summary>
        /// Method to find the PID and IV associated with a nest. Shinies are just allowed
        /// since there is no way gamefreak actually bruteforces top half of the PID to flag illegals.
        /// </summary>
        /// <param name="pk">Passed PKM</param>
        /// <param name="enc">Nest encounter object</param>
        /// <param name="shiny">Shiny boolean</param>
        private static void FindNestPIDIV <T>(PK8 pk, T enc, bool shiny) where T : EncounterStatic8Nest <T>
        {
            // Preserve Nature, Altform, Ability (only if HA)
            // Nest encounter RNG generation
            var iterPKM = pk.Clone();

            while (true)
            {
                ulong seed = GetRandomULong();
                if (!shiny && UseXOROSHIRO)
                {
                    enc.ApplyDetailsTo(pk, seed);
                }
                if (pk.AltForm != iterPKM.AltForm) // no nature checks since only stat nature is relevant.
                {
                    continue;
                }
                if (iterPKM.Gender != pk.Gender) // match gender
                {
                    continue;
                }
                if (iterPKM.AbilityNumber == 4 && !(pk.Ability == iterPKM.Ability && pk.AbilityNumber == iterPKM.AbilityNumber))
                {
                    continue;
                }
                if (iterPKM.AbilityNumber != 4 && pk.AbilityNumber == 4) // cannot ability capsule HA to non HA
                {
                    continue;
                }
                // can be ability capsuled
                pk.RefreshAbility(iterPKM.AbilityNumber >> 1);
                pk.StatNature = iterPKM.StatNature;
                break;
            }
        }
        /// <summary>
        /// Method to find the PID and IV associated with a nest. Shinies are just allowed
        /// since there is no way GameFreak actually brute-forces top half of the PID to flag illegals.
        /// </summary>
        /// <param name="pk">Passed PKM</param>
        /// <param name="enc">Nest encounter object</param>
        /// <param name="shiny">Shiny boolean</param>
        private static void FindNestPIDIV <T>(PK8 pk, T enc, bool shiny) where T : EncounterStatic8Nest <T>
        {
            // Preserve Nature, Altform (all abilities should be possible in gen 8, so no need to early return on a mismatch for enc HA bool vs set HA bool)
            // Nest encounter RNG generation
            var iterPKM = pk.Clone();

            if (pk.Species == (int)Species.Toxtricity && pk.AltForm != EvolutionMethod.GetAmpLowKeyResult(pk.Nature))
            {
                enc.ApplyDetailsTo(pk, GetRandomULong());
                pk.RefreshAbility(iterPKM.AbilityNumber >> 1);
                pk.StatNature = iterPKM.StatNature;
                return;
            }

            if (shiny && enc is EncounterStatic8U)
            {
                // Dynamax Adventure shinies are always XOR 1
                pk.PID ^= (uint)(((pk.TID ^ pk.SID ^ (pk.PID & 0xFFFF) ^ 1) << 16) | (pk.PID & 0xFFFF));
            }

            if (shiny || !UseXOROSHIRO)
            {
                return;
            }

            var count = 0;

            do
            {
                ulong seed = GetRandomULong();
                enc.ApplyDetailsTo(pk, seed);
                if (IsMatchCriteria <T>(pk, iterPKM))
                {
                    break;
                }
            } while (++count < 10_000);

            pk.Species = iterPKM.Species; // possible evolution
            // can be ability capsuled
            if (Legal.FormChange.Contains(pk.Species) || pk.Species == (int)Species.Zygarde)
            {
                pk.AltForm = iterPKM.AltForm; // set alt form if it can be freely changed!
            }
            pk.RefreshAbility(iterPKM.AbilityNumber >> 1);
            pk.StatNature = iterPKM.StatNature;
        }
Beispiel #3
0
        /// <summary>
        /// Method to find the PID and IV associated with a nest. Shinies are just allowed
        /// since there is no way GameFreak actually brute-forces top half of the PID to flag illegals.
        /// </summary>
        /// <param name="pk">Passed PKM</param>
        /// <param name="enc">Nest encounter object</param>
        /// <param name="shiny">Shiny boolean</param>
        private static void FindNestPIDIV <T>(PK8 pk, T enc, bool shiny) where T : EncounterStatic8Nest <T>
        {
            // Preserve Nature, Altform, Ability (only if HA)
            // Nest encounter RNG generation
            var iterPKM = pk.Clone();

            if (enc.Ability != -1 && (pk.AbilityNumber == 4) != (enc.Ability == 4))
            {
                return;
            }
            if (pk.Species == (int)Species.Toxtricity && pk.AltForm != EvolutionMethod.GetAmpLowKeyResult(pk.Nature))
            {
                enc.ApplyDetailsTo(pk, GetRandomULong());
                pk.RefreshAbility(iterPKM.AbilityNumber >> 1);
                pk.StatNature = iterPKM.StatNature;
                return;
            }

            if (shiny || !UseXOROSHIRO)
            {
                return;
            }

            var count = 0;

            do
            {
                ulong seed = GetRandomULong();
                enc.ApplyDetailsTo(pk, seed);
                if (IsMatchCriteria <T>(pk, iterPKM))
                {
                    break;
                }
            } while (++count < 10_000);

            pk.Species = iterPKM.Species; // possible evolution
            // can be ability capsuled
            pk.RefreshAbility(iterPKM.AbilityNumber >> 1);
            pk.StatNature = iterPKM.StatNature;
        }