From 2a2361220d1e7db13aeee647741ba5e7bf3b5f6f Mon Sep 17 00:00:00 2001 From: Kurt Date: Sun, 30 Sep 2018 21:27:36 -0700 Subject: [PATCH] Add more accurate daycare egg detection uses eventflag, different index for each game frlg: https://www.pokecommunity.com/showthread.php?t=302347 "Flag 0x266 is set by the game engine if an Egg is in the Daycare." emerald: https://www.pokecommunity.com/showthread.php?t=330008 "0x86 : Daycare Centre has egg" rs: https://gist.github.com/rboninsegna/a4a63c2b66c42e371a94f860eae55361 " 0x86 Egg ready at Daycare" --- PKHeX.Core/Saves/SAV3.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/PKHeX.Core/Saves/SAV3.cs b/PKHeX.Core/Saves/SAV3.cs index cefed1ff0..5adf604e3 100644 --- a/PKHeX.Core/Saves/SAV3.cs +++ b/PKHeX.Core/Saves/SAV3.cs @@ -557,12 +557,10 @@ public override InventoryPouch[] Inventory public override bool? IsDaycareOccupied(int loc, int slot) => IsPKMPresent(GetDaycareSlotOffset(loc, slot)); public override void SetDaycareOccupied(int loc, int slot, bool occupied) { } public override int GetDaycareSlotOffset(int loc, int slot) => Daycare + (slot * DaycareSlotSize); - public override bool? IsDaycareHasEgg(int loc) => GetDaycareRNGSeed(loc).Any(z => z != '0'); - public override void SetDaycareHasEgg(int loc, bool hasEgg) - { - SetDaycareRNGSeed(loc, E ? Util.Rand32().ToString("X8") : Util.Rand.Next(0x10000).ToString("X4")); - } + private int EggEventFlag => GameVersion.FRLG.Contains(Version) ? 0x266 : 0x86; + public override bool? IsDaycareHasEgg(int loc) => GetEventFlag(EggEventFlag); + public override void SetDaycareHasEgg(int loc, bool hasEgg) => SetEventFlag(EggEventFlag, hasEgg); private int GetDaycareEXPOffset(int slot) {