コード例 #1
0
ファイル: EncounterEgg.cs プロジェクト: puertoricans/PKHeX
        private static void SetPINGA(PKM pk, EncounterCriteria criteria)
        {
            pk.SetRandomIVs(flawless: 3);
            if (pk.Format <= 2)
            {
                return;
            }

            int gender = criteria.GetGender(-1, pk.PersonalInfo);
            int nature = (int)criteria.GetNature(Nature.Random);

            if (pk.Format <= 5)
            {
                pk.SetPIDGender(gender);
                pk.Gender = gender;
                pk.SetPIDNature(nature);
                pk.Nature = nature;
                pk.RefreshAbility(pk.PIDAbility);
            }
            else
            {
                pk.PID    = Util.Rand32();
                pk.Nature = nature;
                pk.Gender = gender;
                pk.RefreshAbility(Util.Rand.Next(2));
            }
        }
コード例 #2
0
ファイル: PIDGenerator.cs プロジェクト: wyatt8740/PKHeX
        public static void SetRandomWildPID(PKM pk, int gen, int nature, int ability, int gender, PIDType specific = PIDType.None)
        {
            if (specific == PIDType.Pokewalker)
            {
                pk.Gender = gender;
                do
                {
                    pk.PID = GetPokeWalkerPID(pk.TID, pk.SID, (uint)nature, gender, pk.PersonalInfo.Gender);
                } while (!pk.IsGenderValid());
                pk.RefreshAbility((int)(pk.PID & 1));
                SetRandomIVs(pk);
                return;
            }
            switch (gen)
            {
            case 3:
            case 4:
                SetRandomWildPID4(pk, nature, ability, gender, specific);
                break;

            case 5:
                SetRandomWildPID5(pk, nature, ability, gender, specific);
                break;

            default:
                SetRandomWildPID(pk, nature, ability, gender);
                break;
            }
        }
コード例 #3
0
ファイル: PIDGenerator.cs プロジェクト: wyatt8740/PKHeX
        private static void SetRandomWildPID(PKM pk, int nature, int ability, int gender)
        {
            uint seed = Util.Rand32();

            pk.PID    = seed;
            pk.Nature = nature;
            pk.Gender = gender;
            pk.RefreshAbility(ability);
            SetRandomIVs(pk);
        }
コード例 #4
0
ファイル: BatchEditing.cs プロジェクト: rboninsegna/PKHeX
        /// <summary>
        /// Sets the <see cref="PKM"/> property to a non-specific smart value.
        /// </summary>
        /// <param name="pk">Pokémon to modify.</param>
        /// <param name="cmd">Modification</param>
        /// <returns>True if modified, false if no modifications done.</returns>
        private static bool SetComplexProperty(PKM pk, StringInstruction cmd)
        {
            DateTime parseDate(string val) => DateTime.ParseExact(val, "yyyyMMdd", CultureInfo.InvariantCulture, DateTimeStyles.None);

            if (cmd.PropertyName == nameof(PKM.MetDate))
            {
                pk.MetDate = parseDate(cmd.PropertyValue);
            }
            else if (cmd.PropertyName == nameof(PKM.EggMetDate))
            {
                pk.EggMetDate = parseDate(cmd.PropertyValue);
            }
            else if (cmd.PropertyName == nameof(PKM.EncryptionConstant) && cmd.PropertyValue == CONST_RAND)
            {
                pk.EncryptionConstant = Util.Rand32();
            }
            else if ((cmd.PropertyName == nameof(PKM.Ability) || cmd.PropertyName == nameof(PKM.AbilityNumber)) && cmd.PropertyValue.StartsWith("$"))
            {
                pk.RefreshAbility(Convert.ToInt16(cmd.PropertyValue[1]) - 0x30);
            }
            else if (cmd.PropertyName == nameof(PKM.PID) && cmd.PropertyValue == CONST_RAND)
            {
                pk.SetPIDGender(pk.Gender);
            }
            else if (cmd.PropertyName == nameof(PKM.EncryptionConstant) && cmd.PropertyValue == nameof(PKM.PID))
            {
                pk.EncryptionConstant = pk.PID;
            }
            else if (cmd.PropertyName == nameof(PKM.PID) && cmd.PropertyValue == CONST_SHINY)
            {
                pk.SetShiny();
            }
            else if (cmd.PropertyName == nameof(PKM.Species) && cmd.PropertyValue == "0")
            {
                pk.Data = new byte[pk.Data.Length];
            }
            else if (cmd.PropertyName.StartsWith("IV") && cmd.PropertyValue == CONST_RAND)
            {
                SetRandomIVs(pk, cmd);
            }
            else if (cmd.PropertyName == nameof(PKM.IsNicknamed) && string.Equals(cmd.PropertyValue, "false", StringComparison.OrdinalIgnoreCase))
            {
                pk.SetDefaultNickname();
            }
            else
            {
                return(false);
            }

            return(true);
        }
