PlayerbotV2: Stay / Follow pause the tank lead, "go" goes on
chris: Stay and Follow should pause the lead, not end it, and "go" picks it up again. - stay, hold, follow and come (typed, whispered or the panel buttons and keys) pause a running lead once for the group and tell the owner to say go; the order itself works as before - "go" alone (also the Russian "вперед" / "го") resumes a paused lead; it is the lead's word only while the lead is on or paused, otherwise it stays chat - the Lead button turns blue when Follow, Stay or Come is pressed - Russian text, docs and tests
This commit is contained in:
@@ -909,6 +909,10 @@ for _, k in ipairs(KEY_ORDERS) do
|
||||
RefreshStance()
|
||||
end)
|
||||
end
|
||||
if k[2] == "follow" or k[2] == "stay" or k[2] == "come" then
|
||||
-- The server pauses a running Tank leads on these (BotCommandParser::PauseLeadForOwnerOrder); the Lead button shows it.
|
||||
b:HookScript("OnClick", function() UI.LeadPausedByOrder() end)
|
||||
end
|
||||
secureOrders[#secureOrders + 1] = b
|
||||
_G["BINDING_NAME_CLICK " .. name .. ":LeftButton"] = k[3]
|
||||
end
|
||||
@@ -1479,6 +1483,13 @@ function UI.LeadClick(button)
|
||||
UI.leadState = state
|
||||
UI.RefreshLead()
|
||||
end
|
||||
-- Follow, Stay and Come pause a running lead on the server (chris, 2026-11-13); "go" or a right-click goes on.
|
||||
function UI.LeadPausedByOrder()
|
||||
if UI.leadState == "on" then
|
||||
UI.leadState = "paused"
|
||||
UI.RefreshLead()
|
||||
end
|
||||
end
|
||||
-- Loading screens: inside a 5-man the lead is in force; leaving the dungeon again ends it (as on the server).
|
||||
function UI.LeadZone()
|
||||
local inside, kind = false, nil
|
||||
@@ -1516,6 +1527,9 @@ function UI.BuildOrders()
|
||||
for i, d in ipairs(OG) do
|
||||
local b = Btn(ordersGrid, ((i - 1) % 3) * 81, 18 + math.floor((i - 1) / 3) * 32, 76, 26, d[1], { order = d[2], size = 11 })
|
||||
Tip(b, d[3], d[4])
|
||||
if d[2] == "follow" or d[2] == "stay" or d[2] == "come" then
|
||||
b:HookScript("OnClick", function() UI.LeadPausedByOrder() end)
|
||||
end
|
||||
end
|
||||
local rally = Btn(ordersGrid, 0, 18 + 3 * 32, 76, 26, L["short:Set rally"], { order = "rally here", size = 11 })
|
||||
Tip(rally, L["Set rally"], L["Sets the rally point to where you stand (used by Fall back and Pull back)."])
|
||||
@@ -1536,7 +1550,7 @@ function UI.BuildOrders()
|
||||
UI.leadBtn = Btn(ordersGrid, 162, 18 + 4 * 32, 76, 26, L["short:Tank leads"], { size = 11 })
|
||||
UI.leadBtn:RegisterForClicks("LeftButtonUp", "RightButtonUp")
|
||||
UI.leadBtn:SetScript("OnClick", function(_, button) UI.LeadClick(button) end)
|
||||
Tip(UI.leadBtn, L["Tank leads"], L["In a dungeon your tank bot leads: it walks on, pulls pack by pack, waits for mana and for you, and goes boss to boss. You follow.\nClick: on or off. Right-click: pause (it holds where it stands) or go on.\nGreen: on. Blue: paused. It ends when you leave the dungeon. Follow and Stay still work: Tank leads again hands the lead back."])
|
||||
Tip(UI.leadBtn, L["Tank leads"], L["In a dungeon your tank bot leads: it walks on, pulls pack by pack, waits for mana and for you, and goes boss to boss. You follow.\nClick: on or off. Right-click: pause (it holds where it stands) or go on.\nGreen: on. Blue: paused. It ends when you leave the dungeon. Follow, Stay and Come pause it: say go (or right-click) and it leads on."])
|
||||
UI.RefreshLead()
|
||||
|
||||
-- Two on/off check boxes at the bottom (the client's own check box). Area spells: on (the server's start setting) the bots use
|
||||
|
||||
@@ -593,6 +593,6 @@ ForeverBotsLocale = {
|
||||
["short:Tank leads"] = "Танк ведет", -- check
|
||||
["short:Lead paused"] = "Пауза",
|
||||
["Tank leads"] = "Танк ведет группу", -- check
|
||||
["In a dungeon your tank bot leads: it walks on, pulls pack by pack, waits for mana and for you, and goes boss to boss. You follow.\nClick: on or off. Right-click: pause (it holds where it stands) or go on.\nGreen: on. Blue: paused. It ends when you leave the dungeon. Follow and Stay still work: Tank leads again hands the lead back."] = "В подземелье группу ведет ваш бот-танк: идет вперед, пулит по одной группе мобов, ждет ману и вас и идет от босса к боссу. Вы следуете за ним.\nЩелчок: вкл. или выкл. Правый щелчок: пауза (стоит на месте) или дальше.\nЗеленый: вкл. Синий: пауза. Заканчивается, когда вы выходите из подземелья. Следовать и Стоять работают как прежде: «Танк ведет» снова отдает ведение танку.", -- check
|
||||
["In a dungeon your tank bot leads: it walks on, pulls pack by pack, waits for mana and for you, and goes boss to boss. You follow.\nClick: on or off. Right-click: pause (it holds where it stands) or go on.\nGreen: on. Blue: paused. It ends when you leave the dungeon. Follow, Stay and Come pause it: say go (or right-click) and it leads on."] = "В подземелье группу ведет ваш бот-танк: идет вперед, пулит по одной группе мобов, ждет ману и вас и идет от босса к боссу. Вы следуете за ним.\nЩелчок: вкл. или выкл. Правый щелчок: пауза (стоит на месте) или дальше.\nЗеленый: вкл. Синий: пауза. Заканчивается, когда вы выходите из подземелья. «За мной», «Стоять» и «Ко мне» ставят ведение на паузу: скажите go (или правый щелчок), и танк ведет дальше.", -- check
|
||||
["the tank does not lead now: click the button first."] = "танк сейчас не ведет: сначала нажмите кнопку.",
|
||||
}
|
||||
|
||||
@@ -288,8 +288,9 @@ A group chat order reaches every bot of yours; to address only some, whisper the
|
||||
Defensive stance. Before every pull and every step on it waits until nobody is dead, everyone has 70 % health, the healer is
|
||||
near and has drunk to the pull mark, the other mana users (you too) have drunk, and you are inside, alive and within 60 yards;
|
||||
in party chat it says `waiting for mana` or `waiting for you`. `lead pause` holds it where it stands (it still fights what
|
||||
comes); `lead on` goes on. `lead off`, or leaving the dungeon, gives the lead back to you. `follow` and `stay` still work while
|
||||
it leads (they hold the tank too); `lead on` hands the lead back to it. It needs one of your bots in the tank role, and is for
|
||||
comes); `go` (also `lead on`, `вперед`) goes on. `lead off`, or leaving the dungeon, gives the lead back to you. `follow`,
|
||||
`stay`, `hold` and `come` (the buttons too) pause the lead and do their own thing; `go` picks it up again. `go` is the lead's
|
||||
word only while the lead is on or paused. It needs one of your bots in the tank role, and is for
|
||||
5-man dungeons only (a raid group runs its own pulls).
|
||||
|
||||
## 9. Battleground behaviour
|
||||
|
||||
@@ -82,6 +82,7 @@
|
||||
#include <cmath> // std::sqrt for /inrange distance calc
|
||||
#include <cctype>
|
||||
#include <cstring>
|
||||
#include <array>
|
||||
#include <string_view>
|
||||
#include <deque>
|
||||
#include <mutex>
|
||||
@@ -2353,6 +2354,80 @@ bool BotCommandParser::ApplyPlaceOrder(Player* sender, std::string const& line,
|
||||
return true;
|
||||
}
|
||||
|
||||
// True when a bot of the sender's in his group has the lead on or paused (every bot of his carries the same state).
|
||||
static bool LeadEngagedFor(Player* sender)
|
||||
{
|
||||
Group* grp = sender ? sender->GetGroup() : nullptr;
|
||||
if (!grp)
|
||||
return false;
|
||||
for (GroupReference const& itr : grp->GetMembers())
|
||||
{
|
||||
Player* m = itr.GetSource();
|
||||
if (!m || m == sender || !BotCommandParser::ControlsForGroupOrder(sender, m))
|
||||
continue;
|
||||
if (BotAI const* ai = Services::Registry().ai(m->GetGUID().GetCounter()); ai && ai->tank_lead_engaged())
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void BotCommandParser::PauseLeadForOwnerOrder(Player* sender, std::string const& line, char const* via)
|
||||
{
|
||||
if (!sender || !sender->GetSession())
|
||||
return;
|
||||
// The order word: past a squad address ("all: stay"), lower case, without a leading '/' or '!'.
|
||||
std::string n = Normalize(line);
|
||||
if (size_t const colon = n.find(':'); colon != std::string::npos)
|
||||
n = Normalize(n.substr(colon + 1));
|
||||
while (!n.empty() && (n.front() == '/' || n.front() == '!' || n.front() == ' '))
|
||||
n.erase(0, 1);
|
||||
ParsedCommand const parsed = SplitArgs(n);
|
||||
std::string const& verb = parsed.verb;
|
||||
bool const manual = verb == "stay" || verb == "halt" || verb == "hold" || verb == "come" || verb == "wait" ||
|
||||
(verb == "follow" && parsed.tail != "stop" && parsed.tail != "off");
|
||||
if (!manual)
|
||||
return;
|
||||
Group* grp = sender->GetGroup();
|
||||
if (!grp)
|
||||
return;
|
||||
uint32 paused = 0;
|
||||
std::string tank_name;
|
||||
for (GroupReference const& itr : grp->GetMembers())
|
||||
{
|
||||
Player* m = itr.GetSource();
|
||||
if (!m || m == sender || !Services::Registry().has(m->GetGUID().GetCounter()) || !ControlsForGroupOrder(sender, m))
|
||||
continue;
|
||||
BotAI* ai = Services::Registry().ai(m->GetGUID().GetCounter());
|
||||
if (!ai || ai->tank_lead() != BotAI::TankLead::On)
|
||||
continue;
|
||||
ai->set_tank_lead(BotAI::TankLead::Paused);
|
||||
++paused;
|
||||
if (tank_name.empty() && BotRole(m) == Role::Tank)
|
||||
tank_name = m->GetName();
|
||||
}
|
||||
if (paused == 0)
|
||||
return;
|
||||
TC_LOG_INFO("playerbot.v2", "[tank_lead] {} ({}): \"{}\" pauses the lead for {} bot(s)", sender->GetName(), via ? via : "?", verb, paused);
|
||||
std::string const reply = tank_name.empty()
|
||||
? std::string("Tank leads is paused: say 'go' when the tank should lead on.")
|
||||
: fmt::format("{} pauses the lead: say 'go' when it should lead on.", tank_name);
|
||||
Playerbot::BotLanguage::LocalizedHandler(sender->GetSession()).PSendSysMessage("%s", reply.c_str());
|
||||
}
|
||||
|
||||
bool BotCommandParser::IsLeadGoWord(std::string const& line)
|
||||
{
|
||||
std::string n = Normalize(line);
|
||||
while (!n.empty() && (n.back() == '!' || n.back() == '.'))
|
||||
n.pop_back();
|
||||
// The Russian testers' words too: "вперед" / "вперёд" / "го", lower case or with a capital (std::tolower leaves Cyrillic alone).
|
||||
static constexpr std::array<std::string_view, 7> kGo = {
|
||||
"go",
|
||||
"\xD0\xB2\xD0\xBF\xD0\xB5\xD1\x80\xD0\xB5\xD0\xB4", "\xD0\x92\xD0\xBF\xD0\xB5\xD1\x80\xD0\xB5\xD0\xB4", // вперед, Вперед
|
||||
"\xD0\xB2\xD0\xBF\xD0\xB5\xD1\x80\xD1\x91\xD0\xB4", "\xD0\x92\xD0\xBF\xD0\xB5\xD1\x80\xD1\x91\xD0\xB4", // вперёд, Вперёд
|
||||
"\xD0\xB3\xD0\xBE", "\xD0\x93\xD0\xBE" }; // го, Го
|
||||
return std::find(kGo.begin(), kGo.end(), n) != kGo.end();
|
||||
}
|
||||
|
||||
bool BotCommandParser::ApplyLeadOrder(Player* sender, std::string const& line, char const* via)
|
||||
{
|
||||
std::string n = line;
|
||||
@@ -2360,12 +2435,19 @@ bool BotCommandParser::ApplyLeadOrder(Player* sender, std::string const& line, c
|
||||
std::istringstream in(n);
|
||||
std::string verb, word, extra;
|
||||
in >> verb;
|
||||
if (verb != "lead" || !sender || !sender->GetSession())
|
||||
if (!sender || !sender->GetSession())
|
||||
return false;
|
||||
// "go" alone picks a paused lead back up (chris, 2026-11-13: Stay and Follow pause the lead, "go" goes on). It is the lead's word
|
||||
// only while the tank leads or is paused; otherwise it stays the chat cue it was (BotChatReactor).
|
||||
bool const go_word = IsLeadGoWord(line);
|
||||
if (verb != "lead" && !go_word)
|
||||
return false;
|
||||
in >> word >> extra;
|
||||
if (go_word && !LeadEngagedFor(sender))
|
||||
return false;
|
||||
Playerbot::BotLanguage::LocalizedHandler answer(sender->GetSession());
|
||||
BotAI::TankLead want = BotAI::TankLead::On;
|
||||
if (word.empty() || word == "on" || word == "start" || word == "go")
|
||||
if (go_word || word.empty() || word == "on" || word == "start" || word == "go" || word == "resume")
|
||||
want = BotAI::TankLead::On;
|
||||
else if (word == "pause" || word == "hold" || word == "wait")
|
||||
want = BotAI::TankLead::Paused;
|
||||
@@ -2447,12 +2529,12 @@ bool BotCommandParser::ApplyLeadOrder(Player* sender, std::string const& line, c
|
||||
switch (want)
|
||||
{
|
||||
case BotAI::TankLead::On:
|
||||
reply = in_dungeon
|
||||
reply = go_word ? fmt::format("{} leads on.", name) : in_dungeon
|
||||
? fmt::format("{} leads the dungeon now: it pulls pack by pack and waits for mana and for you. Say 'lead pause' to hold, 'lead off' to lead yourself.", name)
|
||||
: fmt::format("{} leads once you are inside a dungeon. Say 'lead off' to lead yourself.", name);
|
||||
break;
|
||||
case BotAI::TankLead::Paused:
|
||||
reply = fmt::format("{} holds here and pulls nothing until you say 'lead on'.", name);
|
||||
reply = fmt::format("{} holds here and pulls nothing until you say 'go'.", name);
|
||||
break;
|
||||
default:
|
||||
reply = "You lead again: your bots follow you.";
|
||||
@@ -2477,6 +2559,8 @@ bool BotCommandParser::Dispatch(Player* sender, Player* bot, std::string const&
|
||||
// "lead on|pause|off": the whole group's lead, set on every bot of the sender's at once, answered once.
|
||||
if (ApplyLeadOrder(sender, msg, via))
|
||||
return true;
|
||||
// Stay / Hold / Follow / Come while the tank leads pause the lead; the order itself goes on as usual.
|
||||
PauseLeadForOwnerOrder(sender, msg, via);
|
||||
// A crowd-control order ("@warlock no fear", "off cc") is the owner's, not each bot's: stored once, answered once.
|
||||
if (ApplyCcOrder(sender, msg, via))
|
||||
return true;
|
||||
|
||||
@@ -52,8 +52,14 @@ public:
|
||||
// "Tank leads" (BotAI::TankLead): "lead" / "lead on" hands the lead of a 5-man dungeon to the sender's tank bot (it walks the
|
||||
// route, pulls pack by pack, waits for mana and for him, goes boss to boss; he follows), "lead pause" holds it where it stands,
|
||||
// "lead off" gives the lead back to him. Set on every bot of the sender's in his group, answered once. The ForeverBots Lead
|
||||
// button and `.bot lead` send the same words. Returns false for any other line. World thread.
|
||||
// button and `.bot lead` send the same words. "go" alone (or "lead resume") picks up a paused lead; it is the lead's word only
|
||||
// while the lead is on or paused. Returns false for any other line. World thread.
|
||||
static bool ApplyLeadOrder(Player* sender, std::string const& line, char const* via);
|
||||
// True when `line` is "go" alone (or the Russian "вперед" / "го"), the word that picks up a paused lead.
|
||||
static bool IsLeadGoWord(std::string const& line);
|
||||
// An owner's Stay / Hold / Follow / Come (`line`, a bare order or a squad line) while his tank leads: the lead pauses (chris,
|
||||
// 2026-11-13) and he is told "go" goes on; the order itself is not consumed. Does nothing for any other line. World thread.
|
||||
static void PauseLeadForOwnerOrder(Player* sender, std::string const& line, char const* via);
|
||||
|
||||
// The ForeverBots Positions tab (add-on PLACE_REQ) and the "place" order: the chosen bots of the sender's group stand in `shape`
|
||||
// (close, circle, arc, spread, line, column, spear, arrow; Placement.h) with `gap` (tight, normal, wide) round `anchor` (here =
|
||||
|
||||
@@ -4117,6 +4117,8 @@ void Module::RouteGroupOrder(Player* sender, Group* group, std::string order)
|
||||
return;
|
||||
if (BotCommandParser::ApplyLeadOrder(sender, order, "group"))
|
||||
return;
|
||||
// Stay / Hold / Follow / Come while the tank leads pause the lead ("go" picks it up); the order itself goes on below.
|
||||
BotCommandParser::PauseLeadForOwnerOrder(sender, order, "group");
|
||||
if (order.rfind("crowdcontrol ", 0) == 0 || order.rfind("crowd control ", 0) == 0 || order == "cc on" || order == "cc off")
|
||||
{
|
||||
// A switch of the owner's, not an order to each bot: set once, answer once.
|
||||
@@ -4432,6 +4434,9 @@ void Module::OnPartyChat(Player* sender, Group* group, std::string const& msg, b
|
||||
// A bare group order ("follow", "stay", ...) in party or raid chat goes to every bot of the sender's in the
|
||||
// group. A line that starts with the name of a bot in the group, or with "all", is that bot's (every bot's)
|
||||
// order without the ';' ("Lentha use altar", "all use altar"). Other chatter stays ignored.
|
||||
// "go" while the tank leads or is paused picks the lead up (BotCommandParser::ApplyLeadOrder); otherwise it is chatter.
|
||||
if (BotCommandParser::IsLeadGoWord(msg) && BotCommandParser::ApplyLeadOrder(sender, msg, raid_chat ? "raid" : "party"))
|
||||
return;
|
||||
if (auto const order = ClassifyGroupOrder(msg, Services::Config().behavior_owner_commands()))
|
||||
RouteGroupOrder(sender, group, *order);
|
||||
else if (auto const addressed = AddressedGroupOrder(msg, [group](std::string_view name) { return GroupHasBotNamed(group, name); }))
|
||||
|
||||
@@ -742,8 +742,11 @@ std::vector<Catalog::Entry> const& RussianEntries()
|
||||
"{} ведет группу по подземелью: пулит по одной группе мобов и ждет ману и вас. Скажите 'lead pause', чтобы он ждал, 'lead off', чтобы вести самому." },
|
||||
{ "{} leads once you are inside a dungeon. Say 'lead off' to lead yourself.",
|
||||
"{} поведет группу, когда вы войдете в подземелье. Скажите 'lead off', чтобы вести самому." },
|
||||
{ "{} holds here and pulls nothing until you say 'lead on'.", "{} ждет здесь и никого не пулит, пока вы не скажете 'lead on'." },
|
||||
{ "{} holds here and pulls nothing until you say 'go'.", "{} ждет здесь и никого не пулит, пока вы не скажете 'go'." },
|
||||
{ "You lead again: your bots follow you.", "Снова ведете вы: ваши боты следуют за вами." },
|
||||
{ "{} leads on.", "{} ведет дальше." },
|
||||
{ "{} pauses the lead: say 'go' when it should lead on.", "{} ждет: скажите 'go' (или 'вперед'), когда ему вести дальше." },
|
||||
{ "Tank leads is paused: say 'go' when the tank should lead on.", "Танк ждет: скажите 'go' (или 'вперед'), когда ему вести дальше." },
|
||||
{ "go", "вперед" },
|
||||
{ "drinking", "пью" },
|
||||
{ "drinking, one moment", "пью, секунду" },
|
||||
|
||||
@@ -147,9 +147,13 @@ TEST_CASE("BotLocale: the tank lead lines keep the tank's name", "[BotLocale]")
|
||||
{
|
||||
CHECK(Translate(Lang::Ru, "Raveni leads the dungeon now: it pulls pack by pack and waits for mana and for you. Say 'lead pause' to hold, 'lead off' to lead yourself.") ==
|
||||
"Raveni ведет группу по подземелью: пулит по одной группе мобов и ждет ману и вас. Скажите 'lead pause', чтобы он ждал, 'lead off', чтобы вести самому.");
|
||||
CHECK(Translate(Lang::Ru, "Raveni holds here and pulls nothing until you say 'lead on'.") == "Raveni ждет здесь и никого не пулит, пока вы не скажете 'lead on'.");
|
||||
CHECK(Translate(Lang::Ru, "Raveni holds here and pulls nothing until you say 'go'.") == "Raveni ждет здесь и никого не пулит, пока вы не скажете 'go'.");
|
||||
CHECK(Translate(Lang::Ru, "waiting for mana") == "жду ману");
|
||||
CHECK(Translate(Lang::Ru, "You lead again: your bots follow you.") == "Снова ведете вы: ваши боты следуют за вами.");
|
||||
// Stay / Follow pause the lead, "go" picks it up.
|
||||
CHECK(Translate(Lang::Ru, "Raveni leads on.") == "Raveni ведет дальше.");
|
||||
CHECK(Translate(Lang::Ru, "Raveni pauses the lead: say 'go' when it should lead on.") ==
|
||||
"Raveni ждет: скажите 'go' (или 'вперед'), когда ему вести дальше.");
|
||||
}
|
||||
|
||||
TEST_CASE("BotLocale: captured words are translated, names and numbers are not", "[BotLocale]")
|
||||
|
||||
Reference in New Issue
Block a user