private static void SetNature(PKM pk, IBattleTemplate set) { var val = Math.Min((int)Nature.Quirky, Math.Max((int)Nature.Hardy, set.Nature)); pk.SetNature(val); if (pk.Species == (int)Species.Toxtricity) { if (pk.AltForm == EvolutionMethod.GetAmpLowKeyResult(val)) { pk.Nature = val; // StatNature already set } return; } // Try setting the actual nature (in the event the StatNature was set instead) var orig = pk.Nature; if (orig == val) { return; } var la = new LegalityAnalysis(pk); pk.Nature = val; var la2 = new LegalityAnalysis(pk); var enc1 = la.EncounterOriginal; var enc2 = la2.EncounterOriginal; if ((!ReferenceEquals(enc1, enc2) && !(enc1 is EncounterEgg)) || la2.Info.Parse.Any(z => z.Identifier == CheckIdentifier.Nature && !z.Valid)) { pk.Nature = orig; } }
private void MakeEvolveEveryLevel(EvolutionSet evo, int species) { var evos = evo.PossibleEvolutions; foreach (EvolutionMethod v in evos) { switch (Config.Generation) { case 6: v.Argument = 1; v.Method = 4; v.Species = 1; break; default: v.Argument = 0; v.Form = 0; v.Level = 1; v.Method = 4; v.Species = 1; // will be randomized after break; } } if (evos[1].Species != 0) // has other branched evolutions; remove them { for (int i = 1; i < evos.Length; i++) { evos[i] = new EvolutionMethod(); } } }
public static IReadOnlyList <EvolutionMethod[]> GetArray(ReadOnlySpan <byte> data, int maxSpecies) { var evos = new EvolutionMethod[maxSpecies + 1][]; int ofs = 0; const int bpe = 3; for (int i = 0; i < evos.Length; i++) { int count = data[ofs]; ofs++; if (count == 0) { evos[i] = Array.Empty <EvolutionMethod>(); continue; } var m = new EvolutionMethod[count]; for (int j = 0; j < m.Length; j++) { m[j] = GetMethod(data.Slice(ofs, bpe)); ofs += bpe; } evos[i] = m; } return(evos); }
private void RandomizeSplitChain(EvolutionMethod evo, int devolvedIndex) { var child = Table[devolvedIndex]; var z = Table.GetFormeEntry(evo.Species, evo.Form); RandomizeFrom(z, child, evo.Species); }
protected override EvolutionMethod ReadMethod(BinaryReader r) { EvolutionMethod evo = base.ReadMethod(r); evo.Form = r.ReadSByte(); evo.Level = r.ReadByte(); return(evo); }
public void LoadEvolution(EvolutionMethod s) { var evo = current = s; CB_Species.SelectedIndex = evo.Species; NUD_Form.Value = evo.Form; NUD_Level.Value = evo.Level; CB_Method.SelectedIndex = (int)evo.Method; CB_Arg.SelectedIndex = evo.Argument; }
private static EvolutionMethod[] GetMethods(ReadOnlySpan <byte> data) { var evos = new EvolutionMethod[data.Length / SIZE]; for (int i = 0; i < data.Length; i += SIZE) { var entry = data.Slice(i, SIZE); evos[i / SIZE] = ReadEvolution(entry); } return(evos); }
/// <summary> /// Method to find the PID and IV associated with a nest. Shinies are just allowed /// since there is no way GameFreak actually brute-forces top half of the PID to flag illegals. /// </summary> /// <param name="pk">Passed PKM</param> /// <param name="enc">Nest encounter object</param> /// <param name="shiny">Shiny boolean</param> private static void FindNestPIDIV <T>(PK8 pk, T enc, bool shiny) where T : EncounterStatic8Nest <T> { // Preserve Nature, Altform (all abilities should be possible in gen 8, so no need to early return on a mismatch for enc HA bool vs set HA bool) // Nest encounter RNG generation var iterPKM = pk.Clone(); if (pk.Species == (int)Species.Toxtricity && pk.AltForm != EvolutionMethod.GetAmpLowKeyResult(pk.Nature)) { enc.ApplyDetailsTo(pk, GetRandomULong()); pk.RefreshAbility(iterPKM.AbilityNumber >> 1); pk.StatNature = iterPKM.StatNature; return; } if (shiny && enc is EncounterStatic8U) { // Dynamax Adventure shinies are always XOR 1 pk.PID ^= (uint)(((pk.TID ^ pk.SID ^ (pk.PID & 0xFFFF) ^ 1) << 16) | (pk.PID & 0xFFFF)); } if (shiny || !UseXOROSHIRO) { return; } var count = 0; do { ulong seed = GetRandomULong(); enc.ApplyDetailsTo(pk, seed); if (IsMatchCriteria <T>(pk, iterPKM)) { break; } } while (++count < 10_000); pk.Species = iterPKM.Species; // possible evolution // can be ability capsuled if (Legal.FormChange.Contains(pk.Species) || pk.Species == (int)Species.Zygarde) { pk.AltForm = iterPKM.AltForm; // set alt form if it can be freely changed! } pk.RefreshAbility(iterPKM.AbilityNumber >> 1); pk.StatNature = iterPKM.StatNature; }
private void ReplaceTradeMethod(EvolutionMethod evo, int species, int evoIndex) { switch (evo.Method) { case EvolutionType.Trade when Game.Generation == 6: evo.Method = EvolutionType.LevelUp; // trade -> level up evo.Argument = 30; return; case EvolutionType.Trade when Game.Generation >= 7: evo.Method = EvolutionType.LevelUp; // trade -> level up evo.Level = 30; return; case EvolutionType.TradeHeldItem: evo.Method = EvolutionType.LevelUpHeldItemDay; return; case EvolutionType.TradeShelmetKarrablast: evo.Method = EvolutionType.LevelUpWithTeammate; if (species == (int)Species.Karrablast) { evo.Argument = (int)Species.Shelmet; // Karrablast with Shelmet } if (species == (int)Species.Shelmet) { evo.Argument = (int)Species.Karrablast; // Shelmet with Karrablast } return; case EvolutionType.LevelUpVersion: evo.Method = evoIndex == 0 ? EvolutionType.LevelUpECl5 : EvolutionType.LevelUpECgeq5; evo.Argument = 0; // clear ver return; case EvolutionType.LevelUpVersionDay: evo.Method = EvolutionType.LevelUpFriendshipMorning; evo.Argument = 0; // clear ver return; case EvolutionType.LevelUpVersionNight: evo.Method = EvolutionType.LevelUpFriendshipNight; evo.Argument = 0; // clear ver return; } }
private static void SetNature(PKM pk, IBattleTemplate set) { if (pk.Nature == set.Nature) { return; } var val = Math.Min((int)Nature.Quirky, Math.Max((int)Nature.Hardy, set.Nature)); if (pk.Species == (int)Species.Toxtricity) { if (pk.Form == EvolutionMethod.GetAmpLowKeyResult(val)) { pk.Nature = val; // StatNature already set } if (pk.Format >= 8 && pk.StatNature != pk.Nature && pk.StatNature != 12 && (pk.StatNature > 24 || pk.StatNature % 6 == 0)) // Only Serious Mint for Neutral Natures { pk.StatNature = 12; } return; } pk.SetNature(val); // Try setting the actual nature (in the event the StatNature was set instead) var orig = pk.Nature; if (orig == val) { return; } var la = new LegalityAnalysis(pk); pk.Nature = val; var la2 = new LegalityAnalysis(pk); var enc1 = la.EncounterMatch; var enc2 = la2.EncounterMatch; if ((!ReferenceEquals(enc1, enc2) && enc1 is not EncounterEgg) || la2.Results.Any(z => z.Identifier == CheckIdentifier.Nature && !z.Valid)) { pk.Nature = orig; } if (pk.Format >= 8 && pk.StatNature != pk.Nature && pk.StatNature is 0 or 6 or 18 or >= 24) // Only Serious Mint for Neutral Natures { pk.StatNature = (int)Nature.Serious; } }
private static void MakeEvolveEveryLevel(EvolutionSet evos, int species) { var evoSet = evos.PossibleEvolutions; evoSet[0] = new EvolutionMethod { Argument = 0, // clear Form = 0, // randomized later Level = 1, Method = EvolutionType.LevelUp, Species = species, // randomized later }; if (evoSet[1].HasData) // has other branched evolutions; remove them { for (int i = 1; i < evoSet.Length; i++) { evoSet[i] = new EvolutionMethod(); } } }
/// <summary> /// Method to find the PID and IV associated with a nest. Shinies are just allowed /// since there is no way GameFreak actually brute-forces top half of the PID to flag illegals. /// </summary> /// <param name="pk">Passed PKM</param> /// <param name="enc">Nest encounter object</param> /// <param name="shiny">Shiny boolean</param> private static void FindNestPIDIV <T>(PK8 pk, T enc, bool shiny) where T : EncounterStatic8Nest <T> { // Preserve Nature, Altform, Ability (only if HA) // Nest encounter RNG generation var iterPKM = pk.Clone(); if (enc.Ability != -1 && (pk.AbilityNumber == 4) != (enc.Ability == 4)) { return; } if (pk.Species == (int)Species.Toxtricity && pk.AltForm != EvolutionMethod.GetAmpLowKeyResult(pk.Nature)) { enc.ApplyDetailsTo(pk, GetRandomULong()); pk.RefreshAbility(iterPKM.AbilityNumber >> 1); pk.StatNature = iterPKM.StatNature; return; } if (shiny || !UseXOROSHIRO) { return; } var count = 0; do { ulong seed = GetRandomULong(); enc.ApplyDetailsTo(pk, seed); if (IsMatchCriteria <T>(pk, iterPKM)) { break; } } while (++count < 10_000); pk.Species = iterPKM.Species; // possible evolution // can be ability capsuled pk.RefreshAbility(iterPKM.AbilityNumber >> 1); pk.StatNature = iterPKM.StatNature; }
public EvolutionLink(int species, int form, EvolutionMethod method) { Species = species; Form = form; Method = method; }
//public PokemonEvolution(Pokemons EvolveTo, EvolutionMethod EvolveHow, Type ValueType, object ObjectValue) //{ // PokemonEvolution<ValueType>(EvolveTo, EvolveHow, ObjectValue); //} public PokemonEvolution(Pokemons EvolveTo, EvolutionMethod EvolveHow, object Value = null) { this.Species = EvolveTo; this.EvolveMethod = EvolveHow; this.EvolveValue = Value; #region Switch switch (EvolveHow) { case EvolutionMethod.Level: case EvolutionMethod.LevelFemale: case EvolutionMethod.LevelMale: case EvolutionMethod.Ninjask: case EvolutionMethod.Beauty: case EvolutionMethod.Happiness: case EvolutionMethod.HappinessDay: case EvolutionMethod.HappinessNight: case EvolutionMethod.Hatred: //if (!Value.GetType().Equals(typeof(int))) if (!(Value is int)) { this.EvolveValue = (int)0; } break; case EvolutionMethod.Item: case EvolutionMethod.ItemFemale: case EvolutionMethod.ItemMale: case EvolutionMethod.TradeItem: case EvolutionMethod.HoldItem: case EvolutionMethod.HoldItemDay: case EvolutionMethod.HoldItemNight: //if (!Value.GetType().Equals(typeof(Items))) if (!(Value is Items)) { this.EvolveValue = (Items)Items.NONE; } break; case EvolutionMethod.TradeSpecies: case EvolutionMethod.Party: //case EvolutionMethod.Shedinja: //if (!Value.GetType().Equals(typeof(Pokemons))) if (!(Value is Pokemons)) { this.EvolveValue = (Pokemons)Pokemons.NONE; } break; case EvolutionMethod.Move: //if (!Value.GetType().Equals(typeof(Moves))) if (!(Value is Moves)) { this.EvolveValue = (Moves)Moves.NONE; } break; case EvolutionMethod.Type: //if (!Value.GetType().Equals(typeof(Types))) if (!(Value is Types)) { this.EvolveValue = (Types)Types.NONE; } break; case EvolutionMethod.Shedinja: case EvolutionMethod.Time: case EvolutionMethod.Season: case EvolutionMethod.Location: case EvolutionMethod.Weather: default: //if there's no problem, just ignore it, and move on... this.EvolveValue = Value; break; } #endregion }
protected virtual void WriteMethod(EvolutionMethod evo, BinaryWriter w) { w.Write((ushort)evo.Method); w.Write((ushort)evo.Argument); w.Write((ushort)evo.Species); }
protected override void WriteMethod(EvolutionMethod evo, BinaryWriter w) { base.WriteMethod(evo, w); w.Write((sbyte)evo.Form); w.Write((byte)evo.Level); }
/// <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 is 3 or 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; } // don't bother checking encountertrade nicknames for length validity if (enc is EncounterTrade { HasNickname : true })
public IActionResult EvolutionMethod(int id) { EvolutionMethod model = this.dataService.GetObjectByPropertyValue <EvolutionMethod>("Id", id); return(this.View(model)); }
/// <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; var formchange = Form != pk.Form; if (evolutionRequired) { pk.Species = set.Species; } if (formchange) { pk.Form = Form; } if ((evolutionRequired || formchange) && pk is IScaledSizeValue sv) { sv.HeightAbsolute = sv.CalcHeightAbsolute; sv.WeightAbsolute = sv.CalcWeightAbsolute; } // 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 is 3 or 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; } // don't bother checking encountertrade nicknames for length validity if (enc is EncounterTrade { HasNickname : true } et&& et.Nicknames.Contains(set.Nickname)) { // Nickname matches the requested nickname already if (pk.Nickname == set.Nickname) { return; } // This should be illegal except Meister Magikarp in BDSP, however trust the user and set corresponding OT var index = et.Nicknames.ToList().IndexOf(set.Nickname); pk.Nickname = set.Nickname; if (pk.Format >= 3) { pk.OT_Name = et.TrainerNames[index]; } } var gen = enc.Generation; var maxlen = Legal.GetMaxLengthNickname(gen, finallang); var newnick = RegenUtil.MutateNickname(set.Nickname, finallang, (GameVersion)pk.Version); var nickname = newnick.Length > maxlen ? newnick[..maxlen] : newnick;
public IActionResult EvolutionMethod(EvolutionMethod evolutionMethod) { this.dataService.DeleteEvolutionMethod(evolutionMethod.Id); return(this.RedirectToAction("EvolutionMethods", "Admin")); }
/// <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(); } }