From fda815c3e580846f3a9b741455c7d324e4969bbb Mon Sep 17 00:00:00 2001 From: Samuel Magnan Date: Sat, 28 Oct 2023 00:09:15 -0400 Subject: [PATCH] Gen2: Add MysteryGiftIsUnlocked flag in Simple Editor (#4007) The flag indicates whether the option "Mystery Gift" has been unlocked and it is displayed in the start menu. Note: It is unlocked after talking with the little girl on the fifth floor of the Goldenrod Department Store. --- PKHeX.Core/Saves/SAV2.cs | 20 +++++++++++++++++++ .../Saves/Substructures/Gen12/SAV2Offsets.cs | 4 ++++ 2 files changed, 24 insertions(+) diff --git a/PKHeX.Core/Saves/SAV2.cs b/PKHeX.Core/Saves/SAV2.cs index 7d9f6462e..efa044f21 100644 --- a/PKHeX.Core/Saves/SAV2.cs +++ b/PKHeX.Core/Saves/SAV2.cs @@ -507,6 +507,26 @@ public sealed class SAV2 : SaveFile, ILangDeviantSave, IEventFlagArray, IEventWo } } + public bool MysteryGiftIsUnlocked + { + get + { + int ofs = Offsets.MysteryGiftIsUnlocked; + if (ofs == -1) + return false; + return Data[ofs] == 0x00; + } + set + { + int ofs = Offsets.MysteryGiftIsUnlocked; + if (ofs == -1) + return; + + Data[ofs] = (byte)(value ? 0x00 : 0xFF); + Data[ofs + 2] = Data[ofs]; + } + } + public override IReadOnlyList Inventory { get diff --git a/PKHeX.Core/Saves/Substructures/Gen12/SAV2Offsets.cs b/PKHeX.Core/Saves/Substructures/Gen12/SAV2Offsets.cs index 270ab2599..b136c463a 100644 --- a/PKHeX.Core/Saves/Substructures/Gen12/SAV2Offsets.cs +++ b/PKHeX.Core/Saves/Substructures/Gen12/SAV2Offsets.cs @@ -46,6 +46,7 @@ internal sealed class SAV2Offsets public int Daycare { get; } public int BlueCardPoints { get; private set; } = -1; + public int MysteryGiftIsUnlocked { get; private set; } = -1; public int PouchTMHM { get; private set; } = -1; public int PouchItem { get; private set; } = -1; @@ -60,6 +61,8 @@ internal sealed class SAV2Offsets Rival = 0x2021; DaylightSavings = 0x2042; OtherCurrentBox = 0x284C; + MysteryGiftIsUnlocked = 0xBE3; // And 0xBE5; + switch (version) { case GameVersion.GS: @@ -125,6 +128,7 @@ internal sealed class SAV2Offsets Palette = 0x204C; CurrentBox = 0x2D10; OtherCurrentBox = 0x2842; + MysteryGiftIsUnlocked = 0xB51; // And 0xB53; switch (version) {