From 0b954e8309474d37b5f47d4e0ed2d40c7a31ed89 Mon Sep 17 00:00:00 2001 From: Walter Pagani Date: Mon, 10 Jul 2023 23:44:50 -0300 Subject: [PATCH] Feat. Preventing the procurement of multiple unique items (#16) --- src/AoeLoot_SC.cpp | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/src/AoeLoot_SC.cpp b/src/AoeLoot_SC.cpp index 6adff8a..ffe9fef 100644 --- a/src/AoeLoot_SC.cpp +++ b/src/AoeLoot_SC.cpp @@ -71,16 +71,30 @@ public: { if (LootItem* item = loot->LootItemInSlot(i, player)) { - if (player->AddItem(item->itemid, item->count)) + ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(item->itemid); + + if (itemTemplate->MaxCount != 1) { + if (player->AddItem(item->itemid, item->count)) + { + player->SendNotifyLootItemRemoved(lootSlot); + player->SendLootRelease(player->GetLootGUID()); + } + else if (sConfigMgr->GetOption("AOELoot.MailEnable", true)) + { + player->SendItemRetrievalMail(item->itemid, item->count); + ChatHandler(player->GetSession()).SendSysMessage(AOE_ITEM_IN_THE_MAIL); + } + } + else + { + if (!player->HasItemCount(item->itemid, 1)) + { + player->AddItem(item->itemid, item->count); + } player->SendNotifyLootItemRemoved(lootSlot); player->SendLootRelease(player->GetLootGUID()); } - else if (sConfigMgr->GetOption("AOELoot.MailEnable", true)) - { - player->SendItemRetrievalMail(item->itemid, item->count); - ChatHandler(player->GetSession()).SendSysMessage(AOE_ITEM_IN_THE_MAIL); - } } }