예제 #1
0
        private static PKM SetToEgg(PKM pkm, int origin, GameVersion gameVersion)
        {
            int dayCare      = origin <= 4 ? Locations.Daycare4 : Locations.Daycare5;
            int metLevel     = origin <= 4 ? 0 : 1;
            int currentLevel = origin <= 4 ? 5 : 1;

            // 非初级形态
            PKM tmp = pkm.Clone();

            tmp.IsEgg        = true;
            tmp.Egg_Location = dayCare;
            tmp.Data[0xA8]   = tmp.Data[0xA8 + 1] = 0;    //Milotic
            List <CheckResult> checkResult = EncounterFinder.FindVerifiedEncounter(tmp).Parse;

            if (checkResult.IsPropStrInEleList("Comment", LegalityCheckStrings.LEvoInvalid))
            {
                return(null);
            }

            int language = pkm.Language;

            pkm.Nickname     = SpeciesName.GetSpeciesNameGeneration((int)Species.None, language, pkm.Format);
            pkm.IsNicknamed  = true;
            pkm.IsEgg        = true;
            pkm.HeldItem     = 0;
            pkm.CurrentLevel = currentLevel;
            pkm.StatNature   = pkm.Nature;
            pkm.RefreshAbility(new Random().Next(0, 3));

            pkm.SetIVs();
            pkm.EVs = new int[6];

            pkm.Ball         = (int)Ball.Poke;
            pkm.Met_Location = 0;
            pkm.Met_Level    = metLevel;
            pkm.Egg_Location = dayCare;

            ReflectUtils.methods.TryGetValue("GetEggMoves", out MethodInfo method);
            int[] result = (int[])method.Invoke(null, new object[] { pkm, pkm.Species, pkm.AltForm, gameVersion });
            pkm.SetMoves(new List <int>());
            if (result.Length == 0)
            {
                pkm.SetRelearnMoves(pkm.GetSuggestedRelearnMoves());
            }
            else
            {
                pkm.SetRelearnMoves(GetEggMovesRandom(pkm, result));
            }
            pkm.SetMoves(pkm.RelearnMoves);
            pkm.SetMovesPPUpsToZero();
            pkm.SetMaximumPPCurrent();
            pkm.FixMoves();

            // 8代独有数据
            if (pkm.Format == 8)
            {
                PK8 pk8 = (PK8)pkm;
                pk8.DynamaxLevel  = 0;
                pk8.CanGigantamax = false;
            }

            pkm.ClearAllRibbon();
            pkm.ClearCurrentHandler();
            pkm.ClearMemories();
            pkm.ClearRecordFlags();
            pkm.CurrentFriendship = 4;

            return(pkm);
        }