From 6b472ffd622f8696c3fbf4ed6ab68809cb9b701b Mon Sep 17 00:00:00 2001 From: Kurt Date: Thu, 3 Sep 2020 19:00:46 -0700 Subject: [PATCH] Misc iencounterable->pkm generator fixes Still some pending stuff like bad mystery gifts gen2 static encounters on g/s applying met level and not location gen6 ralts trade (no nickname) being flagged as nicknamed when it shouldn't gen4 manaphy egg not having a hatch location (worked fine if you transferred it up) gen3 antishiny gifts not setting their PIDs (jirachi WC3) gen5 N's pkm gifts setting the wrong nature gen3 unown not being generated correctly, cosplay pikachu being allowed form0, non-BugCatchingContest no longer require Sport ball, oras dexnav marill now uses the azurill eggmove table --- PKHeX.Core/Legality/Encounters/Data/Encounters6.cs | 1 - .../Encounters/EncounterSlot/EncounterSlot.cs | 14 +++++++++++++- .../Encounters/EncounterSlot/EncounterSlot6AO.cs | 3 ++- .../Encounters/EncounterStatic/EncounterStatic.cs | 3 --- .../Encounters/EncounterStatic/EncounterStatic2.cs | 10 ++++++---- .../EncounterStatic/EncounterStatic5N.cs | 5 ++--- .../EncounterStatic/EncounterStaticTyped.cs | 9 +++++++++ .../Encounters/EncounterTrade/EncounterTrade.cs | 8 ++++++-- .../Encounters/Generator/EncounterSlotGenerator.cs | 2 +- PKHeX.Core/Legality/RNG/PIDGenerator.cs | 2 ++ PKHeX.Core/Legality/Verifiers/MiscVerifier.cs | 4 ++-- PKHeX.Core/MysteryGifts/PGT.cs | 1 + PKHeX.Core/PKM/PKM.cs | 8 ++------ 13 files changed, 46 insertions(+), 24 deletions(-) diff --git a/PKHeX.Core/Legality/Encounters/Data/Encounters6.cs b/PKHeX.Core/Legality/Encounters/Data/Encounters6.cs index 43417019c..83f8d0a40 100644 --- a/PKHeX.Core/Legality/Encounters/Data/Encounters6.cs +++ b/PKHeX.Core/Legality/Encounters/Data/Encounters6.cs @@ -208,7 +208,6 @@ namespace PKHeX.Core new EncounterStatic6 { Species = 425, Level = 45, Location = 348 }, // Drifloon new EncounterStatic6 { Species = 628, Level = 45, Location = 348 }, // Braviary - CosplayPikachu, PermuteCosplay(1), PermuteCosplay(2), PermuteCosplay(3), diff --git a/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot.cs b/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot.cs index cfbf4e069..1690b083b 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot.cs @@ -131,7 +131,19 @@ namespace PKHeX.Core if (Area!.Type == SlotType.HiddenGrotto) // don't force hidden for DexNav ability = 2; - PIDGenerator.SetRandomWildPID(pk, pk.Format, nature, ability, gender); + if (Generation == 3 && Species == (int) Core.Species.Unown) + { + do + { + PIDGenerator.SetRandomWildPID(pk, pk.Format, nature, ability, gender); + ability ^= 1; // some nature-forms cannot have a certain PID-ability set, so just flip it as Unown doesn't have dual abilities. + } while (pk.AltForm != Form); + } + else + { + PIDGenerator.SetRandomWildPID(pk, pk.Format, nature, ability, gender); + } + pk.Gender = gender; pk.StatNature = nature; } diff --git a/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot6AO.cs b/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot6AO.cs index de7ad199a..e5a177483 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot6AO.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot6AO.cs @@ -24,7 +24,8 @@ namespace PKHeX.Core var pk6 = (PK6)pk; if (CanDexNav) { - var eggMoves = MoveEgg.GetEggMoves(pk, Species, Form, Version); + var baseSpec = EvoBase.GetBaseSpecies(pk); + var eggMoves = MoveEgg.GetEggMoves(pk, baseSpec.Species, baseSpec.Form, Version); if (eggMoves.Length > 0) pk6.RelearnMove1 = eggMoves[Util.Rand.Next(eggMoves.Length)]; } diff --git a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic.cs b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic.cs index 7dac4f40a..5e97f7e80 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic.cs @@ -82,9 +82,6 @@ namespace PKHeX.Core case PK3 pk3 when this is EncounterStaticShadow: pk3.RibbonNational = true; break; - case PK4 pk4 when this is EncounterStaticTyped t: - pk4.EncounterType = t.TypeEncounter.GetIndex(); - break; case PK6 pk6: pk6.SetRandomMemory6(); break; diff --git a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic2.cs b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic2.cs index 96e0da651..873b0b00b 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic2.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic2.cs @@ -46,10 +46,12 @@ namespace PKHeX.Core protected override void SetMetData(PKM pk, int level, DateTime today) { - pk.Met_Location = Location; - pk.Met_Level = level; - if (Version == GameVersion.C && pk is PK2 pk2) - pk2.Met_TimeOfDay = EncounterTime.Any.RandomValidTime(); + if (Version != GameVersion.C) + return; + var pk2 = (PK2)pk; + pk2.Met_Location = Location; + pk2.Met_Level = level; + pk2.Met_TimeOfDay = EncounterTime.Any.RandomValidTime(); } protected override bool IsMatchLevel(PKM pkm, DexLevel evo) diff --git a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic5N.cs b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic5N.cs index fd85bc204..ac3cf7549 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic5N.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic5N.cs @@ -11,15 +11,14 @@ protected override void SetPINGA(PKM pk, EncounterCriteria criteria) { int gender = criteria.GetGender(PKX.GetGenderFromPID(Species, PID), pk.PersonalInfo); - int nature = (int)(PID % 25); + int nature = (int)Nature; int ability = Ability; pk.PID = PID; pk.Gender = gender; SetIVs(pk); - if (Generation >= 5) - pk.Nature = nature; + pk.Nature = nature; pk.RefreshAbility(ability >> 1); } diff --git a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStaticTyped.cs b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStaticTyped.cs index d8a6efdf9..b7671753d 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStaticTyped.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStaticTyped.cs @@ -24,6 +24,15 @@ namespace PKHeX.Core return locs.Contains(pkm.Met_Location); } + protected override void SetMetData(PKM pk, int level, DateTime today) + { + var pk4 = (PK4)pk; + var type = pk4.EncounterType = TypeEncounter.GetIndex(); + pk.Met_Location = Roaming ? GetRoamLocations(Species, type)[0] : Location; + pk.Met_Level = level; + pk.MetDate = today; + } + private int[] GetRoamLocations(int species, int type) { switch (species) diff --git a/PKHeX.Core/Legality/Encounters/EncounterTrade/EncounterTrade.cs b/PKHeX.Core/Legality/Encounters/EncounterTrade/EncounterTrade.cs index a1cac346d..1bbe5245c 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterTrade/EncounterTrade.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterTrade/EncounterTrade.cs @@ -59,7 +59,7 @@ namespace PKHeX.Core public IReadOnlyList TrainerNames { get; internal set; } = Array.Empty(); public string GetNickname(int language) => (uint)language < Nicknames.Count ? Nicknames[language] : string.Empty; public string GetOT(int language) => (uint)language < TrainerNames.Count ? TrainerNames[language] : string.Empty; - public bool HasNickname => Nicknames.Count != 0; + public bool HasNickname => Nicknames.Count != 0 && IsNicknamed; public bool HasTrainerName => TrainerNames.Count != 0; private static readonly int[] DefaultMetLocation = @@ -103,7 +103,7 @@ namespace PKHeX.Core pk.Language = lang; pk.OT_Name = pk.Format == 1 ? StringConverter12.G1TradeOTStr : HasTrainerName ? GetOT(lang) : sav.OT; pk.OT_Gender = HasTrainerName ? Math.Max(0, OTGender) : sav.Gender; - pk.SetNickname(GetNickname(lang)); + pk.SetNickname(HasNickname ? GetNickname(lang) : string.Empty); pk.CurrentLevel = level; pk.Version = (int) version; @@ -121,6 +121,10 @@ namespace PKHeX.Core var location = Location > 0 ? Location : DefaultMetLocation[Generation - 1]; SetMetData(pk, level, location, time); } + else + { + pk.OT_Gender = 0; + } if (EggLocation != 0) SetEggMetData(pk, time); diff --git a/PKHeX.Core/Legality/Encounters/Generator/EncounterSlotGenerator.cs b/PKHeX.Core/Legality/Encounters/Generator/EncounterSlotGenerator.cs index 02f72642b..25d8e145b 100644 --- a/PKHeX.Core/Legality/Encounters/Generator/EncounterSlotGenerator.cs +++ b/PKHeX.Core/Legality/Encounters/Generator/EncounterSlotGenerator.cs @@ -89,7 +89,7 @@ namespace PKHeX.Core private static bool IsDeferredWurmple(this IEncounterable slot, int currentSpecies, PKM pkm) => slot.Species == (int)Species.Wurmple && currentSpecies != (int)Species.Wurmple && !WurmpleUtil.IsWurmpleEvoValid(pkm); private static bool IsDeferredSafari3(this ILocation slot, bool IsSafariBall) => IsSafariBall != Locations.IsSafariZoneLocation3(slot.Location); private static bool IsDeferredSafari4(this ILocation slot, bool IsSafariBall) => IsSafariBall != Locations.IsSafariZoneLocation4(slot.Location); - private static bool IsDeferredSport(this ILocation slot, bool IsSportBall) => IsSportBall != (slot.Location == Locations.BugCatchingContest4); + private static bool IsDeferredSport(this EncounterSlot slot, bool IsSportBall) => IsSportBall != (slot.Area.Type == SlotType.BugContest); private static bool IsDeferredHiddenAbility(this EncounterSlot slot, bool IsHidden) => IsHidden && !slot.IsHiddenAbilitySlot(); public static IEnumerable GetEncounterSlots(PKM pkm, GameVersion gameSource = GameVersion.Any) diff --git a/PKHeX.Core/Legality/RNG/PIDGenerator.cs b/PKHeX.Core/Legality/RNG/PIDGenerator.cs index 3a6e1e156..33d51560b 100644 --- a/PKHeX.Core/Legality/RNG/PIDGenerator.cs +++ b/PKHeX.Core/Legality/RNG/PIDGenerator.cs @@ -157,10 +157,12 @@ namespace PKHeX.Core case PIDType.BACD_R: case PIDType.BACD_R_A: case PIDType.BACD_R_S: + case PIDType.BACD_R_AX: return (pk, seed) => SetValuesFromSeedBACD(pk, t, seed & 0xFFFF); case PIDType.BACD_U: case PIDType.BACD_U_A: case PIDType.BACD_U_S: + case PIDType.BACD_U_AX: return (pk, seed) => SetValuesFromSeedBACD(pk, t, seed); case PIDType.PokeSpot: diff --git a/PKHeX.Core/Legality/Verifiers/MiscVerifier.cs b/PKHeX.Core/Legality/Verifiers/MiscVerifier.cs index 6fc9d8dfa..f0133f1c0 100644 --- a/PKHeX.Core/Legality/Verifiers/MiscVerifier.cs +++ b/PKHeX.Core/Legality/Verifiers/MiscVerifier.cs @@ -267,10 +267,10 @@ namespace PKHeX.Core case WC8 wc8 when !wc8.CanBeReceivedByVersion(pkm.Version) && !pkm.WasTradedEgg: data.AddLine(GetInvalid(LEncGiftVersionNotDistributed, GameOrigin)); return; - case WC6 wc6 when wc6.RestrictLanguage != 0 && wc6.Language != wc6.RestrictLanguage: + case WC6 wc6 when wc6.RestrictLanguage != 0 && pkm.Language != wc6.RestrictLanguage: data.AddLine(GetInvalid(string.Format(LOTLanguage, wc6.RestrictLanguage, pkm.Language), CheckIdentifier.Language)); return; - case WC7 wc7 when wc7.RestrictLanguage != 0 && wc7.Language != wc7.RestrictLanguage: + case WC7 wc7 when wc7.RestrictLanguage != 0 && pkm.Language != wc7.RestrictLanguage: data.AddLine(GetInvalid(string.Format(LOTLanguage, wc7.RestrictLanguage, pkm.Language), CheckIdentifier.Language)); return; } diff --git a/PKHeX.Core/MysteryGifts/PGT.cs b/PKHeX.Core/MysteryGifts/PGT.cs index 3d02f075c..387c7a3a7 100644 --- a/PKHeX.Core/MysteryGifts/PGT.cs +++ b/PKHeX.Core/MysteryGifts/PGT.cs @@ -181,6 +181,7 @@ namespace PKHeX.Core pk4.Version = 10; // Diamond pk4.Language = (int)LanguageID.English; // English pk4.Nickname = "MANAPHY"; + pk4.Met_Location = Locations.HatchLocationDPPt; pk4.Egg_Location = 1; // Ranger (will be +3000 later) pk4.Move1_PP = pk4.GetMovePP(pk4.Move1, 0); pk4.Move2_PP = pk4.GetMovePP(pk4.Move2, 0); diff --git a/PKHeX.Core/PKM/PKM.cs b/PKHeX.Core/PKM/PKM.cs index 787a40b9b..959c25996 100644 --- a/PKHeX.Core/PKM/PKM.cs +++ b/PKHeX.Core/PKM/PKM.cs @@ -736,11 +736,7 @@ namespace PKHeX.Core AbilityNumber = 1 << n; int[] abilities = PersonalInfo.Abilities; if ((uint)n < abilities.Length) - { - if (abilities[n] == abilities[0]) - n = 0; Ability = abilities[n]; - } if (this is PK5 pk5) pk5.HiddenAbility = n == 2; } @@ -1049,10 +1045,10 @@ namespace PKHeX.Core return 3; if (XY) { - if (Met_Location == 148 && Met_Level == 30) // Friend Safari - return 2; if (PersonalInfo.EggGroup1 == 15) // Undiscovered return 3; + if (Met_Location == 148 && Met_Level == 30) // Friend Safari + return 2; } if (VC) return Species == (int)Core.Species.Mew || Species == (int)Core.Species.Celebi ? 5 : 3;