예제 #1
0
    /// <summary>
    /// Applies junk data to a <see cref="SaveFile.BlankPKM"/>, which is preferable to a completely empty entity.
    /// </summary>
    /// <param name="pk">Blank data</param>
    /// <param name="tr">Trainer info to apply</param>
    public static void TemplateFields(PKM pk, ITrainerInfo tr)
    {
        pk.Move1 = (int)Move.Pound;
        pk.HealPP();
        pk.Ball    = 4;
        pk.MetDate = DateTime.Today;

        if (tr.Game >= 0)
        {
            pk.Version = tr.Game;
        }

        pk.Species  = GetTemplateSpecies(pk, tr);
        pk.Language = GetTemplateLanguage(tr);
        pk.Gender   = pk.GetSaneGender();

        pk.ClearNickname();

        pk.OT_Name   = tr.OT;
        pk.OT_Gender = tr.Gender;
        pk.TID       = tr.TID;
        pk.SID       = tr.SID;
        if (tr is IRegionOrigin o && pk is IRegionOrigin gt)
        {
            gt.ConsoleRegion = o.ConsoleRegion;
            gt.Country       = o.Country;
            gt.Region        = o.Region;
        }

        ApplyTrashBytes(pk, tr);
        pk.RefreshChecksum();
    }
        /// <summary>
        /// Set Species and Level with nickname (Helps with PreEvos)
        /// </summary>
        /// <param name="pk">PKM to modify</param>
        /// <param name="set">Set to use as reference</param>
        /// <param name="Form">Form to apply</param>
        /// <param name="enc">Encounter detail</param>
        /// <param name="lang">Language to apply</param>
        public static void SetSpeciesLevel(this PKM pk, IBattleTemplate set, int Form, IEncounterable enc, LanguageID?lang = null)
        {
            var updatevalues = pk.Species != set.Species;

            if (updatevalues)
            {
                pk.Species = set.Species;
            }
            pk.ApplySetGender(set);
            if (Form != pk.Form)
            {
                pk.SetForm(Form);
            }
            pk.SetFormArgument(enc);
            if (updatevalues)
            {
                pk.RefreshAbility(pk.AbilityNumber >> 1);
            }

            var usedlang = lang ?? (LanguageID)pk.Language;

            var gen      = new LegalityAnalysis(pk).Info.Generation;
            var nickname = Legal.GetMaxLengthNickname(gen, usedlang) < set.Nickname.Length ? set.Nickname.Substring(0, Legal.GetMaxLengthNickname(gen, usedlang)) : set.Nickname;

            if (!WordFilter.IsFiltered(nickname, out _))
            {
                pk.SetNickname(nickname);
            }
            else
            {
                pk.ClearNickname();
            }
            pk.CurrentLevel = set.Level;
        }
예제 #3
0
        /// <summary>
        /// Set Species and Level with nickname (Helps with PreEvos)
        /// </summary>
        /// <param name="pk">PKM to modify</param>
        /// <param name="set">Set to use as reference</param>
        /// <param name="Form">Form to apply</param>
        /// <param name="enc">Encounter detail</param>
        public static void SetSpeciesLevel(this PKM pk, IBattleTemplate set, int Form, IEncounterable enc)
        {
            pk.Species = set.Species;
            pk.ApplySetGender(set);
            pk.SetAltForm(Form);
            pk.SetFormArgument(enc);
            pk.RefreshAbility(pk.AbilityNumber >> 1);

            var gen      = new LegalityAnalysis(pk).Info.Generation;
            var nickname = Legal.GetMaxLengthNickname(gen, LanguageID.English) < set.Nickname.Length ? set.Nickname.Substring(0, Legal.GetMaxLengthNickname(gen, LanguageID.English)) : set.Nickname;

            if (!WordFilter.IsFiltered(nickname, out _))
            {
                pk.SetNickname(nickname);
            }
            else
            {
                pk.ClearNickname();
            }
            pk.CurrentLevel = set.Level;
            if (pk.CurrentLevel == 50)
            {
                pk.CurrentLevel = 100; // VGC Override
            }
        }
