From e3f80919714557ab9924b61dfb4c639361ccfbb2 Mon Sep 17 00:00:00 2001 From: Kurt Date: Mon, 11 Sep 2023 00:54:40 -0700 Subject: [PATCH] Misc fixes Ignore slot match for Swarm3 Honey Tree only yield possible slots via TID/SID Pick min level for EncounterTrade1 Set nickname for CXD Elekid trade Set held item for Pt Giratina Set egg location for Ranch gift hatched egg Set hidden ability flag for N's Darmanitan Set XY Vivillon form based on generated geolocation Force evolve Trade species if encounter requires it Correctly recognize pikachu-colored-pichu Gen4 gift PID type Set hatched manaphy egg's met location & date --- .../ByGeneration/EncounterGenerator3.cs | 2 +- .../ByGeneration/EncounterGenerator4.cs | 4 ++-- .../ByGeneration/EncounterGenerator8b.cs | 4 ++-- .../Moveset/EncounterMovesetGenerator.cs | 4 ++-- .../Generator/Possible/EncounterPossible4.cs | 20 +++++++++---------- .../Generator/Possible/EncounterPossible8b.cs | 14 ++++++------- .../Templates/Gen1/EncounterTrade1.cs | 7 +++++-- .../Templates/Gen3/EncounterSlot3Swarm.cs | 6 +----- .../Templates/Gen3/XD/EncounterTrade3XD.cs | 2 +- .../Templates/Gen4/EncounterSlot4.cs | 9 ++++++++- .../Templates/Gen4/EncounterStatic4.cs | 4 ++++ .../Gen4/EncounterTrade4RanchGift.cs | 6 ++++++ .../Templates/Gen5/EncounterStatic5N.cs | 1 + .../Templates/Gen6/EncounterSlot6XY.cs | 8 +++++++- .../Templates/Gen7/EncounterTrade7.cs | 3 +++ .../Templates/Gen8b/EncounterSlot8b.cs | 10 ++++++++-- .../Templates/Gen9/EncounterTrade9.cs | 2 ++ PKHeX.Core/MysteryGifts/PCD.cs | 5 ++++- PKHeX.Core/MysteryGifts/PGT.cs | 4 ++++ 19 files changed, 78 insertions(+), 37 deletions(-) diff --git a/PKHeX.Core/Legality/Encounters/Generator/ByGeneration/EncounterGenerator3.cs b/PKHeX.Core/Legality/Encounters/Generator/ByGeneration/EncounterGenerator3.cs index cb4c0c734..e9b0369f8 100644 --- a/PKHeX.Core/Legality/Encounters/Generator/ByGeneration/EncounterGenerator3.cs +++ b/PKHeX.Core/Legality/Encounters/Generator/ByGeneration/EncounterGenerator3.cs @@ -60,7 +60,7 @@ public sealed class EncounterGenerator3 : IEncounterGenerator foreach (var enc in iterator) { var e = enc.Encounter; - if (e is not EncounterSlot3 s3) + if (e is not EncounterSlot3 s3 || s3 is EncounterSlot3Swarm) { yield return e; continue; diff --git a/PKHeX.Core/Legality/Encounters/Generator/ByGeneration/EncounterGenerator4.cs b/PKHeX.Core/Legality/Encounters/Generator/ByGeneration/EncounterGenerator4.cs index 92229e7c7..d408b841f 100644 --- a/PKHeX.Core/Legality/Encounters/Generator/ByGeneration/EncounterGenerator4.cs +++ b/PKHeX.Core/Legality/Encounters/Generator/ByGeneration/EncounterGenerator4.cs @@ -20,9 +20,9 @@ public sealed class EncounterGenerator4 : IEncounterGenerator return GetEncounters(pk, chain, info); } - public IEnumerable GetPossible(PKM _, EvoCriteria[] chain, GameVersion game, EncounterTypeGroup groups) + public IEnumerable GetPossible(PKM pk, EvoCriteria[] chain, GameVersion game, EncounterTypeGroup groups) { - var iterator = new EncounterPossible4(chain, groups, game); + var iterator = new EncounterPossible4(chain, groups, game, pk); foreach (var enc in iterator) yield return enc; } diff --git a/PKHeX.Core/Legality/Encounters/Generator/ByGeneration/EncounterGenerator8b.cs b/PKHeX.Core/Legality/Encounters/Generator/ByGeneration/EncounterGenerator8b.cs index 13d630257..f1478010d 100644 --- a/PKHeX.Core/Legality/Encounters/Generator/ByGeneration/EncounterGenerator8b.cs +++ b/PKHeX.Core/Legality/Encounters/Generator/ByGeneration/EncounterGenerator8b.cs @@ -8,9 +8,9 @@ public sealed class EncounterGenerator8b : IEncounterGenerator { public static readonly EncounterGenerator8b Instance = new(); - public IEnumerable GetPossible(PKM _, EvoCriteria[] chain, GameVersion game, EncounterTypeGroup groups) + public IEnumerable GetPossible(PKM pk, EvoCriteria[] chain, GameVersion game, EncounterTypeGroup groups) { - var iterator = new EncounterPossible8b(chain, groups, game); + var iterator = new EncounterPossible8b(chain, groups, game, pk); foreach (var enc in iterator) yield return enc; } diff --git a/PKHeX.Core/Legality/Encounters/Generator/Moveset/EncounterMovesetGenerator.cs b/PKHeX.Core/Legality/Encounters/Generator/Moveset/EncounterMovesetGenerator.cs index e9ccc7a7f..a45e8ea79 100644 --- a/PKHeX.Core/Legality/Encounters/Generator/Moveset/EncounterMovesetGenerator.cs +++ b/PKHeX.Core/Legality/Encounters/Generator/Moveset/EncounterMovesetGenerator.cs @@ -84,9 +84,9 @@ public static class EncounterMovesetGenerator /// /// Rough Pokémon data which contains the requested species, gender, and form. /// Trainer information of the receiver. - public static void OptimizeCriteria(PKM pk, ITrainerID16 info) + public static void OptimizeCriteria(PKM pk, ITrainerID32 info) { - pk.TID16 = info.TID16; // Necessary for Gen2 Headbutt encounters. + pk.ID32 = info.ID32; // Necessary for Gen2 Headbutt encounters and Honey Tree encounters var htTrash = pk.HT_Trash; if (htTrash.Length != 0) htTrash[0] = 1; // Fake Trash to indicate trading. diff --git a/PKHeX.Core/Legality/Encounters/Generator/Possible/EncounterPossible4.cs b/PKHeX.Core/Legality/Encounters/Generator/Possible/EncounterPossible4.cs index 999b3d7c7..e11a0343d 100644 --- a/PKHeX.Core/Legality/Encounters/Generator/Possible/EncounterPossible4.cs +++ b/PKHeX.Core/Legality/Encounters/Generator/Possible/EncounterPossible4.cs @@ -7,7 +7,7 @@ namespace PKHeX.Core; /// /// Iterates to find possible encounters for encounters. /// -public record struct EncounterPossible4(EvoCriteria[] Chain, EncounterTypeGroup Flags, GameVersion Version) : IEnumerator +public record struct EncounterPossible4(EvoCriteria[] Chain, EncounterTypeGroup Flags, GameVersion Version, PKM Entity) : IEnumerator { public IEncounterable Current { get; private set; } @@ -181,23 +181,23 @@ public record struct EncounterPossible4(EvoCriteria[] Chain, EncounterTypeGroup { State = YieldState.SlotSS; goto case YieldState.SlotSS; } throw new ArgumentOutOfRangeException(nameof(Version)); case YieldState.SlotHG: - if (TryGetNext(Encounters4HGSS.SlotsHG)) + if (TryGetNext(Encounters4HGSS.SlotsHG)) return true; goto case YieldState.SlotEnd; case YieldState.SlotSS: - if (TryGetNext(Encounters4HGSS.SlotsSS)) + if (TryGetNext(Encounters4HGSS.SlotsSS)) return true; goto case YieldState.SlotEnd; case YieldState.SlotD: - if (TryGetNext(Encounters4DPPt.SlotsD)) + if (TryGetNext(Encounters4DPPt.SlotsD)) return true; goto case YieldState.SlotEnd; case YieldState.SlotP: - if (TryGetNext(Encounters4DPPt.SlotsP)) + if (TryGetNext(Encounters4DPPt.SlotsP)) return true; goto case YieldState.SlotEnd; case YieldState.SlotPt: - if (TryGetNext(Encounters4DPPt.SlotsPt)) + if (TryGetNext(Encounters4DPPt.SlotsPt)) return true; goto case YieldState.SlotEnd; case YieldState.SlotEnd: @@ -206,9 +206,7 @@ public record struct EncounterPossible4(EvoCriteria[] Chain, EncounterTypeGroup return false; } - private bool TryGetNext(TArea[] areas) - where TArea : class, IEncounterArea - where TSlot : class, IEncounterable, IEncounterMatch + private bool TryGetNext(EncounterArea4[] areas) { for (; Index < areas.Length; Index++, SubIndex = 0) { @@ -236,7 +234,7 @@ public record struct EncounterPossible4(EvoCriteria[] Chain, EncounterTypeGroup return false; } - private bool TryGetNextSub(T[] slots) where T : class, IEncounterable, IEncounterMatch + private bool TryGetNextSub(EncounterSlot4[] slots) { while (SubIndex < slots.Length) { @@ -245,6 +243,8 @@ public record struct EncounterPossible4(EvoCriteria[] Chain, EncounterTypeGroup { if (enc.Species != evo.Species) continue; + if (enc.IsInvalidMunchlaxTree(Entity)) + continue; return SetCurrent(enc); } } diff --git a/PKHeX.Core/Legality/Encounters/Generator/Possible/EncounterPossible8b.cs b/PKHeX.Core/Legality/Encounters/Generator/Possible/EncounterPossible8b.cs index cb63f114d..5e5fd2569 100644 --- a/PKHeX.Core/Legality/Encounters/Generator/Possible/EncounterPossible8b.cs +++ b/PKHeX.Core/Legality/Encounters/Generator/Possible/EncounterPossible8b.cs @@ -7,7 +7,7 @@ namespace PKHeX.Core; /// /// Iterates to find possible encounters for encounters. /// -public record struct EncounterPossible8b(EvoCriteria[] Chain, EncounterTypeGroup Flags, GameVersion Version) : IEnumerator +public record struct EncounterPossible8b(EvoCriteria[] Chain, EncounterTypeGroup Flags, GameVersion Version, PKM Entity) : IEnumerator { public IEncounterable Current { get; private set; } @@ -119,11 +119,11 @@ public record struct EncounterPossible8b(EvoCriteria[] Chain, EncounterTypeGroup { State = YieldState.SlotSP; goto case YieldState.SlotSP; } throw new ArgumentOutOfRangeException(nameof(Version)); case YieldState.SlotBD: - if (TryGetNext(Encounters8b.SlotsBD)) + if (TryGetNext(Encounters8b.SlotsBD)) return true; goto case YieldState.SlotEnd; case YieldState.SlotSP: - if (TryGetNext(Encounters8b.SlotsSP)) + if (TryGetNext(Encounters8b.SlotsSP)) return true; goto case YieldState.SlotEnd; case YieldState.SlotEnd: @@ -132,9 +132,7 @@ public record struct EncounterPossible8b(EvoCriteria[] Chain, EncounterTypeGroup return false; } - private bool TryGetNext(TArea[] areas) - where TArea : class, IEncounterArea - where TSlot : class, IEncounterable, IEncounterMatch + private bool TryGetNext(EncounterArea8b[] areas) { for (; Index < areas.Length; Index++, SubIndex = 0) { @@ -145,7 +143,7 @@ public record struct EncounterPossible8b(EvoCriteria[] Chain, EncounterTypeGroup return false; } - private bool TryGetNextSub(T[] slots) where T : class, IEncounterable, IEncounterMatch + private bool TryGetNextSub(EncounterSlot8b[] slots) { while (SubIndex < slots.Length) { @@ -154,6 +152,8 @@ public record struct EncounterPossible8b(EvoCriteria[] Chain, EncounterTypeGroup { if (enc.Species != evo.Species) continue; + if (enc.IsInvalidMunchlaxTree(Entity)) + continue; return SetCurrent(enc); } } diff --git a/PKHeX.Core/Legality/Encounters/Templates/Gen1/EncounterTrade1.cs b/PKHeX.Core/Legality/Encounters/Templates/Gen1/EncounterTrade1.cs index 333da5a40..e5a5c03e6 100644 --- a/PKHeX.Core/Legality/Encounters/Templates/Gen1/EncounterTrade1.cs +++ b/PKHeX.Core/Legality/Encounters/Templates/Gen1/EncounterTrade1.cs @@ -112,7 +112,8 @@ public sealed record EncounterTrade1 : IEncounterable, IEncounterMatch, IFixedTr public PK1 ConvertToPKM(ITrainerInfo tr, EncounterCriteria criteria) { - var level = ParseSettings.AllowGen1Tradeback ? LevelMinGSC : LevelMinRBY; + bool gsc = CanObtainMinGSC(); + var level = gsc ? LevelMinGSC : LevelMinRBY; int lang = (int)Language.GetSafeLanguage(Generation, (LanguageID)tr.Language, Version); var isJapanese = lang == (int)LanguageID.Japanese; var pi = EncounterUtil1.GetPersonal1(Version, Species); @@ -131,6 +132,8 @@ public sealed record EncounterTrade1 : IEncounterable, IEncounterMatch, IFixedTr pk.OT_Trash[0] = StringConverter12.G1TradeOTCode; EncounterUtil1.SetEncounterMoves(pk, Version, level); + if (EvolveOnTrade) + pk.Species++; pk.ResetPartyStats(); @@ -170,7 +173,7 @@ public sealed record EncounterTrade1 : IEncounterable, IEncounterMatch, IFixedTr private bool IsMatchLevel(PKM pk, int lvl) { - if (pk is not PK1) + if (pk is not PK1 || CanObtainMinGSC()) return lvl >= LevelMinGSC; return lvl >= LevelMin; } diff --git a/PKHeX.Core/Legality/Encounters/Templates/Gen3/EncounterSlot3Swarm.cs b/PKHeX.Core/Legality/Encounters/Templates/Gen3/EncounterSlot3Swarm.cs index 3702130be..9314fb48c 100644 --- a/PKHeX.Core/Legality/Encounters/Templates/Gen3/EncounterSlot3Swarm.cs +++ b/PKHeX.Core/Legality/Encounters/Templates/Gen3/EncounterSlot3Swarm.cs @@ -9,9 +9,5 @@ namespace PKHeX.Core; internal sealed record EncounterSlot3Swarm(EncounterArea3 Parent, ushort Species, byte LevelMin, byte LevelMax, byte SlotNumber, Moveset Moves) : EncounterSlot3(Parent, Species, 0, LevelMin, LevelMax, SlotNumber, 0, 0, 0, 0), IMoveset { - protected override void SetEncounterMoves(PKM pk) - { - pk.SetMoves(Moves); - pk.SetMaximumPPCurrent(Moves); - } + protected override void SetEncounterMoves(PKM pk) => pk.SetMoves(Moves); } diff --git a/PKHeX.Core/Legality/Encounters/Templates/Gen3/XD/EncounterTrade3XD.cs b/PKHeX.Core/Legality/Encounters/Templates/Gen3/XD/EncounterTrade3XD.cs index 1f19e04e5..f2cc20805 100644 --- a/PKHeX.Core/Legality/Encounters/Templates/Gen3/XD/EncounterTrade3XD.cs +++ b/PKHeX.Core/Legality/Encounters/Templates/Gen3/XD/EncounterTrade3XD.cs @@ -76,7 +76,7 @@ public sealed record EncounterTrade3XD : IEncounterable, IEncounterMatch, IEncou OT_Gender = 0, TID16 = TID16, SID16 = tr.SID16, - Nickname = SpeciesName.GetSpeciesNameGeneration(Species, lang, Generation), + Nickname = IsFixedNickname ? GetNickname(lang) : SpeciesName.GetSpeciesNameGeneration(Species, lang, Generation), }; SetPINGA(pk, criteria, pi); diff --git a/PKHeX.Core/Legality/Encounters/Templates/Gen4/EncounterSlot4.cs b/PKHeX.Core/Legality/Encounters/Templates/Gen4/EncounterSlot4.cs index 6981f6b18..ac7c367f8 100644 --- a/PKHeX.Core/Legality/Encounters/Templates/Gen4/EncounterSlot4.cs +++ b/PKHeX.Core/Legality/Encounters/Templates/Gen4/EncounterSlot4.cs @@ -122,12 +122,19 @@ public sealed record EncounterSlot4(EncounterArea4 Parent, ushort Species, byte // A/B/C tables, only Munchlax is a 'C' encounter, and A/B are accessible from any tree. // C table encounters are only available from 4 trees, which are determined by TID16/SID16 of the save file. - if (Type is SlotType.HoneyTree && Species == (int)Core.Species.Munchlax && !Parent.IsMunchlaxTree(pk)) + if (IsInvalidMunchlaxTree(pk)) return false; return true; } + public bool IsInvalidMunchlaxTree(PKM pk) + { + if (Type is not SlotType.HoneyTree) + return false; + return Species == (int)Core.Species.Munchlax && !Parent.IsMunchlaxTree(pk); + } + public EncounterMatchRating GetMatchRating(PKM pk) { if ((pk.Ball == (int)Ball.Safari) != Locations.IsSafariZoneLocation4(Location)) diff --git a/PKHeX.Core/Legality/Encounters/Templates/Gen4/EncounterStatic4.cs b/PKHeX.Core/Legality/Encounters/Templates/Gen4/EncounterStatic4.cs index 319e5d8ed..e70f455b6 100644 --- a/PKHeX.Core/Legality/Encounters/Templates/Gen4/EncounterStatic4.cs +++ b/PKHeX.Core/Legality/Encounters/Templates/Gen4/EncounterStatic4.cs @@ -83,6 +83,10 @@ public sealed record EncounterStatic4(GameVersion Version) pk.Egg_Location = EggLocation; pk.EggMetDate = pk.MetDate; } + else if (Species == (int)Core.Species.Giratina && Form == 1) + { + pk.HeldItem = 0112; // Griseous Orb + } SetPINGA(pk, criteria, pi); if (Moves.HasMoves) diff --git a/PKHeX.Core/Legality/Encounters/Templates/Gen4/EncounterTrade4RanchGift.cs b/PKHeX.Core/Legality/Encounters/Templates/Gen4/EncounterTrade4RanchGift.cs index 9574967ca..aad643f1f 100644 --- a/PKHeX.Core/Legality/Encounters/Templates/Gen4/EncounterTrade4RanchGift.cs +++ b/PKHeX.Core/Legality/Encounters/Templates/Gen4/EncounterTrade4RanchGift.cs @@ -105,6 +105,12 @@ public sealed record EncounterTrade4RanchGift HT_Gender = tr.Gender, }; + if (EggLocation != 0) + { + pk.Egg_Location = EggLocation; + pk.EggMetDate = pk.MetDate; + } + if (Moves.HasMoves) pk.SetMoves(Moves); else diff --git a/PKHeX.Core/Legality/Encounters/Templates/Gen5/EncounterStatic5N.cs b/PKHeX.Core/Legality/Encounters/Templates/Gen5/EncounterStatic5N.cs index 971fb88a9..b7e348ad3 100644 --- a/PKHeX.Core/Legality/Encounters/Templates/Gen5/EncounterStatic5N.cs +++ b/PKHeX.Core/Legality/Encounters/Templates/Gen5/EncounterStatic5N.cs @@ -81,6 +81,7 @@ public sealed record EncounterStatic5N(uint PID) AbilityPermission.OnlySecond => pi.Ability2, _ => pi.AbilityH, }, + HiddenAbility = Ability == AbilityPermission.OnlyHidden, }; EncounterUtil1.SetEncounterMoves(pk, version, LevelMin); diff --git a/PKHeX.Core/Legality/Encounters/Templates/Gen6/EncounterSlot6XY.cs b/PKHeX.Core/Legality/Encounters/Templates/Gen6/EncounterSlot6XY.cs index 47eae1300..ca41c9986 100644 --- a/PKHeX.Core/Legality/Encounters/Templates/Gen6/EncounterSlot6XY.cs +++ b/PKHeX.Core/Legality/Encounters/Templates/Gen6/EncounterSlot6XY.cs @@ -76,6 +76,9 @@ public sealed record EncounterSlot6XY(EncounterArea6XY Parent, ushort Species, b else pk.SetDefaultRegionOrigins(lang); + if (IsRandomUnspecificForm && Form == EncounterUtil1.FormVivillon) + pk.Form = Vivillon3DS.GetPattern(pk.Country, pk.Region); + SetPINGA(pk, criteria); EncounterUtil1.SetEncounterMoves(pk, Version, LevelMin); pk.SetRandomMemory6(); @@ -85,8 +88,11 @@ public sealed record EncounterSlot6XY(EncounterArea6XY Parent, ushort Species, b private byte GetWildForm(byte form) { - if (form != EncounterUtil1.FormRandom) + if (form < EncounterUtil1.FormDynamic) return form; + if (form == EncounterUtil1.FormVivillon) + return 0; // rectify later + // flagged as totally random return (byte)Util.Rand.Next(PersonalTable.XY[Species].FormCount); } diff --git a/PKHeX.Core/Legality/Encounters/Templates/Gen7/EncounterTrade7.cs b/PKHeX.Core/Legality/Encounters/Templates/Gen7/EncounterTrade7.cs index 7a89009ee..baf46d0e1 100644 --- a/PKHeX.Core/Legality/Encounters/Templates/Gen7/EncounterTrade7.cs +++ b/PKHeX.Core/Legality/Encounters/Templates/Gen7/EncounterTrade7.cs @@ -107,6 +107,9 @@ public sealed record EncounterTrade7 : IEncounterable, IEncounterMatch, IFixedTr if (pk.IsShiny) pk.PID ^= 0x1000_0000; criteria.SetRandomIVs(pk, IVs); + if (EvolveOnTrade) + pk.Species++; + pk.RefreshAbility(criteria.GetAbilityFromNumber(Ability)); pk.ResetPartyStats(); diff --git a/PKHeX.Core/Legality/Encounters/Templates/Gen8b/EncounterSlot8b.cs b/PKHeX.Core/Legality/Encounters/Templates/Gen8b/EncounterSlot8b.cs index 7f17fbe50..9deeddf6d 100644 --- a/PKHeX.Core/Legality/Encounters/Templates/Gen8b/EncounterSlot8b.cs +++ b/PKHeX.Core/Legality/Encounters/Templates/Gen8b/EncounterSlot8b.cs @@ -137,12 +137,19 @@ public sealed record EncounterSlot8b(EncounterArea8b Parent, ushort Species, byt // A/B/C tables, only Munchlax is a 'C' encounter, and A/B are accessible from any tree. // C table encounters are only available from 4 trees, which are determined by TID16/SID16 of the save file. - if (Type is SlotType.HoneyTree && Species == (int)Core.Species.Munchlax && !Parent.IsMunchlaxTree(pk)) + if (IsInvalidMunchlaxTree(pk)) return false; return true; } + public bool IsInvalidMunchlaxTree(PKM pk) + { + if (Type is not SlotType.HoneyTree) + return false; + return Species == (int)Core.Species.Munchlax && !Parent.IsMunchlaxTree(pk); + } + public EncounterMatchRating GetMatchRating(PKM pk) { bool isHidden = pk.AbilityNumber == 4; @@ -175,5 +182,4 @@ public sealed record EncounterSlot8b(EncounterArea8b Parent, ushort Species, byt return baseEgg.Contains(move); } #endregion - } diff --git a/PKHeX.Core/Legality/Encounters/Templates/Gen9/EncounterTrade9.cs b/PKHeX.Core/Legality/Encounters/Templates/Gen9/EncounterTrade9.cs index 2c6875275..9260e817e 100644 --- a/PKHeX.Core/Legality/Encounters/Templates/Gen9/EncounterTrade9.cs +++ b/PKHeX.Core/Legality/Encounters/Templates/Gen9/EncounterTrade9.cs @@ -102,6 +102,8 @@ public sealed record EncounterTrade9 EncounterUtil1.SetEncounterMoves(pk, version, Level); SetPINGA(pk, criteria, pi); + if (EvolveOnTrade) + pk.Species++; pk.ResetPartyStats(); diff --git a/PKHeX.Core/MysteryGifts/PCD.cs b/PKHeX.Core/MysteryGifts/PCD.cs index 933f9c8e0..f0af32bdb 100644 --- a/PKHeX.Core/MysteryGifts/PCD.cs +++ b/PKHeX.Core/MysteryGifts/PCD.cs @@ -12,7 +12,7 @@ namespace PKHeX.Core; /// https://projectpokemon.org/home/forums/topic/5870-pok%C3%A9mon-mystery-gift-editor-v143-now-with-bw-support/ /// See also: http://tccphreak.shiny-clique.net/debugger/pcdfiles.htm /// -public sealed class PCD : DataMysteryGift, IRibbonSetEvent3, IRibbonSetEvent4, IRestrictVersion +public sealed class PCD : DataMysteryGift, IRibbonSetEvent3, IRibbonSetEvent4, IRestrictVersion, IRandomCorrelation { public const int Size = 0x358; // 856 public override int Generation => 4; @@ -100,6 +100,9 @@ public sealed class PCD : DataMysteryGift, IRibbonSetEvent3, IRibbonSetEvent4, I public override int Location { get => IsEgg ? 0 : Gift.EggLocation + 3000; set { } } public override int EggLocation { get => IsEgg ? Gift.EggLocation + 3000 : 0; set { } } + public bool IsCompatible(PIDType val, PKM pk) => Gift.IsCompatible(val, pk); + public PIDType GetSuggestedCorrelation() => Gift.GetSuggestedCorrelation(); + public bool GiftEquals(PGT pgt) { // Skip over the PGT's "Corresponding PCD Slot" @ 0x02 diff --git a/PKHeX.Core/MysteryGifts/PGT.cs b/PKHeX.Core/MysteryGifts/PGT.cs index fd121a3b6..deacc3f9f 100644 --- a/PKHeX.Core/MysteryGifts/PGT.cs +++ b/PKHeX.Core/MysteryGifts/PGT.cs @@ -196,6 +196,8 @@ public sealed class PGT : DataMysteryGift, IRibbonSetEvent3, IRibbonSetEvent4, I pk4.Language = lang; pk4.Egg_Location = 1; // Ranger (will be +3000 later) pk4.Nickname = SpeciesName.GetSpeciesNameGeneration((int)Core.Species.Manaphy, lang, 4); + pk4.Met_Location = pk4.Version is (int)GameVersion.HG or (int)GameVersion.SS ? Locations.HatchLocationHGSS : Locations.HatchLocationDPPt; + pk4.MetDate = EncounterDate.GetDateNDS(); } private void SetPINGA(PK4 pk4, EncounterCriteria criteria) @@ -306,6 +308,8 @@ public sealed class PGT : DataMysteryGift, IRibbonSetEvent3, IRibbonSetEvent4, I { if (IsManaphyEgg) return IsG4ManaphyPIDValid(val, pk); + if (PK.PID != 1 && val == PIDType.G5MGShiny) + return true; return val == PIDType.None; }