From 52b3ace59817b56551744caaf52a8ea9064f65a1 Mon Sep 17 00:00:00 2001 From: Eric Robinson Date: Fri, 17 Jan 2025 15:18:31 -0500 Subject: [PATCH 1/2] Revise Spectral Usability --- Source/inv.h | 21 +++++++++++++++++++++ Source/items.cpp | 7 ++++++- Source/towners.cpp | 1 + 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/Source/inv.h b/Source/inv.h index 4a1d56c70..4a460ad5e 100644 --- a/Source/inv.h +++ b/Source/inv.h @@ -384,6 +384,27 @@ inline bool RemoveInventoryOrBeltItemById(Player &player, _item_indexes id) return RemoveInventoryItemById(player, id) || RemoveBeltItemById(player, id); } +/** + * @brief Marks all Spectral Elixir items in the player's inventory as permanently usable + * by setting the CF_USEFUL flag in the item's creation info. + * + * This ensures that Spectral Elixirs remain usable across game sessions, regardless of + * quest status, while maintaining reverse compatibility with the original game. + * + * @param player The player whose inventory is being updated. + */ +inline void SetSpectralUsable(Player &player) +{ + if (player.InvList->isEmpty()) + return; + + for (Item &item : player.InvList) { + if (item.IDidx == IDI_SPECELIX) { + item._iCreateInfo |= CF_ONLYGOOD; // Set the unused flag to mark as permanently usable + } + } +} + /** * @brief Removes the first inventory or belt scroll with the player's current spell. */ diff --git a/Source/items.cpp b/Source/items.cpp index bb817163d..2875bf2c4 100644 --- a/Source/items.cpp +++ b/Source/items.cpp @@ -4779,8 +4779,13 @@ void PutItemRecord(uint32_t nSeed, uint16_t wCI, int nIndex) bool Item::isUsable() const { - if (IDidx == IDI_SPECELIX && Quests[Q_MUSHROOM]._qactive != QUEST_DONE) + // If the item is a Spectral Elixir + if (IDidx == IDI_SPECELIX) { + if ((_iCreateInfo & CF_ONLYGOOD) != 0 || Quests[Q_MUSHROOM]._qactive == QUEST_DONE) + return true; return false; + } + return AllItemsList[IDidx].iUsable; } diff --git a/Source/towners.cpp b/Source/towners.cpp index d07d45cfb..842b08e9a 100644 --- a/Source/towners.cpp +++ b/Source/towners.cpp @@ -450,6 +450,7 @@ void TalkToWitch(Player &player, Towner & /*witch*/) return; } if (HasInventoryOrBeltItemWithId(player, IDI_SPECELIX)) { + SetSpectralUsable(player); Quests[Q_MUSHROOM]._qactive = QUEST_DONE; NetSendCmdQuest(true, Quests[Q_MUSHROOM]); InitQTextMsg(TEXT_MUSH12); From 24e53bc883c800b30cd044ec5f5c365efd525ce6 Mon Sep 17 00:00:00 2001 From: Eric Robinson Date: Fri, 17 Jan 2025 15:19:21 -0500 Subject: [PATCH 2/2] Update inv.h --- Source/inv.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/Source/inv.h b/Source/inv.h index 4a460ad5e..f475e3cc2 100644 --- a/Source/inv.h +++ b/Source/inv.h @@ -395,9 +395,6 @@ inline bool RemoveInventoryOrBeltItemById(Player &player, _item_indexes id) */ inline void SetSpectralUsable(Player &player) { - if (player.InvList->isEmpty()) - return; - for (Item &item : player.InvList) { if (item.IDidx == IDI_SPECELIX) { item._iCreateInfo |= CF_ONLYGOOD; // Set the unused flag to mark as permanently usable