From 2d4e84c561648f21110892fccb0e0a9b62ed0e7a Mon Sep 17 00:00:00 2001 From: obligaron Date: Mon, 2 Jan 2023 12:55:43 +0100 Subject: [PATCH] Multiplayer: Enable Black Mushroom Quest --- Source/inv.cpp | 1 + Source/objects.cpp | 13 +++++++++---- Source/towners.cpp | 7 ++++++- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/Source/inv.cpp b/Source/inv.cpp index 4615ab6569e..8bfd95a4566 100644 --- a/Source/inv.cpp +++ b/Source/inv.cpp @@ -897,6 +897,7 @@ void CheckQuestItem(Player &player, Item &questItem) if (questItem.IDidx == IDI_MUSHROOM && Quests[Q_MUSHROOM]._qactive == QUEST_ACTIVE && Quests[Q_MUSHROOM]._qvar1 == QS_MUSHSPAWNED) { player.Say(HeroSpeech::NowThatsOneBigMushroom, 10); // BUGFIX: Voice for this quest might be wrong in MP Quests[Q_MUSHROOM]._qvar1 = QS_MUSHPICKED; + NetSendCmdQuest(true, Quests[Q_MUSHROOM]); } if (questItem.IDidx == IDI_ANVIL && Quests[Q_ANVIL]._qactive != QUEST_NOTAVAIL) { diff --git a/Source/objects.cpp b/Source/objects.cpp index eb354c52688..aca7239ac42 100644 --- a/Source/objects.cpp +++ b/Source/objects.cpp @@ -2140,8 +2140,13 @@ void OperateMushroomPatch(const Player &player, Object &mushroomPatch) PlaySfxLoc(IS_CHEST, mushroomPatch.position); Point pos = GetSuperItemLoc(mushroomPatch.position); - SpawnQuestItem(IDI_MUSHROOM, pos, 0, 0, true); - Quests[Q_MUSHROOM]._qvar1 = QS_MUSHSPAWNED; + + if (&player == MyPlayer) { + SpawnQuestItem(IDI_MUSHROOM, pos, 0, 0, true); + Quests[Q_MUSHROOM]._qvar1 = QS_MUSHSPAWNED; + NetSendCmdQuest(true, Quests[Q_MUSHROOM]); + NetSendCmdLoc(MyPlayerId, false, CMD_OPERATEOBJ, mushroomPatch.position); + } } void OperateInnSignChest(const Player &player, Object &questContainer, bool sendmsg) @@ -3810,7 +3815,7 @@ void InitObjects() AdvanceRndSeed(); if (currlevel == 9 && !gbIsMultiplayer) AddSlainHero(); - if (currlevel == Quests[Q_MUSHROOM]._qlevel && Quests[Q_MUSHROOM]._qactive == QUEST_INIT) + if (Quests[Q_MUSHROOM].IsAvailable()) AddMushPatch(); if (currlevel == 4 || currlevel == 8 || currlevel == 12) @@ -4538,7 +4543,7 @@ void DeltaSyncOpObject(Object &object) UpdateState(object, 3); break; case OBJ_MUSHPATCH: - if (Quests[Q_MUSHROOM]._qactive == QUEST_ACTIVE) { + if (Quests[Q_MUSHROOM]._qvar1 >= QS_MUSHSPAWNED) { UpdateState(object, object._oAnimFrame + 1); } break; diff --git a/Source/towners.cpp b/Source/towners.cpp index 7b389613733..52940b03288 100644 --- a/Source/towners.cpp +++ b/Source/towners.cpp @@ -421,6 +421,7 @@ void TalkToWitch(Player &player, Towner & /*witch*/) Quests[Q_MUSHROOM]._qactive = QUEST_ACTIVE; Quests[Q_MUSHROOM]._qlog = true; Quests[Q_MUSHROOM]._qvar1 = QS_TOMEGIVEN; + NetSendCmdQuest(true, Quests[Q_MUSHROOM]); InitQTextMsg(TEXT_MUSH8); return; } @@ -431,11 +432,13 @@ void TalkToWitch(Player &player, Towner & /*witch*/) QuestDialogTable[TOWN_HEALER][Q_MUSHROOM] = TEXT_MUSH3; QuestDialogTable[TOWN_WITCH][Q_MUSHROOM] = TEXT_NONE; Quests[Q_MUSHROOM]._qmsg = TEXT_MUSH10; + NetSendCmdQuest(true, Quests[Q_MUSHROOM]); InitQTextMsg(TEXT_MUSH10); return; } if (Quests[Q_MUSHROOM]._qmsg != TEXT_MUSH9) { Quests[Q_MUSHROOM]._qmsg = TEXT_MUSH9; + NetSendCmdQuest(true, Quests[Q_MUSHROOM]); InitQTextMsg(TEXT_MUSH9); return; } @@ -443,12 +446,13 @@ void TalkToWitch(Player &player, Towner & /*witch*/) if (Quests[Q_MUSHROOM]._qvar1 >= QS_MUSHGIVEN) { if (HasInventoryItemWithId(player, IDI_BRAIN)) { Quests[Q_MUSHROOM]._qmsg = TEXT_MUSH11; + NetSendCmdQuest(true, Quests[Q_MUSHROOM]); InitQTextMsg(TEXT_MUSH11); return; } if (HasInventoryOrBeltItemWithId(player, IDI_SPECELIX)) { - InitQTextMsg(TEXT_MUSH12); Quests[Q_MUSHROOM]._qactive = QUEST_DONE; + NetSendCmdQuest(true, Quests[Q_MUSHROOM]); // Ensure Spectral Elixir is usable after the quest is finished for (Item &item : InventoryAndBeltPlayerItemsRange { player }) { item.updateRequiredStatsCacheForPlayer(player); @@ -508,6 +512,7 @@ void TalkToHealer(Player &player, Towner &healer) InitQTextMsg(TEXT_MUSH4); Quests[Q_MUSHROOM]._qvar1 = QS_BRAINGIVEN; QuestDialogTable[TOWN_HEALER][Q_MUSHROOM] = TEXT_NONE; + NetSendCmdQuest(true, Quests[Q_MUSHROOM]); return; } }