From 6b2ea0894ebcc1c494172ad8da7c2eb9599cfbbb Mon Sep 17 00:00:00 2001 From: Kurt Date: Sun, 12 Dec 2021 13:16:27 -0800 Subject: [PATCH] Bypass encounter slot check for radar slots https://projectpokemon.org/home/forums/topic/57375-pkhex-new-update-legality-errors-contribution-page/?do=findComment&comment=271406 https://discord.com/channels/401014193211441153/679178558597496872/908489378043686944 --- .../Encounters/EncounterSlot/EncounterSlot4.cs | 1 + .../Generator/ByGeneration/EncounterGenerator4.cs | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot4.cs b/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot4.cs index a50f4d40c..ee4684cea 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot4.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot4.cs @@ -16,6 +16,7 @@ public sealed record EncounterSlot4 : EncounterSlot, IMagnetStatic, INumberedSlo public SlotType Type => Area.Type; public int SlotNumber { get; } + public bool CanUseRadar => !GameVersion.HGSS.Contains(Version) && GroundTile.HasFlag(GroundTilePermission.Grass); public EncounterSlot4(EncounterArea4 area, int species, int form, int min, int max, int slot, int mpi, int mpc, int sti, int stc) : base(area, species, form, min, max) { diff --git a/PKHeX.Core/Legality/Encounters/Generator/ByGeneration/EncounterGenerator4.cs b/PKHeX.Core/Legality/Encounters/Generator/ByGeneration/EncounterGenerator4.cs index efbfd0538..1ab325d9b 100644 --- a/PKHeX.Core/Legality/Encounters/Generator/ByGeneration/EncounterGenerator4.cs +++ b/PKHeX.Core/Legality/Encounters/Generator/ByGeneration/EncounterGenerator4.cs @@ -74,8 +74,9 @@ private static IEnumerable GenerateRawEncounters4(PKM pkm, Legal } var slots = FrameFinder.GetFrames(info.PIDIV, pkm).ToList(); - foreach (var z in GetValidWildEncounters34(pkm, chain)) + foreach (var slot in GetValidWildEncounters34(pkm, chain)) { + var z = (EncounterSlot4)slot; var match = z.GetMatchRating(pkm); if (match == PartialMatch) { @@ -83,7 +84,14 @@ private static IEnumerable GenerateRawEncounters4(PKM pkm, Legal continue; } - var frame = slots.Find(s => s.IsSlotCompatibile((EncounterSlot4)z, pkm)); + // Can use Radar to force the encounter slot to stay consistent across encounters. + if (z.CanUseRadar) + { + yield return slot; + continue; + } + + var frame = slots.Find(s => s.IsSlotCompatibile(z, pkm)); if (frame == null) { deferred ??= z;