diff --git a/PKHeX.Core/Items/ItemStorage9ZA.cs b/PKHeX.Core/Items/ItemStorage9ZA.cs
index e3f12827a..afdbe10c3 100644
--- a/PKHeX.Core/Items/ItemStorage9ZA.cs
+++ b/PKHeX.Core/Items/ItemStorage9ZA.cs
@@ -210,7 +210,7 @@ public static InventoryType GetInventoryPouch(ushort itemIndex)
Feraligatr when form == 1 => 2564,
Skarmory when form == 1 => 2565,
Froslass when form == 1 => 2566,
- Emboar when form == 1 => 2569,
+ Emboar when form == 1 => 2569,
Excadrill when form == 1 => 2570,
Scolipede when form == 1 => 2571,
Scrafty when form == 1 => 2572,
@@ -228,6 +228,24 @@ public static InventoryType GetInventoryPouch(ushort itemIndex)
Zygarde when form == 5 => 2584,
Drampa when form == 1 => 2585,
Falinks when form == 1 => 2587,
+
+ // DLC Mega Stones
+ Raichu when form == 1 => 2635, // X
+ Raichu when form == 2 => 2636, // Y
+ Chimecho when form == 1 => 2637,
+ Absol when form == 2 => 2638, // ZA
+ Staraptor when form == 1 => 2639,
+ Garchomp when form == 2 => 2640, // ZA
+ Lucario when form == 2 => 2641, // ZA
+ Golurk when form == 1 => 2642,
+ Meowstic when form == 2 => 2643,
+ Crabominable when form == 1 => 2644,
+ Golisopod when form == 1 => 2645,
+ Magearna when form == 2 => 2646,
+ Scovillain when form == 1 => 2647,
+ Baxcalibur when form == 1 => 2648,
+ Tatsugiri when form >= 3 => 2649,
+ Glimmora when form == 1 => 2650,
_ => 0,
};
}
diff --git a/PKHeX.Core/Saves/Substructures/Gen9/ZA/MyItem9a.cs b/PKHeX.Core/Saves/Substructures/Gen9/ZA/MyItem9a.cs
index 9a8106231..45ae67f69 100644
--- a/PKHeX.Core/Saves/Substructures/Gen9/ZA/MyItem9a.cs
+++ b/PKHeX.Core/Saves/Substructures/Gen9/ZA/MyItem9a.cs
@@ -41,7 +41,14 @@ public void SetItemQuantity(ushort itemIndex, int quantity)
var item = InventoryItem9a.Read(itemIndex, span);
item.Count = quantity;
item.Pouch = GetPouchIndex(GetType(itemIndex));
- item.IsUpdated = true;
+
+ if (item.IsNewNotify && quantity != 0)
+ {
+ // Show popup, treat as new.
+ item.IsNewNotify = false;
+ item.IsNew = true;
+ }
+
item.Write(span);
}
diff --git a/PKHeX.Core/Saves/Substructures/Inventory/Item/InventoryItem9a.cs b/PKHeX.Core/Saves/Substructures/Inventory/Item/InventoryItem9a.cs
index 2207d9872..127e32a83 100644
--- a/PKHeX.Core/Saves/Substructures/Inventory/Item/InventoryItem9a.cs
+++ b/PKHeX.Core/Saves/Substructures/Inventory/Item/InventoryItem9a.cs
@@ -21,13 +21,23 @@ public sealed record InventoryItem9a : InventoryItem, IItemFavorite, IItemNewFla
public uint Flags { get; set; }
public uint Padding { get; set; }
- public bool IsNew { get => (Flags & 0x1) != 0; set => Flags = (Flags & ~0x1u) | (value ? 0x1u : 0x0u); } // red dot
- public bool IsFavorite { get => (Flags & 0x2) != 0; set => Flags = (Flags & ~0x2u) | (value ? 0x2u : 0x0u); }
- public bool IsUpdated { get => (Flags & 0x4) != 0; set => Flags = (Flags & ~0x4u) | (value ? 0x4u : 0x0u); } // always true if pouch is set
- public bool IsNewShop { get => (Flags & 0x8) != 0; set => Flags = (Flags & ~0x8u) | (value ? 0x8u : 0x0u); }
- public bool IsHeld { get => (Flags & 0x10) != 0; set => Flags = (Flags & ~0x10u) | (value ? 0x10u : 0x0u); } // only for Mega Stones currently held by a Pokémon
+ /// Indicates the red dot in the inventory pouch list that the item hasn't been looked at yet by the player.
+ public bool IsNew { get => (Flags & 0x1) != 0; set => Flags = (Flags & ~0x1u) | (value ? 0x1u : 0x0u); }
- private const byte DefaultFlagValue = 0b0_1101;
+ /// The player has marked it as a favorite item (for sorting).
+ public bool IsFavorite { get => (Flags & 0x2) != 0; set => Flags = (Flags & ~0x2u) | (value ? 0x2u : 0x0u); }
+
+ /// Flyout notification will show "NEW" when item is picked up. When clearing this flag, the flag is set, however, the initial flag value already has it set.
+ /// Will always false if any quantity of the item has been acquired.
+ public bool IsNewNotify { get => (Flags & 0x4) != 0; set => Flags = (Flags & ~0x4u) | (value ? 0x4u : 0x0u); }
+
+ /// Indicates the item is newly available for purchase in shops. Similar to , but for shop inventory listing.
+ public bool IsNewShop { get => (Flags & 0x8) != 0; set => Flags = (Flags & ~0x8u) | (value ? 0x8u : 0x0u); }
+
+ /// Indicates the item is currently being held by a Pokémon. Only applicable to Mega Stones in this game.
+ public bool IsHeld { get => (Flags & 0x10) != 0; set => Flags = (Flags & ~0x10u) | (value ? 0x10u : 0x0u); }
+
+ private const byte DefaultFlagValue = 0b0_1101; // New in Shop, Not Notified yet, Not Favorite, New in Inventory (redundant)
public override string ToString() => $"{Index:000} x{Count}{(IsNew ? "*" : "")}{(IsFavorite ? "F" : "")} - {Flags:X8}";
@@ -54,7 +64,9 @@ public static InventoryItem9a Read(ushort index, ReadOnlySpan data) => new
public void Write(Span data)
{
- IsUpdated = Pouch != PouchNone;
+ // Ensure the updated flag state is as expected.
+ if (Pouch == PouchNone)
+ Flags = DefaultFlagValue;
// Index is not saved.
WriteUInt32LittleEndian(data, Pouch);
diff --git a/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouch9a.cs b/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouch9a.cs
index fe2ff77b3..65ac7a693 100644
--- a/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouch9a.cs
+++ b/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouch9a.cs
@@ -77,22 +77,10 @@ private void EnsureFlagsConsistent(InventoryItem9a item, InventoryItem9a origina
if (item.Count != 0)
{
// Ensure the flag is set; 0->X and Y->Z
- item.IsUpdated = true;
- if (!original.IsUpdated && SetNew)
+ if (original.IsNewNotify && SetNew)
item.IsNew = true;
+ item.IsNewNotify = false;
}
- else
- {
- if (!item.IsUpdated)
- {
- item.IsNew = item.IsFavorite = false;
- if (item.Pouch is not (0 or uint.MaxValue))
- item.Pouch = 0;
- }
- }
-
- if (item.IsUpdated)
- item.Pouch = PouchIndex; // ensure the pouch is set
}
public static void SetQuantityZero(Span block, ushort index)
@@ -102,7 +90,10 @@ public static void SetQuantityZero(Span block, ushort index)
if (exist.Count == 0)
return;
exist.Count = 0;
- exist.IsUpdated = true;
+ if (exist.IsValidPouch)
+ exist.IsNewNotify = false; // exist was nonzero, must not have the flag.
+ else
+ exist.Clear();
exist.Write(span);
}
}