diff --git a/src/modules/PlayerbotV2/Bot/BotAI.cpp b/src/modules/PlayerbotV2/Bot/BotAI.cpp index 9e175a5b8f..6a810569c0 100644 --- a/src/modules/PlayerbotV2/Bot/BotAI.cpp +++ b/src/modules/PlayerbotV2/Bot/BotAI.cpp @@ -1271,7 +1271,8 @@ void BotAI::dispatch_layers(BotSnapshotView s, GroupSnapshotView g, // ike3 speech that no game event announces: companions' combat / ammo callouts and world // bots' General / Trade suggestions. Rate-limited inside; at most one chat intent. - if (!s.big_raid()) // quiet in 40-man raids + // A 40-man raid hears it only with Playerbot.Raid.Talk on (one voice for the whole raid, Bot/Raid/RaidVoice.h). + if (!s.big_raid() || BotChatter::RaidTalkOn()) BotChatter::SpeechTick(*this, s, em); // Future: detect AtVendor / AtMailbox / AtAh / InInstance / Decorating diff --git a/src/modules/PlayerbotV2/Bot/BotIntentEmitter.h b/src/modules/PlayerbotV2/Bot/BotIntentEmitter.h index 51ab26b55b..0372665bfc 100644 --- a/src/modules/PlayerbotV2/Bot/BotIntentEmitter.h +++ b/src/modules/PlayerbotV2/Bot/BotIntentEmitter.h @@ -169,6 +169,7 @@ public: { return emit(FollowIntent{leader, distance, angle_radians}); } bool say(std::string text) { return emit(ChatIntent{PartyChatIntent{std::move(text)}}); } + bool raid_say(std::string text) { return emit(ChatIntent{RaidChatIntent{std::move(text)}}); } bool say_world(std::string text) { return emit(ChatIntent{SayChatIntent{std::move(text)}}); } bool yell_world(std::string text) { return emit(ChatIntent{YellChatIntent{std::move(text)}}); } bool emote_text(std::string text) { return emit(ChatIntent{EmoteChatIntent{std::move(text)}}); } diff --git a/src/modules/PlayerbotV2/Bot/BotTextMgr.cpp b/src/modules/PlayerbotV2/Bot/BotTextMgr.cpp index 8fcc7cc1d4..a38ff1a515 100644 --- a/src/modules/PlayerbotV2/Bot/BotTextMgr.cpp +++ b/src/modules/PlayerbotV2/Bot/BotTextMgr.cpp @@ -11,6 +11,7 @@ #include "BotRegistry.h" #include "BotSnapshotView.h" #include "BotBridge.h" +#include "Raid/RaidVoice.h" #include "../Fleet/BotPool.h" #include "../Services.h" #include "../Threading/IntentQueue.h" @@ -313,12 +314,35 @@ bool GroupHasRealPlayer(Player const* bot) return false; } +// A raid of more than 15 talks with one voice (Bot/Raid/RaidVoice.h): forty bots each on their own chatter cooldown was spam (ike3's +// quiet-raid rule, which kept a big raid silent), so the whole raid shares one gap instead. +std::mutex g_raid_voice_mtx; +Raid::RaidVoiceGate g_raid_voice; +uint32 g_raid_voice_pruned = 0; + +Raid::RaidVoiceTuning RaidTuning() { return Raid::VoiceTuning(Raid::RaidTalkFromConfig(Services::Config().raid_talk())); } + +bool IsBigRaid(Group const* g) { return g && g->GetMembersCount() > Raid::kRaidVoiceGroupSize; } + +// The raid's turn to hear a bot's own line: one line per raid per chatterGapMs, one per bot per chatterBotMs. +bool TakeRaidVoice(uint64 group_low, BotId bot, uint32 now_ms) +{ + Raid::RaidVoiceTuning const t = RaidTuning(); + std::lock_guard lk(g_raid_voice_mtx); + if (now_ms - g_raid_voice_pruned > 60000) + { + g_raid_voice.Prune(now_ms, std::max(t.chatterGapMs, t.chatterBotMs)); + g_raid_voice_pruned = now_ms; + } + return g_raid_voice.Allow(group_low, bot, t, now_ms); +} + BotAI* ChattyAi(Player const* bot, Verbosity min_verbosity) { if (!bot || !bot->IsAlive() || !BotTextMgr::instance().Enabled()) return nullptr; - // Big raids: forty bots talking at once is spam (ike3's quiet-raid rule). - if (Group const* g = bot->GetGroup(); g && g->GetMembersCount() > 15) + // A big raid hears the bots' own chatter only with Playerbot.Raid.Talk on (and then through TakeRaidVoice). + if (IsBigRaid(bot->GetGroup()) && !RaidTalkOn()) return nullptr; BotId const id = bot->GetGUID().GetCounter(); BotRegistry& reg = Services::Registry(); @@ -350,7 +374,9 @@ void BroadcastToParty(Player* bot, std::string_view key, TextPlaceholders& ph, c if (!mgr.RollChance(key)) return; BotId const id = bot->GetGUID().GetCounter(); - if (!TakeSlot(Slot::Broadcast, bot->GetGroup()->GetGUID().GetCounter(), id, GameTime::GetGameTimeMS())) + uint64 const group_low = bot->GetGroup()->GetGUID().GetCounter(); + bool const raid = IsBigRaid(bot->GetGroup()); + if (raid ? !TakeRaidVoice(group_low, id, GameTime::GetGameTimeMS()) : !TakeSlot(Slot::Broadcast, group_low, id, GameTime::GetGameTimeMS())) return; AddSelfPlaceholders(ph, bot->GetClass(), bot->GetRace(), bot->GetLevel(), bot->GetZoneId(), bot->GetAreaId()); std::string text = mgr.Get(key, ph); @@ -358,8 +384,12 @@ void BroadcastToParty(Player* bot, std::string_view key, TextPlaceholders& ph, c return; if (BotBridge::QueueMoment(id, what, detail, PlainText(text))) return; - // A beat later, like a person glancing at the loot window or quest log before typing. - PushChat(id, ChatIntent{ PartyChatIntent{ std::move(text) } }, urand(1500, 4000)); + // A beat later, like a person glancing at the loot window or quest log before typing. A big raid reads it in raid chat (party chat + // there reaches only the bot's sub-group). + if (raid) + PushChat(id, ChatIntent{ RaidChatIntent{ std::move(text) } }, urand(1500, 4000)); + else + PushChat(id, ChatIntent{ PartyChatIntent{ std::move(text) } }, urand(1500, 4000)); } // Last quest status seen per (bot, quest), so an INCOMPLETE that follows nothing reads as "accepted" @@ -1465,7 +1495,7 @@ void BanterTick(BotAI& ai, BotSnapshotView const& s, BotIntentEmitter& em) return; std::string line = BanterLine(Banter::Ouch, ai, s); if (!line.empty()) - em.say(std::move(line)); + SayToGroup(em, s, std::move(line)); } // A companion's group came to a new zone: with the bot bridge's moments on, one bot of the group may say something about it @@ -1477,7 +1507,8 @@ std::unordered_map> g_zone_said; // group lo void ZoneTick(BotAI& ai, BotSnapshotView const& s) { - if (!BotBridge::MomentsOn() || !s.is_companion_with_owner() || !s.in_group() || s.big_raid() || !s.is_alive() || !s.zone_id()) + if (!BotBridge::MomentsOn() || !s.is_companion_with_owner() || !s.in_group() || (s.big_raid() && !RaidTalkOn()) || !s.is_alive() || + !s.zone_id()) return; uint32 old_zone = 0; { @@ -1556,13 +1587,17 @@ std::string BanterLine(Banter kind, BotAI& ai, BotSnapshotView const& s, bool* t { if (!Services::Config().behavior_party_banter()) return {}; - // A companion, in a group that is not a big raid, with chatter on and a personality that talks. - if (!BotTextMgr::instance().Enabled() || s.big_raid() || !s.in_group() || !s.is_companion_with_owner()) + // A companion with chatter on and a personality that talks; in a big raid only with Playerbot.Raid.Talk, and never the wipe line + // there (the raid leader's wipe talk covers it, RaidBrain WipeBanter). + if (!BotTextMgr::instance().Enabled() || !s.in_group() || !s.is_companion_with_owner()) + return {}; + if (s.big_raid() && (!RaidTalkOn() || kind == Banter::Wipe)) return {}; BotPersonality const& pers = ai.personality(); if (pers.verbosity < Verbosity::Normal) return {}; - if (!TakeBanterSlot(kind, s.group_guid().GetCounter(), s.bot_id(), s.published_at_ms())) + if (s.big_raid() ? (urand(1, 100) > BanterChance(kind) || !TakeRaidVoice(s.group_guid().GetCounter(), s.bot_id(), s.published_at_ms())) + : !TakeBanterSlot(kind, s.group_guid().GetCounter(), s.bot_id(), s.published_at_ms())) return {}; std::string line = PickBanter(kind, s.cls(), ai.effective_role(s), pers); if (!line.empty() && BotBridge::QueueMoment(s.bot_id(), BanterWhat(kind), BanterDetail(kind, s), line)) @@ -1574,12 +1609,25 @@ std::string BanterLine(Banter kind, BotAI& ai, BotSnapshotView const& s, bool* t return line; } +bool RaidTalkOn() +{ + return Raid::RaidTalkFromConfig(Services::Config().raid_talk()) != Raid::RaidTalk::Off; +} + +void SayToGroup(BotIntentEmitter& em, BotSnapshotView const& s, std::string text) +{ + if (s.big_raid()) + em.raid_say(std::move(text)); + else + em.say(std::move(text)); +} + void OnBossKilled(Player* killer, Creature* boss) { if (!killer || !boss || !IsBossCreature(boss)) return; Group* group = killer->GetGroup(); - if (!group || group->GetMembersCount() > 15) + if (!group || IsBigRaid(group)) return; ConfigReader const& cfg = Services::Config(); bool const banter = cfg.behavior_party_banter(); @@ -1633,7 +1681,9 @@ void SpeechTick(BotAI& ai, BotSnapshotView const& s, BotIntentEmitter& em) if (!BotTextMgr::instance().Enabled()) return; uint32 const now_ms = s.published_at_ms(); - Callouts(ai, s, em, now_ms); + // A big raid has its own callouts (Bot/Raid/RaidCallouts.h); the party ones from 39 bots would drown them. + if (!s.big_raid()) + Callouts(ai, s, em, now_ms); Suggest(ai, s, em, now_ms); BanterTick(ai, s, em); ZoneTick(ai, s); diff --git a/src/modules/PlayerbotV2/Bot/BotTextMgr.h b/src/modules/PlayerbotV2/Bot/BotTextMgr.h index 80dbe834a3..97ec0b3e19 100644 --- a/src/modules/PlayerbotV2/Bot/BotTextMgr.h +++ b/src/modules/PlayerbotV2/Bot/BotTextMgr.h @@ -196,9 +196,14 @@ enum class Banter : uint8 { Ready, Wipe, Thanks, Ouch, BossKill }; // bot worker: the line to say now for `kind`, or empty (gates / roll / cooldown said no). The caller emits it. // Handed to the bot bridge's program like GreetLine (empty, *to_program set). std::string BanterLine(Banter kind, BotAI& ai, BotSnapshotView const& s, bool* to_program = nullptr); +// The bot's own line to its group: raid chat in a raid of more than 15 (Bot/Raid/RaidVoice.h; party chat there only reaches the +// bot's sub-group, so the player rarely saw it), party chat otherwise. +void SayToGroup(BotIntentEmitter& em, BotSnapshotView const& s, std::string text); +// Playerbot.Raid.Talk is on: a raid of more than 15 hears the bots' own chatter (one line for the whole raid at a time). +bool RaidTalkOn(); // A boss (IsBossCreature, Bot/BossCheck.h) died to `killer`: the player who gets the credit, also when a pet, totem or // charmed unit of theirs landed the last hit. Called from Module::OnDeath, the boss-kill moment. One nearby companion of the killer's group may say "gg" and one may bow (the killer is a real player, -// "the owner finished the boss") or cheer. +// "the owner finished the boss") or cheer. A raid of more than 15 has its own kill crowd (RaidBrain, Bot/Raid/RaidVoice.h). void OnBossKilled(Player* killer, Creature* boss); // ---- per-tick speech (bot worker; snapshot data only; emits at most one ChatIntent per tick) ---- diff --git a/src/modules/PlayerbotV2/Bot/Raid/README.md b/src/modules/PlayerbotV2/Bot/Raid/README.md index 8ce3ce6ae8..286d874406 100644 --- a/src/modules/PlayerbotV2/Bot/Raid/README.md +++ b/src/modules/PlayerbotV2/Bot/Raid/README.md @@ -31,6 +31,12 @@ Port of Karrz's raid10-revamp ike3 raid logic (Karrz1/wow-1.12, src/game/PlayerB that blame and excuse themselves after a wipe; `SpotMishaps` / `TrackPull` / `EndQuietPulls` in RaidBrain.cpp find them. Fixed lines with a mild and a harsh set, rate limited by `BanterGate`; with the bridge on, a `raid_line` event asks the program first and the fixed line is said when its answer is not back in `kModelWaitMs` (2.5 s). `Playerbot.Raid.Banter` (0 / 1 / 2). +- `RaidVoice.h`: a raid of more than 15 with a real player in it talks like a crowd instead of staying silent. The bots' own chatter + (BotTextMgr: loot, a death, a ready check) comes back with one line for the whole raid per gap (`RaidVoiceGate`) in raid chat; + `KillCrowd` (a few gg / grats and cheers after a kill), `RunBackVoice` (talk on the run back and the leader's rebuff call after a + wipe) and `VoiceBetweenPulls` (a line now and then out of combat, and the leader's brief of a boss a player walks up to, + `BossBrief` / `BossBriefGate`, again after a wipe on it) in RaidBrain.cpp. The program may word the lines (`raid_line`, not the + briefs). `Playerbot.Raid.Talk` (0 off / 1 normal / 2 chatty). - `BossTactics.h`: the player's own plan per boss in plain words (`tactics Lucifron: adds first, no aoe, no fear, tank here`), kept per account and boss (OwnerRegistry, migration 0039). While that boss fights: kill order (`PublishTargets` takes the boss or the adds off the DPS candidates), `no_aoe`, `cc_deny` (left out of the crowd-control election and added to the snapshot's deny), and the diff --git a/src/modules/PlayerbotV2/Bot/Raid/RaidBrain.cpp b/src/modules/PlayerbotV2/Bot/Raid/RaidBrain.cpp index 75fab35efc..afc6b8b821 100644 --- a/src/modules/PlayerbotV2/Bot/Raid/RaidBrain.cpp +++ b/src/modules/PlayerbotV2/Bot/Raid/RaidBrain.cpp @@ -12,6 +12,7 @@ #include "RaidBrainInternal.h" #include "RaidBanter.h" #include "RaidCallouts.h" +#include "RaidVoice.h" #include "../BotBridge.h" #include "RaidEncounters.h" #include "RaidGeometry.h" @@ -4598,6 +4599,174 @@ void WipeBanter(Group* group, Map* map, std::string const& firstDead, std::strin } } +// --------------------------------------------------------------------------- +// The raid's voice (RaidVoice.h, Playerbot.Raid.Talk): a raid of more than 15 with a real player in it talks like a crowd. The kill +// crowd, the run back after a wipe, a line now and then between pulls, and the leader's word on the next boss. +// --------------------------------------------------------------------------- + +RaidTalk TalkNow() { return RaidTalkFromConfig(Services::Config().raid_talk()); } + +bool VoicedRaid(Group const* group) +{ + return group && group->GetMembersCount() > kRaidVoiceGroupSize && TalkNow() != RaidTalk::Off && GroupHasHuman(group); +} + +// A line of the raid's voice (not a mistake): the program may word it like the banter (raid_line, `what` the moment), else the +// fixed `text` at `delayMs`. `ask` false: the fixed line only (the leader's boss brief is information, never reworded). +void QueueVoice(Group* group, Player* bot, char const* what, std::string const& detail, std::string const& text, bool leader, + uint32_t delayMs, uint32_t now, bool ask = true) +{ + if (text.empty() || !bot || g_banterQueue.size() >= 64) + return; + uint64 const id = ask ? BotBridge::AskRaidLine(bot, what, detail, text, "mild", leader ? "raid leader" : "raider", delayMs, kModelWaitMs) : 0; + g_banterQueue.push_back({ now + (id ? std::max(delayMs, kModelWaitMs) : delayMs), group->GetGUID(), bot->GetGUID(), text, id }); + TC_LOG_INFO("playerbot.v2.raid", "[raid_voice] {} ({}{}): {}{}", bot->GetName(), what, leader ? ", leader" : "", text, + id ? " (asked the program first)" : ""); +} + +// The group's bots on `map` other than `except`, in random order (`aliveOnly`: the living only). +std::vector VoiceCrowd(Group* group, Map* map, Player const* except, bool aliveOnly) +{ + std::vector out; + for (GroupReference const& ref : group->GetMembers()) + if (Player* m = ref.GetSource(); m && m != except && m->IsInWorld() && m->GetMap() == map && (!aliveOnly || m->IsAlive()) && + Services::Lifecycle().is_bot(m->GetGUID().GetCounter())) + out.push_back(m); + for (size_t i = out.size(); i > 1; --i) + std::swap(out[i - 1], out[urand(0, uint32(i - 1))]); + return out; +} + +// After a kill: besides the leader's line (RaidBanter BossDown), a few raiders say gg / grats, and a few cheer. +void KillCrowd(Group* group, Map* map, std::string const& boss, uint32_t now) +{ + if (!VoicedRaid(group) || !map) + return; + RaidVoiceTuning const t = VoiceTuning(TalkNow()); + std::vector const crowd = VoiceCrowd(group, map, BanterLeader(group, map), true); + size_t const speakers = std::min(crowd.size(), urand(1, t.killCrowd)); + std::string const detail = "your raid just killed " + (boss.empty() ? std::string("the boss") : boss) + "; say something short in raid chat"; + uint32_t at = urand(2500, 4000); + for (size_t i = 0; i < speakers; ++i) + { + QueueVoice(group, crowd[i], "kill_crowd", detail, std::string(KillLine(urand(0, 63))), false, at, now); + at += urand(1500, 4000); + } + size_t const cheers = std::min(crowd.size(), speakers + urand(2, 4)); + for (size_t i = speakers; i < cheers; ++i) + crowd[i]->HandleEmoteCommand(EMOTE_ONESHOT_CHEER); +} + +// After a wipe: a few raiders talk on the run back (repair, rez, rebuff), and the leader calls the rebuff. +void RunBackVoice(Group* group, Map* map, std::string const& boss, uint32_t now) +{ + if (!VoicedRaid(group) || !map) + return; + RaidVoiceTuning const t = VoiceTuning(TalkNow()); + Player* leader = BanterLeader(group, map); + std::vector const crowd = VoiceCrowd(group, map, leader, false); + size_t const speakers = std::min(crowd.size(), urand(1, t.runBackCrowd)); + std::string const at_boss = boss.empty() ? std::string() : " on " + boss; + uint32_t at = urand(9000, 13000); + for (size_t i = 0; i < speakers; ++i) + { + QueueVoice(group, crowd[i], "run_back", "your raid wiped" + at_boss + " and is running back to try again; say something short", + std::string(RunBackLine(urand(0, 63))), false, at, now); + at += urand(4000, 9000); + } + if (leader) + QueueVoice(group, leader, "rebuff_call", "the raid wiped" + at_boss + "; tell everyone to resurrect, rebuff and try again", + std::string(LeaderRebuffLine(urand(0, 63))), true, at + urand(2000, 5000), now); +} + +// Per raid (group, map): when it last fought, and when somebody next says something between pulls. +struct VoiceClock { uint32_t lastFight = 0; uint32_t nextIdle = 0; uint32_t nextBriefScan = 0; uint32_t seen = 0; }; +std::unordered_map g_voiceClock; +BossBriefGate g_bossBrief; + +uint32_t IdleGap(RaidVoiceTuning const& t) { return urand(t.idleGapMs * 7 / 10, t.idleGapMs * 13 / 10); } + +// The creatures a leader explains besides the map's bosses: Lord Victor Nefarius, who starts Nefarian's fight. +constexpr uint32_t kBriefExtras[] = { 10162 }; + +// Between pulls (the plan pass out of combat): a line now and then, and the leader's word on a boss a player walks up to. +void VoiceBetweenPulls(uint64_t key, Group* group, Plan const& plan, Map* map, uint32_t now) +{ + if (!VoicedRaid(group) || !map) + return; + RaidVoiceTuning const t = VoiceTuning(TalkNow()); + VoiceClock& c = g_voiceClock[key]; + c.seen = now; + if (!c.nextIdle) + c.nextIdle = now + IdleGap(t); + if (!c.lastFight) + c.lastFight = now; + + // The next boss: a real player within 60 y of one that is alive and not fighting. Looked for every 3 s. + if (int32_t(now - c.nextBriefScan) >= 0) + { + c.nextBriefScan = now + 3000; + for (Member const& m : plan.members) + { + if (m.bot || !m.p) + continue; + auto const brief = [&](uint32_t entry) + { + Creature* boss = m.p->FindNearestCreature(entry, 60.0f, true); + if (!boss || boss->IsInCombat() || !g_bossBrief.Allow(plan.groupLow, entry, t, now)) + return false; + if (Player* leader = BanterLeader(group, map)) + QueueVoice(group, leader, "boss_brief", {}, std::string(BossBrief(entry)), true, urand(800, 1600), now, /*ask=*/false); + return true; + }; + bool said = false; + for (uint32_t entry : plan.rules->bosses) + if ((said = brief(entry))) + break; + if (!said && plan.mapId == 469) + for (uint32_t entry : kBriefExtras) + if ((said = brief(entry))) + break; + if (said) + { + c.nextIdle = std::max(c.nextIdle, now + t.idleQuietMs); // no small talk over the brief + return; + } + } + } + + // Small talk: once the raid has been out of combat a while, about every idleGapMs; now and then the leader instead. + if (now - c.lastFight < t.idleQuietMs || int32_t(now - c.nextIdle) < 0) + return; + c.nextIdle = now + IdleGap(t); + Player* leader = BanterLeader(group, map); + if (leader && urand(0, 3) == 0) + { + QueueVoice(group, leader, "between_pulls", "the raid is resting between pulls; say something short to get them ready for the next one", + std::string(LeaderIdleLine(urand(0, 63))), true, urand(0, 1500), now); + return; + } + std::vector const crowd = VoiceCrowd(group, map, leader, true); + if (!crowd.empty()) + QueueVoice(group, crowd.front(), "between_pulls", "your raid is resting between pulls in " + std::string(map->GetMapName()) + + "; say something short a raider would say now", std::string(IdleLine(urand(0, 63))), false, urand(0, 1500), now); +} + +// The plan pass in combat: the raid is fighting. +void VoiceFighting(uint64_t key, uint32_t now) +{ + if (auto it = g_voiceClock.find(key); it != g_voiceClock.end()) + it->second.lastFight = it->second.seen = now; + else if (TalkNow() != RaidTalk::Off) + g_voiceClock[key] = { now, 0, 0, now }; +} + +void ForgetVoiceClocks(uint32_t now) +{ + for (auto it = g_voiceClock.begin(); it != g_voiceClock.end();) + it = now - it->second.seen > 600000 ? g_voiceClock.erase(it) : std::next(it); +} + // Per raid group: what the banter watches between plan passes. struct BanterWatch { @@ -5142,10 +5311,21 @@ void EndQuietPulls(uint32_t now_ms) if (mob.boss && bossName.empty()) bossName = mob.name; if (bossKilled) + { LeaderReacts(bg, map, Mishap::BossDown, pl.firstDead, bossName, now_ms); + KillCrowd(bg, map, bossName, now_ms); + } else if (std::strcmp(result, "wipe") == 0) + { WipeBanter(bg, map, pl.firstDead, bossName, now_ms); + RunBackVoice(bg, map, bossName, now_ms); + } } + // A wipe on a boss: the leader explains it again on the way back in (RaidVoice.h). + if (std::strcmp(result, "wipe") == 0) + for (auto const& [guid, mob] : pl.engaged) + if (mob.boss) + g_bossBrief.Wiped(pl.groupLow, mob.entry); TC_LOG_INFO("playerbot.v2.raid", "[raid_encounter] ts={} map={} group={} pull end: result={} dur={}s killed={}/{} alive={}/{} low={} deaths={} | {}{}{}", uint64_t(GameTime::GetGameTime()), pl.mapId, pl.groupLow, result, (pl.lastSeenMs - pl.startMs) / 1000, killed, uint32_t(pl.engaged.size()), alive, pl.startAlive, pl.aliveLow, pl.deaths, PullLabel(pl), left.empty() ? "" : " | left: ", left); @@ -5313,7 +5493,8 @@ void SayCallout(Player* bot, RaidOrder const& o, uint32_t now_ms) f.move_reason = o.move && o.move_reason ? o.move_reason : ""; f.hold_rotation = o.hold_rotation; f.use_object = !o.use_object.IsEmpty(); - if (o.cast_kind == RaidOrder::CastKind::Taunt || o.cast_kind == RaidOrder::CastKind::CrowdControl) + if (o.cast_kind == RaidOrder::CastKind::Taunt || o.cast_kind == RaidOrder::CastKind::CrowdControl || + o.cast_kind == RaidOrder::CastKind::Purge) { Unit const* target = o.cast_target.IsEmpty() ? nullptr : ObjectAccessor::GetUnit(*bot, o.cast_target); if (target) @@ -5323,7 +5504,20 @@ void SayCallout(Player* bot, RaidOrder const& o, uint32_t now_ms) if (o.cast_kind == RaidOrder::CastKind::CrowdControl) if (SpellInfo const* info = sSpellMgr->GetSpellInfo(o.cast_spell, DIFFICULTY_NONE)) f.long_cc = info->GetMaxDuration() >= 15000; + // A purge is called on a boss only (Flamegor's frenzy, Chromaggus' enrage): on trash it would be every few seconds. + if (o.cast_kind == RaidOrder::CastKind::Purge) + f.purge = target && target->ToCreature() && IsBossCreature(target->ToCreature()); } + // Out of sight: dropping a stacking debuff (Firemaw's Flame Buffet) when the bot carries the rule's aura, else hiding from a + // breath (Chromaggus). + if (f.move_reason == "break sight") + if (RaidRules const* rules = RulesForMap(bot->GetMapId())) + for (BreakSight const& rule : rules->breakSight) + if (rule.aura && bot->HasAura(rule.aura)) + { + f.sight_aura = SpellNameOf(rule.aura); + break; + } if (f.move_reason == "carrier run") if (RaidRules const* rules = RulesForMap(bot->GetMapId())) for (CarrierRun const& rule : rules->carrierRun) @@ -5334,7 +5528,9 @@ void SayCallout(Player* bot, RaidOrder const& o, uint32_t now_ms) } Callout const c = PickCallout(f); - if (!g_callouts.Allow(group->GetGUID().GetCounter(), bot->GetGUID().GetCounter(), c.kind, c.group_wide, now_ms)) + // The same sheep or tranq on the same target is called once for the raid, whichever bot casts it. + std::string_view const subject = c.kind == CalloutKind::CrowdControl || c.kind == CalloutKind::Tranq ? std::string_view(f.target) : std::string_view(); + if (!g_callouts.Allow(group->GetGUID().GetCounter(), bot->GetGUID().GetCounter(), c.kind, c.group_wide, now_ms, subject)) return; ChatMsg type = group->isRaidGroup() ? (group->IsLeader(bot->GetGUID()) ? CHAT_MSG_RAID_LEADER : CHAT_MSG_RAID) @@ -5608,6 +5804,7 @@ void Brain::Update(uint32_t now_ms) LogDeadHumanReleaseState(now_ms); EndAbandonedEncounters(now_ms); SayDueBanter(now_ms); + ForgetVoiceClocks(now_ms); // Bucket bots on raid maps that have rules by (group, map). struct Bucket { Group* group = nullptr; uint32_t mapId = 0; uint64_t refBot = 0; Player* ref = nullptr; }; @@ -5718,9 +5915,11 @@ void Brain::Update(uint32_t now_ms) { FillRaidRoles(key, plan, now_ms); WarnBeforePull(plan, b.ref->GetMap(), now_ms); + VoiceBetweenPulls(key, b.group, plan, b.ref->GetMap(), now_ms); MechanicsPrePull(plan, next, dump, now_ms); continue; } + VoiceFighting(key, now_ms); dump << plan.rules->name << " group " << b.group->GetGUID().GetCounter() << ": " << plan.members.size() << " members, " << plan.enemies.size() << " enemies\n"; diff --git a/src/modules/PlayerbotV2/Bot/Raid/RaidCallouts.h b/src/modules/PlayerbotV2/Bot/Raid/RaidCallouts.h index 2eda8831ba..a86f238c39 100644 --- a/src/modules/PlayerbotV2/Bot/Raid/RaidCallouts.h +++ b/src/modules/PlayerbotV2/Bot/Raid/RaidCallouts.h @@ -32,6 +32,9 @@ enum class CalloutKind : uint8_t HoldHeals, // a healing priest stops for Nefarian's priest call Taunt, // the bot taunts a boss or an add CrowdControl, // the bot polymorphs, banishes or shackles an add for a long time + DropStacks, // the bot steps out of the boss's sight to drop a stacking debuff (Firemaw's Flame Buffet): one bot says it + BreathHide, // the raid hides from a breath (Chromaggus): one bot calls it + Tranq, // the bot removes an enemy's enrage or magic buff (Tranquilizing Shot, Purge, Dispel Magic) Count }; @@ -41,11 +44,13 @@ struct CalloutFacts std::string_view move_reason; // RaidOrder::move_reason, empty when the bot has no move bool taunt = false; // its elected cast is a taunt bool long_cc = false; // its elected cast is crowd control that lasts 15 s or more + bool purge = false; // its elected cast removes a buff from an enemy (an enrage, a magic shield) bool hold_rotation = false; bool use_object = false; std::string spell; // the elected spell's name (taunt, crowd control) std::string target; // the elected cast's target name std::string carried; // carrier run: the name of the aura the bot carries + std::string sight_aura; // break sight: the stacking aura the bot steps away to drop (empty: hiding from a breath) }; struct Callout @@ -67,6 +72,9 @@ inline Callout PickCallout(CalloutFacts const& f) return { CalloutKind::IceBlock, "hiding behind an ice block", false }; if (m == "spread") return { CalloutKind::Spread, "spread out", true }; + if (m == "break sight") + return f.sight_aura.empty() ? Callout{ CalloutKind::BreathHide, "breath coming, get out of its sight", true } + : Callout{ CalloutKind::DropStacks, "dropping " + f.sight_aura + " stacks out of its sight", true }; if (m == "heigan dance" || m == "heigan eruption") return { CalloutKind::HeiganDance, "dance time, follow the safe side", true }; if (f.use_object || m.substr(0, 4) == "orb:") @@ -77,6 +85,8 @@ inline Callout PickCallout(CalloutFacts const& f) return { CalloutKind::Taunt, "taunting " + f.target, false }; if (f.long_cc && !f.spell.empty() && !f.target.empty()) return { CalloutKind::CrowdControl, f.spell + " on " + f.target + ", don't break it", false }; + if (f.purge && !f.spell.empty() && !f.target.empty()) + return { CalloutKind::Tranq, "casting " + f.spell + " on " + f.target, false }; return {}; } @@ -84,6 +94,8 @@ inline Callout PickCallout(CalloutFacts const& f) // * the same bot, the same kind of line: once per kSameKindMs (a re-sheep a few seconds later stays quiet); // * the same bot, any line: once per kBotGapMs; // * a group-wide call (spread, wipe, dance): once per kGroupWideMs for the whole raid, whichever bot says it; +// * the same kind of line about the same target (`subject`, e.g. the sheeped raider): once per kSameKindMs for the whole raid, +// whichever bot casts it (BWL Nefarius 2026-11-13: four mages each said "Polymorph on Carmina, don't break it" within 11 s); // * the whole raid: kGroupGapMs between two lines, at most kWindowMax lines in kWindowMs. class CalloutGate { @@ -96,13 +108,20 @@ public: static constexpr uint32_t kWindowMax = 5; // True when the line may be said now; it is then counted as said. - bool Allow(uint64_t group, uint64_t bot, CalloutKind kind, bool group_wide, uint32_t now) + bool Allow(uint64_t group, uint64_t bot, CalloutKind kind, bool group_wide, uint32_t now, std::string_view subject = {}) { if (kind == CalloutKind::None) return false; GroupState& g = groups_[group]; while (!g.said.empty() && now - g.said.front() >= kWindowMs) g.said.pop_front(); + std::string subjectKey; + if (!subject.empty()) + { + subjectKey.assign(1, char('A' + static_cast(kind))).append(subject); + if (auto s = g.subjects.find(subjectKey); s != g.subjects.end() && now - s->second < kSameKindMs) + return false; + } if (!g.said.empty() && now - g.said.back() < kGroupGapMs) return false; if (g.said.size() >= kWindowMax) @@ -123,6 +142,12 @@ public: g.wide[k] = stamp; b.last = stamp; b.kind[k] = stamp; + if (!subjectKey.empty()) + { + for (auto it = g.subjects.begin(); it != g.subjects.end();) + it = now - it->second >= kSameKindMs ? g.subjects.erase(it) : std::next(it); + g.subjects[subjectKey] = stamp; + } return true; } @@ -141,7 +166,7 @@ public: private: static constexpr size_t kKinds = static_cast(CalloutKind::Count); struct BotState { uint32_t last = 0; uint32_t kind[kKinds] = {}; }; - struct GroupState { std::deque said; uint32_t last = 0; uint32_t wide[kKinds] = {}; }; + struct GroupState { std::deque said; uint32_t last = 0; uint32_t wide[kKinds] = {}; std::unordered_map subjects; }; std::unordered_map bots_; std::unordered_map groups_; }; diff --git a/src/modules/PlayerbotV2/Bot/Raid/RaidVoice.h b/src/modules/PlayerbotV2/Bot/Raid/RaidVoice.h new file mode 100644 index 0000000000..12c0c4727b --- /dev/null +++ b/src/modules/PlayerbotV2/Bot/Raid/RaidVoice.h @@ -0,0 +1,173 @@ +// RaidVoice - a 40-man raid that talks like a crowd of players: not 39 bots at once, and not a silent room. +// +// Up to 0.1.36 a group over 15 was silent for all of the bots' own chatter (the quiet-raid rule: forty bots talking at once is +// spam), so in Blackwing Lair only the callouts and the leader's word on a mistake were ever said (chris, 2026-11-13: "a wee bit +// more chatty"). This is the raid's shared voice instead: +// * the bots' own chatter (loot, a death, a ready check, a new zone) is back, with one line for the whole raid per gap; +// * after a kill a few bots say gg / grats, after a wipe a few talk on the run back and the leader calls the rebuff; +// * between pulls somebody says something now and then; +// * the leader says what the next boss does when a player walks up to it. +// +// Playerbot.Raid.Talk 0 off (the silent raid as before), 1 normal (the default), 2 chatty +// +// The pure part (lines and limits) so it can be unit tested; RaidBrain.cpp and BotTextMgr.cpp pick the bots and send. Every line +// is English and translated per reader where it leaves the server (BotLanguage::GroupChat and the Russian catalog); with the bot +// bridge answering chat the program may word a line first (raid_line events), else the fixed line is said. + +#pragma once + +#include +#include +#include +#include + +namespace Playerbot::Raid { + +enum class RaidTalk : uint8_t { Off = 0, Normal = 1, Chatty = 2 }; + +inline RaidTalk RaidTalkFromConfig(int32_t v) +{ + return v <= 0 ? RaidTalk::Off : (v == 1 ? RaidTalk::Normal : RaidTalk::Chatty); +} + +// A group bigger than this is a raid that talks with one voice (a 20-man and a 40-man; a five-man party grown into a raid group +// for a quest keeps the party's own chatter). +constexpr uint32_t kRaidVoiceGroupSize = 15; + +struct RaidVoiceTuning +{ + uint32_t chatterGapMs = 0; // the bots' own chatter: one line for the whole raid per this + uint32_t chatterBotMs = 0; // ... and one per bot per this + uint32_t killCrowd = 0; // bots who say something after a boss kill besides the leader (1 to this many) + uint32_t runBackCrowd = 0; // bots who talk on the run back after a wipe (1 to this many) + uint32_t idleGapMs = 0; // between pulls: one line from somebody about this often (0.7x to 1.3x) + uint32_t idleQuietMs = 0; // ... once the raid has been out of combat this long + uint32_t explainAgainMs = 0; // the leader explains a boss again after this (and after every wipe on it) +}; + +inline RaidVoiceTuning VoiceTuning(RaidTalk t) +{ + switch (t) + { + case RaidTalk::Normal: return { 30000, 120000, 3, 2, 150000, 20000, 1800000 }; + case RaidTalk::Chatty: return { 15000, 60000, 5, 3, 75000, 15000, 900000 }; + default: return {}; + } +} + +namespace VoiceDetail { + +template +inline std::string_view PickOf(char const* const (&lines)[N], uint32_t pick) { return lines[pick % N]; } + +// Short, lower case, the way people type in raid chat; no pronoun or past tense that needs a gender (the Russian forms). +inline constexpr char const* kKill[] = { + "gg", "gg all", "grats all", "nice one", "ez", "gj everyone", "finally", "gz", "ty all", "good kill", "that went well", + "clean kill", "loot pls" }; +inline constexpr char const* kRunBack[] = { + "brb repair", "rez me pls", "need water before the next one", "rebuff pls", "who has a soulstone up", "running back", + "one more try", "that hurt", "drinking, 1 min", "ok again", "my repair bill though", "we almost had it" }; +inline constexpr char const* kLeaderRebuff[] = { + "rez up, rebuff, we go again", "everyone back, buff up and drink", "rez and rebuff, same plan" }; +inline constexpr char const* kIdle[] = { + "anyone got a spare mana pot", "this place is huge", "how many bosses left", "who's tanking the next one", + "brb 1 min", "mage water pls", "can i get an int buff", "fort pls", "loot's been good so far", "careful with the trash here", + "anyone selling flasks after", "who's on kicks next", "need a soulstone here", "my bags are full already" }; +inline constexpr char const* kLeaderIdle[] = { + "everyone drink up, next pull soon", "stack up, we pull in a minute", "buffs check before the next one" }; + +} // namespace VoiceDetail + +inline std::string_view KillLine(uint32_t pick) { return VoiceDetail::PickOf(VoiceDetail::kKill, pick); } +inline std::string_view RunBackLine(uint32_t pick) { return VoiceDetail::PickOf(VoiceDetail::kRunBack, pick); } +inline std::string_view LeaderRebuffLine(uint32_t pick) { return VoiceDetail::PickOf(VoiceDetail::kLeaderRebuff, pick); } +inline std::string_view IdleLine(uint32_t pick) { return VoiceDetail::PickOf(VoiceDetail::kIdle, pick); } +inline std::string_view LeaderIdleLine(uint32_t pick) { return VoiceDetail::PickOf(VoiceDetail::kLeaderIdle, pick); } + +// The leader's word on a boss before the pull, the way a raid leader explains it; empty for a creature with none. Molten Core, +// Onyxia and Blackwing Lair (Lord Victor Nefarius for Nefarian's first phase). +inline std::string_view BossBrief(uint32_t entry) +{ + switch (entry) + { + // Molten Core + case 12118: return "lucifron: adds first, decurse fast, sheep the mind controlled"; + case 11982: return "magmadar: hunters tranq the frenzy, stay out of the fire, fear ward the tank"; + case 12259: return "gehennas: adds first, decurse, get out of the rain of fire"; + case 12057: return "garr: banish the adds, kill them one at a time, tank garr away from the raid"; + case 12264: return "shazzrah: decurse fast, he blinks, so stay near the tank"; + case 12056: return "geddon: living bomb on you? run out. stay out of inferno"; + case 12098: return "sulfuron: priests first, kick their heals"; + case 11988: return "golemagg: tanks on the dogs, melee watch your stacks, everyone else on golemagg"; + case 12018: return "majordomo: adds only, kick the healers, stop hitting a reflect shield"; + case 11502: return "ragnaros: melee out for the knockback, kill the sons of flame when he goes under"; + // Onyxia + case 10184: return "onyxia: tank her at the back, nobody in front or behind her, phase 3 watch the fear"; + // Blackwing Lair + case 12435: return "razorgore: one dps takes the orb and breaks the eggs, the rest hold the doors"; + case 13020: return "vael: burning adrenaline on you? run out to the wall. tanks swap on it"; + case 12017: return "broodlord: tank him in the corner, watch the knock away, stay off the suppression devices"; + case 11983: return "firemaw: drop your buffet stacks behind the pillar, healers keep the tank up from cover"; + case 14601: return "ebonroc: tanks swap on shadow of ebonroc, everyone else behind him"; + case 11981: return "flamegor: tank him facing away, hunters tranq the frenzy"; + case 14020: return "chromaggus: hide behind the pillars when he breathes, dispel the afflictions, hunters tranq"; + case 10162: return "nefarius: kill the drakonids on both sides, sheep the mind controlled, then nefarian lands"; + case 11583: return "nefarian: tank him facing away, watch your class call, bones come up at 20%"; + default: return {}; + } +} + +// The raid's chatter gate: one line for the whole raid per chatterGapMs, one per bot per chatterBotMs. Not thread safe (the +// caller holds its lock). +class RaidVoiceGate +{ +public: + bool Allow(uint64_t group, uint64_t bot, RaidVoiceTuning const& t, uint32_t now) + { + if (!t.chatterGapMs) + return false; + if (auto g = group_.find(group); g != group_.end() && now - g->second < t.chatterGapMs) + return false; + if (auto b = bot_.find(bot); b != bot_.end() && now - b->second < t.chatterBotMs) + return false; + uint32_t const stamp = now ? now : 1u; + group_[group] = stamp; + bot_[bot] = stamp; + return true; + } + + // Drops what no longer limits anything (call now and then). + void Prune(uint32_t now, uint32_t keepMs) + { + for (auto* m : { &group_, &bot_ }) + for (auto it = m->begin(); it != m->end();) + it = now - it->second >= keepMs ? m->erase(it) : std::next(it); + } + +private: + std::unordered_map group_, bot_; +}; + +// When the leader explains a boss again: never twice within explainAgainMs, at once after a wipe on it. +class BossBriefGate +{ +public: + bool Allow(uint64_t group, uint32_t entry, RaidVoiceTuning const& t, uint32_t now) + { + if (!t.explainAgainMs || BossBrief(entry).empty()) + return false; + uint32_t& last = said_[Key(group, entry)]; + if (last && now - last < t.explainAgainMs) + return false; + last = now ? now : 1u; + return true; + } + + void Wiped(uint64_t group, uint32_t entry) { said_.erase(Key(group, entry)); } + +private: + static uint64_t Key(uint64_t group, uint32_t entry) { return (group << 24) ^ entry; } + std::unordered_map said_; +}; + +} // namespace Playerbot::Raid diff --git a/src/modules/PlayerbotV2/Bot/States/State_Dead.cpp b/src/modules/PlayerbotV2/Bot/States/State_Dead.cpp index 411f9c03d1..c4712c1cb9 100644 --- a/src/modules/PlayerbotV2/Bot/States/State_Dead.cpp +++ b/src/modules/PlayerbotV2/Bot/States/State_Dead.cpp @@ -200,7 +200,7 @@ void DispatchDead(BotAI& ai, { std::string line = BotChatter::BanterLine(BotChatter::Banter::Wipe, ai, snapshot); if (!line.empty()) - emit.say(std::move(line)); + BotChatter::SayToGroup(emit, snapshot, std::move(line)); } } } @@ -277,12 +277,12 @@ void DispatchDead(BotAI& ai, // (no group → no one to thank in chat, would be cringe). if (group.exists() && Services::Config().behavior_party_banter()) { - // Gated, rare and varied (cooldowns, 1-in-2 roll, never in a big raid or when chatter is off). + // Gated, rare and varied (cooldowns, 1-in-2 roll, never when chatter is off; a big raid only with Playerbot.Raid.Talk). bool to_program = false; // the bot bridge's program says it (BotChatter moments) std::string line = BotChatter::BanterLine(BotChatter::Banter::Thanks, ai, snapshot, &to_program); bool const spoke = !line.empty() || to_program; if (!line.empty()) - emit.say(std::move(line)); + BotChatter::SayToGroup(emit, snapshot, std::move(line)); if (Services::Config().behavior_social_emotes() && spoke) emit.perform_emote(2 /*EMOTE_ONESHOT_BOW*/, ObjectGuid::Empty); } diff --git a/src/modules/PlayerbotV2/Bot/States/State_InGroup.cpp b/src/modules/PlayerbotV2/Bot/States/State_InGroup.cpp index 80038992e6..9b6fa5b3a6 100644 --- a/src/modules/PlayerbotV2/Bot/States/State_InGroup.cpp +++ b/src/modules/PlayerbotV2/Bot/States/State_InGroup.cpp @@ -101,14 +101,14 @@ static void AnswerReadyCheck(BotAI& ai, BotSnapshotView const& snapshot, GroupSn if (why) { if (snapshot.is_alive()) - emit.say(why); + BotChatter::SayToGroup(emit, snapshot, why); } else if (ready) { // Now and then a plain "ready" in chat, like a person (Playerbot.Behavior.PartyBanter). std::string line = BotChatter::BanterLine(BotChatter::Banter::Ready, ai, snapshot); if (!line.empty()) - emit.say(std::move(line)); + BotChatter::SayToGroup(emit, snapshot, std::move(line)); } ai.set_ready_check_acked(true); ai.set_last_rule_fired("ingroup:ready_check_ack"); diff --git a/src/modules/PlayerbotV2/Util/BotLocaleRu.cpp b/src/modules/PlayerbotV2/Util/BotLocaleRu.cpp index c3b6fa7d8d..10694caa9c 100644 --- a/src/modules/PlayerbotV2/Util/BotLocaleRu.cpp +++ b/src/modules/PlayerbotV2/Util/BotLocaleRu.cpp @@ -858,6 +858,69 @@ std::vector const& RussianEntries() { "priest call, not healing", "зов жрецов, не лечу" }, { "taunting {}", "провоцирую {}" }, { "{} on {}, don't break it", "{} на {}, не сбивайте" }, + // ---- the raid's voice (Bot/Raid/RaidVoice.h, Playerbot.Raid.Talk) and the newer callouts: raid chat is informal; boss and spell names stay English ---- + { "breath coming, get out of its sight", "сейчас дыхание, уйдите из его видимости" }, + { "dropping {} stacks out of its sight", "сбрасываю стаки {} вне его видимости" }, + { "casting {} on {}", "кастую {} на {}" }, + { "gg all", "гг всем" }, + { "grats all", "всех с победой" }, + { "ez", "изи" }, + { "gj everyone", "все молодцы" }, + { "ty all", "всем спасибо" }, + { "good kill", "хороший килл" }, + { "clean kill", "чистый килл" }, + { "loot pls", "лут пжл" }, + { "brb repair", "щас, на ремонт" }, + { "rez me pls", "реснете пжл" }, + { "need water before the next one", "перед следующим нужна вода" }, + { "rebuff pls", "бафните пжл" }, + { "who has a soulstone up", "у кого камень души" }, + { "running back", "бегу обратно" }, + { "one more try", "ещё одна попытка" }, + { "drinking, 1 min", "пью, 1 мин" }, + { "ok again", "ок, ещё раз" }, + { "my repair bill though", "а ремонт-то дорогой" }, + { "we almost had it", "почти же было" }, + { "rez up, rebuff, we go again", "ресаемся, бафаемся, идём снова" }, + { "everyone back, buff up and drink", "все назад, бафы и попить" }, + { "rez and rebuff, same plan", "рес и бафы, план тот же" }, + { "anyone got a spare mana pot", "у кого есть лишнее зелье маны" }, + { "this place is huge", "здесь всё огромное" }, + { "how many bosses left", "сколько боссов осталось" }, + { "who's tanking the next one", "кто танкует следующего" }, + { "brb 1 min", "отойду на минуту" }, + { "mage water pls", "маги, воды пжл" }, + { "can i get an int buff", "можно бафф на интеллект" }, + { "fort pls", "стойкость пжл" }, + { "loot's been good so far", "лут пока хороший" }, + { "careful with the trash here", "осторожно с трешем тут" }, + { "anyone selling flasks after", "кто-нибудь продаст фласки потом" }, + { "who's on kicks next", "кто на киках дальше" }, + { "need a soulstone here", "нужен камень души сюда" }, + { "my bags are full already", "сумки уже полные" }, + { "everyone drink up, next pull soon", "все пьём, скоро пул" }, + { "stack up, we pull in a minute", "собираемся, пул через минуту" }, + { "buffs check before the next one", "проверка бафов перед следующим" }, + { "lucifron: adds first, decurse fast, sheep the mind controlled", "lucifron: сначала адды, быстро снимайте проклятия, контролируемых в овцу" }, + { "magmadar: hunters tranq the frenzy, stay out of the fire, fear ward the tank", "magmadar: охотники, транк на бешенство, не стойте в огне, защиту от страха на танка" }, + { "gehennas: adds first, decurse, get out of the rain of fire", "gehennas: сначала адды, снимайте проклятия, выходите из огненного дождя" }, + { "garr: banish the adds, kill them one at a time, tank garr away from the raid", "garr: аддов в изгнание, убиваем по одному, garr танкуем подальше от рейда" }, + { "shazzrah: decurse fast, he blinks, so stay near the tank", "shazzrah: быстро снимайте проклятия, он прыгает, держитесь ближе к танку" }, + { "geddon: living bomb on you? run out. stay out of inferno", "geddon: на тебе living bomb? отбегай. не стойте в inferno" }, + { "sulfuron: priests first, kick their heals", "sulfuron: сначала жрецы, сбивайте их хил" }, + { "golemagg: tanks on the dogs, melee watch your stacks, everyone else on golemagg", "golemagg: танки на собаках, мили следят за стаками, остальные на golemagg" }, + { "majordomo: adds only, kick the healers, stop hitting a reflect shield", "majordomo: только адды, сбивайте хилеров, не бейте в щит отражения" }, + { "ragnaros: melee out for the knockback, kill the sons of flame when he goes under", "ragnaros: мили отходят от отбрасывания, убиваем sons of flame, когда он уходит под лаву" }, + { "onyxia: tank her at the back, nobody in front or behind her, phase 3 watch the fear", "onyxia: танкуем у дальней стены, никого перед ней и за ней, в третьей фазе следите за страхом" }, + { "razorgore: one dps takes the orb and breaks the eggs, the rest hold the doors", "razorgore: один дд берёт сферу и бьёт яйца, остальные держат двери" }, + { "vael: burning adrenaline on you? run out to the wall. tanks swap on it", "vael: на тебе burning adrenaline? беги к стене. танки меняются на нём" }, + { "broodlord: tank him in the corner, watch the knock away, stay off the suppression devices", "broodlord: танкуем в углу, следите за отбрасыванием, не наступайте на подавители" }, + { "firemaw: drop your buffet stacks behind the pillar, healers keep the tank up from cover", "firemaw: сбрасывайте стаки buffet за колонной, хилеры держат танка из укрытия" }, + { "ebonroc: tanks swap on shadow of ebonroc, everyone else behind him", "ebonroc: танки меняются на shadow of ebonroc, остальные за ним" }, + { "flamegor: tank him facing away, hunters tranq the frenzy", "flamegor: танкуем мордой от рейда, охотники, транк на бешенство" }, + { "chromaggus: hide behind the pillars when he breathes, dispel the afflictions, hunters tranq", "chromaggus: прячьтесь за колоннами на дыхание, снимайте дебаффы, охотники, транк" }, + { "nefarius: kill the drakonids on both sides, sheep the mind controlled, then nefarian lands", "nefarius: убиваем драконидов с обеих сторон, контролируемых в овцу, потом приземляется nefarian" }, + { "nefarian: tank him facing away, watch your class call, bones come up at 20%", "nefarian: танкуем мордой от рейда, следите за зовом классов, на 20% встают кости" }, // ---- boss tactics (Bot/Raid/BossTactics.h, BotCommandParser::ApplyTacticsOrder); the plan words the player types stay English -- { "Tactics for {}: {}. Your bots use them every time you fight {}.", "Тактика на {1}: {2}. Ваши боты применяют её в каждом бою с {3}." }, { "Tactics for {}: {}.", "Тактика на {}: {}." }, diff --git a/src/modules/PlayerbotV2/Util/ConfigReader.cpp b/src/modules/PlayerbotV2/Util/ConfigReader.cpp index 16c16ac41b..94bead122d 100644 --- a/src/modules/PlayerbotV2/Util/ConfigReader.cpp +++ b/src/modules/PlayerbotV2/Util/ConfigReader.cpp @@ -80,6 +80,7 @@ void ConfigReader::apply_from_loaded_config() boss_warnings_enabled_ = c.GetBoolDefault("Playerbot.Raid.BossWarnings", true, true); raid_callouts_enabled_ = c.GetBoolDefault("Playerbot.Raid.Callouts", true, true); raid_banter_ = c.GetIntDefault("Playerbot.Raid.Banter", 1, true); + raid_talk_ = c.GetIntDefault("Playerbot.Raid.Talk", 1, true); raid_auto_accept_rez_ = c.GetBoolDefault("Playerbot.Raid.AutoAcceptOwnerRez", true, true); housing_enabled_ = c.GetBoolDefault("Playerbot.Housing.Enabled", false, true); diff --git a/src/modules/PlayerbotV2/Util/ConfigReader.h b/src/modules/PlayerbotV2/Util/ConfigReader.h index 791eb8a5d3..d4a25337f0 100644 --- a/src/modules/PlayerbotV2/Util/ConfigReader.h +++ b/src/modules/PlayerbotV2/Util/ConfigReader.h @@ -58,6 +58,7 @@ public: bool boss_warnings_enabled() const { return boss_warnings_enabled_; } bool raid_callouts_enabled() const { return raid_callouts_enabled_; } int32 raid_banter() const { return raid_banter_; } // 0 off, 1 mild, 2 harsh (Raid/RaidBanter.h) + int32 raid_talk() const { return raid_talk_; } // 0 off, 1 normal, 2 chatty (Raid/RaidVoice.h) bool raid_auto_accept_rez() const { return raid_auto_accept_rez_; } // Housing @@ -615,6 +616,7 @@ private: bool boss_warnings_enabled_ = true; bool raid_callouts_enabled_ = true; int32 raid_banter_ = 1; + int32 raid_talk_ = 1; bool raid_auto_accept_rez_ = true; bool housing_enabled_ = true; diff --git a/src/modules/PlayerbotV2/conf/playerbot.conf.dist b/src/modules/PlayerbotV2/conf/playerbot.conf.dist index d622fbbabd..40e7d3dfdb 100644 --- a/src/modules/PlayerbotV2/conf/playerbot.conf.dist +++ b/src/modules/PlayerbotV2/conf/playerbot.conf.dist @@ -582,6 +582,15 @@ Playerbot.Raid.Callouts = 1 # 0 = off, 1 = mild (teasing), 2 = harsh (a leader who freaks out at every mishap) Playerbot.Raid.Banter = 1 +# A raid of more than 15 talks like a crowd of players (Bot/Raid/RaidVoice.h): the bots' own chatter (loot, a death, a ready check) +# with one line for the whole raid at a time, a few gg and grats after a kill, talk on the run back after a wipe and the leader's +# rebuff call, a line now and then between pulls, and the raid leader bot saying what the next boss does when a player walks up to +# it (Molten Core, Onyxia, Blackwing Lair). Only in a raid with a real player in it. With the bot bridge answering chat the +# program may word the lines (a line not back within 2.5 s is said the fixed way). +# 0 = off (the bots stay quiet in a big raid except Callouts and Banter, as before 0.1.37), 1 = normal, 2 = chatty +# (normal: one chatter line per raid every 30 s, between pulls a line every 2 to 3 minutes; chatty: twice as often) +Playerbot.Raid.Talk = 1 + # A resurrection a bot casts on you is accepted for you after 3 s without an answer (the 70205 client shows no accept popup). Playerbot.Raid.AutoAcceptOwnerRez = 1 diff --git a/src/modules/PlayerbotV2/tools/bot_bridge_ollama.py b/src/modules/PlayerbotV2/tools/bot_bridge_ollama.py index 1930da30db..e36af0f427 100644 --- a/src/modules/PlayerbotV2/tools/bot_bridge_ollama.py +++ b/src/modules/PlayerbotV2/tools/bot_bridge_ollama.py @@ -1197,9 +1197,20 @@ def answer_talk(event, api, minds, opts): log("%s [%s, %.1f s]: %s" % (bot, "talk" if channel == "say" else channel, time.time() - started, say)) +# The raid's own talk that is no mistake (Playerbot.Raid.Talk, the server's RaidVoice): what the bot is doing when it speaks. +RAID_VOICE = { + "kill_crowd": "Your raid just killed a boss; you say something short in raid chat the way raiders do then.", + "run_back": "Your raid just wiped and you are on the way back; you say something a raider says then (repair, rez, buffs, a " + "small joke).", + "rebuff_call": "You are the raid leader; after a wipe you get everyone to resurrect, rebuff and go again, calm and short.", + "between_pulls": "Your raid is resting between pulls; you say something a raider says then (buffs, water, loot, the next " + "boss, a small joke).", +} + + def answer_raid_line(event, api, opts): """A bot's raid chat line about something that just happened in the fight (the raid leader reacting to a mistake, a raider - after a wipe). Fast or nothing: the server says its fixed line itself when this one is not back within wait_ms (2.5 s), so + after a wipe), or the raid's own talk (a kill, the run back, between pulls: RAID_VOICE). Fast or nothing: the server says its fixed line itself when this one is not back within wait_ms (2.5 s), so the prompt is short, the answer is a few words, and a slow model simply loses. No persona text of anyone's goes in: the lines stay game banter, never about a person, never a slur (check_line still filters what comes back).""" api = getattr(api, "primary", api) # never the paid backup for banter @@ -1212,16 +1223,21 @@ def answer_raid_line(event, api, opts): harsh = str(event.get("mood", "mild")) == "harsh" leader = str(event.get("role", "")) == "raid leader" russian = str(event.get("locale", "")).lower() == "ruru" + voice = RAID_VOICE.get(str(event.get("what", ""))) + if voice and leader and event.get("what") == "between_pulls": + voice = "You are the raid leader; the raid rests between pulls and you get them ready for the next one, calm and short." system = ("You are %s, a level %s %s in a World of Warcraft raid, writing in raid chat like a real player. %s " - "Write ONE short line (at most 12 words), lowercase, no emoji, no quotes. Only about the game and this mistake: " + "Write ONE short line (at most 12 words), lowercase, no emoji, no quotes. Only about the game and this %s: " "never about the person behind the character, never insults about real life, never slurs, no threats. " "Answer as JSON: {\"say\": \"...\"}." % (bot, event.get("level", "60"), event.get("class", ""), + voice if voice else ("You are the raid leader and you %s." % ("freak out at every mistake, loud and dramatic, CAPS now and then, but it " "is all in good fun" if harsh else "tease people about mistakes, " "calm and a bit dry")) if leader else ("You just wiped with your raid; you %s." % ("blame someone a bit, half joking" if harsh else - "make an excuse, a joke or own up")))) + "make an excuse, a joke or own up")), + "moment" if voice else "mistake")) if russian: system += " " + language_line(True) user = "Just now: %s.\nThe kind of line meant (don't copy it): %s" % (event.get("detail", "something happened"), event.get("example", "")) diff --git a/tests/game/ClassicBossWarnings.cpp b/tests/game/ClassicBossWarnings.cpp index 8fc892b1ec..40de60ae91 100644 --- a/tests/game/ClassicBossWarnings.cpp +++ b/tests/game/ClassicBossWarnings.cpp @@ -21,6 +21,7 @@ #include "../../src/modules/PlayerbotV2/Bot/Raid/RaidCallouts.h" #include "../../src/modules/PlayerbotV2/Bot/Raid/BossTactics.h" #include "../../src/modules/PlayerbotV2/Bot/Raid/RaidBanter.h" +#include "../../src/modules/PlayerbotV2/Bot/Raid/RaidVoice.h" using namespace Playerbot::Raid; namespace CcDeny = Playerbot::CcDeny; @@ -430,3 +431,103 @@ TEST_CASE("Raid banter: config and rate limits", "[ClassicBossWarnings]") h.Prune(t + 500000); CHECK(h.Tracked() == 0); } + +TEST_CASE("Raid callout: breath, stacks and tranq lines", "[ClassicBossWarnings]") +{ + CalloutFacts breath; + breath.move_reason = "break sight"; + CHECK(PickCallout(breath).kind == CalloutKind::BreathHide); + CHECK(PickCallout(breath).text == "breath coming, get out of its sight"); + CHECK(PickCallout(breath).group_wide); + + CalloutFacts stacks = breath; + stacks.sight_aura = "Flame Buffet"; + CHECK(PickCallout(stacks).kind == CalloutKind::DropStacks); + CHECK(PickCallout(stacks).text == "dropping Flame Buffet stacks out of its sight"); + CHECK(PickCallout(stacks).group_wide); // one bot says it for the raid, not all forty + + CalloutFacts tranq; + tranq.purge = true; + tranq.spell = "Tranquilizing Shot"; + tranq.target = "Flamegor"; + CHECK(PickCallout(tranq).text == "casting Tranquilizing Shot on Flamegor"); + tranq.target.clear(); + CHECK(PickCallout(tranq).kind == CalloutKind::None); +} + +TEST_CASE("Raid callout: the same sheep is called once for the raid", "[ClassicBossWarnings]") +{ + // BWL Nefarius 2026-11-13: four mages each said "Polymorph on Carmina, don't break it" within 11 s. + CalloutGate g; + uint32_t const t = 1000; + CHECK(g.Allow(1, 10, CalloutKind::CrowdControl, false, t, "Carmina")); + CHECK_FALSE(g.Allow(1, 11, CalloutKind::CrowdControl, false, t + 2000, "Carmina")); + CHECK_FALSE(g.Allow(1, 12, CalloutKind::CrowdControl, false, t + 6000, "Carmina")); + CHECK(g.Allow(1, 13, CalloutKind::CrowdControl, false, t + 8000, "Darra")); // another target + CHECK(g.Allow(2, 14, CalloutKind::CrowdControl, false, t + 2000, "Carmina")); // another raid + CHECK(g.Allow(1, 15, CalloutKind::Tranq, false, t + 10000, "Carmina")); // another kind of line + CHECK(g.Allow(1, 16, CalloutKind::CrowdControl, false, t + CalloutGate::kSameKindMs, "Carmina")); // later, again +} + +TEST_CASE("Raid voice: config, tuning and the chatter gate", "[ClassicBossWarnings]") +{ + CHECK(RaidTalkFromConfig(0) == RaidTalk::Off); + CHECK(RaidTalkFromConfig(-1) == RaidTalk::Off); + CHECK(RaidTalkFromConfig(1) == RaidTalk::Normal); + CHECK(RaidTalkFromConfig(2) == RaidTalk::Chatty); + CHECK(RaidTalkFromConfig(7) == RaidTalk::Chatty); + + RaidVoiceTuning const off = VoiceTuning(RaidTalk::Off); + RaidVoiceTuning const normal = VoiceTuning(RaidTalk::Normal); + RaidVoiceTuning const chatty = VoiceTuning(RaidTalk::Chatty); + CHECK(off.chatterGapMs == 0); + CHECK(chatty.chatterGapMs < normal.chatterGapMs); + CHECK(chatty.idleGapMs < normal.idleGapMs); + CHECK(chatty.killCrowd > normal.killCrowd); + CHECK(normal.killCrowd >= 1); + CHECK(normal.runBackCrowd >= 1); + + RaidVoiceGate g; + uint32_t const t = 5000; + CHECK_FALSE(g.Allow(1, 10, off, t)); // off: nobody + CHECK(g.Allow(1, 10, normal, t)); + CHECK_FALSE(g.Allow(1, 11, normal, t + 1000)); // the raid just heard a line + CHECK(g.Allow(2, 11, normal, t + 1000)); // another raid + CHECK(g.Allow(1, 12, normal, t + normal.chatterGapMs)); // another bot, after the gap + CHECK_FALSE(g.Allow(1, 10, normal, t + normal.chatterGapMs * 2)); // the first bot again, too soon for it + CHECK(g.Allow(1, 10, normal, t + normal.chatterBotMs)); + g.Prune(t + 10000000, normal.chatterBotMs); + CHECK(g.Allow(1, 12, normal, t + 10000000)); +} + +TEST_CASE("Raid voice: the lines and the boss briefs", "[ClassicBossWarnings]") +{ + for (uint32_t pick = 0; pick < 64; ++pick) + { + CHECK_FALSE(KillLine(pick).empty()); + CHECK_FALSE(RunBackLine(pick).empty()); + CHECK_FALSE(LeaderRebuffLine(pick).empty()); + CHECK_FALSE(IdleLine(pick).empty()); + CHECK_FALSE(LeaderIdleLine(pick).empty()); + } + // Every boss of Molten Core, Onyxia and Blackwing Lair has its brief, and Lord Victor Nefarius for Nefarian's first phase. + for (uint32_t e : { 12118u, 11982u, 12259u, 12057u, 12264u, 12056u, 12098u, 11988u, 12018u, 11502u, 10184u, + 12435u, 13020u, 12017u, 11983u, 14601u, 11981u, 14020u, 11583u, 10162u }) + { + INFO(e); + CHECK_FALSE(BossBrief(e).empty()); + } + CHECK(BossBrief(1).empty()); + + BossBriefGate b; + RaidVoiceTuning const normal = VoiceTuning(RaidTalk::Normal); + uint32_t const t = 1000; + CHECK(b.Allow(1, 11983, normal, t)); + CHECK_FALSE(b.Allow(1, 11983, normal, t + 60000)); // said, not again soon + CHECK(b.Allow(2, 11983, normal, t + 60000)); // another raid + CHECK_FALSE(b.Allow(1, 1, normal, t)); // no brief for it + CHECK_FALSE(b.Allow(1, 11983, VoiceTuning(RaidTalk::Off), t + 9000000)); // off + b.Wiped(1, 11983); + CHECK(b.Allow(1, 11983, normal, t + 61000)); // a wipe on it: explained again + CHECK(b.Allow(1, 11983, normal, t + 61000 + normal.explainAgainMs)); +} diff --git a/tests/game/ClassicBotLocale.cpp b/tests/game/ClassicBotLocale.cpp index 8051ce6ef8..bd6a2ed6f8 100644 --- a/tests/game/ClassicBotLocale.cpp +++ b/tests/game/ClassicBotLocale.cpp @@ -21,6 +21,8 @@ #include "../../src/modules/PlayerbotV2/Util/BotLocaleText.h" #include "../../src/modules/PlayerbotV2/Bot/Raid/RaidBanter.h" +#include "../../src/modules/PlayerbotV2/Bot/Raid/RaidCallouts.h" +#include "../../src/modules/PlayerbotV2/Bot/Raid/RaidVoice.h" #include "../../src/modules/PlayerbotV2/Bot/Quest/QuestRefusal.h" #include #include @@ -223,6 +225,37 @@ TEST_CASE("BotLocale: raid leader banter", "[BotLocale]") } } +TEST_CASE("BotLocale: the raid's voice", "[BotLocale]") +{ + using namespace Playerbot::Raid; + Catalog const& ru = Russian(); + // Every fixed line of the raid's voice and every boss brief has its Russian form. + for (uint32_t pick = 0; pick < 64; ++pick) + for (std::string_view s : { KillLine(pick), RunBackLine(pick), LeaderRebuffLine(pick), IdleLine(pick), LeaderIdleLine(pick) }) + { + INFO(s); + CHECK(ru.Knows(s)); + } + for (uint32_t e : { 12118u, 11982u, 12259u, 12057u, 12264u, 12056u, 12098u, 11988u, 12018u, 11502u, 10184u, + 12435u, 13020u, 12017u, 11983u, 14601u, 11981u, 14020u, 11583u, 10162u }) + { + INFO(BossBrief(e)); + CHECK(ru.Knows(BossBrief(e))); + } + // The newer callouts. + CalloutFacts breath; + breath.move_reason = "break sight"; + CHECK(Translate(Lang::Ru, PickCallout(breath).text) == "сейчас дыхание, уйдите из его видимости"); + breath.sight_aura = "Flame Buffet"; + CHECK(Translate(Lang::Ru, PickCallout(breath).text) == "сбрасываю стаки Flame Buffet вне его видимости"); + CalloutFacts tranq; + tranq.purge = true; + tranq.spell = "Tranquilizing Shot"; + tranq.target = "Flamegor"; + CHECK(Translate(Lang::Ru, PickCallout(tranq).text) == "кастую Tranquilizing Shot на Flamegor"); + CHECK(Translate(Lang::Ru, "Polymorph on Flamewaker Healer, don't break it") == "Polymorph на Flamewaker Healer, не сбивайте"); +} + TEST_CASE("BotLocale: boss tactics answers", "[BotLocale]") { CHECK(Translate(Lang::Ru, "Tactics for Lucifron: adds first, no AoE, tank at your spot. Your bots use them every time you fight Lucifron.")