diff --git a/Source/items.cpp b/Source/items.cpp index 71b15fd62..bc85a3b4e 100644 --- a/Source/items.cpp +++ b/Source/items.cpp @@ -2208,7 +2208,7 @@ void RecreateTownItem(const Player &player, Item &item, _item_indexes idx, uint1 RecreateHealerItem(player, item, idx, icreateinfo & CF_LEVEL, iseed); } -void CreateMagicItem(Point position, int lvl, ItemType itemType, int imid, int icurs, bool sendmsg, bool delta) +void CreateMagicItem(Point position, int lvl, ItemType itemType, int imid, int icurs, bool sendmsg, bool delta, bool spawn = false) { if (ActiveItemCount >= MAXITEMS) return; @@ -2231,6 +2231,8 @@ void CreateMagicItem(Point position, int lvl, ItemType itemType, int imid, int i NetSendCmdPItem(false, CMD_DROPITEM, item.position, item); if (delta) DeltaAddItem(ii); + if (spawn) + NetSendCmdPItem(false, CMD_SPAWNITEM, item.position, item); } void NextItemRecord(int i) @@ -4515,9 +4517,9 @@ void CreateMagicArmor(Point position, ItemType itemType, int icurs, bool sendmsg CreateMagicItem(position, lvl, itemType, IMISC_NONE, icurs, sendmsg, delta); } -void CreateAmulet(Point position, int lvl, bool sendmsg, bool delta) +void CreateAmulet(Point position, int lvl, bool sendmsg, bool delta, bool spawn /*= false*/) { - CreateMagicItem(position, lvl, ItemType::Amulet, IMISC_AMULET, ICURS_AMULET, sendmsg, delta); + CreateMagicItem(position, lvl, ItemType::Amulet, IMISC_AMULET, ICURS_AMULET, sendmsg, delta, spawn); } void CreateMagicWeapon(Point position, ItemType itemType, int icurs, bool sendmsg, bool delta) diff --git a/Source/items.h b/Source/items.h index de6152f47..0ece49908 100644 --- a/Source/items.h +++ b/Source/items.h @@ -549,7 +549,7 @@ void MakeGoldStack(Item &goldItem, int value); int ItemNoFlippy(); void CreateSpellBook(Point position, SpellID ispell, bool sendmsg, bool delta); void CreateMagicArmor(Point position, ItemType itemType, int icurs, bool sendmsg, bool delta); -void CreateAmulet(Point position, int lvl, bool sendmsg, bool delta); +void CreateAmulet(Point position, int lvl, bool sendmsg, bool delta, bool spawn = false); void CreateMagicWeapon(Point position, ItemType itemType, int icurs, bool sendmsg, bool delta); bool GetItemRecord(uint32_t nSeed, uint16_t wCI, int nIndex); void SetItemRecord(uint32_t nSeed, uint16_t wCI, int nIndex); diff --git a/Source/quests.cpp b/Source/quests.cpp index e490bcd91..9c769dc1e 100644 --- a/Source/quests.cpp +++ b/Source/quests.cpp @@ -930,9 +930,12 @@ void SetMultiQuest(int q, quest_state s, bool log, int v1, int v2, int16_t qmsg) // Ensure that changes on another client is also updated on our own ResyncQuests(); + bool questGotCompleted = oldQuestState != QUEST_DONE && quest._qactive == QUEST_DONE; // Ensure that water also changes for remote players - if (quest._qidx == Q_PWATER && oldQuestState == QUEST_ACTIVE && quest._qactive == QUEST_DONE && MyPlayer->isOnLevel(quest._qslvl)) + if (quest._qidx == Q_PWATER && questGotCompleted && MyPlayer->isOnLevel(quest._qslvl)) StartPWaterPurify(); + if (quest._qidx == Q_GIRL && questGotCompleted && MyPlayer->isOnLevel(0)) + UpdateGirlAnimAfterQuestComplete(); } } diff --git a/Source/towners.cpp b/Source/towners.cpp index 1a20bf4f9..7f0da3083 100644 --- a/Source/towners.cpp +++ b/Source/towners.cpp @@ -750,11 +750,9 @@ void TalkToGirl(Player &player, Towner &girl) if (quest._qactive != QUEST_DONE && RemoveInventoryItemById(player, IDI_THEODORE)) { InitQTextMsg(TEXT_GIRL4); - CreateAmulet(girl.position, 13, true, false); + CreateAmulet(girl.position, 13, false, false, true); quest._qactive = QUEST_DONE; - auto curFrame = girl._tAnimFrame; - LoadTownerAnimations(girl, "towners\\girl\\girls1", 20, 6); - girl._tAnimFrame = std::min(curFrame, girl._tAnimLen - 1); + UpdateGirlAnimAfterQuestComplete(); if (gbIsMultiplayer) NetSendCmdQuest(true, quest); return; @@ -917,6 +915,16 @@ void TalkToTowner(Player &player, int t) towner.talk(player, towner); } +void UpdateGirlAnimAfterQuestComplete() +{ + Towner *girl = GetTowner(TOWN_GIRL); + if (girl == nullptr || !girl->ownedAnim) + return; // Girl is not spawned in town yet + auto curFrame = girl->_tAnimFrame; + LoadTownerAnimations(*girl, "towners\\girl\\girls1", 20, 6); + girl->_tAnimFrame = std::min(curFrame, girl->_tAnimLen - 1); +} + #ifdef _DEBUG bool DebugTalkToTowner(std::string targetName) { diff --git a/Source/towners.h b/Source/towners.h index 7e545cbf1..075bbfa50 100644 --- a/Source/towners.h +++ b/Source/towners.h @@ -80,6 +80,8 @@ void FreeTownerGFX(); void ProcessTowners(); void TalkToTowner(Player &player, int t); +void UpdateGirlAnimAfterQuestComplete(); + #ifdef _DEBUG bool DebugTalkToTowner(std::string targetName); #endif