コード例 #5
0
ファイル: BatchEditing.cs プロジェクト: shimakiui/PKHeX
        /// <summary>
        /// Sets the <see cref="PKM"/> property to a non-specific smart value.
        /// </summary>
        /// <param name="pkm">Pokémon to modify.</param>
        /// <param name="cmd">Modification</param>
        private static bool SetComplexProperty(PKM pkm, StringInstruction cmd)
        {
            if (cmd.PropertyName == nameof(pkm.MetDate))
            {
                pkm.MetDate = DateTime.ParseExact(cmd.PropertyValue, "yyyyMMdd", CultureInfo.InvariantCulture, DateTimeStyles.None);
            }
            else if (cmd.PropertyName == nameof(pkm.EggMetDate))
            {
                pkm.EggMetDate = DateTime.ParseExact(cmd.PropertyValue, "yyyyMMdd", CultureInfo.InvariantCulture, DateTimeStyles.None);
            }
            else if (cmd.PropertyName == nameof(pkm.EncryptionConstant) && cmd.PropertyValue == CONST_RAND)
            {
                pkm.EncryptionConstant = Util.Rand32();
            }
            else if ((cmd.PropertyName == nameof(pkm.Ability) || cmd.PropertyName == nameof(pkm.AbilityNumber)) && cmd.PropertyValue.StartsWith("$"))
            {
                pkm.RefreshAbility(Convert.ToInt16(cmd.PropertyValue[1]) - 0x30);
            }
            else if (cmd.PropertyName == nameof(pkm.PID) && cmd.PropertyValue == CONST_RAND)
            {
                pkm.SetPIDGender(pkm.Gender);
            }
            else if (cmd.PropertyName == nameof(pkm.EncryptionConstant) && cmd.PropertyValue == nameof(pkm.PID))
            {
                pkm.EncryptionConstant = pkm.PID;
            }
            else if (cmd.PropertyName == nameof(pkm.PID) && cmd.PropertyValue == CONST_SHINY)
            {
                pkm.SetShinyPID();
            }
            else if (cmd.PropertyName == nameof(pkm.Species) && cmd.PropertyValue == "0")
            {
                pkm.Data = new byte[pkm.Data.Length];
            }
            else if (cmd.PropertyName.StartsWith("IV") && cmd.PropertyValue == CONST_RAND)
            {
                SetRandomIVs(pkm, cmd);
            }
            else if (cmd.PropertyName == nameof(pkm.IsNicknamed) && string.Equals(cmd.PropertyValue, "false", StringComparison.OrdinalIgnoreCase))
            {
                pkm.IsNicknamed = false; pkm.Nickname = PKX.GetSpeciesNameGeneration(pkm.Species, pkm.Language, pkm.Format);
            }
            else
            {
                return(false);
            }

            return(true);
        }
コード例 #6
0
        private static void SetRandomWildPID5(PKM pk, int nature, int ability, int gender, PIDType specific = PIDType.None)
        {
            var tidbit = (pk.TID ^ pk.SID) & 1;

            pk.RefreshAbility(ability);
            pk.Gender = gender;
            pk.Nature = nature;

            if (ability == 2)
            {
                ability = 0;
            }

            while (true)
            {
                uint seed = Util.Rand32();
                if (specific == PIDType.G5MGShiny)
                {
                    SetValuesFromSeedMG5Shiny(pk, seed);
                    seed = pk.PID;
                }
                else
                {
                    var bitxor = (seed >> 31) ^ (seed & 1);
                    if (bitxor != tidbit)
                    {
                        seed ^= 1;
                    }
                }

                if (seed % 25 != nature)
                {
                    continue;
                }
                if (((seed >> 16) & 1) != ability)
                {
                    continue;
                }

                pk.PID = seed;
                if (pk.GetSaneGender() != gender)
                {
                    continue;
                }

                SetRandomIVs(pk);
                return;
            }
        }
コード例 #7
0
ファイル: ShowdownSet.cs プロジェクト: mmands994/PKHeX
        public void ApplyToPKM(PKM pkm)
        {
            if (Species < 0)
            {
                return;
            }
            pkm.Species = Species;

            if (Nickname != null && Nickname.Length <= pkm.NickLength)
            {
                pkm.Nickname = Nickname;
            }
            else
            {
                pkm.Nickname = PKX.GetSpeciesName(pkm.Species, pkm.Language);
            }

            int gender = PKX.GetGenderFromString(Gender);

            pkm.Gender = Math.Max(0, gender);

            var list    = PKX.GetFormList(pkm.Species, types, forms, genders);
            int formnum = Array.IndexOf(list, Form);

            pkm.AltForm = Math.Max(0, formnum);

            var abils = pkm.PersonalInfo.Abilities;
            int index = Array.IndexOf(abils, Ability);

            pkm.RefreshAbility(Math.Max(0, Math.Min(2, index)));

            if (Shiny && !pkm.IsShiny)
            {
                pkm.SetShinyPID();
            }
            else if (!Shiny && pkm.IsShiny)
            {
                pkm.PID = Util.Rand32();
            }

            pkm.CurrentLevel      = Level;
            pkm.HeldItem          = Math.Max(0, HeldItem);
            pkm.CurrentFriendship = Friendship;
            pkm.Nature            = Nature;
            pkm.EVs   = EVs;
            pkm.IVs   = IVs;
            pkm.Moves = Moves;
        }
コード例 #8
0
ファイル: PIDGenerator.cs プロジェクト: wyatt8740/PKHeX
        private static void SetRandomWildPID4(PKM pk, int nature, int ability, int gender, PIDType specific = PIDType.None)
        {
            pk.RefreshAbility(ability);
            pk.Gender = gender;
            var type   = GetPIDType(pk, specific);
            var method = GetGeneratorMethod(type);

            while (true)
            {
                method(pk, Util.Rand32());
                if (!IsValidCriteria4(pk, nature, ability, gender))
                {
                    continue;
                }
                return;
            }
        }