/// <summary> /// Truly code to personalize <see cref="PKM"/> /// </summary> /// <param name="pkm">Pokemon to be personalized</param> /// <param name="gameVersion">Current Game Version</param> /// <returns></returns> private static PKM PersonalizePokemon(PKM pkm, GameVersion gameVersion) { bool isLimited = isLimitedPokemon(pkm, gameVersion); if (!isLimited) { // Change the original version to game version pkm.Version = (int)gameVersion != 56 ? (int)gameVersion : (int)gameVersion; // change version => change met data if (pkm.Format >= 3) { Legalizer.SetMetValid(pkm); } } Personalize(pkm, isLimited); int format = pkm.Format; if (format == 6 || format == 7 || format == 8) { // Check if it is a pokemon that evolves to link trade if (!LinkTradeEvo.GetLinkTradeEvoPkmList.Contains(pkm.Species) && !isLimited) { pkm.ClearCurrentHandler(); if (pkm is IGeoTrack g) { // to be modified g.Geo1_Country = 0; g.Geo1_Region = 0; g.Geo2_Country = 0; g.Geo2_Region = 0; g.Geo3_Country = 0; g.Geo3_Region = 0; g.Geo4_Country = 0; g.Geo4_Region = 0; g.Geo5_Country = 0; g.Geo5_Region = 0; } ITrainerMemories trainerMemories = (ITrainerMemories)pkm; Extensions.ClearMemoriesHT(trainerMemories); } } return(pkm); }
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); }