mirror of
https://github.com/mod-playerbots/mod-playerbots
synced 2025-11-29 15:58:20 +08:00
* Addresses #1360 * Additional check, If item exists in bags, don't roll.
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ protected:
|
||||
};
|
||||
|
||||
bool CanBotUseToken(ItemTemplate const* proto, Player* bot);
|
||||
bool RollUniqueCheck(ItemTemplate const* proto, Player* bot);
|
||||
|
||||
class MasterLootRollAction : public LootRollAction
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user