diff --git a/PKHeX.Core/Legality/Encounters/Templates/Gen8a/EncounterSlot8a.cs b/PKHeX.Core/Legality/Encounters/Templates/Gen8a/EncounterSlot8a.cs index c38e60b4c..3e3ec8101 100644 --- a/PKHeX.Core/Legality/Encounters/Templates/Gen8a/EncounterSlot8a.cs +++ b/PKHeX.Core/Legality/Encounters/Templates/Gen8a/EncounterSlot8a.cs @@ -8,7 +8,7 @@ namespace PKHeX.Core; /// 0=Never, 1=Random, 2=Guaranteed /// public sealed record EncounterSlot8a(EncounterArea8a Parent, ushort Species, byte Form, byte LevelMin, byte LevelMax, byte AlphaType, byte FlawlessIVCount, Gender Gender) - : IEncounterable, IEncounterMatch, IEncounterConvertible, IAlphaReadOnly, IMasteryInitialMoveShop8, IFlawlessIVCount + : IEncounterable, IEncounterMatch, IEncounterConvertible, IAlphaReadOnly, IMasteryInitialMoveShop8, IFlawlessIVCount, ISeedCorrelation64 { public byte Generation => 8; public EntityContext Context => EntityContext.Gen8a; @@ -233,4 +233,21 @@ public sealed record EncounterSlot8a(EncounterArea8a Parent, ushort Species, byt return p.IsValidMasteredEncounter(moves, learn, mastery, level, alpha, allowAlphaPurchaseBug); } #endregion + + public bool TryGetSeed(PKM pk, out ulong seed) + { + // Check if it matches any single-roll seed. + var pi = PersonalTable.LA[Species, Form]; + var param = GetParams(pi) with { RollCount = 1 }; + var solver = new XoroMachineSkip(pk.EncryptionConstant, pk.PID); + foreach (var s in solver) + { + if (!Overworld8aRNG.Verify(pk, s, param)) + continue; + seed = s; + return true; + } + seed = default; + return false; + } } diff --git a/PKHeX.Core/Legality/Encounters/Templates/Gen8a/EncounterStatic8a.cs b/PKHeX.Core/Legality/Encounters/Templates/Gen8a/EncounterStatic8a.cs index 612e75749..f0b586d39 100644 --- a/PKHeX.Core/Legality/Encounters/Templates/Gen8a/EncounterStatic8a.cs +++ b/PKHeX.Core/Legality/Encounters/Templates/Gen8a/EncounterStatic8a.cs @@ -6,7 +6,9 @@ namespace PKHeX.Core; /// Generation 8 Static Encounter /// public sealed record EncounterStatic8a - : IEncounterable, IEncounterMatch, IEncounterConvertible, IAlphaReadOnly, IMasteryInitialMoveShop8, IScaledSizeReadOnly, IMoveset, IFlawlessIVCount, IFatefulEncounterReadOnly, IFixedGender + : IEncounterable, IEncounterMatch, IEncounterConvertible, ISeedCorrelation64, + IAlphaReadOnly, IMasteryInitialMoveShop8, IScaledSizeReadOnly, + IMoveset, IFlawlessIVCount, IFatefulEncounterReadOnly, IFixedGender { public byte Generation => 8; public EntityContext Context => EntityContext.Gen8a; @@ -283,4 +285,20 @@ public sealed record EncounterStatic8a return p.IsValidMasteredEncounter(moves, learn, mastery, level, alpha, allowAlphaPurchaseBug); } #endregion + + public bool TryGetSeed(PKM pk, out ulong seed) + { + // Check if it matches any single-roll seed. + var param = GetParams(); + var solver = new XoroMachineSkip(pk.EncryptionConstant, pk.PID); + foreach (var s in solver) + { + if (!Overworld8aRNG.Verify(pk, s, param, HasFixedHeight, HasFixedWeight)) + continue; + seed = s; + return true; + } + seed = default; + return false; + } } diff --git a/PKHeX.Core/Legality/RNG/Methods/Gen8a/Overworld8aRNG.cs b/PKHeX.Core/Legality/RNG/Methods/Gen8a/Overworld8aRNG.cs index d6e45aaa1..f8bffe86c 100644 --- a/PKHeX.Core/Legality/RNG/Methods/Gen8a/Overworld8aRNG.cs +++ b/PKHeX.Core/Legality/RNG/Methods/Gen8a/Overworld8aRNG.cs @@ -201,7 +201,8 @@ public static class Overworld8aRNG _ => Shiny.Never, }; - public static bool Verify(PKM pk, ulong seed, in OverworldParam8a para) + public static bool Verify(PKM pk, ulong seed, in OverworldParam8a para, + bool isFixedH = false, bool isFixedW = false) { var rand = new Xoroshiro128Plus(seed); var ec = (uint)rand.NextInt(); @@ -290,9 +291,9 @@ public static class Overworld8aRNG if (pk is IScaledSize s) { - if (s.HeightScalar != height) + if (!isFixedH && s.HeightScalar != height) return false; - if (s.WeightScalar != weight) + if (!isFixedW && s.WeightScalar != weight) return false; } diff --git a/PKHeX.Core/Legality/RNG/PIDIV.cs b/PKHeX.Core/Legality/RNG/PIDIV.cs index 43eb4771e..cb71236b7 100644 --- a/PKHeX.Core/Legality/RNG/PIDIV.cs +++ b/PKHeX.Core/Legality/RNG/PIDIV.cs @@ -52,7 +52,7 @@ public readonly struct PIDIV #endif public bool IsClassicMethod() => Type.IsClassicMethod(); - public bool IsSeed64() => Type is PIDType.Raid8; + public bool IsSeed64() => Type is PIDType.Xoroshiro; public PIDIV AsEncounteredVia(LeadSeed condition) => this with { Lead = condition.Lead, EncounterSeed = condition.Seed }; } diff --git a/PKHeX.Core/Legality/RNG/PIDType.cs b/PKHeX.Core/Legality/RNG/PIDType.cs index 08b21af60..48cf8b7cf 100644 --- a/PKHeX.Core/Legality/RNG/PIDType.cs +++ b/PKHeX.Core/Legality/RNG/PIDType.cs @@ -172,10 +172,10 @@ public enum PIDType : byte Pokewalker, /// - /// Generation 8 Raid PID + /// Generation 8 Xoroshiro correlation /// /// Formulaic based on PID & EC values from a 64bit-seed. - Raid8, + Xoroshiro, /// /// Generation 8 Overworld Spawn PID diff --git a/PKHeX.Core/Legality/Verifiers/MiscVerifier.cs b/PKHeX.Core/Legality/Verifiers/MiscVerifier.cs index 344dc24fe..13ab6c129 100644 --- a/PKHeX.Core/Legality/Verifiers/MiscVerifier.cs +++ b/PKHeX.Core/Legality/Verifiers/MiscVerifier.cs @@ -130,11 +130,8 @@ public sealed class MiscVerifier : Verifier else if (enc is ISeedCorrelation64 s64) { if (s64.TryGetSeed(pk, out var seed)) - data.Info.PIDIV = new PIDIV(PIDType.Raid8, seed); - } - else if (enc is IMasteryInitialMoveShop8 m) - { - if (!m.IsForcedMasteryCorrect(pk)) + data.Info.PIDIV = new PIDIV(PIDType.Xoroshiro, seed); + if (enc is IMasteryInitialMoveShop8 m && !m.IsForcedMasteryCorrect(pk)) data.AddLine(GetInvalid(LEncMasteryInitial)); }