mirror of
https://github.com/mod-playerbots/mod-playerbots
synced 2025-11-29 15:58:20 +08:00
Hunter equip bug (#1050)
This commit is contained in:
@@ -132,7 +132,8 @@ void EquipAction::EquipItem(Item* item)
|
|||||||
Item* currentMHItem = bot->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND);
|
Item* currentMHItem = bot->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND);
|
||||||
bool have2HWeaponEquipped = (currentMHItem && currentMHItem->GetTemplate()->InventoryType == INVTYPE_2HWEAPON);
|
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 this is a weapon and we can dual wield or Titan Grip, check if we can improve main/off-hand setup
|
||||||
if (isWeapon && canDualWieldOrTG)
|
if (isWeapon && canDualWieldOrTG)
|
||||||
@@ -154,7 +155,7 @@ void EquipAction::EquipItem(Item* item)
|
|||||||
// Determine where this weapon can go
|
// Determine where this weapon can go
|
||||||
bool canGoMain = (invType == INVTYPE_WEAPON ||
|
bool canGoMain = (invType == INVTYPE_WEAPON ||
|
||||||
invType == INVTYPE_WEAPONMAINHAND ||
|
invType == INVTYPE_WEAPONMAINHAND ||
|
||||||
(canTitanGrip && isTwoHander));
|
isTwoHander);
|
||||||
|
|
||||||
bool canTGOff = false;
|
bool canTGOff = false;
|
||||||
if (canTitanGrip && isTwoHander && isValidTGWeapon)
|
if (canTitanGrip && isTwoHander && isValidTGWeapon)
|
||||||
@@ -186,6 +187,7 @@ void EquipAction::EquipItem(Item* item)
|
|||||||
// and if conditions allow (e.g. no conflicting 2H logic)
|
// and if conditions allow (e.g. no conflicting 2H logic)
|
||||||
bool betterThanMH = (newItemScore > mainHandScore);
|
bool betterThanMH = (newItemScore > mainHandScore);
|
||||||
bool mhConditionOK = ((invType != INVTYPE_2HWEAPON && !have2HWeaponEquipped) ||
|
bool mhConditionOK = ((invType != INVTYPE_2HWEAPON && !have2HWeaponEquipped) ||
|
||||||
|
(isTwoHander && !canTitanGrip) ||
|
||||||
(canTitanGrip && isValidTGWeapon));
|
(canTitanGrip && isValidTGWeapon));
|
||||||
|
|
||||||
if (canGoMain && betterThanMH && mhConditionOK)
|
if (canGoMain && betterThanMH && mhConditionOK)
|
||||||
@@ -288,7 +290,7 @@ void EquipAction::EquipItem(Item* item)
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::ostringstream out;
|
std::ostringstream out;
|
||||||
out << "equipping " << chat->FormatItem(itemProto);
|
out << "Equipping " << chat->FormatItem(itemProto);
|
||||||
botAI->TellMaster(out);
|
botAI->TellMaster(out);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -318,7 +320,7 @@ bool EquipUpgradesAction::Execute(Event event)
|
|||||||
ItemUsage usage = AI_VALUE2(ItemUsage, "item usage", i->first);
|
ItemUsage usage = AI_VALUE2(ItemUsage, "item usage", i->first);
|
||||||
if (usage == ITEM_USAGE_EQUIP || usage == ITEM_USAGE_REPLACE || usage == ITEM_USAGE_BAD_EQUIP)
|
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(),
|
// 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 ?
|
// bot->GetName().c_str(), i->first, usage == 1 ? "no item in slot" : usage == 2 ? "replace" : usage == 3 ?
|
||||||
// "wrong item but empty slot" : "");
|
// "wrong item but empty slot" : "");
|
||||||
items.insert(i->first);
|
items.insert(i->first);
|
||||||
@@ -340,6 +342,9 @@ bool EquipUpgradeAction::Execute(Event event)
|
|||||||
ItemUsage usage = AI_VALUE2(ItemUsage, "item usage", i->first);
|
ItemUsage usage = AI_VALUE2(ItemUsage, "item usage", i->first);
|
||||||
if (usage == ITEM_USAGE_EQUIP || usage == ITEM_USAGE_REPLACE || usage == ITEM_USAGE_BAD_EQUIP)
|
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);
|
items.insert(i->first);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,35 @@
|
|||||||
|
|
||||||
bool QueryItemUsageAction::Execute(Event event)
|
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)
|
uint32 QueryItemUsageAction::GetCount(ItemTemplate const* item)
|
||||||
|
|||||||
@@ -94,6 +94,8 @@ void ChatCommandHandlerStrategy::InitTriggers(std::vector<TriggerNode*>& trigger
|
|||||||
new TriggerNode("disperse", NextAction::array(0, new NextAction("disperse set", relevance), NULL)));
|
new TriggerNode("disperse", NextAction::array(0, new NextAction("disperse set", relevance), NULL)));
|
||||||
triggers.push_back(
|
triggers.push_back(
|
||||||
new TriggerNode("open items", NextAction::array(0, new NextAction("open items", relevance), nullptr)));
|
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)
|
ChatCommandHandlerStrategy::ChatCommandHandlerStrategy(PlayerbotAI* botAI) : PassTroughStrategy(botAI)
|
||||||
@@ -168,4 +170,5 @@ ChatCommandHandlerStrategy::ChatCommandHandlerStrategy(PlayerbotAI* botAI) : Pas
|
|||||||
supported.push_back("drink");
|
supported.push_back("drink");
|
||||||
supported.push_back("calc");
|
supported.push_back("calc");
|
||||||
supported.push_back("open items");
|
supported.push_back("open items");
|
||||||
|
supported.push_back("qi");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -127,6 +127,7 @@ public:
|
|||||||
creators["dps"] = &ChatTriggerContext::dps;
|
creators["dps"] = &ChatTriggerContext::dps;
|
||||||
creators["disperse"] = &ChatTriggerContext::disperse;
|
creators["disperse"] = &ChatTriggerContext::disperse;
|
||||||
creators["calc"] = &ChatTriggerContext::calc;
|
creators["calc"] = &ChatTriggerContext::calc;
|
||||||
|
creators["qi"] = &ChatTriggerContext::qi;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -233,6 +234,7 @@ private:
|
|||||||
static Trigger* dps(PlayerbotAI* ai) { return new ChatCommandTrigger(ai, "dps"); }
|
static Trigger* dps(PlayerbotAI* ai) { return new ChatCommandTrigger(ai, "dps"); }
|
||||||
static Trigger* disperse(PlayerbotAI* ai) { return new ChatCommandTrigger(ai, "disperse"); }
|
static Trigger* disperse(PlayerbotAI* ai) { return new ChatCommandTrigger(ai, "disperse"); }
|
||||||
static Trigger* calc(PlayerbotAI* ai) { return new ChatCommandTrigger(ai, "calc"); }
|
static Trigger* calc(PlayerbotAI* ai) { return new ChatCommandTrigger(ai, "calc"); }
|
||||||
|
static Trigger* qi(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "qi"); }
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user