From 6edae7cf6c89186ff95cc64359153e6a7b356c19 Mon Sep 17 00:00:00 2001 From: obligaron Date: Sun, 29 Jan 2023 19:43:15 +0100 Subject: [PATCH] Ensure Spectral Elixir is only usable after black mushroom quest is finished --- Source/itemdat.cpp | 4 ++-- Source/itemdat.h | 2 +- Source/player.h | 2 ++ Source/towners.cpp | 5 ++++- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Source/itemdat.cpp b/Source/itemdat.cpp index ca3dcc982..a1108cfbf 100644 --- a/Source/itemdat.cpp +++ b/Source/itemdat.cpp @@ -47,7 +47,7 @@ string_view ItemTypeToString(ItemType itemType) } /** Contains the data related to each item ID. */ -ItemData AllItemsList[] = { +const ItemData AllItemsList[] = { // clang-format off // _item_indexes iRnd, iClass, iLoc, iCurs, itype, iItemId, iName, iSName, iMinMLvl, iDurability, iMinDam, iMaxDam, iMinAC, iMaxAC, iMinStr, iMinMag, iMinDex, iFlags, iMiscId, iSpell, iUsable, iValue /*IDI_GOLD */ { IDROP_REGULAR, ICLASS_GOLD, ILOC_UNEQUIPABLE, ICURS_GOLD, ItemType::Gold, UITYPE_NONE, N_("Gold"), nullptr, 1, 0, 0, 0, 0, 0, 0, 0, 0, ItemSpecialEffect::None, IMISC_NONE, SpellID::Null, true, 0 }, @@ -70,7 +70,7 @@ ItemData AllItemsList[] = { /*IDI_MUSHROOM */ { IDROP_NEVER, ICLASS_QUEST, ILOC_UNEQUIPABLE, ICURS_BLACK_MUSHROOM, ItemType::Misc, UITYPE_NONE, N_("Black Mushroom"), nullptr, 0, 0, 0, 0, 0, 0, 0, 0, 0, ItemSpecialEffect::None, IMISC_NONE, SpellID::Null, false, 0 }, /*IDI_BRAIN */ { IDROP_NEVER, ICLASS_QUEST, ILOC_UNEQUIPABLE, ICURS_BRAIN, ItemType::Misc, UITYPE_NONE, N_("Brain"), nullptr, 0, 0, 0, 0, 0, 0, 0, 0, 0, ItemSpecialEffect::None, IMISC_NONE, SpellID::Null, false, 0 }, /*IDI_FUNGALTM */ { IDROP_NEVER, ICLASS_QUEST, ILOC_UNEQUIPABLE, ICURS_FUNGAL_TOME, ItemType::Misc, UITYPE_NONE, N_("Fungal Tome"), nullptr, 0, 0, 0, 0, 0, 0, 0, 0, 0, ItemSpecialEffect::None, IMISC_NONE, SpellID::Null, false, 0 }, -/*IDI_SPECELIX */ { IDROP_NEVER, ICLASS_MISC, ILOC_UNEQUIPABLE, ICURS_SPECTRAL_ELIXIR, ItemType::Misc, UITYPE_ELIXIR, N_("Spectral Elixir"), nullptr, 15, 0, 0, 0, 0, 0, 0, 0, 0, ItemSpecialEffect::None, IMISC_SPECELIX, SpellID::Null, false, 0 }, +/*IDI_SPECELIX */ { IDROP_NEVER, ICLASS_MISC, ILOC_UNEQUIPABLE, ICURS_SPECTRAL_ELIXIR, ItemType::Misc, UITYPE_ELIXIR, N_("Spectral Elixir"), nullptr, 15, 0, 0, 0, 0, 0, 0, 0, 0, ItemSpecialEffect::None, IMISC_SPECELIX, SpellID::Null, true, 0 }, /*IDI_BLDSTONE */ { IDROP_NEVER, ICLASS_QUEST, ILOC_UNEQUIPABLE, ICURS_BLOOD_STONE, ItemType::Misc, UITYPE_NONE, N_("Blood Stone"), nullptr, 0, 0, 0, 0, 0, 0, 0, 0, 0, ItemSpecialEffect::None, IMISC_NONE, SpellID::Null, false, 0 }, /*IDI_MAPOFDOOM */ { IDROP_NEVER, ICLASS_QUEST, ILOC_UNEQUIPABLE, ICURS_MAP_OF_THE_STARS, ItemType::Misc, UITYPE_MAPOFDOOM, N_("Cathedral Map"), nullptr, 0, 0, 0, 0, 0, 0, 0, 0, 0, ItemSpecialEffect::None, IMISC_MAPOFDOOM, SpellID::Null, true, 0 }, /*IDI_EAR */ { IDROP_NEVER, ICLASS_QUEST, ILOC_UNEQUIPABLE, ICURS_EAR_SORCERER, ItemType::Misc, UITYPE_NONE, N_("Heart"), nullptr, 0, 0, 0, 0, 0, 0, 0, 0, 0, ItemSpecialEffect::None, IMISC_EAR, SpellID::Null, false, 0 }, diff --git a/Source/itemdat.h b/Source/itemdat.h index f57945067..b52c8cd88 100644 --- a/Source/itemdat.h +++ b/Source/itemdat.h @@ -590,7 +590,7 @@ struct UniqueItem { ItemPower powers[6]; }; -extern ItemData AllItemsList[]; +extern const ItemData AllItemsList[]; extern const PLStruct ItemPrefixes[]; extern const PLStruct ItemSuffixes[]; extern const UniqueItem UniqueItems[]; diff --git a/Source/player.h b/Source/player.h index 36f453cd3..c34817192 100644 --- a/Source/player.h +++ b/Source/player.h @@ -372,6 +372,8 @@ struct Player { bool CanUseItem(const Item &item) const { + if (item.IDidx == IDI_SPECELIX && Quests[Q_MUSHROOM]._qactive != QUEST_DONE) + return false; return _pStrength >= item._iMinStr && _pMagic >= item._iMinMag && _pDexterity >= item._iMinDex; diff --git a/Source/towners.cpp b/Source/towners.cpp index eb327e5ca..7b3896137 100644 --- a/Source/towners.cpp +++ b/Source/towners.cpp @@ -449,7 +449,10 @@ void TalkToWitch(Player &player, Towner & /*witch*/) if (HasInventoryOrBeltItemWithId(player, IDI_SPECELIX)) { InitQTextMsg(TEXT_MUSH12); Quests[Q_MUSHROOM]._qactive = QUEST_DONE; - AllItemsList[IDI_SPECELIX].iUsable = true; /// BUGFIX: This will cause the elixir to be usable in the next game + // Ensure Spectral Elixir is usable after the quest is finished + for (Item &item : InventoryAndBeltPlayerItemsRange { player }) { + item.updateRequiredStatsCacheForPlayer(player); + } return; } }