From 94195c3b9b4b4c1fd76fd84a8df4ddacb0ea7443 Mon Sep 17 00:00:00 2001 From: Crow Date: Sat, 2 May 2026 14:20:03 -0500 Subject: [PATCH] Bots Don't Autoequip Tools & Other Misc Weapons (#2346) ## Pull Request Description Solve the rest of #2344 Now, bots won't autoequip any weapon from ITEM_SUBCLASS_WEAPON_MISC, which includes all of the basic tools and some other crap that they have no need to autoequip, either. Bots are still eligible to equip those weapons (such as through the "e" command). Note that MISC includes the Argent Tournament lances. I've not played WotLK, but I assume those might be relevant for a strategy. It shouldn't be a problem though because I've intentionally not made bots ineligible for MISC weapons; they just won't consider them upgrades on their own. I also cleaned up ItemUsageValue::QueryItemUsageForEquip to consolidate checks and so on. None of that should be functional, or I screwed up. The check for MISC is on lines 219 through 221. ## Feature Evaluation - Describe the **minimum logic** required to achieve the intended behavior. - Describe the **processing cost** when this logic executes across many bots. ## How to Test the Changes Activate selfbot. Unequip all weapons and have nothing in the inventory except for a MISC weapon such as a skinning knife. Whisper self "equip upgrade"--nothing should happen. Whisper self "e [LINK TO WEAPON]"--the bot should equip the weapon. ## Impact Assessment - Does this change increase per-bot/per-tick processing or risk scaling poorly with thousands of bots? - - [ ] No, not at all - - [x] Minimal impact (**explain below**) - - [ ] Moderate impact (**explain below**) There's an extra check but totally meaningless with respect to performance. - Does this change modify default bot behavior? - - [ ] No - - [x] Yes (**explain why**) They won't auto-equip crap that will prevent them from using abilities. - Does this change add new decision branches or increase maintenance complexity? - - [x] No - - [ ] Yes (**explain below**) ## AI Assistance Was AI assistance used while working on this change? - - [ ] No - - [x] Yes (**explain below**) I had GPT-5.4 evaluate different spots where I thought an exclusion could be added before settling on this one. ## Final Checklist - - [x] Stability is not compromised. - - [x] Performance impact is understood, tested, and acceptable. - - [x] Added logic complexity is justified and explained. - - [x] Any new bot dialogue lines are translated. - - [x] Documentation updated if needed (Conf comments, WiKi commands). ## Notes for Reviewers --- src/Ai/Base/Value/ItemUsageValue.cpp | 57 ++++++++-------------------- 1 file changed, 15 insertions(+), 42 deletions(-) diff --git a/src/Ai/Base/Value/ItemUsageValue.cpp b/src/Ai/Base/Value/ItemUsageValue.cpp index c3d976f0f..a1f9688d2 100644 --- a/src/Ai/Base/Value/ItemUsageValue.cpp +++ b/src/Ai/Base/Value/ItemUsageValue.cpp @@ -180,19 +180,11 @@ ItemUsage ItemUsageValue::QueryItemUsageForEquip(ItemTemplate const* itemProto, delete pItem; if (result != EQUIP_ERR_OK && result != EQUIP_ERR_CANT_CARRY_MORE_OF_THIS) - { return ITEM_USAGE_NONE; - } - // Check is unique items are equipped or not - bool needToCheckUnique = false; - if (result == EQUIP_ERR_CANT_CARRY_MORE_OF_THIS) - { - needToCheckUnique = true; - } - else if (itemProto->HasFlag(ITEM_FLAG_UNIQUE_EQUIPPABLE)) - { - needToCheckUnique = true; - } + + // Check if unique items are equipped or not + bool needToCheckUnique = result == EQUIP_ERR_CANT_CARRY_MORE_OF_THIS || + itemProto->HasFlag(ITEM_FLAG_UNIQUE_EQUIPPABLE); if (needToCheckUnique) { @@ -206,28 +198,27 @@ ItemUsage ItemUsageValue::QueryItemUsageForEquip(ItemTemplate const* itemProto, bool isEquipped = (totalItemCount > bagItemCount); if (isEquipped) - { return ITEM_USAGE_NONE; // Item is already equipped - } // If not equipped, continue processing } - if (itemProto->Class == ITEM_CLASS_QUIVER) - if (bot->getClass() != CLASS_HUNTER) - return ITEM_USAGE_NONE; + if (itemProto->Class == ITEM_CLASS_QUIVER && bot->getClass() != CLASS_HUNTER) + return ITEM_USAGE_NONE; if (itemProto->Class == ITEM_CLASS_CONTAINER) { if (itemProto->SubClass != ITEM_SUBCLASS_CONTAINER) return 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) return ITEM_USAGE_NONE; return ITEM_USAGE_EQUIP; } + if (itemProto->Class == ITEM_CLASS_WEAPON && itemProto->SubClass == ITEM_SUBCLASS_WEAPON_MISC) + return ITEM_USAGE_NONE; + bool shouldEquip = false; // uint32 statWeight = sRandomItemMgr.GetLiveStatWeight(bot, itemProto->ItemId); StatsWeightCalculator calculator(bot); @@ -254,19 +245,14 @@ ItemUsage ItemUsageValue::QueryItemUsageForEquip(ItemTemplate const* itemProto, uint8 dstSlot = botAI->FindEquipSlot(itemProto, NULL_SLOT, true); // Check if dest wasn't set correctly by CanEquipItem and use FindEquipSlot instead // This occurs with unique items that are already in the bots bags when CanEquipItem is called - if (dest == 0) + if (dest == 0 && dstSlot != NULL_SLOT) { - if (dstSlot != NULL_SLOT) - { - // Construct dest from dstSlot - dest = (INVENTORY_SLOT_BAG_0 << 8) | dstSlot; - } + // Construct dest from dstSlot + dest = (INVENTORY_SLOT_BAG_0 << 8) | dstSlot; } if (dstSlot == EQUIPMENT_SLOT_FINGER1 || dstSlot == EQUIPMENT_SLOT_TRINKET1) - { possibleSlots = 2; - } // Check weapon case separately to keep things a bit cleaner bool have2HWeapon = false; @@ -283,14 +269,9 @@ ItemUsage ItemUsageValue::QueryItemUsageForEquip(ItemTemplate const* itemProto, itemProto->SubClass == ITEM_SUBCLASS_WEAPON_SWORD2); // If the bot can Titan Grip, ignore any 2H weapon that isn't a 2H sword, mace, or axe. - if (bot->CanTitanGrip()) - { - // If this weapon is 2H but not one of the valid TG weapon types, do not equip it at all. - if (itemProto->InventoryType == INVTYPE_2HWEAPON && !isValidTGWeapon) - { - return ITEM_USAGE_NONE; - } - } + // If this weapon is 2H but not one of the valid TG weapon types, do not equip it at all. + if (bot->CanTitanGrip() && itemProto->InventoryType == INVTYPE_2HWEAPON && !isValidTGWeapon) + return ITEM_USAGE_NONE; // Now handle the logic for equipping and possible offhand slots // If the bot can Dual Wield and: @@ -317,9 +298,7 @@ ItemUsage ItemUsageValue::QueryItemUsageForEquip(ItemTemplate const* itemProto, if (shouldEquipInSlot) return ITEM_USAGE_EQUIP; else - { return ITEM_USAGE_BAD_EQUIP; - } } ItemTemplate const* oldItemProto = oldItem->GetTemplate(); @@ -328,22 +307,16 @@ ItemUsage ItemUsageValue::QueryItemUsageForEquip(ItemTemplate const* itemProto, { // uint32 oldStatWeight = sRandomItemMgr.GetLiveStatWeight(bot, oldItemProto->ItemId); if (itemScore || oldScore) - { shouldEquipInSlot = itemScore > oldScore * sPlayerbotAIConfig.equipUpgradeThreshold; - } } // Bigger quiver if (itemProto->Class == ITEM_CLASS_QUIVER) { if (!oldItem || oldItemProto->ContainerSlots < itemProto->ContainerSlots) - { return ITEM_USAGE_EQUIP; - } else - { return ITEM_USAGE_NONE; - } } bool existingShouldEquip = true;