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

In multiplayer randomly drop unique quest reward or magic item of same type #5619

Merged
merged 1 commit into from
May 31, 2023
Merged
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
21 changes: 16 additions & 5 deletions Source/items.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3205,7 +3205,7 @@ void SetupItem(Item &item)
item._iIdentified = false;
}

Item *SpawnUnique(_unique_items uid, Point position, bool sendmsg /*= true*/)
Item *SpawnUnique(_unique_items uid, Point position, std::optional<int> level /*= std::nullopt*/, bool sendmsg /*= true*/)
{
if (ActiveItemCount >= MAXITEMS)
return nullptr;
Expand All @@ -3219,9 +3219,20 @@ Item *SpawnUnique(_unique_items uid, Point position, bool sendmsg /*= true*/)
while (AllItemsList[idx].iItemId != UniqueItems[uid].UIItemId)
idx++;

GetItemAttrs(item, static_cast<_item_indexes>(idx), curlv);
GetUniqueItem(*MyPlayer, item, uid);
SetupItem(item);
if (gbIsMultiplayer) {
if (level)
curlv = *level;
const ItemData &uniqueItemData = AllItemsList[idx];
_item_indexes idx = GetItemIndexForDroppableItem(false, [&uniqueItemData](const ItemData &item) {
return item.itype == uniqueItemData.itype || (uniqueItemData.itype == ItemType::Amulet && item.itype == ItemType::Ring);
});
SetupAllItems(*MyPlayer, item, idx, AdvanceRndSeed(), curlv * 2, 15, true, false, false);
AJenbo marked this conversation as resolved.
Show resolved Hide resolved
}
if (!gbIsMultiplayer || item._iMagical == ITEM_QUALITY_UNIQUE) {
GetItemAttrs(item, static_cast<_item_indexes>(idx), curlv);
GetUniqueItem(*MyPlayer, item, uid);
SetupItem(item);
}

if (sendmsg)
NetSendCmdPItem(false, CMD_SPAWNITEM, item.position, item);
Expand All @@ -3238,7 +3249,7 @@ void SpawnItem(Monster &monster, Point position, bool sendmsg, bool spawn /*= fa
bool dropBrain = Quests[Q_MUSHROOM]._qactive == QUEST_ACTIVE && Quests[Q_MUSHROOM]._qvar1 == QS_MUSHGIVEN;

if (dropsSpecialTreasure && !UseMultiplayerQuests()) {
Item *uniqueItem = SpawnUnique(static_cast<_unique_items>(monster.data().treasure & T_MASK), position, false);
Item *uniqueItem = SpawnUnique(static_cast<_unique_items>(monster.data().treasure & T_MASK), position, std::nullopt, false);
if (uniqueItem != nullptr && sendmsg)
NetSendCmdPItem(false, CMD_DROPITEM, uniqueItem->position, *uniqueItem);
return;
Expand Down
2 changes: 1 addition & 1 deletion Source/items.h
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ uint8_t PlaceItemInWorld(Item &&item, WorldTilePosition position);
Point GetSuperItemLoc(Point position);
void GetItemAttrs(Item &item, _item_indexes itemData, int lvl);
void SetupItem(Item &item);
Item *SpawnUnique(_unique_items uid, Point position, bool sendmsg = true);
Item *SpawnUnique(_unique_items uid, Point position, std::optional<int> level = std::nullopt, bool sendmsg = true);
void SpawnItem(Monster &monster, Point position, bool sendmsg, bool spawn = false);
void CreateRndItem(Point position, bool onlygood, bool sendmsg, bool delta);
void CreateRndUseful(Point position, bool sendmsg);
Expand Down
10 changes: 5 additions & 5 deletions Source/towners.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ void TalkToBarOwner(Player &player, Towner &barOwner)
bannerQuest._qactive = QUEST_DONE;
bannerQuest._qvar1 = 3;
NetSendCmdQuest(true, bannerQuest);
SpawnUnique(UITEM_HARCREST, barOwner.position + Direction::SouthWest);
SpawnUnique(UITEM_HARCREST, barOwner.position + Direction::SouthWest, bannerQuest._qlevel);
InitQTextMsg(TEXT_BANNER3);
return;
}
Expand Down Expand Up @@ -392,7 +392,7 @@ void TalkToBlackSmith(Player &player, Towner &blackSmith)
if (Quests[Q_ROCK]._qvar2 == 1 && RemoveInventoryItemById(player, IDI_ROCK)) {
Quests[Q_ROCK]._qactive = QUEST_DONE;
NetSendCmdQuest(true, Quests[Q_ROCK]);
SpawnUnique(UITEM_INFRARING, blackSmith.position + Direction::SouthWest);
SpawnUnique(UITEM_INFRARING, blackSmith.position + Direction::SouthWest, Quests[Q_ROCK]._qlevel);
InitQTextMsg(TEXT_INFRA7);
return;
}
Expand All @@ -413,7 +413,7 @@ void TalkToBlackSmith(Player &player, Towner &blackSmith)
if (Quests[Q_ANVIL]._qvar2 == 1 && RemoveInventoryItemById(player, IDI_ANVIL)) {
Quests[Q_ANVIL]._qactive = QUEST_DONE;
NetSendCmdQuest(true, Quests[Q_ANVIL]);
SpawnUnique(UITEM_GRISWOLD, blackSmith.position + Direction::SouthWest);
SpawnUnique(UITEM_GRISWOLD, blackSmith.position + Direction::SouthWest, Quests[Q_ANVIL]._qlevel);
InitQTextMsg(TEXT_ANVIL7);
return;
}
Expand Down Expand Up @@ -511,7 +511,7 @@ void TalkToHealer(Player &player, Towner &healer)
if (poisonWater._qactive == QUEST_DONE && poisonWater._qvar1 != 2) {
poisonWater._qvar1 = 2;
InitQTextMsg(TEXT_POISON5);
SpawnUnique(UITEM_TRING, healer.position + Direction::SouthWest);
SpawnUnique(UITEM_TRING, healer.position + Direction::SouthWest, poisonWater._qlevel);
NetSendCmdQuest(true, poisonWater);
return;
}
Expand Down Expand Up @@ -670,7 +670,7 @@ void TalkToCowFarmer(Player &player, Towner &cowFarmer)
auto &quest = Quests[Q_JERSEY];

if (RemoveInventoryItemById(player, IDI_BROWNSUIT)) {
SpawnUnique(UITEM_BOVINE, cowFarmer.position + Direction::SouthEast);
SpawnUnique(UITEM_BOVINE, cowFarmer.position + Direction::SouthEast, quest._qlevel);
InitQTextMsg(TEXT_JERSEY8);
quest._qactive = QUEST_DONE;
UpdateCowFarmerAnimAfterQuestComplete();
Expand Down