mirror of
https://github.com/mod-playerbots/mod-playerbots.git
synced 2026-03-16 05:45:08 +00:00
Refactor of EquipActions (#1994)
#PR Description The root cause of issue #1987 was the AI Value item usage becoming a very expensive call when bots gained professions accidentally. My original approach was to eliminate it entirely, but after inputs and testing I decided to introduce a more focused Ai value "Item upgrade" that only checks equipment and ammo inheriting directly from item usage, so the logic is unified between them. Upgrades are now only assessed when receiving an item that can be equipped. Additionally, I noticed that winning loot rolls did not trigger the upgrade action, so I added a new package handler for that. Performance needs to be re-evaluated, but I expect a reduction in calls and in the cost of each call. I tested with bots and selfbot in deadmines and ahadowfang keep. --------- Co-authored-by: bashermens <31279994+hermensbas@users.noreply.github.com>
This commit is contained in:
@@ -14,7 +14,11 @@ class Player;
|
||||
class PlayerbotAI;
|
||||
|
||||
struct ItemTemplate;
|
||||
|
||||
struct ParsedItemUsage
|
||||
{
|
||||
uint32 itemId = 0;
|
||||
int32 randomPropertyId = 0;
|
||||
};
|
||||
enum ItemUsage : uint32
|
||||
{
|
||||
ITEM_USAGE_NONE = 0,
|
||||
@@ -42,8 +46,12 @@ public:
|
||||
|
||||
ItemUsage Calculate() override;
|
||||
|
||||
private:
|
||||
protected:
|
||||
ItemUsage QueryItemUsageForEquip(ItemTemplate const* proto, int32 randomPropertyId = 0);
|
||||
ItemUsage QueryItemUsageForAmmo(ItemTemplate const* proto);
|
||||
ParsedItemUsage GetItemIdFromQualifier();
|
||||
|
||||
private:
|
||||
uint32 GetSmallestBagSize();
|
||||
bool IsItemUsefulForQuest(Player* player, ItemTemplate const* proto);
|
||||
bool IsItemNeededForSkill(ItemTemplate const* proto);
|
||||
@@ -61,4 +69,14 @@ public:
|
||||
static std::string const GetConsumableType(ItemTemplate const* proto, bool hasMana);
|
||||
};
|
||||
|
||||
class ItemUpgradeValue : public ItemUsageValue
|
||||
{
|
||||
public:
|
||||
ItemUpgradeValue(PlayerbotAI* botAI, std::string const name = "item upgrade") : ItemUsageValue(botAI, name)
|
||||
{
|
||||
}
|
||||
|
||||
ItemUsage Calculate() override;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user