Hunter equip bug (#1050)

This commit is contained in:
avirar
2025-03-04 01:09:47 +11:00
committed by GitHub
parent d8cb75d376
commit 9edddc5b26
4 changed files with 46 additions and 8 deletions

View File

@@ -132,7 +132,8 @@ void EquipAction::EquipItem(Item* item)
Item* currentMHItem = bot->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND);
bool have2HWeaponEquipped = (currentMHItem && currentMHItem->GetTemplate()->InventoryType == INVTYPE_2HWEAPON);
bool canDualWieldOrTG = (canDualWield || (canTitanGrip && isTwoHander));
// bool canDualWieldOrTG = (canDualWield || (canTitanGrip && isTwoHander));
bool canDualWieldOrTG = (canDualWield || isTwoHander);
// If this is a weapon and we can dual wield or Titan Grip, check if we can improve main/off-hand setup
if (isWeapon && canDualWieldOrTG)
@@ -154,7 +155,7 @@ void EquipAction::EquipItem(Item* item)
// Determine where this weapon can go
bool canGoMain = (invType == INVTYPE_WEAPON ||
invType == INVTYPE_WEAPONMAINHAND ||
(canTitanGrip && isTwoHander));
isTwoHander);
bool canTGOff = false;
if (canTitanGrip && isTwoHander && isValidTGWeapon)
@@ -186,7 +187,8 @@ void EquipAction::EquipItem(Item* item)
// and if conditions allow (e.g. no conflicting 2H logic)
bool betterThanMH = (newItemScore > mainHandScore);
bool mhConditionOK = ((invType != INVTYPE_2HWEAPON && !have2HWeaponEquipped) ||
(canTitanGrip && isValidTGWeapon));
(isTwoHander && !canTitanGrip) ||
(canTitanGrip && isValidTGWeapon));
if (canGoMain && betterThanMH && mhConditionOK)
{
@@ -288,7 +290,7 @@ void EquipAction::EquipItem(Item* item)
}
std::ostringstream out;
out << "equipping " << chat->FormatItem(itemProto);
out << "Equipping " << chat->FormatItem(itemProto);
botAI->TellMaster(out);
}
@@ -318,9 +320,9 @@ bool EquipUpgradesAction::Execute(Event event)
ItemUsage usage = AI_VALUE2(ItemUsage, "item usage", i->first);
if (usage == ITEM_USAGE_EQUIP || usage == ITEM_USAGE_REPLACE || usage == ITEM_USAGE_BAD_EQUIP)
{
// LOG_INFO("playerbots", "Bot {} <{}> auto equips item {} ({})", bot->GetGUID().ToString().c_str(),
// bot->GetName().c_str(), i->first, usage == 1 ? "no item in slot" : usage == 2 ? "replace" : usage == 3 ?
// "wrong item but empty slot" : "");
// LOG_INFO("playerbots", "Bot {} <{}> EquipUpgradesAction {} ({})", bot->GetGUID().ToString().c_str(),
// bot->GetName().c_str(), i->first, usage == 1 ? "no item in slot" : usage == 2 ? "replace" : usage == 3 ?
// "wrong item but empty slot" : "");
items.insert(i->first);
}
}
@@ -340,6 +342,9 @@ bool EquipUpgradeAction::Execute(Event event)
ItemUsage usage = AI_VALUE2(ItemUsage, "item usage", i->first);
if (usage == ITEM_USAGE_EQUIP || usage == ITEM_USAGE_REPLACE || usage == ITEM_USAGE_BAD_EQUIP)
{
// LOG_INFO("playerbots", "Bot {} <{}> EquipUpgradeAction item {} ({})", bot->GetGUID().ToString().c_str(),
// bot->GetName().c_str(), i->first, usage == 1 ? "no item in slot" : usage == 2 ? "replace" : usage == 3 ?
// "wrong item but empty slot" : "");
items.insert(i->first);
}
}

View File

@@ -12,7 +12,35 @@
bool QueryItemUsageAction::Execute(Event event)
{
return true;
std::string param = event.getParam();
if (param.empty())
{
return false;
}
// Use parseItems() to extract item IDs from the input
ItemIds itemIds = chat->parseItems(param);
if (itemIds.empty())
{
return false;
}
// Process each extracted item ID (assuming single-item queries for now)
for (uint32 itemId : itemIds)
{
ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(itemId);
if (!itemTemplate)
continue;
uint32 count = GetCount(itemTemplate);
uint32 total = bot->GetItemCount(itemTemplate->ItemId, true);
std::string itemInfo = QueryItem(itemTemplate, count, total);
botAI->TellMaster(itemInfo);
return true; // Only process the first valid item
}
return false;
}
uint32 QueryItemUsageAction::GetCount(ItemTemplate const* item)

View File

@@ -94,6 +94,8 @@ void ChatCommandHandlerStrategy::InitTriggers(std::vector<TriggerNode*>& trigger
new TriggerNode("disperse", NextAction::array(0, new NextAction("disperse set", relevance), NULL)));
triggers.push_back(
new TriggerNode("open items", NextAction::array(0, new NextAction("open items", relevance), nullptr)));
triggers.push_back(
new TriggerNode("qi", NextAction::array(0, new NextAction("query item usage", relevance), nullptr)));
}
ChatCommandHandlerStrategy::ChatCommandHandlerStrategy(PlayerbotAI* botAI) : PassTroughStrategy(botAI)
@@ -168,4 +170,5 @@ ChatCommandHandlerStrategy::ChatCommandHandlerStrategy(PlayerbotAI* botAI) : Pas
supported.push_back("drink");
supported.push_back("calc");
supported.push_back("open items");
supported.push_back("qi");
}

View File

@@ -127,6 +127,7 @@ public:
creators["dps"] = &ChatTriggerContext::dps;
creators["disperse"] = &ChatTriggerContext::disperse;
creators["calc"] = &ChatTriggerContext::calc;
creators["qi"] = &ChatTriggerContext::qi;
}
private:
@@ -233,6 +234,7 @@ private:
static Trigger* dps(PlayerbotAI* ai) { return new ChatCommandTrigger(ai, "dps"); }
static Trigger* disperse(PlayerbotAI* ai) { return new ChatCommandTrigger(ai, "disperse"); }
static Trigger* calc(PlayerbotAI* ai) { return new ChatCommandTrigger(ai, "calc"); }
static Trigger* qi(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "qi"); }
};
#endif