예제 #4
0
 /// <summary>
 /// Sets the <see cref="PKM.Nickname"/> to the provided value.
 /// </summary>
 /// <param name="pk">Pokémon to modify.</param>
 /// <param name="nick"><see cref="PKM.Nickname"/> to set. If no nickname is provided, the <see cref="PKM.Nickname"/> is set to the default value for its current language and format.</param>
 public static void SetNickname(this PKM pk, string nick)
 {
     if (string.IsNullOrWhiteSpace(nick))
     {
         pk.ClearNickname();
         return;
     }
     pk.IsNicknamed = true;
     pk.Nickname    = nick;
 }
예제 #5
0
        public static void DittoTrade(PKM pk8)
        {
            if (pk8.IsNicknamed == false)
            {
                return;
            }

            var dittoStats = new string[] { "ATK", "SPE", "SPA" };

            pk8.MetDate    = DateTime.Now.Date;
            pk8.StatNature = pk8.Nature;
            pk8.SetAbility(7);
            pk8.SetAbilityIndex(1);
            pk8.Met_Level    = 60;
            pk8.Move1        = 144;
            pk8.Move1_PP     = 0;
            pk8.Met_Location = 154;
            pk8.Ball         = 21;
            pk8.IVs          = new int[] { 31, pk8.Nickname.Contains(dittoStats[0]) ? 0 : 31, 31, pk8.Nickname.Contains(dittoStats[1]) ? 0 : 31, pk8.Nickname.Contains(dittoStats[2]) ? 0 : 31, 31 };
            pk8.ClearNickname();
            pk8.SetSuggestedHyperTrainingData();
        }
예제 #6
0
        /// <summary>
        /// Set Species and Level with nickname (Helps with PreEvos)
        /// </summary>
        /// <param name="pk">PKM to modify</param>
        /// <param name="set">Set to use as reference</param>
        /// <param name="Form">Form to apply</param>
        /// <param name="enc">Encounter detail</param>
        /// <param name="lang">Language to apply</param>
        public static void SetSpeciesLevel(this PKM pk, IBattleTemplate set, int Form, IEncounterable enc, LanguageID?lang = null)
        {
            pk.ApplySetGender(set);

            var evolutionRequired = pk.Species != set.Species;

            if (evolutionRequired)
            {
                pk.Species = set.Species;
            }
            if (Form != pk.Form)
            {
                pk.SetForm(Form);
            }

            // Don't allow invalid tox nature, set random nature first and then statnature later
            if (pk.Species == (int)Species.Toxtricity)
            {
                while (true)
                {
                    var result = EvolutionMethod.GetAmpLowKeyResult(pk.Nature);
                    if (result == pk.Form)
                    {
                        break;
                    }
                    pk.Nature = Util.Rand.Next(25);
                }
            }

            pk.SetSuggestedFormArgument(enc.Species);
            if (evolutionRequired)
            {
                pk.RefreshAbility(pk.AbilityNumber >> 1);
            }

            pk.CurrentLevel = set.Level;
            if (pk.Met_Level > pk.CurrentLevel)
            {
                pk.Met_Level = pk.CurrentLevel;
            }
            if (set.Level != 100 && set.Level == enc.LevelMin && (pk.Format == 3 || pk.Format == 4))
            {
                pk.EXP = Experience.GetEXP(enc.LevelMin + 1, PersonalTable.HGSS[enc.Species].EXPGrowth) - 1;
            }

            var currentlang = (LanguageID)pk.Language;
            var finallang   = lang ?? currentlang;

            if (finallang == LanguageID.Hacked)
            {
                finallang = LanguageID.English;
            }
            pk.Language = (int)finallang;

            // check if nickname even needs to be updated
            if (set.Nickname.Length == 0 && finallang == currentlang && !evolutionRequired)
            {
                return;
            }

            var gen      = enc.Generation;
            var maxlen   = Legal.GetMaxLengthNickname(gen, finallang);
            var nickname = set.Nickname.Length > maxlen?set.Nickname.Substring(0, maxlen) : set.Nickname;

            if (!WordFilter.IsFiltered(nickname, out _))
            {
                pk.SetNickname(nickname);
            }
            else
            {
                pk.ClearNickname();
            }
        }