From 90e5776dbccc7fd770b5836006e537569c8e536e Mon Sep 17 00:00:00 2001 From: Kurt Date: Thu, 3 Jan 2019 21:29:19 -0800 Subject: [PATCH] Update ereader 0IV detection the ereader mons are nature/gender locked too, so unroll a little prior to rechecking the overall team (with ereader mon included). Have to do it this way as a lock can pop if the ereader data matches a prior spread before the prior teammate can be generated. --- .../Encounters/Data/Encounters3Shadow.cs | 5 +++- .../Generator/EncounterGenerator.cs | 29 ++++++++++++++++--- PKHeX.Core/Legality/RNG/MethodFinder.cs | 18 ++++++++++-- 3 files changed, 45 insertions(+), 7 deletions(-) diff --git a/PKHeX.Core/Legality/Encounters/Data/Encounters3Shadow.cs b/PKHeX.Core/Legality/Encounters/Data/Encounters3Shadow.cs index 1013498dd..c76dcdb17 100644 --- a/PKHeX.Core/Legality/Encounters/Data/Encounters3Shadow.cs +++ b/PKHeX.Core/Legality/Encounters/Data/Encounters3Shadow.cs @@ -49,9 +49,10 @@ public static class Encounters3Shadow public static readonly TeamLock ETogepi = new TeamLock { Species = 175, // Togepi Locks = new[] { - new NPCLock(302, 23, 0, 025), // Sableye (M) (Careful) + new NPCLock(302, 23, 0, 127), // Sableye (M) (Careful) new NPCLock(088, 08, 0, 127), // Grimer (M) (Impish) new NPCLock(316, 24, 0, 127), // Gulpin (M) (Quirky) + new NPCLock(175, 22, 1, 031), // Togepi (F) (Sassy) -- itself! }}; public static readonly TeamLock EMareep = new TeamLock { @@ -60,6 +61,7 @@ public static class Encounters3Shadow new NPCLock(300, 04, 1, 191), // Skitty (F) (Naughty) new NPCLock(211, 10, 1, 127), // Qwilfish (F) (Timid) new NPCLock(355, 12, 1, 127), // Duskull (F) (Serious) + new NPCLock(179, 16, 1, 127), // Mareep (F) (Mild) -- itself! }}; public static readonly TeamLock EScizor = new TeamLock { @@ -68,6 +70,7 @@ public static class Encounters3Shadow new NPCLock(198, 13, 1, 191), // Murkrow (F) (Jolly) new NPCLock(344, 02, 2, 256), // Claydol (-) (Brave) new NPCLock(208, 03, 0, 127), // Steelix (M) (Adamant) + new NPCLock(212, 11, 0, 127), // Scizor (M) (Hasty) -- itself! }}; #endregion diff --git a/PKHeX.Core/Legality/Encounters/Generator/EncounterGenerator.cs b/PKHeX.Core/Legality/Encounters/Generator/EncounterGenerator.cs index 35d1f6752..41f86644a 100644 --- a/PKHeX.Core/Legality/Encounters/Generator/EncounterGenerator.cs +++ b/PKHeX.Core/Legality/Encounters/Generator/EncounterGenerator.cs @@ -61,17 +61,38 @@ private static IEnumerable GetEncounters3(PKM pkm, LegalInfo inf var deferred = new List(); foreach (var z in GenerateRawEncounters3(pkm, info)) { - if (pkm.Version == 15) + if (pkm.Version == (int)GameVersion.CXD) // C/XD { if (z is EncounterSlot w) { var seeds = MethodFinder.GetPokeSpotSeeds(pkm, w.SlotNumber).FirstOrDefault(); info.PIDIV = seeds ?? info.PIDIV; } - else if (z is EncounterStaticShadow s && !LockFinder.IsAllShadowLockValid(s, info.PIDIV, pkm)) + else if (z is EncounterStaticShadow s) { - deferred.Add(s); - continue; + bool valid = false; + if (s.IVs == null) // not ereader + { + valid = !LockFinder.IsAllShadowLockValid(s, info.PIDIV, pkm); + } + else + { + var possible = MethodFinder.GetColoEReaderMatches(pkm.EncryptionConstant); + foreach (var poss in possible) + { + if (!LockFinder.IsAllShadowLockValid(s, poss, pkm)) + continue; + valid = true; + info.PIDIV = poss; + break; + } + } + + if (!valid) + { + deferred.Add(s); + continue; + } } } if (info.PIDIV.Type.IsCompatible3(z, pkm)) diff --git a/PKHeX.Core/Legality/RNG/MethodFinder.cs b/PKHeX.Core/Legality/RNG/MethodFinder.cs index 888a89a48..c21f11ef6 100644 --- a/PKHeX.Core/Legality/RNG/MethodFinder.cs +++ b/PKHeX.Core/Legality/RNG/MethodFinder.cs @@ -628,6 +628,22 @@ private static uint GetIVChunk(uint[] IVs, int start) return val; } + public static IEnumerable GetColoEReaderMatches(uint PID) + { + var top = PID >> 16; + var bot = (ushort)PID; + var xdc = GetSeedsFromPIDEuclid(RNG.XDRNG, top, bot); + foreach (var seed in xdc) + { + var B = RNG.XDRNG.Prev(seed); + var A = RNG.XDRNG.Prev(B); + + var C = RNG.XDRNG.Advance(A, 7); + + yield return new PIDIV { OriginSeed = RNG.XDRNG.Prev(C), RNG = RNG.XDRNG, Type = PIDType.CXD }; + } + } + public static IEnumerable GetPokeSpotSeeds(PKM pkm, int slot) { // Activate (rand % 3) @@ -694,8 +710,6 @@ public static bool IsCompatible3(this PIDType val, IEncounterable encounter, PKM return true; // forced shiny eggs, when hatched, can lose their detectable correlation. return g.IsEgg && !pkm.IsEgg && val == PIDType.None && (g.Method == PIDType.BACD_R_S || g.Method == PIDType.BACD_U_S); - case EncounterStaticShadow d when d.EReader: - return val == PIDType.None; // All IVs are 0 case EncounterStatic s: switch (pkm.Version) {