Skip to content

Commit

Permalink
-Travel improvement: Bots no longer look at all the uses for items th…
Browse files Browse the repository at this point in the history
…at drop from a boss to determine if they drop an upgrade. Bots now also use keep need items to pick a boss to farm.
  • Loading branch information
mostlikely4r committed Sep 19, 2024
1 parent e3c9941 commit a50e46a
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 9 deletions.
11 changes: 7 additions & 4 deletions playerbot/strategy/values/ItemUsageValue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ ItemUsage ItemUsageValue::Calculate()
return hasSameMount ? ItemUsage::ITEM_USAGE_KEEP : ItemUsage::ITEM_USAGE_EQUIP;
}

ItemUsage equip = QueryItemUsageForEquip(itemQualifier);
ItemUsage equip = QueryItemUsageForEquip(itemQualifier, bot);
if (equip != ItemUsage::ITEM_USAGE_NONE)
return equip;

Expand Down Expand Up @@ -395,8 +395,11 @@ ItemUsage ItemUsageValue::Calculate()
return ItemUsage::ITEM_USAGE_NONE;
}

ItemUsage ItemUsageValue::QueryItemUsageForEquip(ItemQualifier& itemQualifier)
ItemUsage ItemUsageValue::QueryItemUsageForEquip(ItemQualifier& itemQualifier, Player* bot)
{
PlayerbotAI* ai = bot->GetPlayerbotAI();
AiObjectContext* context = ai->GetAiObjectContext();
ChatHelper* chat = ai->GetChatHelper();
ItemPrototype const* itemProto = itemQualifier.GetProto();

if (bot->CanUseItem(itemProto) != EQUIP_ERR_OK)
Expand Down Expand Up @@ -477,7 +480,7 @@ ItemUsage ItemUsageValue::QueryItemUsageForEquip(ItemQualifier& itemQualifier)
if (itemProto->SubClass != ITEM_SUBCLASS_CONTAINER)
return ItemUsage::ITEM_USAGE_NONE; //Todo add logic for non-bag containers. We want to look at professions/class and only replace if non-bag is larger than bag.

if (GetSmallestBagSize() >= itemProto->ContainerSlots)
if (GetSmallestBagSize(bot) >= itemProto->ContainerSlots)
return ItemUsage::ITEM_USAGE_NONE;

return ItemUsage::ITEM_USAGE_EQUIP;
Expand Down Expand Up @@ -552,7 +555,7 @@ ItemUsage ItemUsageValue::QueryItemUsageForEquip(ItemQualifier& itemQualifier)
}

//Return smaltest bag size equipped
uint32 ItemUsageValue::GetSmallestBagSize()
uint32 ItemUsageValue::GetSmallestBagSize(Player* bot)
{
int8 curSlot = 0;
uint32 curSlots = 0;
Expand Down
6 changes: 3 additions & 3 deletions playerbot/strategy/values/ItemUsageValue.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ namespace ai
ItemUsageValue(PlayerbotAI* ai, std::string name = "item usage") : CalculatedValue<ItemUsage>(ai, name), Qualified() {}
virtual ItemUsage Calculate();

private:
ItemUsage QueryItemUsageForEquip(ItemQualifier& itemQualifier);
uint32 GetSmallestBagSize();
static ItemUsage QueryItemUsageForEquip(ItemQualifier& itemQualifier, Player* bot);
static uint32 GetSmallestBagSize(Player* bot);
private:
bool IsItemUsefulForQuest(Player* player, ItemPrototype const* proto, bool ignoreInventory = false);
bool IsItemNeededForSkill(ItemPrototype const* proto);
bool IsItemUsefulForSkill(ItemPrototype const* proto);
Expand Down
18 changes: 18 additions & 0 deletions playerbot/strategy/values/LootValues.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,24 @@ itemUsageMap EntryLootUsageValue::Calculate()
return items;
}

bool HasUpgradeValue::Calculate()
{
for (auto itemId : GAI_VALUE2(std::list<uint32>, "entry loot list", getQualifier()))
{
ForceItemUsage forceUsage = AI_VALUE2_EXISTS(ForceItemUsage, "force item usage", itemId, ForceItemUsage::FORCE_USAGE_NONE);

if (forceUsage == ForceItemUsage::FORCE_USAGE_NEED)
return true;

ItemQualifier qualifier(itemId);

ItemUsage equip = ItemUsageValue::QueryItemUsageForEquip(qualifier, bot);
if (equip == ItemUsage::ITEM_USAGE_EQUIP)
return true;
}
return false;
}

//How many (stack) items can be looted while still having free space.
uint32 StackSpaceForItem::Calculate()
{
Expand Down
4 changes: 2 additions & 2 deletions playerbot/strategy/values/LootValues.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ namespace ai
{
public:
HasUpgradeValue(PlayerbotAI* ai) : BoolCalculatedValue(ai, "has upgrade", 2), Qualified() {}
virtual bool Calculate() { itemUsageMap uMap = AI_VALUE2(itemUsageMap, "entry loot usage", getQualifier()); return uMap.find(ItemUsage::ITEM_USAGE_EQUIP) != uMap.end(); };
virtual bool Calculate();

#ifdef GenerateBotHelp
virtual std::string GetHelpName() { return "has upgrade"; } //Must equal iternal name
Expand All @@ -170,7 +170,7 @@ namespace ai
{
return "This value checks if a specific creature or game object drops an item that is an equipment upgrade for the bot.";
}
virtual std::vector<std::string> GetUsedValues() { return { "entry loot usage" }; }
virtual std::vector<std::string> GetUsedValues() { return {"entry loot list"}; }
#endif
};

Expand Down

0 comments on commit a50e46a

Please sign in to comment.