From 9986469042541d6de35bb75fab456ba6630c54b7 Mon Sep 17 00:00:00 2001 From: Jelly Date: Fri, 6 Jun 2025 01:55:03 -0500 Subject: [PATCH] Addresses #1360 (#1361) * Addresses #1360 * Additional check, If item exists in bags, don't roll. --- src/strategy/actions/LootRollAction.cpp | 30 ++++++++++++++++++++++++- src/strategy/actions/LootRollAction.h | 1 + 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/strategy/actions/LootRollAction.cpp b/src/strategy/actions/LootRollAction.cpp index 1094d94b..53007b4e 100644 --- a/src/strategy/actions/LootRollAction.cpp +++ b/src/strategy/actions/LootRollAction.cpp @@ -89,7 +89,14 @@ bool LootRollAction::Execute(Event event) { if (vote == NEED) { - vote = GREED; + if (RollUniqueCheck(proto, bot)) + { + vote = PASS; + } + else + { + vote = GREED; + } } else if (vote == GREED) { @@ -196,3 +203,24 @@ bool CanBotUseToken(ItemTemplate const* proto, Player* bot) return false; // Bot's class cannot use this token } + +bool RollUniqueCheck(ItemTemplate const* proto, Player* bot) +{ + // Count the total number of the item (equipped + in bags) + uint32 totalItemCount = bot->GetItemCount(proto->ItemId, true); + + // Count the number of the item in bags only + uint32 bagItemCount = bot->GetItemCount(proto->ItemId, false); + + // Determine if the unique item is already equipped + bool isEquipped = (totalItemCount > bagItemCount); + if (isEquipped && proto->HasFlag(ITEM_FLAG_UNIQUE_EQUIPPABLE)) + { + return true; // Unique Item is already equipped + } + else if (proto->HasFlag(ITEM_FLAG_UNIQUE_EQUIPPABLE) && (bagItemCount > 1)) + { + return true; // Unique item already in bag, don't roll for it + } + return false; // Item is not equipped or in bags, roll for it +} diff --git a/src/strategy/actions/LootRollAction.h b/src/strategy/actions/LootRollAction.h index a278f593..bb0c3d89 100644 --- a/src/strategy/actions/LootRollAction.h +++ b/src/strategy/actions/LootRollAction.h @@ -26,6 +26,7 @@ protected: }; bool CanBotUseToken(ItemTemplate const* proto, Player* bot); +bool RollUniqueCheck(ItemTemplate const* proto, Player* bot); class MasterLootRollAction : public LootRollAction {