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;