mirror of
https://github.com/mod-playerbots/mod-playerbots.git
synced 2026-02-11 06:21:30 +00:00
#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>
49 lines
1.3 KiB
C++
49 lines
1.3 KiB
C++
/*
|
|
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU AGPL v3 license, you may redistribute it
|
|
* and/or modify it under version 3 of the License, or (at your option), any later version.
|
|
*/
|
|
|
|
#ifndef _PLAYERBOT_EQUIPACTION_H
|
|
#define _PLAYERBOT_EQUIPACTION_H
|
|
|
|
#include "ChatHelper.h"
|
|
#include "InventoryAction.h"
|
|
#include "Item.h"
|
|
|
|
class FindItemVisitor;
|
|
class Item;
|
|
class PlayerbotAI;
|
|
|
|
class EquipAction : public InventoryAction
|
|
{
|
|
public:
|
|
EquipAction(PlayerbotAI* botAI, std::string const name = "equip") : InventoryAction(botAI, name) {}
|
|
|
|
bool Execute(Event event) override;
|
|
void EquipItems(ItemIds ids);
|
|
ItemIds SelectInventoryItemsToEquip();
|
|
|
|
private:
|
|
void EquipItem(FindItemVisitor* visitor);
|
|
uint8 GetSmallestBagSlot();
|
|
void EquipItem(Item* item);
|
|
};
|
|
|
|
class EquipUpgradesTriggeredAction : public EquipAction
|
|
{
|
|
public:
|
|
explicit EquipUpgradesTriggeredAction(PlayerbotAI* botAI, std::string const name = "equip upgrades") : EquipAction(botAI, name) {}
|
|
|
|
bool Execute(Event event) override;
|
|
};
|
|
|
|
class EquipUpgradeAction : public EquipAction
|
|
{
|
|
public:
|
|
explicit EquipUpgradeAction(PlayerbotAI* botAI, std::string const name = "equip upgrade") : EquipAction(botAI, name) {}
|
|
|
|
bool Execute(Event event) override;
|
|
};
|
|
|
|
#endif
|