Bots: say why a quest could not be taken
When a player tells a bot to take a quest ("accept", the AI bots bridge,
or a quest shared with the group) and the server refuses it, the bot
used to go quiet. Now it whispers the reason: level too low or too high,
not for its class or race, the quest before it not done, already done
or in the log, another quest rules it out, daily not reset yet, quest
log full, no bag room for the quest item, giver gone or too far, turned
off on this server. A named quest that nobody near offers gets the same
reason when the bot could not take it anyway.
The reason is the first of the server's own accept gates that fails,
checked without a message to the bot's client. The bot's own questing
stays quiet. Russian lines included.
This commit is contained in:
@@ -7418,8 +7418,39 @@ Result API::use_game_object(ObjectGuid go_guid)
|
||||
|
||||
// ---- Quest ---------------------------------------------------------------
|
||||
|
||||
QuestRefusal API::why_cant_take_quest(uint32 quest_id) const
|
||||
{
|
||||
if (!p_) return QuestRefusal::Other;
|
||||
Quest const* q = sObjectMgr->GetQuestTemplate(quest_id);
|
||||
if (!q) return QuestRefusal::Other;
|
||||
// CanTakeQuest's own gates, in its order, each asked without a message to the bot's client.
|
||||
if (DisableMgr::IsDisabledFor(DISABLE_TYPE_QUEST, quest_id, p_)) return QuestRefusal::Disabled;
|
||||
if (!p_->SatisfyQuestStatus(q, false))
|
||||
return p_->GetQuestStatus(quest_id) == QUEST_STATUS_REWARDED ? QuestRefusal::Done : QuestRefusal::OnIt;
|
||||
if (!p_->SatisfyQuestExclusiveGroup(q, false)) return QuestRefusal::OtherChoice;
|
||||
if (!p_->SatisfyQuestClass(q, false)) return QuestRefusal::Class;
|
||||
if (!p_->SatisfyQuestRace(q, false)) return QuestRefusal::Race;
|
||||
if (!p_->SatisfyQuestMinLevel(q, false)) return QuestRefusal::LowLevel;
|
||||
if (!p_->SatisfyQuestMaxLevel(q, false)) return QuestRefusal::HighLevel;
|
||||
if (!p_->SatisfyQuestSkill(q, false)) return QuestRefusal::Skill;
|
||||
if (!p_->SatisfyQuestReputation(q, false)) return QuestRefusal::Reputation;
|
||||
if (!p_->SatisfyQuestDependentQuests(q, false)) return QuestRefusal::Prerequisite;
|
||||
if (!p_->SatisfyQuestTimed(q, false)) return QuestRefusal::Timed;
|
||||
if (!p_->SatisfyQuestDay(q, false) || !p_->SatisfyQuestWeek(q, false) ||
|
||||
!p_->SatisfyQuestMonth(q, false) || !p_->SatisfyQuestSeasonal(q, false))
|
||||
return QuestRefusal::NotAgainYet;
|
||||
if (!p_->SatisfyQuestConditions(q, false)) return QuestRefusal::Conditions;
|
||||
if (!p_->SatisfyQuestExpansion(q, false)) return QuestRefusal::Expansion;
|
||||
if (!p_->CanTakeQuest(q, false)) return QuestRefusal::Other; // a gate added to CanTakeQuest later
|
||||
if (!p_->SatisfyQuestLog(false)) return QuestRefusal::LogFull;
|
||||
if (!p_->CanAddQuest(q, false)) return QuestRefusal::BagsFull;
|
||||
return QuestRefusal::None;
|
||||
}
|
||||
|
||||
Result API::accept_quest(ObjectGuid quest_giver, uint32 quest_id)
|
||||
{
|
||||
last_quest_refusal_ = QuestRefusal::None;
|
||||
last_quest_refusal_quest_ = quest_id;
|
||||
if (!p_) return Result::Other;
|
||||
Quest const* quest = sObjectMgr->GetQuestTemplate(quest_id);
|
||||
if (!quest)
|
||||
@@ -7427,11 +7458,13 @@ Result API::accept_quest(ObjectGuid quest_giver, uint32 quest_id)
|
||||
TC_LOG_INFO("playerbot.v2",
|
||||
"[accept_quest] {} reject quest={} reason=template_missing",
|
||||
"?", quest_id);
|
||||
last_quest_refusal_ = QuestRefusal::Other;
|
||||
return Result::NotKnown;
|
||||
}
|
||||
|
||||
auto log_reject = [&](char const* why)
|
||||
auto log_reject = [&](char const* why, QuestRefusal refusal)
|
||||
{
|
||||
last_quest_refusal_ = refusal;
|
||||
TC_LOG_INFO("playerbot.v2",
|
||||
"[accept_quest] {} reject quest={} lvl={} reason={}",
|
||||
p_->GetName(), quest_id, uint32(p_->GetLevel()), why);
|
||||
@@ -7447,10 +7480,10 @@ Result API::accept_quest(ObjectGuid quest_giver, uint32 quest_id)
|
||||
object = ObjectAccessor::GetObjectByTypeMask(*p_, quest_giver,
|
||||
TYPEMASK_UNIT | TYPEMASK_GAMEOBJECT | TYPEMASK_ITEM);
|
||||
}
|
||||
if (!object) { log_reject("giver_not_found"); return Result::InvalidTarget; }
|
||||
if (quest_giver.IsPlayer()) { log_reject("player_giver_unsupp"); return Result::Other; }
|
||||
if (!object->hasQuest(quest_id)) { log_reject("giver_lost_relation"); return Result::InvalidTarget; }
|
||||
if (!p_->CanInteractWithQuestGiver(object)) { log_reject("out_of_range"); return Result::OutOfRange; }
|
||||
if (!object) { log_reject("giver_not_found", QuestRefusal::NoGiver); return Result::InvalidTarget; }
|
||||
if (quest_giver.IsPlayer()) { log_reject("player_giver_unsupp", QuestRefusal::Other); return Result::Other; }
|
||||
if (!object->hasQuest(quest_id)) { log_reject("giver_lost_relation", QuestRefusal::NoGiver); return Result::InvalidTarget; }
|
||||
if (!p_->CanInteractWithQuestGiver(object)) { log_reject("out_of_range", QuestRefusal::OutOfRange); return Result::OutOfRange; }
|
||||
// Junk-quest accept-gate (R2, defense-in-depth). A quest with ZERO
|
||||
// objectives AND no creature/GO turn-in NPC is structurally unfinishable
|
||||
// and unturnable — accepting it parks the bot forever (current_quest_id=0
|
||||
@@ -7463,11 +7496,11 @@ Result API::accept_quest(ObjectGuid quest_giver, uint32 quest_id)
|
||||
auto ce = sObjectMgr->GetCreatureQuestInvolvedRelationReverseBounds(quest_id);
|
||||
auto ge = sObjectMgr->GetGOQuestInvolvedRelationReverseBounds(quest_id);
|
||||
if (ce.begin() == ce.end() && ge.begin() == ge.end())
|
||||
{ log_reject("no_ender_or_objectives"); return Result::Locked; }
|
||||
{ log_reject("no_ender_or_objectives", QuestRefusal::Unfinishable); return Result::Locked; }
|
||||
}
|
||||
if (!p_->CanTakeQuest(quest, true)) { log_reject("cant_take_quest"); return Result::Locked; }
|
||||
if (!p_->SatisfyQuestLog(false)) { log_reject("quest_log_full"); return Result::InventoryFull; }
|
||||
if (!p_->CanAddQuest(quest, true)) { log_reject("src_item_no_bag_space"); return Result::InventoryFull; }
|
||||
if (!p_->CanTakeQuest(quest, true)) { log_reject("cant_take_quest", why_cant_take_quest(quest_id)); return Result::Locked; }
|
||||
if (!p_->SatisfyQuestLog(false)) { log_reject("quest_log_full", QuestRefusal::LogFull); return Result::InventoryFull; }
|
||||
if (!p_->CanAddQuest(quest, true)) { log_reject("src_item_no_bag_space", QuestRefusal::BagsFull); return Result::InventoryFull; }
|
||||
|
||||
p_->AddQuestAndCheckCompletion(quest, object);
|
||||
p_->PlayerTalkClass->SendCloseGossip();
|
||||
@@ -8043,15 +8076,20 @@ Result API::equip_item(uint8 from_bag, uint8 from_slot, uint8 to_slot)
|
||||
|
||||
Result API::accept_shared_quest()
|
||||
{
|
||||
last_quest_refusal_ = QuestRefusal::None;
|
||||
last_quest_refusal_quest_ = 0;
|
||||
if (!p_) return Result::Other;
|
||||
const ObjectGuid sender_guid = p_->GetPlayerSharingQuest();
|
||||
const uint32 quest_id = p_->GetSharedQuestID();
|
||||
if (sender_guid.IsEmpty() || quest_id == 0) return Result::Locked;
|
||||
// The share ran out (or was answered already) between the order and this tick.
|
||||
if (sender_guid.IsEmpty() || quest_id == 0) { last_quest_refusal_ = QuestRefusal::NoGiver; return Result::Locked; }
|
||||
last_quest_refusal_quest_ = quest_id;
|
||||
Quest const* quest = sObjectMgr->GetQuestTemplate(quest_id);
|
||||
if (!quest) { p_->ClearQuestSharingInfo(); return Result::NotKnown; }
|
||||
if (!quest) { p_->ClearQuestSharingInfo(); last_quest_refusal_ = QuestRefusal::Other; return Result::NotKnown; }
|
||||
Player* sender = ObjectAccessor::FindConnectedPlayer(sender_guid);
|
||||
if (!p_->CanTakeQuest(quest, false) || !p_->CanAddQuest(quest, false))
|
||||
{
|
||||
last_quest_refusal_ = why_cant_take_quest(quest_id);
|
||||
TC_LOG_INFO("playerbot.v2", "[quest_share] {} cannot take shared quest {} from {} (CanTake={} CanAdd={})",
|
||||
p_->GetName(), quest_id, sender ? sender->GetName() : std::string("?"),
|
||||
p_->CanTakeQuest(quest, false), p_->CanAddQuest(quest, false));
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
#include "Define.h"
|
||||
#include "ObjectGuid.h"
|
||||
#include "Bot/Quest/QuestRefusal.h"
|
||||
#include <chrono>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@@ -169,6 +170,13 @@ public:
|
||||
// rejoin rule waits for a slot instead of walking a full instance's entrance.
|
||||
uint32 last_instance_full_map() const { return last_instance_full_map_; }
|
||||
void clear_instance_full_map() { last_instance_full_map_ = 0; }
|
||||
// Why the last accept_quest / accept_shared_quest was refused (None after an accept that went through), and the quest it was
|
||||
// for, so the executor can tell the player who ordered it (Bot/Quest/QuestRefusal.h).
|
||||
QuestRefusal last_quest_refusal() const { return last_quest_refusal_; }
|
||||
uint32 last_quest_refusal_quest() const { return last_quest_refusal_quest_; }
|
||||
// The first of the server's own accept gates `quest_id` fails for this bot right now (CanTakeQuest, then the quest log and
|
||||
// the bag room CanAddQuest checks), None when it could take it. No message reaches the bot's client. World thread.
|
||||
QuestRefusal why_cant_take_quest(uint32 quest_id) const;
|
||||
static char const* CastFailName(uint32 code);
|
||||
|
||||
// Why a mount spell would draw nothing on the client, nullptr when its model resolves: the display the aura picks (Mount
|
||||
@@ -1167,6 +1175,8 @@ private:
|
||||
Player* p_;
|
||||
uint32 last_cast_fail_ = 0; // see last_cast_fail()
|
||||
uint32 last_instance_full_map_ = 0; // see last_instance_full_map()
|
||||
QuestRefusal last_quest_refusal_ = QuestRefusal::None; // see last_quest_refusal()
|
||||
uint32 last_quest_refusal_quest_ = 0;
|
||||
};
|
||||
|
||||
} // namespace Playerbot
|
||||
|
||||
@@ -10,7 +10,10 @@
|
||||
#include "BotSnapshot.h"
|
||||
#include "ChannelTalk.h"
|
||||
#include "ClassicUpkeep.h"
|
||||
#include "Quest/CompanionQuest.h"
|
||||
#include "Quest/QuestOrders.h"
|
||||
#include "Quest/QuestRefusal.h"
|
||||
#include "../Api/PlayerbotAPI.h"
|
||||
#include "../Api/BotTradeShop.h"
|
||||
#include "../Diagnostics/ScenarioHuman.h"
|
||||
#include "../Fleet/BotGuildCharter.h"
|
||||
@@ -1364,7 +1367,12 @@ std::string RunAction(ConfigReader::BridgeConfig const& cfg, Player* bot, Player
|
||||
for (auto const& off : snap->quest_discovery.quest_offers)
|
||||
offered = offered || off.quest_id == a.quest;
|
||||
if (!offered)
|
||||
{
|
||||
QuestRefusal const why = API(bot).why_cant_take_quest(a.quest);
|
||||
if (why != QuestRefusal::None && why != QuestRefusal::Other)
|
||||
return QuestRefusalLine(why, CompanionQuest::QuestLabel(a.quest));
|
||||
return "nobody close offers me that quest";
|
||||
}
|
||||
detail = JoinLines(QuestOrders::AcceptAll(speaker, bot, std::to_string(a.quest)));
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -144,7 +144,9 @@ struct RepairAllIntent { ObjectGuid npc; bool from_guild_bank; };
|
||||
struct VendorBuyByCategoryIntent { ObjectGuid npc; uint8 item_class, item_subclass; uint8 total_count; };
|
||||
|
||||
// ---- Quest ----
|
||||
struct QuestAcceptIntent { ObjectGuid npc; uint32 quest_id; };
|
||||
// tell: the player who ordered the accept; when the server refuses it, the bot whispers them why (Bot/Quest/QuestRefusal.h).
|
||||
// Empty for the bot's own questing, which retries quietly.
|
||||
struct QuestAcceptIntent { ObjectGuid npc; uint32 quest_id; ObjectGuid tell; };
|
||||
// `reward_choice` selects from the quest's choice-item list (0 = first).
|
||||
// Pass 0xFF to let PlayerbotAPI auto-pick (ScoreQuestReward weighs equippable
|
||||
// upgrades > vendor value). Quests with only fixed rewards ignore the field.
|
||||
@@ -154,8 +156,8 @@ struct QuestAbandonIntent { uint32 quest_id; };
|
||||
// Accept a quest just shared by a group member. The receiver-side popup is
|
||||
// driven by `Player::SetQuestSharingInfo`; the API uses GetSharedQuestID for
|
||||
// the actual accept. No fields needed on the intent — the bot side already
|
||||
// knows what's pending via the snapshot.
|
||||
struct QuestSharedAcceptIntent {};
|
||||
// knows what's pending via the snapshot. `tell` as in QuestAcceptIntent.
|
||||
struct QuestSharedAcceptIntent { ObjectGuid tell; };
|
||||
// Run JunkQuestResolver on the bot: force-complete auto-granted feature quests
|
||||
// (55660 "Time Trials" etc. — abandon doesn't stick, they re-push at login) and
|
||||
// resolve profession-spec choice quests. No fields — the resolver processes the
|
||||
|
||||
@@ -323,12 +323,12 @@ public:
|
||||
{ return emit(VehicleSpellIntent{spell_id, target}); }
|
||||
bool cast_vehicle_at(uint32 spell_id, float x, float y, float z)
|
||||
{ return emit(VehicleGroundSpellIntent{spell_id, x, y, z}); }
|
||||
bool accept_quest(ObjectGuid giver, uint32 quest_id)
|
||||
{ return emit(QuestAcceptIntent{giver, quest_id}); }
|
||||
bool accept_quest(ObjectGuid giver, uint32 quest_id, ObjectGuid tell = ObjectGuid::Empty)
|
||||
{ return emit(QuestAcceptIntent{giver, quest_id, tell}); }
|
||||
bool complete_quest(ObjectGuid giver, uint32 quest_id, uint8 reward_choice = 0, bool copy_leader = false)
|
||||
{ return emit(QuestCompleteIntent{giver, quest_id, reward_choice, copy_leader}); }
|
||||
bool abandon_quest(uint32 quest_id) { return emit(QuestAbandonIntent{quest_id}); }
|
||||
bool accept_shared_quest() { return emit(QuestSharedAcceptIntent{}); }
|
||||
bool accept_shared_quest(ObjectGuid tell = ObjectGuid::Empty) { return emit(QuestSharedAcceptIntent{tell}); }
|
||||
bool resolve_junk_quests() { return emit(ResolveJunkQuestsIntent{}); }
|
||||
|
||||
// Mail. Mailbox guid is a GameObject (mailbox) or Creature (mailbox NPC);
|
||||
|
||||
@@ -39,6 +39,8 @@
|
||||
#include "GameTime.h"
|
||||
#include "Log.h"
|
||||
#include "Bot/DrainOrder.h"
|
||||
#include "Bot/Quest/CompanionQuest.h"
|
||||
#include "Bot/Quest/QuestRefusal.h"
|
||||
#include "Bot/ReactionTiming.h"
|
||||
#include "Combat/Apl/ApInterrupt.h"
|
||||
#include <chrono>
|
||||
@@ -98,6 +100,27 @@ Result SayInZoneChannel(Player* bot, uint8 channel_id, std::string const& text)
|
||||
return Result::Ok;
|
||||
}
|
||||
|
||||
// A quest accept a player ordered (QuestAcceptIntent / QuestSharedAcceptIntent with `tell`) and the server refused: the bot
|
||||
// whispers that player the gate that failed, in their language, instead of going quiet. The bot's own questing has no `tell`.
|
||||
static void TellQuestRefusal(API& api, IntentBody const& body)
|
||||
{
|
||||
ObjectGuid tell;
|
||||
if (auto const* a = std::get_if<QuestAcceptIntent>(&body))
|
||||
tell = a->tell;
|
||||
else if (auto const* s = std::get_if<QuestSharedAcceptIntent>(&body))
|
||||
tell = s->tell;
|
||||
if (tell.IsEmpty() || api.last_quest_refusal() == QuestRefusal::None)
|
||||
return;
|
||||
Player* const who = ObjectAccessor::FindConnectedPlayer(tell);
|
||||
if (!who)
|
||||
return;
|
||||
uint32 const quest = api.last_quest_refusal_quest();
|
||||
if (quest == 0) // a share that ran out before this tick: there is no quest id left to name
|
||||
api.whisper(who->GetName(), "The quest share ran out before I could take it.");
|
||||
else
|
||||
api.whisper(who->GetName(), QuestRefusalLine(api.last_quest_refusal(), CompanionQuest::QuestLabel(quest)));
|
||||
}
|
||||
|
||||
// [bot_cc_onset]: the tick a bot goes from free to feared / confused / stunned, name the aura, its caster and how far the
|
||||
// caster is. Deadmines Sneed's Shredder Terrify hit the priest standing at 1.4 y and the warrior at 2.5-5 y; the log had no
|
||||
// onset line, so the radius of the effect was unknown. Edge-triggered per bot, no polling cost beyond a bit test.
|
||||
@@ -784,6 +807,8 @@ size_t V2::Module::DrainIntents()
|
||||
if (r == Result::ServerRefused && api.last_instance_full_map() != 0 && entry.ai)
|
||||
entry.ai->note_instance_full(api.last_instance_full_map(), GameTime::GetGameTimeMS());
|
||||
api.clear_instance_full_map();
|
||||
if (r != Result::Ok)
|
||||
TellQuestRefusal(api, intent.body);
|
||||
Services::Perf().record_intent_executed();
|
||||
Services::Perf().record_intent_result(static_cast<size_t>(r));
|
||||
if (r != Result::Ok)
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
#include "Bot/Quest/QuestOrders.h"
|
||||
#include "Bot/Quest/CompanionQuest.h"
|
||||
#include "Bot/Quest/QuestRefusal.h"
|
||||
#include "Api/PlayerbotAPI.h"
|
||||
#include "Bot/BotSnapshot.h"
|
||||
#include "Bot/BotIntentEmitter.h"
|
||||
#include "Bot/BotRegistry.h"
|
||||
@@ -193,7 +195,7 @@ std::vector<std::string> List(Player* /*sender*/, Player* bot, std::string_view
|
||||
return out;
|
||||
}
|
||||
|
||||
std::vector<std::string> AcceptAll(Player* /*sender*/, Player* bot, std::string_view arg)
|
||||
std::vector<std::string> AcceptAll(Player* sender, Player* bot, std::string_view arg)
|
||||
{
|
||||
std::vector<std::string> out;
|
||||
auto snap = SnapOf(bot);
|
||||
@@ -209,7 +211,7 @@ std::vector<std::string> AcceptAll(Player* /*sender*/, Player* bot, std::string_
|
||||
// A quest the group just shared with me.
|
||||
if (snap->social_events.shared_quest_id != 0)
|
||||
{
|
||||
emit.accept_shared_quest();
|
||||
emit.accept_shared_quest(sender ? sender->GetGUID() : ObjectGuid::Empty);
|
||||
LogOrder(bot, "accept shared", snap->social_events.shared_quest_id);
|
||||
out.push_back(fmt::format("Taking the shared quest: {}", CompanionQuest::QuestLabel(snap->social_events.shared_quest_id)));
|
||||
++taken;
|
||||
@@ -224,7 +226,7 @@ std::vector<std::string> AcceptAll(Player* /*sender*/, Player* bot, std::string_
|
||||
if (taken >= kMaxAcceptPerOrder) break;
|
||||
if (want && off.quest_id != want) continue;
|
||||
if (!needle.empty() && Lower(CompanionQuest::QuestLabel(off.quest_id)).find(needle) == std::string::npos) continue;
|
||||
emit.accept_quest(off.giver, off.quest_id);
|
||||
emit.accept_quest(off.giver, off.quest_id, sender ? sender->GetGUID() : ObjectGuid::Empty);
|
||||
LogOrder(bot, "accept", off.quest_id);
|
||||
out.push_back(fmt::format("Accepting: {}", CompanionQuest::QuestLabel(off.quest_id)));
|
||||
++taken;
|
||||
@@ -238,7 +240,15 @@ std::vector<std::string> AcceptAll(Player* /*sender*/, Player* bot, std::string_
|
||||
out.push_back("Nothing on offer right here; I'll pick up what the quest givers near us have for the next 45 seconds.");
|
||||
}
|
||||
else if (taken == 0)
|
||||
out.push_back("That quest isn't on offer from anyone next to me.");
|
||||
{
|
||||
// A quest named by id or link that the offers left out: the offers only hold what the bot can take, so say which gate
|
||||
// keeps it out (level, class, done, log full ...) before saying nobody here has it.
|
||||
QuestRefusal const why = want ? API(bot).why_cant_take_quest(want) : QuestRefusal::None;
|
||||
if (why != QuestRefusal::None && why != QuestRefusal::Other)
|
||||
out.push_back(QuestRefusalLine(why, CompanionQuest::QuestLabel(want)));
|
||||
else
|
||||
out.push_back("That quest isn't on offer from anyone next to me.");
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,8 +2,10 @@
|
||||
//
|
||||
// Every function runs on the WORLD thread (the whisper / party-chat hook, where BotCommandParser::Dispatch
|
||||
// runs): it reads the bot's latest published snapshot and static data (ObjectMgr) and QUEUES intents on the
|
||||
// bot's own intent queue; it never touches the bot's Player. The sender's Player is only read (quest status,
|
||||
// CanTakeQuest) to filter what is worth sharing. It returns the reply lines for the owner; the caller whispers
|
||||
// bot's own intent queue; it never changes the bot's Player (it reads it only through API::why_cant_take_quest, to say
|
||||
// why a named quest is not on offer). The sender's Player is only read (quest status, CanTakeQuest) to filter what is
|
||||
// worth sharing. An accept it queues carries the sender, so a refusal on the world thread is whispered back with its
|
||||
// reason (Bot/Quest/QuestRefusal.h). It returns the reply lines for the owner; the caller whispers
|
||||
// them (WhisperIntent{sender->GetName(), line} through Push, or Chat). Nothing is whispered here.
|
||||
//
|
||||
// `arg` is the text after the verb, trimmed: a quest id, a quest link ("|Hquest:123:45|h[Title]|h|r"), a title
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
// QuestRefusal - why a bot could not take a quest, said to the player who asked for it (pure: no game objects, unit tested).
|
||||
//
|
||||
// The server's accept path (API::accept_quest / accept_shared_quest, Api/PlayerbotAPI.cpp) runs the same gates as a player's
|
||||
// accept and records the first one that failed. When the owner ordered the accept ("accept", the AI bots bridge, a shared
|
||||
// quest), the bot then says which gate it was instead of going quiet. The lines are English templates with `{}` for the quest;
|
||||
// Util/BotLocaleRu.cpp has every one of them, so a Russian client reads them in Russian.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
namespace Playerbot {
|
||||
|
||||
enum class QuestRefusal : uint8_t
|
||||
{
|
||||
None = 0, // nothing refused (or nothing recorded)
|
||||
Other, // the quest is unknown, or a giver the bot cannot take quests from
|
||||
Disabled, // turned off on this server (disables table)
|
||||
OnIt, // already in the quest log
|
||||
Done, // already handed in and not repeatable
|
||||
OtherChoice, // one quest of its exclusive group is already taken or done
|
||||
Class,
|
||||
Race,
|
||||
LowLevel,
|
||||
HighLevel,
|
||||
Skill,
|
||||
Reputation,
|
||||
Prerequisite, // the quest before it (or a breadcrumb's follow-up) is not done
|
||||
Timed, // another timed quest is running
|
||||
NotAgainYet, // a daily / weekly / monthly / seasonal quest already done this time
|
||||
Conditions, // the conditions table says no (a phase, an aura, a world state)
|
||||
Expansion,
|
||||
LogFull,
|
||||
BagsFull, // the item the quest hands out has no room
|
||||
NoGiver, // the giver or the sharer is gone, or the share ran out
|
||||
OutOfRange,
|
||||
Unfinishable, // no objectives and nobody to hand it in to
|
||||
};
|
||||
|
||||
// The template for `why` ("I can't take {}: ..."), or an empty view for None.
|
||||
inline std::string_view QuestRefusalTemplate(QuestRefusal why)
|
||||
{
|
||||
switch (why)
|
||||
{
|
||||
case QuestRefusal::None: return {};
|
||||
case QuestRefusal::Other: return "I can't take {}.";
|
||||
case QuestRefusal::Disabled: return "I can't take {}: it is turned off on this server.";
|
||||
case QuestRefusal::OnIt: return "I already have {}.";
|
||||
case QuestRefusal::Done: return "I already did {}.";
|
||||
case QuestRefusal::OtherChoice: return "I can't take {}: I already took another quest that rules it out.";
|
||||
case QuestRefusal::Class: return "I can't take {}: it is not for my class.";
|
||||
case QuestRefusal::Race: return "I can't take {}: it is not for my race.";
|
||||
case QuestRefusal::LowLevel: return "I can't take {}: my level is too low.";
|
||||
case QuestRefusal::HighLevel: return "I can't take {}: my level is too high.";
|
||||
case QuestRefusal::Skill: return "I can't take {}: I don't have the skill for it.";
|
||||
case QuestRefusal::Reputation: return "I can't take {}: my reputation isn't right for it.";
|
||||
case QuestRefusal::Prerequisite: return "I can't take {}: I haven't done the quest that comes before it.";
|
||||
case QuestRefusal::Timed: return "I can't take {}: I'm already on a timed quest.";
|
||||
case QuestRefusal::NotAgainYet: return "I can't take {} again yet.";
|
||||
case QuestRefusal::Conditions: return "I can't take {} yet: something else has to happen first.";
|
||||
case QuestRefusal::Expansion: return "I can't take {}: it is from a later expansion.";
|
||||
case QuestRefusal::LogFull: return "I can't take {}: my quest log is full.";
|
||||
case QuestRefusal::BagsFull: return "I can't take {}: no room in my bags for its item.";
|
||||
case QuestRefusal::NoGiver: return "I can't take {}: whoever offered it is gone.";
|
||||
case QuestRefusal::OutOfRange: return "I can't take {}: I'm too far from the quest giver.";
|
||||
case QuestRefusal::Unfinishable: return "I won't take {}: it can't be finished.";
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
// The line for `why` with the quest's name in it, or an empty string for None.
|
||||
inline std::string QuestRefusalLine(QuestRefusal why, std::string_view quest)
|
||||
{
|
||||
std::string_view const t = QuestRefusalTemplate(why);
|
||||
size_t const at = t.find("{}");
|
||||
if (t.empty() || at == std::string_view::npos)
|
||||
return std::string(t);
|
||||
std::string out;
|
||||
out.reserve(t.size() + quest.size());
|
||||
out.append(t.substr(0, at));
|
||||
out.append(quest.empty() ? std::string_view("that quest") : quest);
|
||||
out.append(t.substr(at + 2));
|
||||
return out;
|
||||
}
|
||||
|
||||
} // namespace Playerbot
|
||||
@@ -386,6 +386,31 @@ std::vector<Catalog::Entry> const& RussianEntries()
|
||||
{ "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.", "Это задание никто рядом со мной не дает." },
|
||||
// why an accept was refused (Bot/Quest/QuestRefusal.h)
|
||||
{ "I can't take {}.", "Я не могу взять задание {}." },
|
||||
{ "I can't take {}: it is turned off on this server.", "Я не могу взять задание {}: на этом сервере оно отключено." },
|
||||
{ "I already have {}.", "Задание {} у меня уже есть." },
|
||||
{ "I already did {}.", "Задание {} у меня уже сдано." },
|
||||
{ "I can't take {}: I already took another quest that rules it out.",
|
||||
"Я не могу взять задание {}: у меня уже было другое задание, которое его исключает." },
|
||||
{ "I can't take {}: it is not for my class.", "Я не могу взять задание {}: оно не для моего класса." },
|
||||
{ "I can't take {}: it is not for my race.", "Я не могу взять задание {}: оно не для моей расы." },
|
||||
{ "I can't take {}: my level is too low.", "Я не могу взять задание {}: у меня слишком низкий уровень." },
|
||||
{ "I can't take {}: my level is too high.", "Я не могу взять задание {}: у меня слишком высокий уровень." },
|
||||
{ "I can't take {}: I don't have the skill for it.", "Я не могу взять задание {}: у меня нет нужного навыка." },
|
||||
{ "I can't take {}: my reputation isn't right for it.", "Я не могу взять задание {}: не та репутация." },
|
||||
{ "I can't take {}: I haven't done the quest that comes before it.",
|
||||
"Я не могу взять задание {}: сначала нужно выполнить задание перед ним." },
|
||||
{ "I can't take {}: I'm already on a timed quest.", "Я не могу взять задание {}: у меня уже есть задание на время." },
|
||||
{ "I can't take {} again yet.", "Задание {} пока нельзя взять снова." },
|
||||
{ "I can't take {} yet: something else has to happen first.", "Задание {} пока нельзя взять: сначала должно случиться другое." },
|
||||
{ "I can't take {}: it is from a later expansion.", "Я не могу взять задание {}: оно из более позднего дополнения." },
|
||||
{ "I can't take {}: my quest log is full.", "Я не могу взять задание {}: мой журнал заданий полон." },
|
||||
{ "I can't take {}: no room in my bags for its item.", "Я не могу взять задание {}: в сумках нет места для его предмета." },
|
||||
{ "I can't take {}: whoever offered it is gone.", "Я не могу взять задание {}: того, кто его дал, уже нет рядом." },
|
||||
{ "I can't take {}: I'm too far from the quest giver.", "Я не могу взять задание {}: я слишком далеко от того, кто его дает." },
|
||||
{ "I won't take {}: it can't be finished.", "Я не возьму задание {}: его нельзя выполнить." },
|
||||
{ "The quest share ran out before I could take it.", "Время на общее задание вышло, взять его уже нельзя." },
|
||||
{ "I can't drop quests right now.", "Сейчас я не могу отменять задания." },
|
||||
{ "Drop which quest? Give its name, link or id, or \"all\".", "Какое задание отменить? Назовите его, дайте ссылку или номер, или \"all\"." },
|
||||
{ "I have no quest matching \"{}\".", "У меня нет задания \"{}\"." },
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
|
||||
#include "../../src/modules/PlayerbotV2/Util/BotLocaleText.h"
|
||||
#include "../../src/modules/PlayerbotV2/Bot/Raid/RaidBanter.h"
|
||||
#include "../../src/modules/PlayerbotV2/Bot/Quest/QuestRefusal.h"
|
||||
#include <cctype>
|
||||
#include <set>
|
||||
#include <string>
|
||||
@@ -231,6 +232,28 @@ TEST_CASE("BotLocale: boss tactics answers", "[BotLocale]")
|
||||
CHECK(Translate(Lang::Ru, "Bosses here: Lucifron, Magmadar.") == "Боссы здесь: Lucifron, Magmadar.");
|
||||
}
|
||||
|
||||
TEST_CASE("BotLocale: why a quest accept was refused", "[BotLocale]")
|
||||
{
|
||||
using Playerbot::QuestRefusal;
|
||||
using Playerbot::QuestRefusalLine;
|
||||
CHECK(QuestRefusalLine(QuestRefusal::None, "Wolves") == "");
|
||||
CHECK(QuestRefusalLine(QuestRefusal::LowLevel, "Wolves Across the Border") == "I can't take Wolves Across the Border: my level is too low.");
|
||||
CHECK(QuestRefusalLine(QuestRefusal::Done, "") == "I already did that quest.");
|
||||
CHECK(Translate(Lang::Ru, QuestRefusalLine(QuestRefusal::LogFull, "Wolves")) == "Я не могу взять задание Wolves: мой журнал заданий полон.");
|
||||
CHECK(Translate(Lang::Ru, QuestRefusalLine(QuestRefusal::NotAgainYet, "Wolves")) == "Задание Wolves пока нельзя взять снова.");
|
||||
|
||||
// Every reason has a line with the quest in it, and every line has its Russian form.
|
||||
Catalog const& ru = Russian();
|
||||
for (uint8_t r = uint8_t(QuestRefusal::Other); r <= uint8_t(QuestRefusal::Unfinishable); ++r)
|
||||
{
|
||||
std::string const s = QuestRefusalLine(QuestRefusal(r), "Wolves");
|
||||
INFO(s);
|
||||
CHECK(s.find("Wolves") != std::string::npos);
|
||||
CHECK(ru.Knows(s));
|
||||
}
|
||||
CHECK(ru.Knows("The quest share ran out before I could take it."));
|
||||
}
|
||||
|
||||
TEST_CASE("BotLocale: unknown lines come back in English", "[BotLocale]")
|
||||
{
|
||||
CHECK(Translate(Lang::Ru, "Perf: ticks=5 emit=3") == "Perf: ticks=5 emit=3");
|
||||
|
||||
Reference in New Issue
Block a user