From c59c0cc8024c6c9410feef2105eaa8a48b5df5a9 Mon Sep 17 00:00:00 2001 From: avirar Date: Sat, 4 Jan 2025 02:06:06 +1100 Subject: [PATCH] Added logic for early ranged/thrown weapon equipping (#839) Ranged weapons get caught up in the ITEM_CLASS_WEAPON logic but aren't handled. Added an early check and equip for ranged INVTYPE_ --- src/strategy/actions/EquipAction.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/strategy/actions/EquipAction.cpp b/src/strategy/actions/EquipAction.cpp index 9ea2a797..1f147364 100644 --- a/src/strategy/actions/EquipAction.cpp +++ b/src/strategy/actions/EquipAction.cpp @@ -96,6 +96,21 @@ void EquipAction::EquipItem(Item* item) // If we didn't equip as a bag, try to equip as gear if (!equippedBag) { + // Ranged weapons aren't handled by the rest of the weapon equip logic + // Handle them early here to avoid issues. + if (invType == INVTYPE_RANGED || invType == INVTYPE_THROWN || invType == INVTYPE_RANGEDRIGHT) + { + WorldPacket packet(CMSG_AUTOEQUIP_ITEM_SLOT, 2); + ObjectGuid itemguid = item->GetGUID(); + packet << itemguid << uint8(EQUIPMENT_SLOT_RANGED); + bot->GetSession()->HandleAutoEquipItemSlotOpcode(packet); + + std::ostringstream out; + out << "Equipping " << chat->FormatItem(itemProto) << " in ranged slot"; + botAI->TellMaster(out); + return; + } + uint8 dstSlot = botAI->FindEquipSlot(itemProto, NULL_SLOT, true); // Check if the item is a weapon and whether the bot can dual wield or use Titan Grip