diff --git a/src/modules/PlayerbotV2/Bot/BotBridge.cpp b/src/modules/PlayerbotV2/Bot/BotBridge.cpp index 1e56ce7488..3f163630eb 100644 --- a/src/modules/PlayerbotV2/Bot/BotBridge.cpp +++ b/src/modules/PlayerbotV2/Bot/BotBridge.cpp @@ -1364,8 +1364,12 @@ std::string RunAction(ConfigReader::BridgeConfig const& cfg, Player* bot, Player auto snap = Services::Snapshots().latest(id); bool offered = false; if (snap) + { for (auto const& off : snap->quest_discovery.quest_offers) offered = offered || off.quest_id == a.quest; + for (auto const& si : snap->quest_discovery.quest_starting_items) // an item in my bags starts it + offered = offered || si.quest_id == a.quest; + } if (!offered) { QuestRefusal const why = API(bot).why_cant_take_quest(a.quest); diff --git a/src/modules/PlayerbotV2/Bot/BotSnapshot.h b/src/modules/PlayerbotV2/Bot/BotSnapshot.h index 08dfe86f8f..73550d518f 100644 --- a/src/modules/PlayerbotV2/Bot/BotSnapshot.h +++ b/src/modules/PlayerbotV2/Bot/BotSnapshot.h @@ -1112,7 +1112,8 @@ struct PositionState // In The World") are never accepted and gate the whole racial starter chain. struct QuestTurnIn { ObjectGuid giver; uint32 quest_id; bool auto_accept = false; }; // Bag-item that starts a not-yet-accepted quest. -struct StartingItem { uint32 item_entry; uint32 quest_id; }; +// item_guid: the item in the bags, the quest giver an accept names (API::accept_quest takes a quest from an item as from an NPC). +struct StartingItem { uint32 item_entry; uint32 quest_id; ObjectGuid item_guid; }; // World quest discovery row. type 0=offer, 1=turn-in. struct WorldQuestEntry { diff --git a/src/modules/PlayerbotV2/Bot/BotSnapshotBuilder.cpp b/src/modules/PlayerbotV2/Bot/BotSnapshotBuilder.cpp index c3895efe5d..ee01c791ab 100644 --- a/src/modules/PlayerbotV2/Bot/BotSnapshotBuilder.cpp +++ b/src/modules/PlayerbotV2/Bot/BotSnapshotBuilder.cpp @@ -2997,6 +2997,7 @@ std::shared_ptr BotSnapshotBuilder::Build(Player* p, BotAI* b BotSnapshot::StartingItem si{}; si.item_entry = ii.entry; si.quest_id = start_qid; + si.item_guid = item->GetGUID(); snap->quest_discovery.quest_starting_items.push_back(si); } } diff --git a/src/modules/PlayerbotV2/Bot/Quest/QuestOrders.cpp b/src/modules/PlayerbotV2/Bot/Quest/QuestOrders.cpp index e329fcefa5..40b4fb966b 100644 --- a/src/modules/PlayerbotV2/Bot/Quest/QuestOrders.cpp +++ b/src/modules/PlayerbotV2/Bot/Quest/QuestOrders.cpp @@ -217,10 +217,24 @@ std::vector AcceptAll(Player* sender, Player* bot, std::string_view ++taken; } - // Offers of the NPCs next to me (the snapshot's own can-take filter), one named quest or all. + // Offers of the NPCs and quest objects next to me (the snapshot's own can-take filter), one named quest or all. std::string_view const a = Trim(arg); uint32 const want = (a.empty() || a == "all" || a == "*") ? 0 : ExtractQuestId(a); std::string const needle = (a.empty() || a == "all" || a == "*" || want) ? std::string{} : TitleNeedle(a); + + // Quests that start from an item in my bags (a dropped letter, a head, a wanted note): taken from the item at once, as a + // player does with a right click. The bot's own idle:quest_start_item does this too, a few seconds later. + for (auto const& si : snap->quest_discovery.quest_starting_items) + { + if (taken >= kMaxAcceptPerOrder) break; + if (si.item_guid.IsEmpty()) continue; + if (want && si.quest_id != want) continue; + if (!needle.empty() && Lower(CompanionQuest::QuestLabel(si.quest_id)).find(needle) == std::string::npos) continue; + emit.accept_quest(si.item_guid, si.quest_id, sender ? sender->GetGUID() : ObjectGuid::Empty); + LogOrder(bot, "accept from item", si.quest_id); + out.push_back(fmt::format("Starting from an item in my bags: {}", CompanionQuest::QuestLabel(si.quest_id))); + ++taken; + } for (auto const& off : snap->quest_discovery.quest_offers) { if (taken >= kMaxAcceptPerOrder) break; diff --git a/src/modules/PlayerbotV2/Util/BotLocaleRu.cpp b/src/modules/PlayerbotV2/Util/BotLocaleRu.cpp index bd2c3b6845..632e47ae44 100644 --- a/src/modules/PlayerbotV2/Util/BotLocaleRu.cpp +++ b/src/modules/PlayerbotV2/Util/BotLocaleRu.cpp @@ -383,6 +383,7 @@ std::vector const& RussianEntries() { "I can't take quests right now.", "Сейчас я не могу брать задания." }, { "Taking the shared quest: {}", "Беру общее задание: {}" }, { "Accepting: {}", "Беру задание: {}" }, + { "Starting from an item in my bags: {}", "Беру задание от предмета в сумке: {}" }, { "Nothing on offer right here; I'll pick up what the quest givers near us have for the next 45 seconds.", "Здесь заданий нет; следующие 45 секунд беру то, что дадут ближайшие NPC с заданиями." }, { "That quest isn't on offer from anyone next to me.", "Это задание никто рядом со мной не дает." }, diff --git a/tests/game/ClassicBotLocale.cpp b/tests/game/ClassicBotLocale.cpp index b77e3cb4c0..8051ce6ef8 100644 --- a/tests/game/ClassicBotLocale.cpp +++ b/tests/game/ClassicBotLocale.cpp @@ -252,6 +252,8 @@ TEST_CASE("BotLocale: why a quest accept was refused", "[BotLocale]") CHECK(ru.Knows(s)); } CHECK(ru.Knows("The quest share ran out before I could take it.")); + CHECK(Translate(Lang::Ru, "Starting from an item in my bags: An Undelivered Letter") + == "Беру задание от предмета в сумке: An Undelivered Letter"); } TEST_CASE("BotLocale: unknown lines come back in English", "[BotLocale]")