Skip to content

Commit

Permalink
added ilvl and quality checks for quivers for hunters (#54)
Browse files Browse the repository at this point in the history
added GetEquippedAnyBags() GetEquippedQuivers() methods
  • Loading branch information
Redbu11dev authored Aug 9, 2024
1 parent a59d43a commit b25468b
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 1 deletion.
33 changes: 33 additions & 0 deletions playerbot/PlayerbotAI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5988,6 +5988,39 @@ void PlayerbotAI::InventoryIterateItems(IterateItemsVisitor* visitor, IterateIte
InventoryIterateItemsInBuyBack(visitor);
}

std::vector<Bag*> PlayerbotAI::GetEquippedAnyBags()
{
std::vector<Bag*> bags;

for (int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i)
{
if (Bag* bag = (Bag*)bot->GetItemByPos(INVENTORY_SLOT_BAG_0, i))
{
bags.push_back(bag);
}
}

return bags;
}

std::vector<Bag*> PlayerbotAI::GetEquippedQuivers()
{
std::vector<Bag*> bags;

for (int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i)
{
if (Bag* bag = (Bag*)bot->GetItemByPos(INVENTORY_SLOT_BAG_0, i))
{
if (bag->GetProto()->Class == ITEM_CLASS_QUIVER)
{
bags.push_back(bag);
}
}
}

return bags;
}

std::vector<Item*> PlayerbotAI::GetInventoryAndEquippedItems()
{
std::vector<Item*> items;
Expand Down
2 changes: 2 additions & 0 deletions playerbot/PlayerbotAI.h
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,8 @@ class PlayerbotAI : public PlayerbotAIBase
std::list<Unit*> GetAllHostileNPCNonPetUnitsAroundWO(WorldObject* wo, float distanceAround);

public:
std::vector<Bag*> GetEquippedAnyBags();
std::vector<Bag*> GetEquippedQuivers();
std::vector<Item*> GetInventoryAndEquippedItems();
std::vector<Item*> GetInventoryItems();
uint32 GetInventoryItemsCountWithId(uint32 itemId);
Expand Down
15 changes: 14 additions & 1 deletion playerbot/strategy/values/ItemUsageValue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,20 @@ ItemUsage ItemUsageValue::QueryItemUsageForEquip(ItemQualifier& itemQualifier)
{
if (bot->getClass() == CLASS_HUNTER)
{
return ItemUsage::ITEM_USAGE_EQUIP;
std::vector<Bag*> equippedQuivers = bot->GetPlayerbotAI()->GetEquippedQuivers();

for (auto quiver : equippedQuivers)
{
if (quiver->GetProto()->ItemLevel < itemProto->ItemLevel)
{
return ItemUsage::ITEM_USAGE_EQUIP;
}

if (quiver->GetProto()->ItemLevel == itemProto->ItemLevel && quiver->GetProto()->Quality < itemProto->Quality)
{
return ItemUsage::ITEM_USAGE_EQUIP;
}
}
}

return ItemUsage::ITEM_USAGE_NONE;
Expand Down

0 comments on commit b25468b

Please sign in to comment.