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 {