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:
Keleborn
2026-02-08 03:41:33 -08:00
committed by GitHub
parent 8585f10f48
commit 3db2a5a193
10 changed files with 176 additions and 149 deletions

View File

@@ -8,6 +8,7 @@
#include "ChatHelper.h"
#include "InventoryAction.h"
#include "Item.h"
class FindItemVisitor;
class Item;
@@ -20,6 +21,7 @@ public:
bool Execute(Event event) override;
void EquipItems(ItemIds ids);
ItemIds SelectInventoryItemsToEquip();
private:
void EquipItem(FindItemVisitor* visitor);
@@ -27,10 +29,10 @@ private:
void EquipItem(Item* item);
};
class EquipUpgradesAction : public EquipAction
class EquipUpgradesTriggeredAction : public EquipAction
{
public:
EquipUpgradesAction(PlayerbotAI* botAI, std::string const name = "equip upgrades") : EquipAction(botAI, name) {}
explicit EquipUpgradesTriggeredAction(PlayerbotAI* botAI, std::string const name = "equip upgrades") : EquipAction(botAI, name) {}
bool Execute(Event event) override;
};
@@ -38,7 +40,7 @@ public:
class EquipUpgradeAction : public EquipAction
{
public:
EquipUpgradeAction(PlayerbotAI* botAI, std::string const name = "equip upgrade") : EquipAction(botAI, name) {}
explicit EquipUpgradeAction(PlayerbotAI* botAI, std::string const name = "equip upgrade") : EquipAction(botAI, name) {}
bool Execute(Event event) override;
};