From a320a716fafe00798554ce36bc8eea42eb1bfacb Mon Sep 17 00:00:00 2001 From: Yunfan Li Date: Thu, 2 Nov 2023 22:01:52 +0800 Subject: [PATCH] auto equip upgrade --- conf/playerbots.conf.dist | 8 ++++++-- src/PlayerbotAIConfig.cpp | 1 + src/PlayerbotAIConfig.h | 1 + src/strategy/actions/InventoryAction.cpp | 2 +- src/strategy/values/ItemUsageValue.cpp | 3 ++- 5 files changed, 11 insertions(+), 4 deletions(-) diff --git a/conf/playerbots.conf.dist b/conf/playerbots.conf.dist index 98f8144d..e15de488 100644 --- a/conf/playerbots.conf.dist +++ b/conf/playerbots.conf.dist @@ -155,8 +155,12 @@ AiPlayerbot.FreeMethodLoot = 0 AiPlayerbot.AutoPickReward = no # Bots equip upgrades (Bots will equip any item obtained from looting or a quest if they are upgrades) -# Default: 0 (disabled) -AiPlayerbot.AutoEquipUpgradeLoot = 0 +# Default: 1 (enable) +AiPlayerbot.AutoEquipUpgradeLoot = 1 + +# Equip upgrade threshold for auto equip upgrade +# Default: 1.1 (Equip when the equipment score is 1.1 times higher than the current) +AiPlayerbot.EquipUpgradeThreshold = 1.1 # Sync quests with player (Bots will complete quests the moment you hand them in. Bots will ignore looting quest items.) # Default: 0 (disabled) diff --git a/src/PlayerbotAIConfig.cpp b/src/PlayerbotAIConfig.cpp index 460143d1..db4db04a 100644 --- a/src/PlayerbotAIConfig.cpp +++ b/src/PlayerbotAIConfig.cpp @@ -334,6 +334,7 @@ bool PlayerbotAIConfig::Initialize() freeMethodLoot = sConfigMgr->GetOption("AiPlayerbot.FreeMethodLoot", false); autoPickReward = sConfigMgr->GetOption("AiPlayerbot.AutoPickReward", "yes"); autoEquipUpgradeLoot = sConfigMgr->GetOption("AiPlayerbot.AutoEquipUpgradeLoot", true); + equipUpgradeThreshold = sConfigMgr->GetOption("AiPlayerbot.EquipUpgradeThreshold", 1.1f); syncQuestWithPlayer = sConfigMgr->GetOption("AiPlayerbot.SyncQuestWithPlayer", false); syncQuestForPlayer = sConfigMgr->GetOption("AiPlayerbot.SyncQuestForPlayer", false); autoTrainSpells = sConfigMgr->GetOption("AiPlayerbot.AutoTrainSpells", "yes"); diff --git a/src/PlayerbotAIConfig.h b/src/PlayerbotAIConfig.h index d13d98d9..81b1296b 100644 --- a/src/PlayerbotAIConfig.h +++ b/src/PlayerbotAIConfig.h @@ -151,6 +151,7 @@ class PlayerbotAIConfig bool freeMethodLoot; std::string autoPickReward; bool autoEquipUpgradeLoot; + float equipUpgradeThreshold; bool syncQuestWithPlayer; bool syncQuestForPlayer; std::string autoTrainSpells; diff --git a/src/strategy/actions/InventoryAction.cpp b/src/strategy/actions/InventoryAction.cpp index 75a3af74..d9753574 100644 --- a/src/strategy/actions/InventoryAction.cpp +++ b/src/strategy/actions/InventoryAction.cpp @@ -289,7 +289,7 @@ std::vector InventoryAction::parseItems(std::string const text, IterateIt found.insert(visitor.GetResult().begin(), visitor.GetResult().end()); } - FindUsableNamedItemVisitor visitor(bot, text); + FindNamedItemVisitor visitor(bot, text); IterateItems(&visitor, ITERATE_ITEMS_IN_BAGS); found.insert(visitor.GetResult().begin(), visitor.GetResult().end()); diff --git a/src/strategy/values/ItemUsageValue.cpp b/src/strategy/values/ItemUsageValue.cpp index f07cf635..4a447705 100644 --- a/src/strategy/values/ItemUsageValue.cpp +++ b/src/strategy/values/ItemUsageValue.cpp @@ -6,6 +6,7 @@ #include "AiFactory.h" #include "ChatHelper.h" #include "GuildTaskMgr.h" +#include "PlayerbotAIConfig.h" #include "PlayerbotFactory.h" #include "Playerbots.h" #include "RandomItemMgr.h" @@ -208,7 +209,7 @@ ItemUsage ItemUsageValue::QueryItemUsageForEquip(ItemTemplate const* itemProto) // uint32 oldStatWeight = sRandomItemMgr->GetLiveStatWeight(bot, oldItemProto->ItemId); if (itemScore || oldScore) { - shouldEquip = itemScore > oldScore * 1.1; + shouldEquip = itemScore > oldScore * sPlayerbotAIConfig->equipUpgradeThreshold; } }