diff --git a/src/Ai/Base/Actions/CastCustomSpellAction.cpp b/src/Ai/Base/Actions/CastCustomSpellAction.cpp index 15c35ee43..3defe55d1 100644 --- a/src/Ai/Base/Actions/CastCustomSpellAction.cpp +++ b/src/Ai/Base/Actions/CastCustomSpellAction.cpp @@ -143,14 +143,17 @@ bool CastCustomSpellAction::Execute(Event event) std::ostringstream spellName; spellName << ChatHelper::FormatSpell(spellInfo) << " on "; + bool const hasItemTarget = itemTarget && + (spellInfo->Targets & TARGET_FLAG_ITEM || spellInfo->Targets & TARGET_FLAG_GAMEOBJECT_ITEM); + if (bot->GetTrader()) spellName << "trade item"; - else if (itemTarget) + else if (hasItemTarget) spellName << chat->FormatItem(itemTarget->GetTemplate()); - else if (target == bot) - spellName << "self"; - else + else if (target != bot) spellName << target->GetName(); + else + spellName << "self"; if (!bot->GetTrader() && !botAI->CanCastSpell(spell, target, true, itemTarget)) { diff --git a/src/Ai/Base/Actions/InventoryAction.cpp b/src/Ai/Base/Actions/InventoryAction.cpp index 83fc00f12..8d3046061 100644 --- a/src/Ai/Base/Actions/InventoryAction.cpp +++ b/src/Ai/Base/Actions/InventoryAction.cpp @@ -10,6 +10,31 @@ #include "ItemVisitors.h" #include "Playerbots.h" +namespace +{ +bool isReservedQualifier(std::string const& text) +{ + static std::array const exactQualifiers = { + "ammo", + "conjured drink", + "conjured food", + "conjured water", + "drink", + "food", + "healing potion", + "mount", + "mana potion", + "pet", + "quest", + "recipe", + "water" + }; + + return std::find(exactQualifiers.begin(), exactQualifiers.end(), text) != exactQualifiers.end() || + text.rfind("usage ", 0) == 0; +} +} + void InventoryAction::IterateItems(IterateItemsVisitor* visitor, IterateItemsMask mask) { if (mask & ITERATE_ITEMS_IN_BAGS) @@ -292,9 +317,12 @@ std::vector InventoryAction::parseItems(std::string const text, IterateIt found.insert(visitor.GetResult().begin(), visitor.GetResult().end()); } - FindNamedItemVisitor visitor(bot, text); - IterateItems(&visitor, ITERATE_ITEMS_IN_BAGS); - found.insert(visitor.GetResult().begin(), visitor.GetResult().end()); + if (!isReservedQualifier(text)) + { + FindNamedItemVisitor visitor(bot, text); + IterateItems(&visitor, ITERATE_ITEMS_IN_BAGS); + found.insert(visitor.GetResult().begin(), visitor.GetResult().end()); + } uint32 quality = chat->parseItemQuality(text); if (quality != MAX_ITEM_QUALITY)