Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revise Spectral Usability #7662

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions Source/inv.h
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,24 @@ 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)
{
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.
*/
Expand Down
7 changes: 6 additions & 1 deletion Source/items.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
1 change: 1 addition & 0 deletions Source/towners.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading