public static PKM?GetLivingEntry(this ITrainerInfo tr, PKM template, int species, int form, Type destType) { template.Species = species; template.Form = form; template.Gender = template.GetSaneGender(); var f = EncounterMovesetGenerator.GeneratePKMs(template, tr).FirstOrDefault(); if (f == null) { return(null); } var result = PKMConverter.ConvertToType(f, destType, out _); if (result == null) { return(null); } result.CurrentLevel = 100; result.Species = species; result.Form = form; result.Heal(); return(result); }
/// <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> /// Sets the <see cref="PKM.Gender"/> value, with special consideration for the <see cref="PKM.Format"/> values which derive the <see cref="PKM.Gender"/> value. /// </summary> /// <param name="pk">Pokémon to modify.</param> /// <param name="gender">Desired <see cref="PKM.Gender"/> value to set.</param> public static void SetGender(this PKM pk, string gender) { int g = string.IsNullOrEmpty(gender) ? pk.GetSaneGender() : PKX.GetGenderFromString(gender); pk.SetGender(g); }
/// <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 = 1; pk.Move1_PP = 40; pk.Ball = 4; pk.MetDate = DateTime.Today; if (tr.Game >= 0) { pk.Version = tr.Game; } int spec = ((GameVersion)pk.Version).GetMaxSpeciesID(); if (spec <= 0) { spec = pk.MaxSpeciesID; } pk.Species = spec; var lang = tr.Language; if (lang <= 0) { lang = (int)LanguageID.English; } pk.Language = lang; 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.ConsoleRegion >= 0) { pk.ConsoleRegion = tr.ConsoleRegion; pk.Country = tr.Country; pk.Region = tr.SubRegion; } // Copy OT trash bytes for sensitive games (Gen1/2) if (pk is GBPKM pk12) { switch (tr) { case SAV1 s1: pk12.OT_Trash = s1.OT_Trash; break; case SAV2 s2: pk12.OT_Trash = s2.OT_Trash; break; } } pk.RefreshChecksum(); }
/// <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; } int species = tr is IGameValueLimit s ? s.MaxSpeciesID : ((GameVersion)pk.Version).GetMaxSpeciesID(); if (species <= 0) { species = pk.MaxSpeciesID; } pk.Species = species; var lang = tr.Language; if (lang <= 0) { lang = (int)LanguageID.English; } pk.Language = lang; 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; } // Copy OT trash bytes for sensitive games (Gen1/2) if (pk is GBPKM pk12) { switch (tr) { case SAV1 s1: pk12.OT_Trash = s1.OT_Trash; break; case SAV2 s2: pk12.OT_Trash = s2.OT_Trash; break; } } pk.RefreshChecksum(); }
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; } }
private static bool IsValidCriteria4(PKM pk, int nature, int ability, int gender) { if (pk.GetSaneGender() != gender) { return(false); } if (pk.Nature != nature) { return(false); } if ((pk.PID & 1) != ability) { return(false); } return(true); }
private static bool IsValidCriteria4(PKM pk, int nature, int ability, int gender) { if (pk.GetSaneGender() != gender) { Console.WriteLine("not sane gender"); return(false); } if (pk.Nature != nature) { Console.WriteLine(pk.Nature + "!=" + nature); return(false); } if ((pk.PID & 1) != ability) { Console.WriteLine("not sane ability: " + (pk.PID & 1) + "!=" + ability); return(false); } return(true); }
/// <summary> /// Sets the <see cref="PKM.Gender"/> value, with special consideration for the <see cref="PKM.Format"/> values which derive the <see cref="PKM.Gender"/> value. /// </summary> /// <param name="pk">Pokémon to modify.</param> /// <param name="gender">Desired <see cref="PKM.Gender"/> value to set.</param> /// <remarks>Has special logic for an unspecified gender.</remarks> public static void SetSaneGender(this PKM pk, int gender) { int g = gender == -1 ? pk.GetSaneGender() : gender; pk.SetGender(g); }