diff --git a/sql/playerbot_v2/0037_hired_bots.sql b/sql/playerbot_v2/0037_hired_bots.sql deleted file mode 100644 index 41438d4862..0000000000 --- a/sql/playerbot_v2/0037_hired_bots.sql +++ /dev/null @@ -1,27 +0,0 @@ --- Migration: 0037_hired_bots --- Date: 2026-10-29 --- Purpose: Hired bots (Playerbot.Hire.*, Fleet/HireMgr). In hired mode a player's companions are hired from a mercenary NPC for --- gold instead of being made out of nothing; each hired bot keeps its grade, what was paid for it and how long its --- upkeep is paid. A player chooses hired bots for their account when the server leaves it to them (Hire.Mode = 2). --- --- Columns (playerbot_v2_character): --- hire_grade 0 = not hired (made before hired mode, or by a GM), 1 = Sellsword, 2 = Veteran, 3 = Legend --- hire_price copper paid for the bot; its daily upkeep is Playerbot.Hire.UpkeepPct of this --- hire_paid_until unix seconds; the upkeep is due again from then, the next time the bot is called --- Table playerbot_v2_hire_pref: account_id, hired_only (1 = the account chose hired bots). --- Reverts: yes (DROP COLUMN hire_grade, hire_price, hire_paid_until; DROP TABLE playerbot_v2_hire_pref). - -ALTER TABLE playerbot_v2_character - ADD COLUMN hire_grade TINYINT UNSIGNED NOT NULL DEFAULT 0, - ADD COLUMN hire_price BIGINT UNSIGNED NOT NULL DEFAULT 0, - ADD COLUMN hire_paid_until BIGINT UNSIGNED NOT NULL DEFAULT 0; - -CREATE TABLE IF NOT EXISTS playerbot_v2_hire_pref ( - account_id INT UNSIGNED NOT NULL, - hired_only TINYINT UNSIGNED NOT NULL DEFAULT 0, - PRIMARY KEY (account_id) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; - -INSERT INTO playerbot_v2_schema_version (version, sha256) VALUES - (37, REPEAT('0', 64)) -ON DUPLICATE KEY UPDATE applied_at = CURRENT_TIMESTAMP; diff --git a/src/modules/PlayerbotV2/Addon/ForeverBots/ForeverBots.lua b/src/modules/PlayerbotV2/Addon/ForeverBots/ForeverBots.lua index b4a9df4d58..d293783402 100644 --- a/src/modules/PlayerbotV2/Addon/ForeverBots/ForeverBots.lua +++ b/src/modules/PlayerbotV2/Addon/ForeverBots/ForeverBots.lua @@ -1597,10 +1597,7 @@ function UI.BuildBots() SelectClass(1) local quick = Btn(botsPane, 0, 106, 117, 24, L["Quick party"], {}) quick:SetScript("OnClick", QuickParty) - Tip(quick, L["Quick party"], L["Fills your group with bots at your level: to five in the open world and 5-player dungeons, to the size of a bigger instance (10 in Upper Blackrock Spire) or raid. With hired bots on (/fb hire), your hired bots come; next to a mercenary broker the missing places are hired for gold."]) - -- hired bots only hides the class and role buttons (ForeverBots_Hire.lua) - Cmd.ns.addButtons = { roles = roleBtns, classes = classBtns, sel = selFS, pane = botsPane } - if Cmd.ns.Hire then Cmd.ns.Hire.Attach(botsPane) end + Tip(quick, L["Quick party"], L["Fills your group with bots at your level: to five in the open world and 5-player dungeons, to the size of a bigger instance (10 in Upper Blackrock Spire) or raid."]) gearBtn = Btn(botsPane, 121, 106, 117, 24, "", {}) gearBtn:SetScript("OnClick", function() local cur = ForeverBotsDB.gear or "match" @@ -2120,7 +2117,7 @@ local function ToggleMinimapMenu() if not mmMenu then local m = CreateFrame("Frame", "ForeverBotsMinimapMenu", UIParent, BackdropTemplateMixin and "BackdropTemplate" or nil) mmMenu = m - m:SetSize(150, 7 * 28 + 12) -- seven items below + m:SetSize(150, 4 * 28 + 12) m:SetFrameStrata("DIALOG") m:EnableMouse(true) if m.SetBackdrop then @@ -2134,10 +2131,6 @@ local function ToggleMinimapMenu() { L["Raid ready"], RaidReady }, { L["Call saved bots"], function() ServerCommand(".bot summon saved") end }, { L["Dismiss all bots"], function() ServerCommand(".bot dismiss all") end }, - -- arena (".bot arena"): the party leader queues the party; 2v2 needs a party of 2, 3v3 a party of 3 (bots count) - { L["Arena 2v2"], function() ServerCommand(".bot arena 2") end }, - { L["Arena 3v3"], function() ServerCommand(".bot arena 3") end }, - { L["Leave arena queue"], function() ServerCommand(".bot arena leave") end }, { L["Hide this button"], function() ForeverBotsDB.minimap.hidden = true mmButton:Hide() @@ -3155,10 +3148,6 @@ SlashCmdList.FOREVERBOTS = function(msg) GroupOrder("flee") elseif verb == "quick" then QuickParty() - elseif verb == "hire" then - -- Hired bots (the server's Playerbot.Hire.Mode): no word shows whether you must hire and the prices here; on / off is your - -- own choice when the realm leaves it to each player. - ServerCommand((class == "on" or class == "off") and (".bot hire " .. class) or ".bot hire") elseif verb == "dungeon" or verb == "dungeons" then UI.DungeonQueue((class and class ~= "") and class or "list") elseif verb == "maintank" then @@ -3167,7 +3156,7 @@ SlashCmdList.FOREVERBOTS = function(msg) Toggle() else Print(L["unknown /fb word \"%s\" (add-on %s)"]:format(tostring(verb), UI.version or "?")) - Print("/fb opens the window; /fb add [tank|healer|dps]; /fb raidready; /fb call|dismiss|save|unsave|regear [name|all]; /fb delete ; /fb list; /fb fallback; /fb pullback; /fb rally; /fb formation circle|arrow|line|none; /fb spacing tight|close|spread; /fb distance <1-20>; /fb maintank [name]; /fb bot on|off; /fb tank |clear; /fb assign [role]|clear|list; /fb minimap on|off|reset; /fb scale <0.7-1.5>; /fb resume; /fb flee; /fb quick; /fb hire [on|off]; /fb dungeon [name|any|leave|cancel]; /fb debug on|off; /fb perf [reset]; /fb part [name on|off]") + Print("/fb opens the window; /fb add [tank|healer|dps]; /fb raidready; /fb call|dismiss|save|unsave|regear [name|all]; /fb delete ; /fb list; /fb fallback; /fb pullback; /fb rally; /fb formation circle|arrow|line|none; /fb spacing tight|close|spread; /fb distance <1-20>; /fb maintank [name]; /fb bot on|off; /fb tank |clear; /fb assign [role]|clear|list; /fb minimap on|off|reset; /fb scale <0.7-1.5>; /fb resume; /fb flee; /fb quick; /fb dungeon [name|any|leave|cancel]; /fb debug on|off; /fb perf [reset]; /fb part [name on|off]") end end UI.slash = SlashCmdList.FOREVERBOTS diff --git a/src/modules/PlayerbotV2/Addon/ForeverBots/Locale_ruRU.lua b/src/modules/PlayerbotV2/Addon/ForeverBots/Locale_ruRU.lua index 6d8df7e8c1..821c21e6a2 100644 --- a/src/modules/PlayerbotV2/Addon/ForeverBots/Locale_ruRU.lua +++ b/src/modules/PlayerbotV2/Addon/ForeverBots/Locale_ruRU.lua @@ -98,7 +98,7 @@ ForeverBotsLocale = { ["A new bot joins you at your level, wearing the gear chosen below."] = "Новый бот вашего уровня присоединяется к вам в выбранной ниже экипировке.", ["Pick the class, then a role below."] = "Выберите класс, затем роль ниже.", ["Quick party"] = "Быстрая группа", - ["Fills your group with bots at your level: to five in the open world and 5-player dungeons, to the size of a bigger instance (10 in Upper Blackrock Spire) or raid. With hired bots on (/fb hire), your hired bots come; next to a mercenary broker the missing places are hired for gold."] = "Заполняет группу ботами вашего уровня: до пяти в открытом мире и подземельях на 5 игроков, до размера большего подземелья (10 в Верхней части вершины Черной горы) или рейда. Если включены наемники (/fb hire), приходят ваши нанятые боты; рядом с вербовщиком наемников недостающие места нанимаются за золото.", -- check + ["Fills your group with bots at your level: to five in the open world and 5-player dungeons, to the size of a bigger instance (10 in Upper Blackrock Spire) or raid."] = "Заполняет группу ботами вашего уровня: до пяти в открытом мире и подземельях на 5 игроков, до размера большего подземелья (10 в Верхней части вершины Черной горы) или рейда.", ["Match my gear"] = "Как у меня", ["Best for their level"] = "Лучшее для уровня", ["Best in slot"] = "БиС", @@ -204,12 +204,6 @@ ForeverBotsLocale = { ["two macros are named %s but differ; a key bound to that name uses the first. Rename or delete one in /macro."] = "два макроса называются %s, но различаются; клавиша с этим именем запускает первый. Переименуйте или удалите один в /macro.", ["Call saved bots"] = "Призвать сохраненных", ["Dismiss all bots"] = "Отозвать всех ботов", - ["Arena 2v2"] = "Арена 2 на 2", - ["Arena 3v3"] = "Арена 3 на 3", - ["Leave arena queue"] = "Покинуть очередь на арену", - ["Your %dv%d arena is ready."] = "Ваша арена %d на %d готова.", - ["Enter"] = "Войти", - ["Leave"] = "Отказаться", ["Hide this button"] = "Скрыть эту кнопку", ["minimap button hidden: /fb minimap brings it back."] = "кнопка у миникарты скрыта: команда /fb minimap вернет ее.", ["Click: open or close the bot window"] = "ЛКМ: открыть/закрыть окно ботов", @@ -538,8 +532,6 @@ ForeverBotsLocale = { ["Delete"] = "Удалить", ["Deletes the bot's character for good (asks first)."] = "Навсегда удаляет персонажа бота (сначала спросит).", ["Details"] = "Сведения", - -- Hired bots only (ForeverBots_Hire.lua), 0.6.10 -- check - ["Hired bots only on this realm. Hire bots from a Sellsword Captain at an inn, a Veteran Recruiter in a capital or a Black Market Broker in Gadgetzan, Booty Bay or Ratchet. The Group finder and the dungeon finder still bring bots."] = "На этом сервере только наемные боты. Нанимайте ботов у капитана наемников в таверне, у вербовщика ветеранов в столице или у торговца черного рынка в Прибамбасске, Пиратской Бухте или Кабестане. Поиск группы и поиск подземелий по-прежнему приводят ботов.", -- Positions tab (ForeverBots_Place.lua), 0.6.12 -- check ["Positions"] = "Позиции", ["Arc"] = "Дуга", diff --git a/src/modules/PlayerbotV2/Addon/ForeverBots/README.md b/src/modules/PlayerbotV2/Addon/ForeverBots/README.md index df57446bdb..cab3f7d2b1 100644 --- a/src/modules/PlayerbotV2/Addon/ForeverBots/README.md +++ b/src/modules/PlayerbotV2/Addon/ForeverBots/README.md @@ -30,15 +30,8 @@ regroup, formation and spacing, tanks and markers), Assign a bot to an icon, You - Ignore target and Clear (0.6.9): your target goes on the list of mobs your bots never attack, even when it attacks you (a beast you tame); the button again on it takes it off, Clear empties the list. Group orders `ignore target` / `ignore clear`; the server answers in a system line. Secure buttons, so they work in combat. -- Arena (0.6.11), in the minimap button's menu: Arena 2v2, Arena 3v3 and Leave arena queue send `.bot arena 2|3|leave`. The - party leader queues the party; 2v2 needs a party of exactly 2 and 3v3 of exactly 3, your bots count. The other team is a real - party or a bot party the server makes. The same lines can be typed in chat. -- Arena ready pop-up: when your arena is ready a small window shows Enter and Leave (the game's own arena pop has Enter only). - They send `.bot arena enter` and `.bot arena leave`; Leave also takes your party's bots out of the same queue. - One button per class and role: adds that bot (`.bot add `). It joins you at your level, geared, in your group. -- Hired bots only (0.6.10, the server's Playerbot.Hire.Mode): when you must hire, the class and role buttons are hidden and a - line says where to hire bots instead (HIRE_REQ / HIRE_RESP, ForeverBots_Hire.lua). Quick party, Call saved and Raid ready stay. - Orders to the group: Follow, Stay, Attack (your target), Resume; Pull (your tank bots open on your target, the rest join once it is engaged), Flee (break off and run to you), Come (teleport to you), Stop (stop attacking and return to normal), Release (after a wipe: every dead bot releases its spirit, runs back to its corpse as a ghost, diff --git a/src/modules/PlayerbotV2/Api/PlayerbotAPI.cpp b/src/modules/PlayerbotV2/Api/PlayerbotAPI.cpp index 60a35406bd..5091f7e8da 100644 --- a/src/modules/PlayerbotV2/Api/PlayerbotAPI.cpp +++ b/src/modules/PlayerbotV2/Api/PlayerbotAPI.cpp @@ -9310,12 +9310,6 @@ Result API::bg_queue(ObjectGuid battlemaster, uint16 bg_type_id, uint8 arena_typ return Result::Locked; } - // a template with no map (Classic data has no "All Arenas" map unless the arena SQL is in) would read address 0 - if (bg_tmpl->MapIDs.empty()) - { - TC_LOG_INFO("playerbot.v2", "[bg_queue] {} reject: no_map (bg_type_id={})", p_->GetName(), bg_type_id); - return Result::NotKnown; - } PVPDifficultyEntry const* bracket = DB2Manager::GetBattlegroundBracketByLevel(bg_tmpl->MapIDs.front(), p_->GetLevel()); if (!bracket) @@ -9336,20 +9330,22 @@ Result API::bg_queue(ObjectGuid battlemaster, uint16 bg_type_id, uint8 arena_typ // SKIRMISH arenas (no arena-team / MMR dependency), mirroring // HandleBattlemasterJoinArena with arena teams disabled. const bool is_arena = arena_type > 0 || bg_tmpl->IsArena(); - // Bots queue the SAME arena queue a real party joins (HandleBattlemasterJoinArena): the Arena queue id, rated bit set, - // team size 2, 3 or 5, rating 1/1 and no arena team. A bot team in the old 3v3 skirmish queue could never meet a real - // party, and 2v2 was impossible. With no arena team the match changes no rating. - if (is_arena && arena_type != 2 && arena_type != 3 && arena_type != 5) + // Bots queue UNRATED SKIRMISH only (they have no persistent ArenaTeam). + // Per BattlegroundMgr::IsValidQueueId, the unrated path is the dedicated + // ArenaSkirmish queue type which (in this core) is 3v3-ONLY and still + // carries the Rated bit set. The plain Arena queue type REQUIRES rated + + // an ArenaTeam, so it can never be a bot path. Hence arena == 3v3 skirmish. + if (is_arena && arena_type != 3) { TC_LOG_INFO("playerbot.v2", - "[bg_queue] {} reject: arena_type_not_2_3_5 (arena_type={} bg_type_id={})", + "[bg_queue] {} reject: arena_skirmish_is_3v3_only (arena_type={} bg_type_id={})", p_->GetName(), uint32(arena_type), bg_type_id); return Result::NotKnown; } BattlegroundQueueTypeId qid = is_arena ? BattlegroundMgr::BGQueueTypeId(bg_type_id, - BattlegroundQueueIdType::Arena, - /*rated*/ true, // IsValidQueueId requires the bit for the Arena queue + BattlegroundQueueIdType::ArenaSkirmish, + /*rated*/ true, // IsValidQueueId requires the bit set for skirmish /*teamSize*/ arena_type) : BattlegroundMgr::BGQueueTypeId(bg_type_id, BattlegroundQueueIdType::Battleground, @@ -9553,22 +9549,6 @@ Result API::bg_port(uint16 bg_type_id, bool accept) break; } } - // An arena (or random battleground) invite names the match's own type (Mak'gora Arena 1169), while the queue slot holds the queue - // that picked it ("All Arenas" 6): take the slot of that kind the bot is invited from. Before, bots never entered an arena. - if (qid == BATTLEGROUND_QUEUE_NONE) - { - for (uint8 i = 0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i) - { - BattlegroundQueueTypeId q = p_->GetBattlegroundQueueTypeId(i); - if (q != BATTLEGROUND_QUEUE_NONE - && (q.BattlemasterListId == BATTLEGROUND_AA || BattlegroundMgr::IsRandomBattleground(q.BattlemasterListId)) - && p_->IsInvitedForBattlegroundQueueType(q)) - { - qid = q; - break; - } - } - } if (qid == BATTLEGROUND_QUEUE_NONE) { TC_LOG_INFO("playerbot.v2", "[bg_port] {} no queue slot for bg_type_id={}", p_->GetName(), bg_type_id); diff --git a/src/modules/PlayerbotV2/BOT_COMMANDS.md b/src/modules/PlayerbotV2/BOT_COMMANDS.md index 55310bb7c3..aa3b58c191 100644 --- a/src/modules/PlayerbotV2/BOT_COMMANDS.md +++ b/src/modules/PlayerbotV2/BOT_COMMANDS.md @@ -67,7 +67,6 @@ The `.bot` commands for your own bots work for every account, no GM needed; each | `.bot dismiss ` | Removes it from your group and logs it out. Gear is kept. | | `.bot delete ` | Deletes the character for good (the addon asks first). Only bots made for you: one of your own characters summoned as a bot (`.playerbot summon`) is refused with a pointer to `.bot dismiss`. | | `.bot list` | Your companions, online or not (`saved` marks roster ones). | -| `.bot hire [on\|off]` | Hired bots (`Playerbot.Hire.Mode`). No word: whether you must hire and what one bot costs where you stand. `on` / `off`: your own choice when the realm leaves it to each player. With hired bots on, `.bot add`, Quick party and the Group finder bring a hired companion of yours that is not out; next to a broker they hire a Sellsword. Brokers sell by gossip: Sellsword Captains at inns and capitals, Veteran Recruiters in capitals (level cap), Black Market Brokers in Gadgetzan, Booty Bay and Ratchet (Legends, level cap). Wages: `Playerbot.Hire.UpkeepPct` of the price, on each day the bot is called. `.bot delete` ends a contract (no refund). | | `.bot regear ` | Re-rolls the equipment of online companions so they do not all wear the same pieces. Better pieces they wear stay; replaced ones go to the bags. | | `.bot world` | Status of the world-bot spawner (Playerbot.World.*), console too. | | `.bot population [off\|low\|medium\|high\|file]` | How many world bots the realm has, GM only, until the next restart (the launcher's Bots setting, `Bots.Size`, decides at every start; the add-on has no World bots tab since 0.6.13). Applies right away (a step down logs the world bots out first). It wins over `Bots.Size` and `Playerbot.World.Enable` until then; `file` hands back to the config files. No word: what it is now. Console too. | diff --git a/src/modules/PlayerbotV2/Bot/Battleground/Scripts/ArenaScript.cpp b/src/modules/PlayerbotV2/Bot/Battleground/Scripts/ArenaScript.cpp index 7ab78b3895..a1e149cd94 100644 --- a/src/modules/PlayerbotV2/Bot/Battleground/Scripts/ArenaScript.cpp +++ b/src/modules/PlayerbotV2/Bot/Battleground/Scripts/ArenaScript.cpp @@ -130,17 +130,6 @@ static ArenaGeometry const& GeometryFor(uint16_t id) }; return rl; } - // Mak'gora Arena (id 1169), played in the Ring of Law (map 3200, an arena copy of Blackrock Depths): a walled round floor - // about 40 yards across, the teams start in tunnels behind the south and east gates. No pillars, no hazards; the rally - // is the ring centre (the Blackrock Depths script's own ring point). - if (id == 1169) { - static const ArenaGeometry mk = { - /*pillars*/ {}, - /*hazards*/ {}, - /*rally*/ 596.285f, -188.699f, -54.132f - }; - return mk; - } // Blade's Edge (id 5) — bridge box high-ground breaks LoS both ways. if (id == 5 || id == 875 || id == 907 || id == 908) { static const ArenaGeometry be = { @@ -244,8 +233,6 @@ ARENA_FACTORY(TolViron3, 912, "arena_tolviron_3") ARENA_FACTORY(BlackRookHold3, 913, "arena_black_rook_hold_3") ARENA_FACTORY(Robodrome, 1025, "arena_robodrome") ARENA_FACTORY(EmpyreanDomain, 1041, "arena_empyrean_domain") -// Classic 1.60 (Forever) arena. -ARENA_FACTORY(Makgora, 1169, "arena_makgora") #undef ARENA_FACTORY diff --git a/src/modules/PlayerbotV2/Bot/BotSnapshot.h b/src/modules/PlayerbotV2/Bot/BotSnapshot.h index 8cf89c13ee..96f4b76e73 100644 --- a/src/modules/PlayerbotV2/Bot/BotSnapshot.h +++ b/src/modules/PlayerbotV2/Bot/BotSnapshot.h @@ -2415,12 +2415,6 @@ struct BgState // prep. TC source: Battleground::GetInProgressDuration(). uint32 in_progress_ms = 0; - // Arena only, once the gates are open: the nearest living enemy player anywhere in the match (not stealthed or - // invisible). Arena teams start out of sight of each other, so the 40 y enemy scan alone left a bot nobody hit - // standing at its start spot for the whole match. Empty guid = none known. - ObjectGuid arena_enemy; - float arena_enemy_x = 0.f, arena_enemy_y = 0.f, arena_enemy_z = 0.f; - // CTF flag carriers + their world positions (resolved at builder time). // Scalar fields hold the FIRST detected carrier per side (back-compat // for WSG/TP/EotS/BfG/DG semantics where the BG has at most one @@ -2556,8 +2550,6 @@ struct BgState gate_doors = 0; mount_ok = false; in_progress_ms = 0; - arena_enemy = ObjectGuid::Empty; - arena_enemy_x = arena_enemy_y = arena_enemy_z = 0.f; friendly_flag_carrier = ObjectGuid::Empty; enemy_flag_carrier = ObjectGuid::Empty; friendly_carrier_hp_pct = 0; diff --git a/src/modules/PlayerbotV2/Bot/BotSnapshotBuilder.cpp b/src/modules/PlayerbotV2/Bot/BotSnapshotBuilder.cpp index 74493a7570..cf481ec026 100644 --- a/src/modules/PlayerbotV2/Bot/BotSnapshotBuilder.cpp +++ b/src/modules/PlayerbotV2/Bot/BotSnapshotBuilder.cpp @@ -8980,33 +8980,6 @@ std::shared_ptr BotSnapshotBuilder::Build(Player* p, BotAI* b // returns Milliseconds(0) during prep / waiting. Cast to uint32 // ms; ~50 day overflow is well past any realistic match length. snap->bg.in_progress_ms = uint32(bg->GetInProgressDuration().count()); - // Arena: the nearest enemy player in the whole match, for idle:arena_seek_enemy. Stealthed and invisible players are - // left out (a bot must not walk straight to a hidden rogue). - if (bg->isArena() && bg->GetStatus() == STATUS_IN_PROGRESS) - { - float best_dsq = std::numeric_limits::max(); - for (auto const& [guid, ref] : bg->GetPlayers()) - { - if (guid == p->GetGUID()) - continue; - Player* other = ObjectAccessor::FindPlayer(guid); - if (!other || other->GetMap() != p->GetMap() || !other->IsAlive() || other->IsGameMaster()) - continue; - if (other->GetBGTeam() == p->GetBGTeam()) - continue; - if (other->HasStealthAura() || other->HasInvisibilityAura()) - continue; - float const dsq = p->GetExactDistSq(other); - if (dsq < best_dsq) - { - best_dsq = dsq; - snap->bg.arena_enemy = other->GetGUID(); - snap->bg.arena_enemy_x = other->GetPositionX(); - snap->bg.arena_enemy_y = other->GetPositionY(); - snap->bg.arena_enemy_z = other->GetPositionZ(); - } - } - } snap->bg.score_alliance = bg->GetTeamScore(TEAM_ALLIANCE); snap->bg.score_horde = bg->GetTeamScore(TEAM_HORDE); // Real match clock (audit N54). TC's GetRemainingTime() exposes diff --git a/src/modules/PlayerbotV2/Bot/States/State_Idle.cpp b/src/modules/PlayerbotV2/Bot/States/State_Idle.cpp index 21cd482922..2a2db6f0ed 100644 --- a/src/modules/PlayerbotV2/Bot/States/State_Idle.cpp +++ b/src/modules/PlayerbotV2/Bot/States/State_Idle.cpp @@ -15566,29 +15566,6 @@ bool BgDispatch(BotSnapshotView const& s, BotAI& ai, // through target acquisition; no formation follow is needed // for that small a roster. - // Arena, gates open, not fighting: go and find the other team. The teams start out of sight of each other (Mak'gora: - // 90 yards), so a bot that nobody came to hit stood at its start spot for the whole match (Karrz, 2026-11-08 2v2). - // Close enough: attack; further: run to the enemy. The combat state does the rest (healers heal from there). - if (s.is_alive() && !s.is_casting() && !s.in_combat() && - s.bg_status() == 3 /*STATUS_IN_PROGRESS*/ && !s.raw().bg.arena_enemy.IsEmpty()) - { - float self_x = 0.f, self_y = 0.f, self_z = 0.f; - s.position(self_x, self_y, self_z); - float const ex = s.raw().bg.arena_enemy_x, ey = s.raw().bg.arena_enemy_y, ez = s.raw().bg.arena_enemy_z; - float const dsq = (ex - self_x) * (ex - self_x) + (ey - self_y) * (ey - self_y); - if (dsq <= 35.0f * 35.0f && emit.start_attack(s.raw().bg.arena_enemy)) - { - ai.set_last_rule_fired("idle:arena_attack_enemy"); - return true; - } - if (dsq > 8.0f * 8.0f) - { - emit.move_to(ex, ey, ez, /*run=*/true); - ai.set_last_rule_fired("idle:arena_seek_enemy"); - return true; - } - } - // Arena positional intelligence — pillars / hazards / opening // rally. Gated on the script populating at least one of those // fields, so non-arena BGs see zero cost (vector empty checks). @@ -15600,12 +15577,12 @@ bool BgDispatch(BotSnapshotView const& s, BotAI& ai, { float self_x = 0.f, self_y = 0.f, self_z = 0.f; s.position(self_x, self_y, self_z); - // Opening rally: once the gates are open and no enemy is known (all hidden), go to the middle. Not during the - // preparation minute: the bots wait at their start spot like players (walking out then made the battleground - // put them back at the start every second, the "jumping" Karrz saw on 2026-11-08). + // Opening rally: while gates still up OR match elapsed + // is brief (start_delay_ms running), advance to the rally + // coord so bots don't dawdle in the starting cage AABB. if ((bg_advice.opening_rally_x != 0.f || bg_advice.opening_rally_y != 0.f) && - s.bg_status() == 3 /*STATUS_IN_PROGRESS*/ && s.bg_start_delay_ms() == 0) + s.bg_start_delay_ms() > 0) { float dx = bg_advice.opening_rally_x - self_x; float dy = bg_advice.opening_rally_y - self_y; diff --git a/src/modules/PlayerbotV2/Commands/cs_playerbot_v2.cpp b/src/modules/PlayerbotV2/Commands/cs_playerbot_v2.cpp index 518245f621..3755107c30 100644 --- a/src/modules/PlayerbotV2/Commands/cs_playerbot_v2.cpp +++ b/src/modules/PlayerbotV2/Commands/cs_playerbot_v2.cpp @@ -39,9 +39,6 @@ #include "PlayerbotAPI.h" #include "PlayerbotV2.h" #include "LfgBotFill.h" -#include "Fleet/HireBroker.h" -#include "Fleet/HireMgr.h" -#include "Bot/ClassTables.h" #include "StringFormat.h" #include "PlayerbotMovement.h" // BotMovement::SafeTeleport for GM summonall #include "RBAC.h" @@ -668,8 +665,6 @@ public: { "addon", HandleBotAddonHello, rbac::RBAC_PERM_JOIN_NORMAL_BG, Console::No }, { "add", HandleBotAdd, rbac::RBAC_PERM_JOIN_NORMAL_BG, Console::No }, { "lfg", HandleBotLfg, rbac::RBAC_PERM_JOIN_NORMAL_BG, Console::No }, - // Every player: `.bot arena 2|3|leave` queues the caller's party (leader only) for a 2v2 / 3v3 arena, or leaves it. - { "arena", HandleBotArena, rbac::RBAC_PERM_JOIN_NORMAL_BG, Console::No }, { "dungeon", HandleBotDungeon, rbac::RBAC_PERM_JOIN_NORMAL_BG, Console::No }, { "call", HandleBotCall, rbac::RBAC_PERM_JOIN_NORMAL_BG, Console::No }, // Every player: brings the caller's own bots only (`.bot summon all|saved|`). @@ -682,7 +677,6 @@ public: { "unsave", HandleBotUnsave, rbac::RBAC_PERM_JOIN_NORMAL_BG, Console::No }, { "delete", HandleBotDelete, rbac::RBAC_PERM_JOIN_NORMAL_BG, Console::No }, { "list", HandleBotList, rbac::RBAC_PERM_JOIN_NORMAL_BG, Console::No }, - { "hire", HandleBotHire, rbac::RBAC_PERM_JOIN_NORMAL_BG, Console::No }, { "language", HandleBotLanguage, rbac::RBAC_PERM_JOIN_NORMAL_BG, Console::No }, { "world", HandleBotWorld, rbac::RBAC_PERM_COMMAND_GM, Console::Yes }, // GM only: how many world bots the realm has (Off / Low / Medium / High), set in game until the next restart (the launcher's Bots setting decides at every start). @@ -885,137 +879,8 @@ public: return true; } - // .bot hire [on|off]: hired bots (Playerbot.Hire.*). No word: whether you must hire, and what one bot costs here. on / off: your - // own choice when the realm leaves it to each player (Hire.Mode = 2). - static bool HandleBotHire(ChatHandler* handler, Optional word) - { - namespace Hire = Playerbot::V2::Fleet::Hire; - using Playerbot::V2::Fleet::HireMgr; - WorldSession* sess = handler->GetSession(); - Player* me = sess ? sess->GetPlayer() : nullptr; - if (!me) - return Refuse(handler); - Hire::Mode const mode = HireMgr::ConfigMode(); - if (word) - { - std::string const w = ToLowerAscii(*word); - if (w != "on" && w != "off") - { handler->SendSysMessage("Usage: .bot hire [on|off]"); return Refuse(handler); } - if (mode != Hire::Mode::PlayerChoice) - { - handler->SendSysMessage(mode == Hire::Mode::Everyone ? "This realm has hired bots for everyone." : "Hired bots are off on this realm."); - return Refuse(handler); - } - HireMgr::Instance().SetOptedIn(sess->GetAccountId(), w == "on"); - } - bool const must = HireMgr::Instance().MustHire(me); - std::string prices; - for (Hire::Grade g : { Hire::Grade::Sellsword, Hire::Grade::Veteran, Hire::Grade::Legend }) - if (uint64 const p = HireMgr::PriceHere(me, g)) - prices += Trinity::StringFormat("{}{} {}", prices.empty() ? "" : ", ", Hire::GradeName(g), Hire::MoneyText(p)); - handler->PSendSysMessage("Hired bots: %s. One bot costs %s here; upkeep %u%% a day you call it.", - must ? "on (your companions come from the brokers)" : "off (bots are free)", prices.c_str(), - HireMgr::ConfigPrices().upkeep_pct); - return true; - } - // .bot lfg [tank|healer|dps]: fill the group's missing tank / healer / damage places now with level-matched companions // (the Group Finder does the same by itself when nobody joins a posted listing in time). The word is your own role. - // `.bot arena 2|3|enter|leave`: the arena join without the client's arena window. The party leader queues the whole party through - // the same handler as the client's join (party size, level bracket and the bot opponents all as for the window). "enter" takes - // the arena that is ready (the same as Enter on the pop), "leave" leaves the arena queue or turns down the ready arena (not a - // running match): the client's own arena pop has Enter only. The ForeverBots add-on sends the same lines from its pop-up. - static bool HandleBotArena(ChatHandler* handler, Optional what) - { - Playerbot::BotLanguage::LocalizedHandler localized(handler); handler = localized.Get(); // replies in the player's language - WorldSession* session = handler->GetSession(); - Player* player = session ? session->GetPlayer() : nullptr; - if (!player) - return false; - std::string const w = what ? ToLowerAscii(*what) : std::string(); - if (w == "enter") - { - for (uint8 slot = 0; slot < PLAYER_MAX_BATTLEGROUND_QUEUES; ++slot) - { - BattlegroundQueueTypeId const q = player->GetBattlegroundQueueTypeId(slot); - if (q == BATTLEGROUND_QUEUE_NONE || q.Type != uint8(BattlegroundQueueIdType::Arena) || !player->IsInvitedForBattlegroundQueueType(q)) - continue; - WorldPackets::Battleground::BattlefieldPort port{ WorldPacket(CMSG_BATTLEFIELD_PORT) }; - port.Ticket.RequesterGuid = player->GetGUID(); - port.Ticket.Id = slot; - port.Ticket.Type = WorldPackets::LFG::RideType::Battlegrounds; - port.AcceptedInvite = true; - session->HandleBattleFieldPortOpcode(port); - return true; - } - handler->SendSysMessage("No arena is ready for you yet."); - handler->SetSentErrorMessage(true); - return false; - } - if (w == "leave") - { - bool left = false; - for (uint8 slot = 0; slot < PLAYER_MAX_BATTLEGROUND_QUEUES; ++slot) - { - BattlegroundQueueTypeId const q = player->GetBattlegroundQueueTypeId(slot); - if (q == BATTLEGROUND_QUEUE_NONE || q.Type != uint8(BattlegroundQueueIdType::Arena)) - continue; - WorldPackets::Battleground::BattlefieldPort port{ WorldPacket(CMSG_BATTLEFIELD_PORT) }; - port.Ticket.RequesterGuid = player->GetGUID(); - port.Ticket.Id = slot; - port.Ticket.Type = WorldPackets::LFG::RideType::Battlegrounds; - port.AcceptedInvite = false; - session->HandleBattleFieldPortOpcode(port); - left = true; - } - // The party's bots leave the same queue with you (and an arena that has not begun yet), so they do not go in alone. - if (left) - if (Group* group = player->GetGroup()) - for (GroupReference const& itr : group->GetMembers()) - { - Player* member = itr.GetSource(); - if (!member || member == player || !member->GetSession() || !member->GetSession()->IsBot()) - continue; - if (Battleground* bg = member->GetBattleground(); bg && bg->isArena() && bg->GetStatus() == STATUS_WAIT_JOIN) - member->LeaveBattleground(true, /*withoutDeserterDebuff*/ true); - for (uint8 slot = 0; slot < PLAYER_MAX_BATTLEGROUND_QUEUES; ++slot) - { - BattlegroundQueueTypeId const q = member->GetBattlegroundQueueTypeId(slot); - if (q == BATTLEGROUND_QUEUE_NONE || q.Type != uint8(BattlegroundQueueIdType::Arena)) - continue; - sBattlegroundMgr->GetBattlegroundQueue(q).RemovePlayer(member->GetGUID(), true); - member->RemoveBattlegroundQueueId(q); - } - } - handler->SendSysMessage(left ? "You left the arena queue." : "You are not in an arena queue."); - return true; - } - uint8 slot = 0xFF; - if (w == "2" || w == "2v2") slot = 0; // ArenaTeam::GetTypeBySlot: 0 = 2v2, 1 = 3v3 - else if (w == "3" || w == "3v3") slot = 1; - if (slot == 0xFF) - { - handler->SendSysMessage("Usage: .bot arena 2 (2v2, a party of 2), .bot arena 3 (3v3, a party of 3), .bot arena enter, .bot arena leave"); - handler->SetSentErrorMessage(true); - return false; - } - if (Group const* grp = player->GetGroup(); grp && grp->GetLeaderGUID() != player->GetGUID()) - { - handler->SendSysMessage("Only the party leader can queue the party for an arena."); - handler->SetSentErrorMessage(true); - return false; - } - if (player->InBattleground()) - { - handler->SendSysMessage("You are already in a battleground or arena."); - handler->SetSentErrorMessage(true); - return false; - } - // HandleBattlemasterJoinArena answers on its own (queued, wrong party size, arenas off) - BattlegroundMgr::QueuePlayerForArena(player, slot, 0); - return true; - } - static bool HandleBotLfg(ChatHandler* handler, Optional ownRoleArg) { Playerbot::BotLanguage::LocalizedHandler localized(handler); handler = localized.Get(); // replies in the player's language @@ -1127,98 +992,15 @@ public: std::string outMsg; bool const ok = AddCompanionFor(me, sess, cls, role, race, gender, class_arg, outMsg); - if (!outMsg.empty()) // a hired companion that was called instead has said so itself - handler->SendSysMessage(outMsg.c_str()); + handler->SendSysMessage(outMsg.c_str()); return ok ? true : Refuse(handler); } - // A companion of `me`'s account that is not out (not in the group, not called a moment ago) for `role`, the same class first: - // in hired mode it comes instead of a new bot. 0 = none. - static Playerbot::BotId IdleHiredCompanion(Player* me, WorldSession* sess, uint8 cls, Playerbot::Role role) - { - using Playerbot::V2::Fleet::HireMgr; - uint32 const now = getMSTime(); - Group const* group = me->GetGroup(); - Playerbot::BotId fallback = 0; - for (Playerbot::BotId id : CompanionsMatching(sess, "all")) - { - ObjectGuid const guid = ObjectGuid::Create(id); - if ((group && group->IsMember(guid)) || HireMgr::Instance().RecentlyCalled(id, now) || HireMgr::Instance().IsLoaned(id)) - continue; // (a Group Finder loan bot only plays inside the group it was made for) - if (Player const* online = ObjectAccessor::FindConnectedPlayer(guid); online && online->GetGroup()) - continue; // out with someone else of the account - // A companion bound to another character of the account stays with that character: called for this one it joined, the - // group check (CompanionGroupHygiene) found its owner character missing and sent it away a second later, and it came at - // that character's level (the owner 2026-11-07: his main's level 60 companions for his level 33 alt). - if (uint64 const ownerChar = Playerbot::Services::Owners().GetOwner(id).player_guid; ownerChar != 0 && ownerChar != me->GetGUID().GetCounter()) - continue; - Playerbot::Role const declared = Playerbot::Services::Owners().DeclaredRole(id); - if (role != Playerbot::Role::Unknown && declared != role) - continue; - CharacterCacheEntry const* entry = sCharacterCache->GetCharacterCacheByGuid(guid); - if (!entry) - continue; - // A companion above the caller's level would come at its own level (bots are levelled up to the owner, never down): a - // fitting one is hired instead (the owner 2026-11-07: an account-wide level 60 companion joined his level 33 character). - if (entry->Level > me->GetLevel()) - continue; - if (entry->Class == cls) - return id; - if (!fallback && role != Playerbot::Role::Unknown) - fallback = id; - } - return fallback; - } - // Creates one companion of `cls` (race 0 = pick one) for `me` and logs it in; it joins the owner's group through the - // normal companion setup. Shared by `.bot add`, the Group Finder bot fill and the hire brokers. `outMsg` is what the owner - // is told. In hired mode (Playerbot.Hire.*, HirePolicy.h) nothing is made out of nothing: an idle companion of the account - // comes instead, or next to a broker a Sellsword is hired; `hireGrade` hires that grade from the broker beside `me`. - // `finder`: the Group Finder / dungeon finder fill (`.bot lfg`, `.bot dungeon`, a posted listing). It still works in hired mode - // (Karrz 2026-11-03: "you can still look for group"), but the bot is only lent: free, it stays with the group and is deleted - // when it leaves it, and it cannot be called on its own (HireMgr::SetLoaned). + // normal companion setup. Shared by `.bot add` and the Group Finder bot fill. `outMsg` is what the owner is told. static bool AddCompanionFor(Player* me, WorldSession* sess, uint8 cls, Playerbot::Role role, uint8 race, uint8 gender, - std::string const& className, std::string& outMsg, - Playerbot::V2::Fleet::Hire::Grade hireGrade = Playerbot::V2::Fleet::Hire::Grade::None, - bool finder = false) + std::string const& className, std::string& outMsg) { - namespace Hire = Playerbot::V2::Fleet::Hire; - using Playerbot::V2::Fleet::HireMgr; - HireMgr& hire = HireMgr::Instance(); - bool const loan = finder && hireGrade == Hire::Grade::None && hire.MustHire(me); - if (!loan && hireGrade == Hire::Grade::None && hire.MustHire(me)) - { - if (Playerbot::BotId const idle = IdleHiredCompanion(me, sess, cls, role)) - { - hire.NoteCalled(idle, getMSTime()); - ChatHandler handler(sess); - outMsg.clear(); - return CallCompanions(&handler, CompanionName(idle), false); - } - if (!hire.NearbyBroker(me, Hire::Grade::Sellsword)) - { - char const* const what = role == Playerbot::Role::Tank ? "tank" : role == Playerbot::Role::Healer ? "healer" : "fighter"; - outMsg = Trinity::StringFormat("Hired bots only on this realm: you have no hired {} free. Hire one from a Sellsword Captain at an inn or in a capital city (the Group Finder and the dungeon finder still bring bots).", what); - return false; - } - hireGrade = Hire::Grade::Sellsword; - } - uint64 price = 0; - if (hireGrade != Hire::Grade::None) - { - if (!hire.NearbyBroker(me, hireGrade)) - { outMsg = Trinity::StringFormat("There is nobody here who hires out a {}.", Hire::GradeName(hireGrade)); return false; } - price = HireMgr::PriceHere(me, hireGrade); - if (!price) - { outMsg = Trinity::StringFormat("A {} only signs on with a level {} hero.", Hire::GradeName(hireGrade), uint32(Playerbot::MaxPlayerLevel())); return false; } - if (uint32 const max = HireMgr::MaxPerAccount(); max && Playerbot::Services::Owners().BotsOwnedBy(sess->GetAccountId()).size() >= max) - { outMsg = Trinity::StringFormat("You have {} bots already, the most this realm allows. End a contract first.", max); return false; } - if (uint32 const max = HireMgr::LegendMaxPerAccount(); hireGrade == Hire::Grade::Legend && max && hire.CountGrade(sess->GetAccountId(), Hire::Grade::Legend) >= max) - { outMsg = Trinity::StringFormat("The cartel hires out {} Legend(s) to one hero at a time.", max); return false; } - if (!me->HasEnoughMoney(price)) - { outMsg = Trinity::StringFormat("You need {} to hire a {}.", Hire::MoneyText(price), Hire::GradeName(hireGrade)); return false; } - } - if (race && !Playerbot::V2::BotComposition::IsLegalRaceClass(race, cls)) { outMsg = "That race can't be a " + className + "."; return false; } if (race && Player::TeamForRace(race) != me->GetTeam()) @@ -1242,19 +1024,6 @@ public: Playerbot::BotId const id = created.guid.GetCounter(); Playerbot::Services::Owners().SetOwner(id, sess->GetAccountId(), me->GetGUID().GetCounter()); - if (hireGrade != Hire::Grade::None) - { - // Paid and graded before the setup, so its first gear is its grade's. - me->ModifyMoney(-int64(price)); - hire.SetHired(id, hireGrade, price); - hire.NoteCalled(id, getMSTime()); - TC_LOG_INFO("playerbot.v2", "[hire] {} hired {} ({} {}) for {} copper", me->GetName(), pick.name, Hire::GradeName(hireGrade), className, price); - } - else if (loan) - { - hire.SetLoaned(id, getMSTime()); - TC_LOG_INFO("playerbot.v2", "[hire] {} gets {} ({}) from the group finder, lent while it stays in the group", me->GetName(), pick.name, className); - } Playerbot::Services::Population().QueueCompanionSetup(id, me->GetGUID().GetCounter(), uint8(role)); auto const login = Playerbot::Services::SessionMgr().LoginBot(created.guid); if (!login.ok) @@ -1262,8 +1031,7 @@ public: outMsg = Trinity::StringFormat("Created {} but the login was refused ({}). Try `.bot call {}`.", pick.name, login.reason, pick.name); return false; } - outMsg = hireGrade == Hire::Grade::None ? pick.name + " is on the way." - : Trinity::StringFormat("{} the {} signs on for {} and is on the way.", pick.name, Hire::GradeName(hireGrade), Hire::MoneyText(price)); + outMsg = pick.name + " is on the way."; return true; } @@ -1393,16 +1161,9 @@ public: Group const* myGroup = me->GetGroup(); uint32 members = myGroup ? myGroup->GetMembersCount() : 1; uint32 out = cap ? Playerbot::V2::Fleet::CompanionsOut(me) : 0; - bool const mustHire = Playerbot::V2::Fleet::HireMgr::Instance().MustHire(me); for (Playerbot::BotId id : ids) { ObjectGuid const guid = ObjectGuid::Create(id); - // Hired bots only: a Group Finder bot was lent for that group and cannot be called back on its own. - if (mustHire && Playerbot::V2::Fleet::HireMgr::Instance().IsLoaned(id) && !(myGroup && myGroup->IsMember(guid))) - { - handler->PSendSysMessage("%s came with the group finder and only plays in that group (hired bots only on this realm).", CompanionName(id).c_str()); - continue; - } if (cap && !ObjectAccessor::FindConnectedPlayer(guid)) { if (!inInstance && out >= cap) { ++refused; continue; } @@ -1413,12 +1174,6 @@ public: if (members >= cap) { ++refused; continue; } ++members; } - // A hired bot wants the day's wages before it comes (Playerbot.Hire.UpkeepPct; once a day, only on a day it is called). - if (std::string why; !Playerbot::V2::Fleet::HireMgr::Instance().TakeUpkeep(me, id, CompanionName(id), why)) - { - handler->SendSysMessage(why.c_str()); - continue; - } Playerbot::Services::Population().QueueCompanionSetup(id, me->GetGUID().GetCounter(), uint8(Playerbot::Role::Unknown)); if (!ObjectAccessor::FindConnectedPlayer(guid) && !Playerbot::Services::SessionMgr().LoginBot(guid).ok) continue; @@ -1782,7 +1537,6 @@ public: group->RemoveMember(guid); Playerbot::Services::SessionMgr().LogoutBot(guid); Playerbot::Services::Population().QueueCompanionDelete(id); - Playerbot::V2::Fleet::HireMgr::Instance().Forget(id); // a hired bot's contract ends with it, nothing is paid back handler->PSendSysMessage("%s is leaving and will be deleted.", CompanionName(id).c_str()); } return true; @@ -6589,25 +6343,7 @@ public: bool Playerbot::V2::AddCompanionForOwner(Player* owner, uint8 cls, Playerbot::Role role, std::string& msg) { return playerbot_v2_commandscript::AddCompanionFor(owner, owner->GetSession(), cls, role, 0, - uint8(urand(GENDER_MALE, GENDER_FEMALE)), "bot", msg, - Playerbot::V2::Fleet::Hire::Grade::None, /*finder*/ true); -} - -bool Playerbot::V2::HireCompanionForOwner(Player* owner, uint8 cls, Playerbot::Role role, Playerbot::V2::Fleet::Hire::Grade grade, - std::string const& className, std::string& msg) -{ - // The same room checks as `.bot add`: a full raid, the open-world companion cap, a full instance. - if (Group const* group = owner->GetGroup(); group && group->isRaidGroup() && group->IsFull()) - { msg = "Your raid is full."; return false; } - if (std::string full; Playerbot::V2::Fleet::CompanionSpawnFull(owner, 0, full)) - { msg = "No room: " + full + "."; return false; } - return playerbot_v2_commandscript::AddCompanionFor(owner, owner->GetSession(), cls, role, 0, - uint8(urand(GENDER_MALE, GENDER_FEMALE)), className, msg, grade); -} - -bool Playerbot::V2::CanHaveCompanionClass(Player const* owner, uint8 cls) -{ - return owner && playerbot_v2_commandscript::PickCompanionRace(owner, cls) != 0; + uint8(urand(GENDER_MALE, GENDER_FEMALE)), "bot", msg); } void AddSC_playerbot_v2_commandscript() diff --git a/src/modules/PlayerbotV2/Fleet/BotGroupBuilder.cpp b/src/modules/PlayerbotV2/Fleet/BotGroupBuilder.cpp index f1c8218582..593a10d360 100644 --- a/src/modules/PlayerbotV2/Fleet/BotGroupBuilder.cpp +++ b/src/modules/PlayerbotV2/Fleet/BotGroupBuilder.cpp @@ -23,58 +23,12 @@ #include "WorldSession.h" #include "Log.h" -#include "BotPopulationManager.h" // arena team: log offline pool bots in (DeferLogin / ProtectFromKick) -#include "../Bot/ClassTables.h" // MaxPlayerLevel -#include "DatabaseEnv.h" - #include -#include namespace Playerbot::V2 { namespace { -// An arena team for a real party (ArenaTeamForming) found too few free bots: the online world bots of that faction and level -// stand as residents around real players (WorldBusy) or play elsewhere. Log in up to `need` offline pool bots of the faction -// and level band, as the battleground filler's reuse pass does, so the next ask (Module::RecheckArenaWaits, every 30 s) finds -// them free. No queue tag is set: the team is formed and queued by BotGroupBuilder, not by the solo queue pipeline. -// A bot asked for in the last 3 minutes is not asked for again while its login is under way. -uint32 LoginOfflineArenaBots(uint32 faction_mask, uint8 level_min, uint8 level_max, uint32 need) -{ - static std::unordered_map recently; // guid -> getMSTime() of the login request (world thread only) - uint32 const now = getMSTime(); - std::erase_if(recently, [now](auto const& kv) { return getMSTimeDiff(kv.second, now) > 3u * 60u * 1000u; }); - - QueryResult res = CharacterDatabase.PQuery( - "SELECT c.guid, c.race FROM characters c " - "JOIN playerbot_v2_character pv ON pv.character_guid_low = c.guid " - "JOIN playerbot_v2_account pa ON pa.account_id = c.account " - "WHERE c.online = 0 AND c.totaltime > 0 AND pv.owner_account_id = 0 " - "AND (pv.jit_for_queue IS NULL OR pv.jit_for_queue = '') " - "AND c.level BETWEEN {} AND {} ORDER BY RAND() LIMIT 200", - uint32(level_min ? level_min : 1), uint32(level_max ? level_max : ::Playerbot::MaxPlayerLevel())); - if (!res) - return 0; - - uint32 asked = 0; - do - { - Field const* f = res->Fetch(); - uint64 const guid = f[0].GetUInt64(); - uint8 const race = f[1].GetUInt8(); - uint32 const bit = Player::TeamForRace(race) == ALLIANCE ? 0x1u : 0x2u; - if (faction_mask != 0 && (faction_mask & bit) == 0) - continue; - if (::Playerbot::Pool::IsScenarioBot(guid) || recently.contains(guid)) - continue; - recently[guid] = now; - Services::Population().DeferLogin(guid); - Services::Population().ProtectFromKick(guid, 10u * 60u * 1000u); - ++asked; - } while (asked < need && res->NextRow()); - return asked; -} - // Pull a bot's faction-team (Alliance/Horde) from its Player* via TC's // race table. Returns 0 = Alliance, 1 = Horde, or 0xFF when unknown // (caller should skip). @@ -177,13 +131,30 @@ std::vector BotGroupBuilder::PickCandidates(GroupRequest const& req) // registry iteration order yields first (which was all-DPS in practice). std::vector pool; pool.reserve(req.required * 4); - // why bots of the right faction and level were not taken (logged for an arena team that cannot be made) - struct { uint32 fits = 0, not_free = 0, deserter = 0, in_bg = 0, in_dungeon = 0, owned = 0; } why; reg.for_each([&](BotId id, BotRegistryEntry const& /*entry*/) { if (id == req.leader_low) return; Player* p = ObjectAccessor::FindConnectedPlayer( ObjectGuid::Create(id)); if (!p) return; + // The shared eligibility rule (BotPool.h): never a companion, a real player's alt, a bot in an instance, or a + // resident the world spawner holds for a player. + if (::Playerbot::Pool::CheckFreeBot(p, id) != ::Playerbot::Pool::Verdict::Free) return; + + // Availability filters: never pull a bot that's mid-fight, sitting + // under a Deserter debuff, or already parked in a BG/arena queue + // into a fresh group. These were previously enforced only at the + // final api.bg_queue gate; doing it here too keeps the formed group + // from including members that the leader's queue would then reject + // (which, for arenas, fails the whole group's CanJoinBattlegroundQueue). + if (p->IsDeserter()) return; + if (p->InBattleground() || p->InBattlegroundQueue(/*ignoreArena*/ false)) return; + + // Same exemptions as the queue filler: a player's own companion or alt, and a bot inside a dungeon or raid, are not + // drafted into a premade (audit B 1.2). + if (p->GetMap() && p->GetMap()->IsDungeon()) return; + if (Services::Owners().GetOwner(id).account_id != 0) return; + if (WorldSession const* bsess = p->GetSession()) + if (!Services::Accounts().is_pool_account(bsess->GetAccountId())) return; // Faction filter. if (req.faction_mask != 0) @@ -197,34 +168,9 @@ std::vector BotGroupBuilder::PickCandidates(GroupRequest const& req) if (req.level_max != 0 && lvl > req.level_max) return; // Guild filter. if (req.guild_id != 0 && p->GetGuildId() != req.guild_id) return; - ++why.fits; - - // The shared eligibility rule (BotPool.h): never a companion, a real player's alt, a bot in an instance, or a - // resident the world spawner holds for a player. - if (::Playerbot::Pool::CheckFreeBot(p, id) != ::Playerbot::Pool::Verdict::Free) { ++why.not_free; return; } - - // Availability filters: never pull a bot that's mid-fight, sitting - // under a Deserter debuff, or already parked in a BG/arena queue - // into a fresh group. These were previously enforced only at the - // final api.bg_queue gate; doing it here too keeps the formed group - // from including members that the leader's queue would then reject - // (which, for arenas, fails the whole group's CanJoinBattlegroundQueue). - if (p->IsDeserter()) { ++why.deserter; return; } - if (p->InBattleground() || p->InBattlegroundQueue(/*ignoreArena*/ false)) { ++why.in_bg; return; } - - // Same exemptions as the queue filler: a player's own companion or alt, and a bot inside a dungeon or raid, are not - // drafted into a premade (audit B 1.2). - if (p->GetMap() && p->GetMap()->IsDungeon()) { ++why.in_dungeon; return; } - if (Services::Owners().GetOwner(id).account_id != 0) { ++why.owned; return; } - if (WorldSession const* bsess = p->GetSession()) - if (!Services::Accounts().is_pool_account(bsess->GetAccountId())) { ++why.owned; return; } pool.push_back(id); }); - if (req.source == CoordSignal::ArenaTeamForming && pool.size() < req.required) - TC_LOG_INFO("playerbot.v2", "[arena] bots of the faction and level: {}; taken elsewhere: {} not free (world spawner, " - "instance), {} deserter, {} in a battleground or its queue, {} in a dungeon, {} owned; free: {}", - why.fits, why.not_free, why.deserter, why.in_bg, why.in_dungeon, why.owned, pool.size()); // Role balancing (#4C item 5). When the request specifies role wants // (tank/healer/dps), fill the tank + healer slots FIRST from the bots @@ -294,16 +240,6 @@ std::vector BotGroupBuilder::PickCandidates(GroupRequest const& req) uint32 BotGroupBuilder::BuildGroup(GroupRequest const& req, uint64* leader_out) { std::vector cands = PickCandidates(req); - // An arena team must be the full size: a short one would only wait in the queue (api.bg_queue refuses it anyway). - if (req.source == CoordSignal::ArenaTeamForming && cands.size() < req.required) - { - uint32 const missing = uint32(req.required - cands.size()); - uint32 const logging_in = LoginOfflineArenaBots(req.faction_mask, req.level_min, req.level_max, missing); - TC_LOG_INFO("playerbot.v2", "[arena] no bot team yet: {} free bot(s) of {} needed (faction mask {}, level {}-{}); " - "{} offline bot(s) logging in for the next try", - cands.size(), uint32(req.required), req.faction_mask, uint32(req.level_min), uint32(req.level_max), logging_in); - return 0; - } if (cands.size() < 2) // can't form a group of one return 0; diff --git a/src/modules/PlayerbotV2/Fleet/BotPopulationManager.cpp b/src/modules/PlayerbotV2/Fleet/BotPopulationManager.cpp index 8e771c0661..7bb8998a7f 100644 --- a/src/modules/PlayerbotV2/Fleet/BotPopulationManager.cpp +++ b/src/modules/PlayerbotV2/Fleet/BotPopulationManager.cpp @@ -5,8 +5,6 @@ #include "MotionMaster.h" // ship rides clear the bot's movement before boarding #include "../Util/SlowCall.h" #include "BotPopulationManager.h" -#include "HireMgr.h" -#include "CompanionDelete.h" // a finder loan bot is deleted like `.bot delete` #include "ClassicSpec.h" #include "SoakAnchors.h" #include "CompanionRole.h" @@ -1253,7 +1251,6 @@ void BotPopulationManager::RunGearBackfill(uint32 now_ms) gear_scan_pos_ = 0; gear_regear_count_ = 0; Services::Registry().for_each([&](BotId id, BotRegistryEntry const&) { gear_scan_.push_back(id); }); - ReleaseOfflineLoans(now_ms); } const uint32 t0 = getMSTime(); while (gear_scan_pos_ < gear_scan_.size() && getMSTimeDiff(t0, getMSTime()) < kGearBudgetMs) @@ -1280,53 +1277,10 @@ void BotPopulationManager::RunGearBackfill(uint32 now_ms) } } -// Hired bots only (Playerbot.Hire.Mode): a Group Finder / dungeon finder bot is lent to its group (HireMgr::SetLoaned). Once it is -// out of its owner's group (left, dismissed, the owner went offline) it is deleted like `.bot delete`, so a free bot never becomes -// one to keep. True when it was taken back. -bool BotPopulationManager::ReleaseLoan(BotId id, Player* p, uint32 now_ms) -{ - HireMgr& hire = HireMgr::Instance(); - if (!hire.IsLoaned(id) || !hire.LoanSettled(id, now_ms) || pending_companions_.contains(id) || pending_deletes_.contains(id)) - return false; - ObjectGuid const guid = ObjectGuid::Create(id); - if (p) - { - uint64 const owner_guid = Services::Owners().OwnerCharacter(id); - Player const* owner = owner_guid ? ObjectAccessor::FindConnectedPlayer(ObjectGuid::Create(owner_guid)) : nullptr; - Group* group = p->GetGroup(); - if (owner && group && group->IsMember(owner->GetGUID())) - return false; // still playing with the group it was lent to - } - if (!Fleet::MayDeleteCompanion(Services::Accounts().is_pool_account(sCharacterCache->GetCharacterAccountIdByGuid(guid)))) - { - hire.Forget(id); // never a player's own character; just not a loan any more - return false; - } - TC_LOG_INFO("playerbot.v2", "[hire] finder loan bot {} left its group: it goes", guid.ToString()); - if (p) - { - if (Group* group = p->GetGroup()) - group->RemoveMember(guid); - Services::SessionMgr().LogoutBot(guid); - } - QueueCompanionDelete(id); - hire.Forget(id); - return true; -} - -void BotPopulationManager::ReleaseOfflineLoans(uint32 now_ms) -{ - for (BotId id : HireMgr::Instance().LoanedBots()) - if (!ObjectAccessor::FindConnectedPlayer(ObjectGuid::Create(id))) - ReleaseLoan(id, nullptr, now_ms); -} - void BotPopulationManager::CompanionUpkeep(BotId id, Player* p) { if (Services::Owners().OwnerCharacter(id) == 0 || IsPlayersOwnCharacter(p)) return; - if (ReleaseLoan(id, p, getMSTime())) - return; ::Playerbot::API api(p); api.learn_class_quest_spells_free(); api.learn_trainer_spells_free(); @@ -1355,8 +1309,6 @@ void BotPopulationManager::CompanionUpkeep(BotId id, Player* p) TC_LOG_INFO("playerbot.v2", "[Companion] {} one-time varied gear re-roll: {} slot(s) changed", p->GetName(), changed); } } - // A hired bot's grade health follows its level and gear (and a changed Playerbot.Hire..HealthPct after `.reload config`). - HireMgr::Instance().ApplyHealth(p); } void BotPopulationManager::GrantCompanionStarterPet(BotId id, Player* p) @@ -1883,8 +1835,6 @@ void BotPopulationManager::FinishCompanionSetup(Player* bot, Player* owner, uint } } RegearNow(bot); - // A hired bot's grade health (Playerbot.Hire..HealthPct), on the health its new level and gear give it. - HireMgr::Instance().ApplyHealth(bot); // GiveLevel fills health and mana for the new level, but the gear put on after it raises the pools again: three mages made for // the owner in UBRS (2026-10-29 09:28:31) stood at 18-19 % mana with their new L60 gear and were in the fight 12 s later, wanding. // A companion just levelled here joins rested. @@ -2264,10 +2214,6 @@ static Gear::Owned::GearMode CompanionGearMode(Player const* bot) uint32 const account = Services::Owners().GetOwner(bot->GetGUID().GetCounter()).account_id; if (!account) return Gear::Owned::GearMode::Match; - // A hired bot wears its grade's gear (Veteran best, Legend bis), a Sellsword or any companion of a player who must hire the - // normal companion gear, whatever the owner chose (HirePolicy.h). - if (int const hired = HireMgr::Instance().GearModeOverride(bot->GetGUID().GetCounter(), account); hired >= 0) - return Gear::Owned::GearMode(hired); return Gear::Owned::EffectiveMode(Gear::Owned::GearMode(Services::Owners().OwnerGearMode(account)), Gear::OwnedAllowedModes(), bot->GetLevel() >= MaxPlayerLevel()); } diff --git a/src/modules/PlayerbotV2/Fleet/BotPopulationManager.h b/src/modules/PlayerbotV2/Fleet/BotPopulationManager.h index 3f1193c373..c99ec8a71f 100644 --- a/src/modules/PlayerbotV2/Fleet/BotPopulationManager.h +++ b/src/modules/PlayerbotV2/Fleet/BotPopulationManager.h @@ -204,9 +204,6 @@ public: // each RunGearBackfill pass teaches it its new ranks, class-quest abilities and talents, and mends its gear. Runs // for every companion, whatever its gear. Cheap; no-op for any other bot. void CompanionUpkeep(BotId id, Player* p); - // Hired bots only: a Group Finder loan bot out of its owner's group is deleted (HireMgr::SetLoaned). - bool ReleaseLoan(BotId id, Player* p, uint32 now_ms); - void ReleaseOfflineLoans(uint32 now_ms); // A hunter companion's starter pet, granted once per bot (OwnerRegistry::StarterPetGranted). void GrantCompanionStarterPet(BotId id, Player* p); // A bot hunter of level 10+ nobody owns (world, pool and scenario bots) that has no pet, summoned, dismissed or stabled, gets a beast of its own: diff --git a/src/modules/PlayerbotV2/Fleet/HireBroker.cpp b/src/modules/PlayerbotV2/Fleet/HireBroker.cpp deleted file mode 100644 index 35c72b330f..0000000000 --- a/src/modules/PlayerbotV2/Fleet/HireBroker.cpp +++ /dev/null @@ -1,266 +0,0 @@ -#include "HireBroker.h" -#include "HireMgr.h" -#include "OwnerRegistry.h" -#include "../Services.h" -#include "../Bot/ClassTables.h" -#include "CharacterCache.h" -#include "Chat.h" -#include "Creature.h" -#include "GossipDef.h" -#include "Log.h" -#include "ObjectGuid.h" -#include "Player.h" -#include "ScriptMgr.h" -#include "ScriptedCreature.h" -#include "ScriptedGossip.h" -#include "SharedDefines.h" -#include "StringFormat.h" -#include "WorldSession.h" - -using namespace Playerbot::V2; -using namespace Playerbot::V2::Fleet; - -namespace { - -// Gossip actions: a grade's role menu, a role's class menu, a class hired. 1000 + grade * 100 + role * 20 + class stays under 2000. -constexpr uint32 kActionGrade = 1; // + grade (1..3): the role menu -constexpr uint32 kActionContracts = 5; // the player's hired bots, in chat -constexpr uint32 kActionOptIn = 6; // `.bot hire on|off` from the gossip (Hire.Mode = 2) -constexpr uint32 kActionRole = 10; // + grade * 10 + role (1..3): the class menu -constexpr uint32 kActionHire = 1000; // + grade * 100 + role * 20 + class - -// The gossip text: npc_text 3959, "Greetings, $r." (BroadcastText 6498). Not DEFAULT_GOSSIP_MESSAGE: its npc_text 16777215 points at -// BroadcastText 50429, a retail text the Classic client does not have, and the client then opens no gossip window at all (Goldshire, -// 2026-11-01: right-click on Brannock Ironhale opened nothing although his NPC flags and script were right). -constexpr uint32 kBrokerText = 3959; - -// The menu the client is shown: gossip menu 6110000 (the first broker entry), options 61100000 + their place in the menu. Every menu the -// Classic client opens carries a gossip menu id and positive option ids; a script menu left at menu 0 gets ids 0, -1, -2 ... from -// GossipMenu::AddMenuItem, the one difference left after right-click on Brannock Ironhale still opened nothing with a text the -// client has (Goldshire, 2026-11-01, dev build with npc_text 3959). The script builds the options; the menu itself must also be in the -// database (gossip_menu 6110000 -> npc_text 3959, creature_template_gossip for every broker), because the server hides the gossip NPC -// flag from a player when Player::CanSeeGossipOn finds no menu, and the client then shows no talk cursor and never sends the hello. -// The hello is logged (playerbot.v2, INFO) so Server.log shows whether a click reached the broker at all. -constexpr uint32 kBrokerMenu = 6110000; -constexpr int32 kBrokerOptionId = 61100000; - -void StartMenu(Player* player) -{ - ClearGossipMenuFor(player); - InitGossipMenuFor(player, kBrokerMenu); -} - -void AddOption(Player* player, std::string text, uint32 action, std::string confirm = {}, uint64 money = 0) -{ - GossipMenu& menu = player->PlayerTalkClass->GetGossipMenu(); - int32 const id = kBrokerOptionId + int32(menu.GetMenuItemCount()); - menu.AddMenuItem(id, -1, GossipOptionNpc::None, std::move(text), 0, GossipOptionFlags::None, {}, 0, 0, false, money, std::move(confirm), {}, {}, - GOSSIP_SENDER_MAIN, action); -} - -struct ClassInfo { uint8 cls; char const* name; bool tank, healer, dps; }; -constexpr ClassInfo kClasses[] = { - { CLASS_WARRIOR, "Warrior", true, false, true }, - { CLASS_PALADIN, "Paladin", true, true, true }, - { CLASS_HUNTER, "Hunter", false, false, true }, - { CLASS_ROGUE, "Rogue", false, false, true }, - { CLASS_PRIEST, "Priest", false, true, true }, - { CLASS_SHAMAN, "Shaman", false, true, true }, - { CLASS_MAGE, "Mage", false, false, true }, - { CLASS_WARLOCK, "Warlock", false, false, true }, - { CLASS_DRUID, "Druid", true, true, true }, -}; - -ClassInfo const* FindClass(uint8 cls) -{ - for (ClassInfo const& c : kClasses) - if (c.cls == cls) - return &c; - return nullptr; -} - -bool Plays(ClassInfo const& c, Playerbot::Role role) -{ - return role == Playerbot::Role::Tank ? c.tank : role == Playerbot::Role::Healer ? c.healer : c.dps; -} - -// Role index 1..3 in the gossip actions. -Playerbot::Role RoleOfIndex(uint32 i) -{ - return i == 1 ? Playerbot::Role::Tank : i == 2 ? Playerbot::Role::Healer : Playerbot::Role::Dps; -} - -char const* RoleWord(Playerbot::Role role) -{ - return role == Playerbot::Role::Tank ? "tank" : role == Playerbot::Role::Healer ? "healer" : "damage dealer"; -} - -std::string GradeOffer(Hire::Grade grade, uint64 price) -{ - switch (grade) - { - case Hire::Grade::Sellsword: return Trinity::StringFormat("I need a sellsword. ({} each)", Hire::MoneyText(price)); - case Hire::Grade::Veteran: return Trinity::StringFormat("I need a veteran raider. ({} each)", Hire::MoneyText(price)); - case Hire::Grade::Legend: return Trinity::StringFormat("I hear you know someone... legendary. ({} each)", Hire::MoneyText(price)); - default: return {}; - } -} - -// What the broker says when a hire goes through. -char const* HiredLine(Hire::Broker broker) -{ - switch (broker) - { - case Hire::Broker::BlackMarket: return "Pleasure doing business. No refunds, no questions, and you never saw me."; - case Hire::Broker::Capital: return "A fine choice. They have stood in the line before, they will not break."; - default: return "Done. Your new sword arm will meet you outside."; - } -} - -void Tell(Player* player, std::string const& text) -{ - if (player && player->GetSession()) - ChatHandler(player->GetSession()).SendSysMessage(text.c_str()); -} - -void ListContracts(Player* player) -{ - uint32 const account = player->GetSession()->GetAccountId(); - Hire::Prices const prices = HireMgr::ConfigPrices(); - uint32 n = 0; - for (Playerbot::BotId id : Playerbot::Services::Owners().BotsOwnedBy(account)) - { - CharacterCacheEntry const* entry = sCharacterCache->GetCharacterCacheByGuid(ObjectGuid::Create(id)); - if (!entry) - continue; - HireRecord const rec = HireMgr::Instance().RecordOf(id); - uint64 const upkeep = Hire::UpkeepFor(prices, rec.price); - ClassInfo const* c = FindClass(entry->Class); - Tell(player, Trinity::StringFormat("{}: level {} {} {}{}", entry->Name, uint32(entry->Level), c ? c->name : "", - Hire::GradeName(rec.grade), - upkeep ? " (" + Hire::MoneyText(upkeep) + " a day you call them)" : std::string())); - ++n; - } - if (!n) - Tell(player, "Nobody works for you yet."); -} - -} // namespace - -struct npc_fb_hire_broker : public ScriptedAI -{ - explicit npc_fb_hire_broker(Creature* creature) : ScriptedAI(creature) { } - - Hire::Broker BrokerKind() const { return Hire::BrokerOfEntry(me->GetEntry()); } - - void MainMenu(Player* player) - { - StartMenu(player); - Hire::Broker const broker = BrokerKind(); - for (Hire::Grade g : { Hire::Grade::Sellsword, Hire::Grade::Veteran, Hire::Grade::Legend }) - { - if (!Hire::BrokerSells(HireMgr::ConfigRules(), broker, g)) - continue; - if (uint64 const price = HireMgr::PriceHere(player, g)) - AddOption(player, GradeOffer(g, price), kActionGrade + uint32(g) - 1); - else - AddOption(player, Trinity::StringFormat("({} only sign on with level {} heroes.)", g == Hire::Grade::Legend ? "Legends" : "Veterans", - uint32(Playerbot::MaxPlayerLevel())), 0); - } - AddOption(player, "Who works for me?", kActionContracts); - if (HireMgr::ConfigMode() == Hire::Mode::PlayerChoice) - AddOption(player, - HireMgr::Instance().OptedIn(player->GetSession()->GetAccountId()) - ? "I'd rather gather my own company again. (Bots are free again.)" - : "From now on I only fight beside those I pay. (Hired bots only.)", - kActionOptIn); - TC_LOG_INFO("playerbot.v2", "[hire] {} talks to broker {} ({}): menu {} with {} options", player->GetName(), me->GetName(), me->GetEntry(), - kBrokerMenu, player->PlayerTalkClass->GetGossipMenu().GetMenuItemCount()); - SendGossipMenuFor(player, kBrokerText, me->GetGUID()); - } - - bool OnGossipHello(Player* player) override - { - MainMenu(player); - return true; - } - - bool OnGossipSelect(Player* player, uint32 /*menuId*/, uint32 gossipListId) override - { - uint32 const action = GetGossipActionFor(player, gossipListId); - StartMenu(player); - Hire::Broker const broker = BrokerKind(); - - if (action == kActionContracts) - { - CloseGossipMenuFor(player); - ListContracts(player); - return true; - } - if (action == kActionOptIn) - { - uint32 const account = player->GetSession()->GetAccountId(); - bool const on = !HireMgr::Instance().OptedIn(account); - HireMgr::Instance().SetOptedIn(account, on); - CloseGossipMenuFor(player); - Tell(player, on ? "Hired bots only: your companions now come from the brokers." : "Hired bots off: you can bring bots for free again."); - return true; - } - if (action >= kActionGrade && action < kActionGrade + 3) - { - Hire::Grade const grade = Hire::Grade(action - kActionGrade + 1); - if (!Hire::BrokerSells(HireMgr::ConfigRules(), broker, grade)) - return MainMenuAgain(player); - for (uint32 r = 1; r <= 3; ++r) - AddOption(player, Trinity::StringFormat("A {}.", RoleWord(RoleOfIndex(r))), kActionRole + uint32(grade) * 10 + r); - SendGossipMenuFor(player, kBrokerText, me->GetGUID()); - return true; - } - if (action >= kActionRole + 10 && action < kActionRole + 40) - { - Hire::Grade const grade = Hire::Grade((action - kActionRole) / 10); - uint32 const roleIndex = (action - kActionRole) % 10; - Playerbot::Role const role = RoleOfIndex(roleIndex); - uint64 const price = HireMgr::PriceHere(player, grade); - if (!Hire::BrokerSells(HireMgr::ConfigRules(), broker, grade) || !price || roleIndex < 1 || roleIndex > 3) - return MainMenuAgain(player); - for (ClassInfo const& c : kClasses) - if (Plays(c, role) && CanHaveCompanionClass(player, c.cls)) - AddOption(player, c.name, kActionHire + uint32(grade) * 100 + roleIndex * 20 + c.cls, - Trinity::StringFormat("Hire a {} {} ({})?", c.name, Hire::GradeName(grade), RoleWord(role)), price); - SendGossipMenuFor(player, kBrokerText, me->GetGUID()); - return true; - } - if (action >= kActionHire + 100 && action < kActionHire + 400) - { - uint32 const rest = action - kActionHire; - Hire::Grade const grade = Hire::Grade(rest / 100); - Playerbot::Role const role = RoleOfIndex((rest % 100) / 20); - ClassInfo const* c = FindClass(uint8(rest % 20)); - CloseGossipMenuFor(player); - if (!c || !Hire::BrokerSells(HireMgr::ConfigRules(), broker, grade) || !Plays(*c, role)) - return true; - std::string msg; - bool const ok = HireCompanionForOwner(player, c->cls, role, grade, c->name, msg); - if (!msg.empty()) - Tell(player, msg); - if (ok) - me->Say(HiredLine(broker), LANG_UNIVERSAL, player); - return true; - } - CloseGossipMenuFor(player); - return true; - } - -private: - bool MainMenuAgain(Player* player) - { - MainMenu(player); - return true; - } -}; - -void AddSC_playerbot_v2_hire_broker() -{ - RegisterCreatureAI(npc_fb_hire_broker); -} diff --git a/src/modules/PlayerbotV2/Fleet/HireBroker.h b/src/modules/PlayerbotV2/Fleet/HireBroker.h deleted file mode 100644 index e27b2b9878..0000000000 --- a/src/modules/PlayerbotV2/Fleet/HireBroker.h +++ /dev/null @@ -1,23 +0,0 @@ -// The hire brokers (Playerbot.Hire.*): Sellsword Captains at inns, Veteran Recruiters in the capitals, black-market brokers in -// Gadgetzan, Booty Bay and Ratchet. Their gossip hires a bot of the broker's grade; the hiring itself is `.bot add`'s -// (cs_playerbot_v2.cpp AddCompanionFor), so a hired bot is set up, geared and grouped like any companion. - -#pragma once - -#include "HirePolicy.h" -#include "../Bot/BotTypes.h" -#include - -class Player; - -namespace Playerbot::V2 { - -// Hires one companion of `cls` and `grade` from the broker beside `owner`; `msg` is what the owner is told. -bool HireCompanionForOwner(Player* owner, uint8 cls, Playerbot::Role role, Fleet::Hire::Grade grade, std::string const& className, - std::string& msg); -// Whether a race of the owner's faction can be a companion of class `cls` on this realm. -bool CanHaveCompanionClass(Player const* owner, uint8 cls); - -} // namespace Playerbot::V2 - -void AddSC_playerbot_v2_hire_broker(); diff --git a/src/modules/PlayerbotV2/Fleet/HireMgr.cpp b/src/modules/PlayerbotV2/Fleet/HireMgr.cpp deleted file mode 100644 index 21e3432ded..0000000000 --- a/src/modules/PlayerbotV2/Fleet/HireMgr.cpp +++ /dev/null @@ -1,376 +0,0 @@ -#include "HireMgr.h" -#include "../Bot/ClassTables.h" -#include "../Bot/Gear/OwnedGearPolicy.h" -#include "Cell.h" -#include "CellImpl.h" -#include "Chat.h" -#include "Config.h" -#include "Creature.h" -#include "DatabaseEnv.h" -#include "GameTime.h" -#include "GridNotifiers.h" -#include "GridNotifiersImpl.h" -#include "Timer.h" -#include "Group.h" -#include "InstanceGroupCap.h" -#include "Log.h" -#include "ObjectAccessor.h" -#include "Player.h" -#include "../Services.h" -#include "WorldSession.h" -#include "OwnerRegistry.h" -#include -#include -#include -#include -#include - -namespace Playerbot::V2::Fleet { - -namespace { -auto& Db() { return CharacterDatabase; } - -uint64 PriceKey(char const* key, uint64 def) -{ - int64 const v = sConfigMgr->GetInt64Default(key, int64(def), true); - return v < 0 ? 0 : uint64(v); -} -} - -HireMgr& HireMgr::Instance() -{ - static HireMgr instance; - return instance; -} - -Hire::Mode HireMgr::ConfigMode() -{ - int32 const m = sConfigMgr->GetIntDefault("Playerbot.Hire.Mode", 0, true); - return (m == 1 || m == 2) ? Hire::Mode(m) : Hire::Mode::Off; -} - -Hire::Prices HireMgr::ConfigPrices() -{ - Hire::Prices p; - using Hire::Grade; - p.grade[uint8(Grade::Sellsword)].party = PriceKey("Playerbot.Hire.Sellsword.PartyPrice", p.grade[uint8(Grade::Sellsword)].party); - p.grade[uint8(Grade::Sellsword)].raid = PriceKey("Playerbot.Hire.Sellsword.RaidPrice", p.grade[uint8(Grade::Sellsword)].raid); - p.grade[uint8(Grade::Veteran)].party = PriceKey("Playerbot.Hire.Veteran.PartyPrice", p.grade[uint8(Grade::Veteran)].party); - p.grade[uint8(Grade::Veteran)].raid = PriceKey("Playerbot.Hire.Veteran.RaidPrice", p.grade[uint8(Grade::Veteran)].raid); - p.grade[uint8(Grade::Legend)].party = PriceKey("Playerbot.Hire.Legend.PartyPrice", p.grade[uint8(Grade::Legend)].party); - p.grade[uint8(Grade::Legend)].raid = PriceKey("Playerbot.Hire.Legend.RaidPrice", p.grade[uint8(Grade::Legend)].raid); - p.upkeep_pct = uint32(std::clamp(sConfigMgr->GetIntDefault("Playerbot.Hire.UpkeepPct", int32(p.upkeep_pct), true), 0, 1000)); - return p; -} - -Hire::Rules HireMgr::ConfigRules() -{ - Hire::Rules r; - using Hire::Grade; - struct GradeKeys { Grade grade; char const* gear; char const* health; }; - static constexpr GradeKeys kGrades[] = { - { Grade::Sellsword, "Playerbot.Hire.Sellsword.Gear", "Playerbot.Hire.Sellsword.HealthPct" }, - { Grade::Veteran, "Playerbot.Hire.Veteran.Gear", "Playerbot.Hire.Veteran.HealthPct" }, - { Grade::Legend, "Playerbot.Hire.Legend.Gear", "Playerbot.Hire.Legend.HealthPct" }, - }; - for (GradeKeys const& k : kGrades) - { - uint8 const g = uint8(k.grade); - std::string word = sConfigMgr->GetStringDefault(k.gear, "", true); - std::transform(word.begin(), word.end(), word.begin(), [](unsigned char c) { return char(std::tolower(c)); }); - Gear::Owned::GearMode mode; - if (!word.empty() && Gear::Owned::ParseGearMode(word, mode)) - r.gear_mode[g] = int(mode); - else if (!word.empty()) - TC_LOG_ERROR("playerbot.v2", "[hire] {} = \"{}\" is no gear mode (match, best, bis, t1, t2, t3): the default stays", k.gear, word); - int32 const pct = sConfigMgr->GetIntDefault(k.health, int32(r.health_pct[g]), true); - r.health_pct[g] = uint32(std::clamp(pct, int32(Hire::kMinHealthPct), int32(Hire::kMaxHealthPct))); - } - struct BrokerKey { Hire::Broker broker; char const* key; }; - static constexpr BrokerKey kBrokers[] = { - { Hire::Broker::Inn, "Playerbot.Hire.Inn.Sells" }, - { Hire::Broker::Capital, "Playerbot.Hire.Capital.Sells" }, - { Hire::Broker::BlackMarket, "Playerbot.Hire.BlackMarket.Sells" }, - }; - for (BrokerKey const& k : kBrokers) - { - // A missing line keeps the default; a line that is there (even empty or "none") is the server owner's list. - std::string const unset = "\x01"; - std::string const list = sConfigMgr->GetStringDefault(k.key, unset, true); - if (list != unset) - r.sells[uint8(k.broker)] = Hire::ParseGradeList(list); - } - return r; -} - -float HireMgr::BrokerRange() -{ - return std::clamp(sConfigMgr->GetFloatDefault("Playerbot.Hire.BrokerRange", 15.0f, true), 3.0f, 100.0f); -} - -uint32 HireMgr::MaxPerAccount() -{ - return uint32(std::max(sConfigMgr->GetIntDefault("Playerbot.Hire.MaxPerAccount", 0, true), 0)); -} - -uint32 HireMgr::LegendMaxPerAccount() -{ - return uint32(std::max(sConfigMgr->GetIntDefault("Playerbot.Hire.Legend.MaxPerAccount", 0, true), 0)); -} - -void HireMgr::LoadFromDb() -{ - auto rows = Db().Query("SELECT character_guid_low, hire_grade, hire_price, hire_paid_until FROM playerbot_v2_character WHERE hire_grade != 0"); - auto prefs = Db().Query("SELECT account_id FROM playerbot_v2_hire_pref WHERE hired_only != 0"); - std::unique_lock lk(mtx_); - hired_.clear(); - opted_in_.clear(); - loaned_.clear(); - if (rows) - do - { - Field* f = rows->Fetch(); - uint8 const g = f[1].GetUInt8(); - if (g == Hire::kLoanGradeDb) - { - loaned_[f[0].GetUInt64()] = 0; - continue; - } - if (g == 0 || g >= Hire::kGradeCount) - continue; - hired_[f[0].GetUInt64()] = HireRecord{ Hire::Grade(g), f[2].GetUInt64(), f[3].GetUInt64() }; - } while (rows->NextRow()); - if (prefs) - do { opted_in_.insert(prefs->Fetch()[0].GetUInt32()); } while (prefs->NextRow()); - TC_LOG_INFO("playerbot.v2", "[hire] mode={} hired bots={} finder loan bots={} accounts choosing hired bots={}", uint32(ConfigMode()), - hired_.size(), loaned_.size(), opted_in_.size()); -} - -bool HireMgr::OptedIn(uint32 account_id) const -{ - std::shared_lock lk(mtx_); - return opted_in_.contains(account_id); -} - -void HireMgr::SetOptedIn(uint32 account_id, bool on) -{ - { - std::unique_lock lk(mtx_); - if (on ? !opted_in_.insert(account_id).second : opted_in_.erase(account_id) == 0) - return; - } - Db().DirectPExecute("REPLACE INTO playerbot_v2_hire_pref (account_id, hired_only) VALUES ({}, {})", account_id, on ? 1 : 0); -} - -bool HireMgr::MustHire(Player const* player) const -{ - if (!player || !player->GetSession() || player->GetSession()->IsBot()) - return false; - bool const gm = player->GetSession()->GetSecurity() > SEC_PLAYER; - bool const bypass = sConfigMgr->GetBoolDefault("Playerbot.Hire.GmBypass", false, true); - return Hire::Required(ConfigMode(), OptedIn(player->GetSession()->GetAccountId()), gm, bypass); -} - -bool HireMgr::MustHireAccount(uint32 account_id) const -{ - if (!account_id) - return false; - return Hire::Required(ConfigMode(), OptedIn(account_id), false, false); -} - -HireRecord HireMgr::RecordOf(BotId bot) const -{ - std::shared_lock lk(mtx_); - auto const it = hired_.find(bot); - return it == hired_.end() ? HireRecord{} : it->second; -} - -void HireMgr::SetHired(BotId bot, Hire::Grade grade, uint64 price) -{ - uint64 const until = uint64(GameTime::GetGameTime()) + Hire::kDaySeconds; - { - std::unique_lock lk(mtx_); - hired_[bot] = HireRecord{ grade, price, until }; - } - Db().DirectPExecute("UPDATE playerbot_v2_character SET hire_grade = {}, hire_price = {}, hire_paid_until = {} WHERE character_guid_low = {}", - uint32(grade), price, until, bot); -} - -void HireMgr::Forget(BotId bot) -{ - { - std::unique_lock lk(mtx_); - bool const was_hired = hired_.erase(bot) != 0; - bool const was_loaned = loaned_.erase(bot) != 0; - if (!was_hired && !was_loaned) - return; - called_ms_.erase(bot); - } - Db().DirectPExecute("UPDATE playerbot_v2_character SET hire_grade = 0, hire_price = 0, hire_paid_until = 0 WHERE character_guid_low = {}", bot); -} - -void HireMgr::SetLoaned(BotId bot, uint32 now_ms) -{ - { - std::unique_lock lk(mtx_); - hired_.erase(bot); - loaned_[bot] = now_ms ? now_ms : 1; - } - Db().DirectPExecute("UPDATE playerbot_v2_character SET hire_grade = {}, hire_price = 0, hire_paid_until = 0 WHERE character_guid_low = {}", - uint32(Hire::kLoanGradeDb), bot); -} - -bool HireMgr::IsLoaned(BotId bot) const -{ - std::shared_lock lk(mtx_); - return loaned_.contains(bot); -} - -bool HireMgr::LoanSettled(BotId bot, uint32 now_ms) const -{ - std::shared_lock lk(mtx_); - auto const it = loaned_.find(bot); - return it != loaned_.end() && (it->second == 0 || getMSTimeDiff(it->second, now_ms) >= Hire::kLoanGraceMs); -} - -std::vector HireMgr::LoanedBots() const -{ - std::shared_lock lk(mtx_); - std::vector out; - out.reserve(loaned_.size()); - for (auto const& [id, _] : loaned_) - out.push_back(id); - return out; -} - -uint32 HireMgr::CountGrade(uint32 account_id, Hire::Grade grade) const -{ - uint32 n = 0; - for (BotId id : Services::Owners().BotsOwnedBy(account_id)) - if (RecordOf(id).grade == grade) - ++n; - return n; -} - -int HireMgr::GearModeOverride(BotId bot, uint32 owner_account) const -{ - Hire::Grade const grade = RecordOf(bot).grade; - if (grade == Hire::Grade::None && ConfigMode() == Hire::Mode::Off) - return -1; - bool must = MustHireAccount(owner_account); - // A GM's own companions keep the GM's gear choice (testing), as long as the GM is online to be asked. - if (must) - if (uint64 const owner_guid = Services::Owners().OwnerCharacter(bot)) - if (Player const* owner = ObjectAccessor::FindConnectedPlayer(ObjectGuid::Create(owner_guid))) - must = MustHire(owner); - return Hire::GearModeFor(ConfigRules(), grade, must); -} - -Creature* HireMgr::NearbyBroker(Player* player, Hire::Grade grade) const -{ - if (!player || !player->IsInWorld()) - return nullptr; - float const range = BrokerRange(); - Hire::Rules const rules = ConfigRules(); - std::list near; - Trinity::AnyUnitInObjectRangeCheck check(player, range); - Trinity::CreatureListSearcher searcher(player, near, check); - Cell::VisitGridObjects(player, searcher, range); - for (Creature* c : near) - if (c && c->IsAlive() && Hire::BrokerSells(rules, Hire::BrokerOfEntry(c->GetEntry()), grade)) - return c; - return nullptr; -} - -void HireMgr::ApplyHealth(Player* bot) -{ - if (!bot || !bot->IsInWorld()) - return; - BotId const id = bot->GetGUID().GetCounter(); - float given = 0.0f; - if (auto const it = health_bonus_.find(id); it != health_bonus_.end() && it->second.who == bot) - given = it->second.amount; - uint32 const pct = Hire::HealthPctFor(ConfigRules(), RecordOf(id).grade); - // The bot's health without the bonus, at its class, level and gear now (the bonus follows a level-up or new gear here). - float const normal = std::max(float(bot->GetMaxHealth()) - given, 1.0f); - float want = float(Hire::HealthBonusFor(uint64(normal), pct)); - if (normal + want < 1.0f) - want = 1.0f - normal; - if (std::abs(want - given) < 1.0f) - { - if (given == 0.0f) - health_bonus_.erase(id); - return; - } - bool const was_full = bot->IsAlive() && bot->GetHealth() >= bot->GetMaxHealth(); - if (given != 0.0f) - bot->HandleStatFlatModifier(UNIT_MOD_HEALTH, TOTAL_VALUE, given, false); - if (want != 0.0f) - bot->HandleStatFlatModifier(UNIT_MOD_HEALTH, TOTAL_VALUE, want, true); - if (was_full && !bot->IsInCombat()) - bot->SetFullHealth(); - if (want != 0.0f) - health_bonus_[id] = HealthBonus{ bot, want }; - else - health_bonus_.erase(id); - TC_LOG_DEBUG("playerbot.v2", "[hire] {} health {}% ({:+.0f}, max {})", bot->GetName(), pct, want, bot->GetMaxHealth()); -} - -bool HireMgr::RaidPlace(Player* player) -{ - if (!player) - return false; - if (Group const* g = player->GetGroup(); g && g->isRaidGroup()) - return true; - Map const* map = player->GetMap(); - return map && map->IsDungeon() && InstanceGroupCapFor(player) > 5; -} - -uint64 HireMgr::PriceHere(Player* player, Hire::Grade grade) -{ - if (!player) - return 0; - return Hire::PriceFor(ConfigPrices(), grade, player->GetLevel(), MaxPlayerLevel(), RaidPlace(player)); -} - -bool HireMgr::TakeUpkeep(Player* owner, BotId bot, std::string const& bot_name, std::string& why) -{ - HireRecord const rec = RecordOf(bot); - uint64 const now = uint64(GameTime::GetGameTime()); - if (rec.grade == Hire::Grade::None || !Hire::UpkeepDue(rec.paid_until, now) || !owner || !MustHire(owner)) - return true; - uint64 const fee = Hire::UpkeepFor(ConfigPrices(), rec.price); - if (fee && !owner->HasEnoughMoney(fee)) - { - why = bot_name + " wants a day's wages first (" + Hire::MoneyText(fee) + ")."; - return false; - } - if (fee) - owner->ModifyMoney(-int64(fee)); - uint64 const until = now + Hire::kDaySeconds; - { - std::unique_lock lk(mtx_); - if (auto it = hired_.find(bot); it != hired_.end()) - it->second.paid_until = until; - } - Db().DirectPExecute("UPDATE playerbot_v2_character SET hire_paid_until = {} WHERE character_guid_low = {}", until, bot); - if (fee && owner->GetSession()) - ChatHandler(owner->GetSession()).PSendSysMessage("You paid %s %s for today.", bot_name.c_str(), Hire::MoneyText(fee).c_str()); - TC_LOG_INFO("playerbot.v2", "[hire] {} paid {} copper upkeep for {}", owner->GetName(), fee, bot_name); - return true; -} - -void HireMgr::NoteCalled(BotId bot, uint32 now_ms) -{ - std::unique_lock lk(mtx_); - called_ms_[bot] = now_ms; -} - -bool HireMgr::RecentlyCalled(BotId bot, uint32 now_ms) const -{ - std::shared_lock lk(mtx_); - auto const it = called_ms_.find(bot); - return it != called_ms_.end() && now_ms - it->second < 30000u; -} - -} // namespace Playerbot::V2::Fleet diff --git a/src/modules/PlayerbotV2/Fleet/HireMgr.h b/src/modules/PlayerbotV2/Fleet/HireMgr.h deleted file mode 100644 index 4dfb1f5aff..0000000000 --- a/src/modules/PlayerbotV2/Fleet/HireMgr.h +++ /dev/null @@ -1,101 +0,0 @@ -// HireMgr - hired bots (Playerbot.Hire.*; the rules are HirePolicy.h). Keeps each hired bot's grade, what was paid for it and how -// long its upkeep is paid, and which accounts chose hired bots (Playerbot.Hire.Mode = 2). Stored in playerbot_v2_character -// (hire_grade, hire_price, hire_paid_until) and playerbot_v2_hire_pref, migration 0037. Reads from any thread, writes on the world -// thread (hiring, upkeep, `.bot hire on|off`). - -#pragma once - -#include "HirePolicy.h" -#include "../Bot/BotTypes.h" -#include -#include -#include -#include -#include - -class Creature; -class Player; - -namespace Playerbot::V2::Fleet { - -struct HireRecord -{ - Hire::Grade grade = Hire::Grade::None; - uint64 price = 0; // copper paid for the bot (its upkeep is a share of this) - uint64 paid_until = 0; // unix seconds; the upkeep is due again from then, the next time the bot is called -}; - -class HireMgr -{ -public: - static HireMgr& Instance(); - - void LoadFromDb(); - - // The server's settings, read from the config each call (a `.reload config` takes effect at once). - static Hire::Mode ConfigMode(); - static Hire::Prices ConfigPrices(); - // Each grade's gear and health and what each kind of broker sells (Playerbot.Hire..Gear / .HealthPct, .Sells). - static Hire::Rules ConfigRules(); - static float BrokerRange(); - static uint32 MaxPerAccount(); // 0 = no limit - static uint32 LegendMaxPerAccount(); // 0 = no limit - - // Whether `player` must hire companions instead of making them (Hire::Required with the player's choice and GM bypass). - bool MustHire(Player const* player) const; - // The same for the account owning a bot (its owner offline: the account's choice, no GM bypass). - bool MustHireAccount(uint32 account_id) const; - - bool OptedIn(uint32 account_id) const; - void SetOptedIn(uint32 account_id, bool on); - - HireRecord RecordOf(BotId bot) const; - // A bot was hired for `price`: its first day is paid. - void SetHired(BotId bot, Hire::Grade grade, uint64 price); - void Forget(BotId bot); - // Group Finder / dungeon finder bots of a player who must hire (Hire::kLoanGradeDb): free while they stay in that player's - // group, never called on their own, deleted when they leave it (BotPopulationManager::CompanionUpkeep / ReleaseLoans). - void SetLoaned(BotId bot, uint32 now_ms); - bool IsLoaned(BotId bot) const; - // A loan bot older than Hire::kLoanGraceMs (made before this start counts as old). - bool LoanSettled(BotId bot, uint32 now_ms) const; - std::vector LoanedBots() const; - uint32 CountGrade(uint32 account_id, Hire::Grade grade) const; - - // The gear mode a companion wears under hired mode (Gear::Owned::GearMode value), -1 when the owner's own choice stands. - int GearModeOverride(BotId bot, uint32 owner_account) const; - - // Gives a hired bot its grade's health (Playerbot.Hire..HealthPct) on top of what its class, level and gear give it, or - // takes an old bonus off again (the grade's percent changed, or the bot is no longer hired). Cheap when nothing changed; called - // when a companion is set up and on its regular upkeep. World thread. - void ApplyHealth(Player* bot); - - // The broker NPC within Playerbot.Hire.BrokerRange of `player` that sells `grade`, or nullptr. World thread. - Creature* NearbyBroker(Player* player, Hire::Grade grade) const; - // Whether a new bot for `player` fills a raid place: a raid group, or an instance for more than 5. - static bool RaidPlace(Player* player); - // The price `player` pays for one bot of `grade` here (0 = not for sale at this level). - static uint64 PriceHere(Player* player, Hire::Grade grade); - - // A companion of `owner` is being called: takes the day's upkeep when it is due. False (and `why` says so) when the owner cannot - // pay; the bot then stays home. World thread. - bool TakeUpkeep(Player* owner, BotId bot, std::string const& bot_name, std::string& why); - - // A hired bot that was just called by an add (Quick party sends one `.bot add` per place) is not picked again for the next - // place while it logs in. - void NoteCalled(BotId bot, uint32 now_ms); - bool RecentlyCalled(BotId bot, uint32 now_ms) const; - -private: - mutable std::shared_mutex mtx_; - std::unordered_map hired_; - std::unordered_set opted_in_; - std::unordered_map called_ms_; - std::unordered_map loaned_; // bot -> when it was lent (getMSTime), 0 = before this start - // The health given by ApplyHealth, per bot, with the Player it was given to (a bot that logged out and in again is a new Player - // object without it). World thread only. - struct HealthBonus { Player const* who = nullptr; float amount = 0.0f; }; - std::unordered_map health_bonus_; -}; - -} // namespace Playerbot::V2::Fleet diff --git a/src/modules/PlayerbotV2/Fleet/HirePolicy.h b/src/modules/PlayerbotV2/Fleet/HirePolicy.h deleted file mode 100644 index d825e0494b..0000000000 --- a/src/modules/PlayerbotV2/Fleet/HirePolicy.h +++ /dev/null @@ -1,232 +0,0 @@ -// HirePolicy - the rules of hired bots (Playerbot.Hire.*), kept free of game types so tests/game/ClassicHirePolicy.cpp can pin them. -// -// In hired mode a player's companions are not made out of nothing: they are hired from a mercenary NPC for gold. Three grades: -// Sellsword every listed inn and the capitals, at the hirer's level, the normal companion gear (match). -// Veteran the capitals only, level cap only, raid gear up to Playerbot.Gear.MaxTier whatever the owner wears (best). -// Legend the black-market brokers of Gadgetzan, Booty Bay and Ratchet, level cap only, best in slot (bis). -// Prices are package prices at the level cap, as the server owner sets them: a 5-man (the 4 places beside the player) and a 40-man -// (39 places). One bot costs its package price divided by those places; a Sellsword below the cap costs (level / cap)^2 of that, -// never under kMinPriceCopper. Upkeep: a share of what was paid for the bot, once for each day the bot is called. - -#pragma once - -#include -#include -#include -#include - -namespace Playerbot::V2::Fleet::Hire { - -enum class Grade : uint8_t { None = 0, Sellsword = 1, Veteran = 2, Legend = 3 }; -constexpr uint8_t kGradeCount = 4; - -// Playerbot.Hire.Mode: 0 off (bots are free, as before), 1 hired bots for everyone, 2 each player chooses (`.bot hire on|off`). -enum class Mode : uint8_t { Off = 0, Everyone = 1, PlayerChoice = 2 }; - -// What a broker NPC sells, from its creature entry (kBrokerEntryFirst.. in blocks of 100). -enum class Broker : uint8_t { None = 0, Inn = 1, Capital = 2, BlackMarket = 3 }; - -// (an entry travels in 23 bits to the client: nothing above 8388607 can be a creature the client lets you talk to) -constexpr uint32_t kBrokerEntryFirst = 6110000; // 6110000-6110099 inn, 6110100-6110199 capital, 6110200-6110299 black market -constexpr uint32_t kBrokerEntryLast = 6110299; -constexpr uint64_t kMinPriceCopper = 100; // 1 silver -constexpr uint32_t kPartyPlaces = 4; // the places beside the player in a 5-man -constexpr uint32_t kRaidPlaces = 39; // ... in a 40-man -constexpr uint32_t kDaySeconds = 86400; -// A Group Finder / dungeon finder bot made for a player who must hire: it plays with them for free while it stays in their group, -// cannot be called on its own and is deleted once it leaves the group (a loan, not a hire). Stored as this hire_grade value. -constexpr uint8_t kLoanGradeDb = 9; -constexpr uint32_t kLoanGraceMs = 120000; // a loan bot that is still logging in or joining is not taken back yet - -constexpr Broker BrokerOfEntry(uint32_t entry) -{ - if (entry < kBrokerEntryFirst || entry > kBrokerEntryLast) - return Broker::None; - return Broker(1 + (entry - kBrokerEntryFirst) / 100); -} - -// The grades each kind of broker sells by default: an inn Sellswords, a capital Sellswords and Veterans, the black market Legends. -// A server owner changes this with Playerbot.Hire..Sells (Rules below). -constexpr bool BrokerSells(Broker b, Grade g) -{ - switch (b) - { - case Broker::Inn: return g == Grade::Sellsword; - case Broker::Capital: return g == Grade::Sellsword || g == Grade::Veteran; - case Broker::BlackMarket: return g == Grade::Legend; - default: return false; - } -} - -// Veterans and Legends are level-cap only: raid gear means nothing below it, and a Legend hired at 15 for pocket money would grow -// into best-in-slot gear for free. -constexpr bool GradeForLevel(Grade g, uint32_t level, uint32_t cap) -{ - if (g == Grade::Sellsword) - return level >= 1; - return (g == Grade::Veteran || g == Grade::Legend) && level >= cap; -} - -// A grade's package prices at the level cap, in copper. -struct GradePrices -{ - uint64_t party = 0; // the 4 bots of a 5-man - uint64_t raid = 0; // the 39 bots of a 40-man -}; - -struct Prices -{ - GradePrices grade[kGradeCount] = { - {}, - { 10000, 200000 }, // Sellsword 1g / 20g - { 30000, 600000 }, // Veteran 3g / 60g - { 50000, 1000000 }, // Legend 5g / 100g - }; - uint32_t upkeep_pct = 25; // of the price paid, per day the bot is called; 0 = no upkeep -}; - -// The server owner's rules for each grade and broker (Playerbot.Hire..Gear / .HealthPct, Playerbot.Hire..Sells). The -// defaults are the built-in rules above, so a server without these lines plays as before. -struct Rules -{ - // Gear mode (Gear::Owned::GearMode value: 0 match, 1 best, 2 t1, 3 t2, 4 t3, 5 bis) each grade wears. - int gear_mode[kGradeCount] = { -1, 0, 1, 5 }; - // A hired bot's health in percent of what its class, level and gear give it (100 = normal). - uint32_t health_pct[kGradeCount] = { 100, 100, 100, 100 }; - // Bit (1 << grade) for each grade a kind of broker sells, by Broker value. - uint8_t sells[4] = { 0, 1u << 1, (1u << 1) | (1u << 2), 1u << 3 }; -}; - -constexpr uint32_t kMinHealthPct = 25; -constexpr uint32_t kMaxHealthPct = 1000; - -constexpr bool BrokerSells(Rules const& r, Broker b, Grade g) -{ - if (b == Broker::None || uint8_t(b) > 3 || g == Grade::None || uint8_t(g) >= kGradeCount) - return false; - return (r.sells[uint8_t(b)] >> uint8_t(g)) & 1u; -} - -constexpr uint32_t HealthPctFor(Rules const& r, Grade g) -{ - if (g == Grade::None || uint8_t(g) >= kGradeCount) - return 100; - return std::clamp(r.health_pct[uint8_t(g)], kMinHealthPct, kMaxHealthPct); -} - -// The extra (or, under 100%, missing) health of a bot whose class, level and gear give it `normal` health, at `pct` percent. -constexpr int64_t HealthBonusFor(uint64_t normal, uint32_t pct) -{ - pct = std::clamp(pct, kMinHealthPct, kMaxHealthPct); - return int64_t(normal) * (int64_t(pct) - 100) / 100; -} - -// A list of grade names ("sellsword, veteran"; commas or spaces, any case) as Rules::sells bits. "none" or an empty list = nothing. -// Unknown words are skipped. -inline uint8_t ParseGradeList(std::string_view list) -{ - uint8_t mask = 0; - size_t i = 0; - while (i <= list.size()) - { - size_t j = list.find_first_of(", ", i); - if (j == std::string_view::npos) - j = list.size(); - std::string w(list.substr(i, j - i)); - for (char& c : w) - if (c >= 'A' && c <= 'Z') - c = char(c - 'A' + 'a'); - if (w == "sellsword" || w == "sellswords") - mask |= 1u << uint8_t(Grade::Sellsword); - else if (w == "veteran" || w == "veterans") - mask |= 1u << uint8_t(Grade::Veteran); - else if (w == "legend" || w == "legends") - mask |= 1u << uint8_t(Grade::Legend); - i = j + 1; - } - return mask; -} - -// The price of one bot of grade `g` for a hirer of `level`; `raid` = the bot fills a raid place (a raid group, or an instance for -// more than 5). 0 = not for sale. -constexpr uint64_t PriceFor(Prices const& p, Grade g, uint32_t level, uint32_t cap, bool raid) -{ - if (g == Grade::None || uint8_t(g) >= kGradeCount || !GradeForLevel(g, level, cap) || cap == 0) - return 0; - GradePrices const& gp = p.grade[uint8_t(g)]; - uint64_t const package = raid ? gp.raid : gp.party; - uint64_t const places = raid ? kRaidPlaces : kPartyPlaces; - uint64_t one = package / places; - if (g == Grade::Sellsword && level < cap) - one = one * uint64_t(level) * uint64_t(level) / (uint64_t(cap) * uint64_t(cap)); - return std::max(one, kMinPriceCopper); -} - -// The day's upkeep for a bot that was hired for `paid` copper (0 = no upkeep: a bot owned before hired mode came on, or upkeep off). -constexpr uint64_t UpkeepFor(Prices const& p, uint64_t paid) -{ - if (!paid || !p.upkeep_pct) - return 0; - return std::max(paid * p.upkeep_pct / 100, kMinPriceCopper); -} - -// Whether a bot's upkeep is due when it is called at `now` (unix seconds): its paid day has run out. Days the bot is not called cost -// nothing; the next paid day runs a full day from the payment. -constexpr bool UpkeepDue(uint64_t paid_until, uint64_t now) { return paid_until != 0 && now >= paid_until; } - -// Whether the player must hire: hired mode is on for everyone, or the player chose it; a GM skips it when GmBypass is on. -constexpr bool Required(Mode mode, bool player_opted_in, bool is_gm, bool gm_bypass) -{ - if (is_gm && gm_bypass) - return false; - return mode == Mode::Everyone || (mode == Mode::PlayerChoice && player_opted_in); -} - -// The gear mode (Gear::Owned::GearMode value) a hired bot wears: a Veteran the raid gear (best = 1), a Legend best in slot -// (bis = 5). A Sellsword, or an owned bot of a player who must hire, wears match (0) whatever the owner chose; -1 = no rule (the -// owner's own choice stands). -constexpr int GearModeFor(Grade g, bool owner_must_hire) -{ - if (g == Grade::Legend) return 5; - if (g == Grade::Veteran) return 1; - if (g == Grade::Sellsword || owner_must_hire) return 0; - return -1; -} - -// The same with the server owner's gear for each grade (Playerbot.Hire..Gear). -constexpr int GearModeFor(Rules const& r, Grade g, bool owner_must_hire) -{ - if (g != Grade::None && uint8_t(g) < kGradeCount && r.gear_mode[uint8_t(g)] >= 0) - return r.gear_mode[uint8_t(g)]; - return owner_must_hire ? 0 : -1; -} - -constexpr char const* GradeName(Grade g) -{ - switch (g) - { - case Grade::Sellsword: return "Sellsword"; - case Grade::Veteran: return "Veteran"; - case Grade::Legend: return "Legend"; - default: return "Companion"; - } -} - -// "1g 25s", "75s", "12s 50c": gold, silver and copper, the parts that are not zero. -inline std::string MoneyText(uint64_t copper) -{ - uint64_t const g = copper / 10000, s = (copper / 100) % 100, c = copper % 100; - std::string out; - auto part = [&](uint64_t v, char const* unit) - { - if (!v) return; - if (!out.empty()) out += ' '; - out += std::to_string(v) + unit; - }; - part(g, "g"); - part(s, "s"); - part(c, "c"); - return out.empty() ? std::string("0c") : out; -} - -} // namespace Playerbot::V2::Fleet::Hire diff --git a/src/modules/PlayerbotV2/LfgBotFill.cpp b/src/modules/PlayerbotV2/LfgBotFill.cpp index a77d660959..cec6666f3b 100644 --- a/src/modules/PlayerbotV2/LfgBotFill.cpp +++ b/src/modules/PlayerbotV2/LfgBotFill.cpp @@ -19,7 +19,6 @@ #include "Bot/BotArchetype.h" #include "Bot/BotRegistry.h" #include "Fleet/BotGroupBuilder.h" -#include "Fleet/HireMgr.h" #include "Fleet/InstanceGroupCap.h" #include "Fleet/OwnerRegistry.h" #include "GroupFinderListings.h" @@ -514,10 +513,7 @@ namespace for (GroupReference const& ref : group->GetMembers()) if (Player const* member = ref.GetSource(); member && member != human && !IsHuman(member)) { - // In hired mode (Playerbot.Hire.*) the group's bots play with the player but are nobody's to keep: they stay world bots, - // ordered as group members, so joining a listed group never becomes a free hire. - if (!Fleet::HireMgr::Instance().MustHire(human)) - Playerbot::Services::Owners().SetOwner(member->GetGUID().GetCounter(), human->GetSession()->GetAccountId(), 0); + Playerbot::Services::Owners().SetOwner(member->GetGUID().GetCounter(), human->GetSession()->GetAccountId(), 0); ++bots; } TC_LOG_INFO("playerbot.v2", "[lfg] {} joined the listed bot group of {}: {} bot(s) are now their companions", human->GetName(), diff --git a/src/modules/PlayerbotV2/LfgBotFill.h b/src/modules/PlayerbotV2/LfgBotFill.h index 176ff7cd8d..8bcc69ec69 100644 --- a/src/modules/PlayerbotV2/LfgBotFill.h +++ b/src/modules/PlayerbotV2/LfgBotFill.h @@ -33,7 +33,7 @@ bool LfgBotGroupCanTake(Player* member, Player* applicant); // A member (the leader) of a listed bot group that `applicant` (a player without a group) could join, for the dungeon on `map` // (0 = any) and about his level; nullptr when none. A channel LFG line is answered from it (Bot/ChannelChat.cpp). Player* LfgBotGroupMemberFor(Player* applicant, uint32 map); -// Creates one companion for the owner (shared with `.bot add`). In hired mode it is a finder loan bot (HireMgr::SetLoaned). +// Creates one companion for the owner (shared with `.bot add`). bool AddCompanionForOwner(Player* owner, uint8 cls, Playerbot::Role role, std::string& msg); // Fills the leader's group up to `size` now with level-matched companions (`.bot lfg` and the dungeon finder). `gap` is what was // missing; returns the bots started, `report` says why any could not be. diff --git a/src/modules/PlayerbotV2/PlayerbotV2.cpp b/src/modules/PlayerbotV2/PlayerbotV2.cpp index 27119e3471..36b88b2d5a 100644 --- a/src/modules/PlayerbotV2/PlayerbotV2.cpp +++ b/src/modules/PlayerbotV2/PlayerbotV2.cpp @@ -1780,7 +1780,6 @@ void Module::OnWorldUpdate(std::chrono::milliseconds diff) { last_hint_check = total; SendDueAddonHints(); - RecheckArenaWaits(GameTime::GetGameTimeMS()); // real parties in an arena queue with no team against them } } { @@ -4484,110 +4483,6 @@ void Module::DispatchSquadLine(Player* sender, Group* group, std::string const& } } -void Module::OnHumanArenaQueue(Player* player, BattlegroundTemplate const* tmpl, uint8 bracket) -{ - // Only a real party asks for opponents; a bot party queuing for an arena is the opponent. - if (!player || !player->GetSession() || player->GetSession()->IsBot() || !Services::Initialized()) - return; - if (!sConfigMgr->GetBoolDefault("Playerbot.Arena.BotOpponents", true)) - return; - if (!AskArenaOpponents(player, tmpl, bracket, 0)) - return; - - // Asked once; RecheckArenaWaits asks again every kArenaReaskMs while the party still waits with no team against it - // (2026-11-04 playtest: one ask found no free bots and the queue waited for ever). - std::lock_guard lock(arena_waits_mtx_); - ArenaWait& w = arena_waits_[player->GetGUID()]; - w.bg_type_id = uint32(tmpl->Id); - w.bracket = bracket; - w.next_ask_ms = GameTime::GetGameTimeMS() + kArenaReaskMs; - w.asks = 1; -} - -bool Module::AskArenaOpponents(Player* player, BattlegroundTemplate const* tmpl, uint8 bracket, uint32 asks) -{ - if (tmpl->MapIDs.empty()) - return false; - - // team size of the queue the party is in (2, 3 or 5) - BattlegroundQueueTypeId queueId{}; - uint8 teamSize = 0; - for (uint32 i = 0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i) - { - BattlegroundQueueTypeId const q = player->GetBattlegroundQueueTypeId(i); - if (q.BattlemasterListId == uint16(tmpl->Id) && q.Type == uint8(BattlegroundQueueIdType::Arena) && q.TeamSize) - { - queueId = q; - teamSize = q.TeamSize; - } - } - if (teamSize != 2 && teamSize != 3 && teamSize != 5) - return false; - - PVPDifficultyEntry const* diff = DB2Manager::GetBattlegroundBracketById(tmpl->MapIDs.front(), BattlegroundBracketId(bracket)); - if (!diff) - return false; - - // A team of the other faction already waits in the same queue and bracket (a real party, or a bot team asked for before): - // the queue matches the two by itself, no further team is made. - TeamId const other = player->GetTeamId() == TEAM_ALLIANCE ? TEAM_HORDE : TEAM_ALLIANCE; - if (asks > 0 && sBattlegroundMgr->GetBattlegroundQueue(queueId).GetQueuedPlayersCount(other, BattlegroundBracketId(bracket)) >= teamSize) - return true; - - // Opponents of the other faction, in the party's level bracket. BotGroupBuilder takes idle, ungrouped bots of that band, forms - // the party and its leader queues the same Arena queue (team size, rating 1) about 10 s later; the queue then matches the two. - V2::CoordEvent ev{}; - ev.kind = V2::CoordSignal::ArenaTeamForming; - ev.origin_low = player->GetGUID().GetCounter(); - ev.content_id = uint32(tmpl->Id); - ev.level_min = uint8(std::clamp(diff->MinLevel, 1, int32(MaxPlayerLevel()))); - ev.level_max = uint8(std::clamp(diff->MaxLevel, 1, int32(MaxPlayerLevel()))); - ev.faction_mask = player->GetTeam() == ALLIANCE ? 0x2 : 0x1; - ev.arena_type = teamSize; - ev.content_name = "Arena opponents"; - Services::Coordination().Publish(ev); - - TC_LOG_INFO("playerbot.v2", "[arena] {} queued {}v{} (bracket {}-{}): asked for a bot team of the other faction (ask {})", - player->GetName(), uint32(teamSize), uint32(teamSize), uint32(ev.level_min), uint32(ev.level_max), asks + 1); - return true; -} - -void Module::RecheckArenaWaits(uint32 now_ms) -{ - std::vector> due; - { - std::lock_guard lock(arena_waits_mtx_); - for (auto it = arena_waits_.begin(); it != arena_waits_.end();) - { - Player* p = ObjectAccessor::FindConnectedPlayer(it->first); - // gone, in the arena (or any battleground), or out of that arena queue: nothing more to ask - if (!p || p->InBattleground() || !p->InBattlegroundQueue(/*ignoreArena*/ false)) - { - it = arena_waits_.erase(it); - continue; - } - if (int32(now_ms - it->second.next_ask_ms) >= 0) - { - due.emplace_back(it->first, it->second); - it->second.next_ask_ms = now_ms + kArenaReaskMs; - ++it->second.asks; - } - ++it; - } - } - - for (auto const& [guid, w] : due) - { - Player* p = ObjectAccessor::FindConnectedPlayer(guid); - BattlegroundTemplate const* tmpl = sBattlegroundMgr->GetBattlegroundTemplateByTypeId(BattlegroundTypeId(w.bg_type_id)); - if (!p || !tmpl || !AskArenaOpponents(p, tmpl, w.bracket, w.asks)) - { - std::lock_guard lock(arena_waits_mtx_); - arena_waits_.erase(guid); - } - } -} - void Module::OnPlayerJoinedBgQueue(Player* player, uint32 bg_type_id, uint8 bracket) { if (!initialized_ || !player) return; @@ -4605,15 +4500,6 @@ void Module::OnPlayerJoinedBgQueue(Player* player, uint32 bg_type_id, uint8 brac // fall through: bot premade leader — fill both factions below } - // Arena (2v2 / 3v3): the party is one team; the opposing team is a bot party formed for it. The battleground fill below - // fills two sides with solo bots and does not fit an arena queue. - if (BattlegroundTemplate const* tmpl = sBattlegroundMgr->GetBattlegroundTemplateByTypeId(BattlegroundTypeId(bg_type_id)); - tmpl && tmpl->IsArena()) - { - OnHumanArenaQueue(player, tmpl, bracket); - return; - } - // A real player waiting for a place: MakeRoomForRealPlayers watches the wait. Fleet::BotQueueFiller::NoteHumanBgQueue(player, bg_type_id, bracket); // A running battleground of this type that has or can make room: the human joins it (a bot leaves), no second @@ -4808,18 +4694,8 @@ namespace // queue's BattlemasterListId only, so a queue id built from that type reaches the same instance. Battleground* FindInvitedBattleground(uint32 bg_instance_id, uint32 bg_type_id) { - if (Battleground* bg = sBattlegroundMgr->GetBattleground(bg_instance_id, - BattlegroundMgr::BGQueueTypeId(uint16(bg_type_id), BattlegroundQueueIdType::Battleground, false, 0))) - return bg; - // An arena match (Mak'gora Arena 1169) is queued through "All Arenas" (6) with its team size, so its queue id is not built from - // the match type. Without this the bots of an arena with a real player waited for a player they never saw and did not port in. - if (BattlegroundTemplate const* bgTemplate = sBattlegroundMgr->GetBattlegroundTemplateByTypeId(BattlegroundTypeId(bg_type_id)); bgTemplate && bgTemplate->IsArena()) - for (uint8 teamSize : { uint8(2), uint8(3), uint8(5) }) - for (bool rated : { true, false }) - if (Battleground* bg = sBattlegroundMgr->GetBattleground(bg_instance_id, - BattlegroundMgr::BGQueueTypeId(uint16(BATTLEGROUND_AA), BattlegroundQueueIdType::Arena, rated, teamSize))) - return bg; - return nullptr; + return sBattlegroundMgr->GetBattleground(bg_instance_id, + BattlegroundMgr::BGQueueTypeId(uint16(bg_type_id), BattlegroundQueueIdType::Battleground, false, 0)); } } @@ -4850,15 +4726,8 @@ void Module::OnBGInvitationReceived(Player* player, uint32 bg_instance_id, uint3 bool const is_bot = player->GetSession() && player->GetSession()->IsBot(); if (!is_bot) { - { - std::lock_guard lk(pending_bg_ports_mtx_); - ++bg_invite_state_[bg_instance_id].expected_humans; - } - // The client's arena pop has Enter only: say how to turn it down (the ForeverBots add-on also shows Enter / Leave buttons). - if (BattlegroundTemplate const* bgTemplate = sBattlegroundMgr->GetBattlegroundTemplateByTypeId(BattlegroundTypeId(bg_type_id)); - bgTemplate && bgTemplate->IsArena() && player->GetSession()) - BotLanguage::LocalizedHandler(player->GetSession()).SendSysMessage( - "Your arena is ready. Enter: click Enter at the minimap or type .bot arena enter. Leave: type .bot arena leave."); + std::lock_guard lk(pending_bg_ports_mtx_); + ++bg_invite_state_[bg_instance_id].expected_humans; return; } diff --git a/src/modules/PlayerbotV2/PlayerbotV2.h b/src/modules/PlayerbotV2/PlayerbotV2.h index a9bcd66ee8..1b84bdbf8f 100644 --- a/src/modules/PlayerbotV2/PlayerbotV2.h +++ b/src/modules/PlayerbotV2/PlayerbotV2.h @@ -22,7 +22,6 @@ class Aura; class Group; class Channel; struct Position; -struct BattlegroundTemplate; namespace Playerbot { class SnapshotBuildPool; struct GroupSnapshot; } @@ -112,8 +111,6 @@ public: // core when a Player joins a BG / LFG queue; we hand off to // BotQueueFiller to invite online + JIT-spawn missing roles. void OnPlayerJoinedBgQueue(Player* player, uint32 bg_type_id, uint8 bracket); - // arena (2v2 / 3v3) queue of a real party: asks BotGroupBuilder for an opposing bot team - void OnHumanArenaQueue(Player* player, BattlegroundTemplate const* tmpl, uint8 bracket); void OnPlayerJoinedLfg(Player* player, uint32 dungeon_id, uint8 role_mask); bool HoldNewBattleground(uint32 bg_type_id, uint8 bracket); @@ -239,22 +236,6 @@ private: bool any_human_seen = false; // sticky once a human is detected in-bg }; std::unordered_map bg_invite_state_; - - // A real party waiting in an arena queue (OnHumanArenaQueue): asked again for an opposing bot team every kArenaReaskMs - // until the arena starts, the party leaves the queue, or a team of the other faction waits in the same queue. - struct ArenaWait { - uint32 bg_type_id = 0; - uint8 bracket = 0; - uint32 next_ask_ms = 0; - uint32 asks = 0; - }; - static constexpr uint32 kArenaReaskMs = 30000; - std::unordered_map arena_waits_; - std::mutex arena_waits_mtx_; - // Publishes ArenaTeamForming for `player`'s arena queue; false when the player is not (or no longer) in one. `asks` > 0 is - // a repeat ask, skipped while a team of the other faction already waits in that queue. - bool AskArenaOpponents(Player* player, BattlegroundTemplate const* tmpl, uint8 bracket, uint32 asks); - void RecheckArenaWaits(uint32 now_ms); std::mutex pending_bg_ports_mtx_; // Deferred LFG-proposal accept queue. Mirror of pending_bg_ports_ but for diff --git a/src/modules/PlayerbotV2/PlayerbotV2Scripts.cpp b/src/modules/PlayerbotV2/PlayerbotV2Scripts.cpp index 71fe484ffe..bae1ce205b 100644 --- a/src/modules/PlayerbotV2/PlayerbotV2Scripts.cpp +++ b/src/modules/PlayerbotV2/PlayerbotV2Scripts.cpp @@ -31,7 +31,6 @@ #include void AddSC_playerbot_v2_commandscript(); -void AddSC_playerbot_v2_hire_broker(); namespace { @@ -441,7 +440,6 @@ void AddSC_playerbot_v2() new playerbot_v2_group(); new playerbot_v2_guild(); AddSC_playerbot_v2_commandscript(); - AddSC_playerbot_v2_hire_broker(); PathGenerator::SetLiquidRouteCheck(&BotPathTouchesAvoidedLiquid); } diff --git a/src/modules/PlayerbotV2/Services.cpp b/src/modules/PlayerbotV2/Services.cpp index 36af19fbff..c013ec4f45 100644 --- a/src/modules/PlayerbotV2/Services.cpp +++ b/src/modules/PlayerbotV2/Services.cpp @@ -223,7 +223,6 @@ std::unique_ptr MakeTolViron3ArenaScript(); std::unique_ptr MakeBlackRookHold3ArenaScript(); std::unique_ptr MakeRobodromeArenaScript(); std::unique_ptr MakeEmpyreanDomainArenaScript(); -std::unique_ptr MakeMakgoraArenaScript(); } #include "Session/BotSessionMgr.h" #include "Travel/QuestHubDatabase.h" @@ -246,7 +245,6 @@ std::unique_ptr MakeMakgoraArenaScript(); #include "Threading/TickScheduler.h" #include "Util/ConfigReader.h" #include "Diagnostics/PerfCounters.h" -#include "Fleet/HireMgr.h" #include "Config.h" // sConfigMgr->GetFilename for resolving playerbot.conf next to worldserver.conf #include #include @@ -335,8 +333,6 @@ void Init() // also reads, so safe to load right after. h->owners = std::make_unique(); h->owners->LoadFromDb(); - // Hired bots (Playerbot.Hire.*): grades, prices paid and upkeep, from the same character table. - V2::Fleet::HireMgr::Instance().LoadFromDb(); // Dungeon script registry — pure in-memory, populated by // factories defined in Bot/Dungeon/Scripts/*.cpp. Empty registry // is fine — script-less dungeons fall back to generic logic. @@ -565,7 +561,6 @@ void Init() h->battlegrounds->Register(MakeBlackRookHold3ArenaScript()); h->battlegrounds->Register(MakeRobodromeArenaScript()); h->battlegrounds->Register(MakeEmpyreanDomainArenaScript()); - h->battlegrounds->Register(MakeMakgoraArenaScript()); // Team-level BG coordinator (BG audit N60). Driven from // Module::OnWorldUpdate ahead of the snapshot pass. h->bg_coordinator = std::make_unique(); diff --git a/src/modules/PlayerbotV2/Session/AddonControl.cpp b/src/modules/PlayerbotV2/Session/AddonControl.cpp index 5133461505..f50896cecf 100644 --- a/src/modules/PlayerbotV2/Session/AddonControl.cpp +++ b/src/modules/PlayerbotV2/Session/AddonControl.cpp @@ -13,7 +13,6 @@ #include "Fleet/BotIdentityRegistry.h" #include "Fleet/BotPopulationManager.h" #include "Fleet/BotSize.h" -#include "Fleet/HireMgr.h" #include "LfgBotFill.h" #include "Services.h" #include "Session/BotSessionMgr.h" @@ -889,23 +888,6 @@ void HandlePopReq(uint32 client_seq, WorldSession* sess, std::vector| -// ---------------------------------------------------------------------------- -void HandleHireReq(uint32 client_seq, WorldSession* sess) -{ - Player* me = sess ? sess->GetPlayer() : nullptr; - if (!me || !Services::Initialized()) - { - SendFields(sess, client_seq, "HIRE_RESP", {"0", "0"}); - return; - } - bool const must = V2::Fleet::HireMgr::Instance().MustHire(me); - SendFields(sess, client_seq, "HIRE_RESP", { must ? "1" : "0", std::to_string(uint32(V2::Fleet::HireMgr::ConfigMode())) }); -} - // ---------------------------------------------------------------------------- // PLACE_REQ - the ForeverBots Positions tab: chosen bots stand in a shape at a spot // and stay there (BotCommandParser::PlaceBots, Bot/Placement.h). @@ -1655,10 +1637,6 @@ void DispatchAssembled(WorldSession* sess, uint32 seq, { HandlePopReq(seq, sess, fields); } - else if (mtype == "HIRE_REQ") - { - HandleHireReq(seq, sess); - } else if (mtype == "PLACE_REQ") { HandlePlaceReq(seq, sess, fields); @@ -1765,7 +1743,6 @@ bool OnAddonWhisper(Player* sender, Player* /*receiver*/, && mtype != "PING" && mtype != "LFG_REQ" && mtype != "POP_REQ" - && mtype != "HIRE_REQ" && mtype != "ASSIGN_REQ") return false; } diff --git a/src/modules/PlayerbotV2/Util/BotLocaleRu.cpp b/src/modules/PlayerbotV2/Util/BotLocaleRu.cpp index 923d30f88d..7238ae58b7 100644 --- a/src/modules/PlayerbotV2/Util/BotLocaleRu.cpp +++ b/src/modules/PlayerbotV2/Util/BotLocaleRu.cpp @@ -780,14 +780,6 @@ std::vector const& RussianEntries() { "sorry, the invite didn't go through", "извините, приглашение не прошло" }, { "sure! invite to <{}> sent, welcome :)", "конечно! приглашение в <{}> отправлено, добро пожаловать :)" }, { "i can't invite myself, so {} sent you the invite to <{}>", "у меня нет права приглашать, поэтому {} отправляет вам приглашение в <{}>" }, - // ---- arena (.bot arena, the arena ready line) ------------------------------------------------------------------------ - { "Your arena is ready. Enter: click Enter at the minimap or type .bot arena enter. Leave: type .bot arena leave.", "Ваша арена готова. Войти: нажмите «Войти» у миникарты или введите .bot arena enter. Отказаться: введите .bot arena leave." }, - { "No arena is ready for you yet.", "Для вас пока нет готовой арены." }, - { "You left the arena queue.", "Вы покинули очередь на арену." }, - { "You are not in an arena queue.", "Вы не стоите в очереди на арену." }, - { "Only the party leader can queue the party for an arena.", "Только лидер группы может поставить группу в очередь на арену." }, - { "You are already in a battleground or arena.", "Вы уже на поле боя или на арене." }, - { "Usage: .bot arena 2 (2v2, a party of 2), .bot arena 3 (3v3, a party of 3), .bot arena enter, .bot arena leave", "Использование: .bot arena 2 (2 на 2, группа из 2), .bot arena 3 (3 на 3, группа из 3), .bot arena enter, .bot arena leave" }, }; return entries; } diff --git a/src/modules/PlayerbotV2/conf/playerbot.conf.dist b/src/modules/PlayerbotV2/conf/playerbot.conf.dist index 9aa5ee34d9..bf0c2a1721 100644 --- a/src/modules/PlayerbotV2/conf/playerbot.conf.dist +++ b/src/modules/PlayerbotV2/conf/playerbot.conf.dist @@ -281,7 +281,7 @@ Playerbot.World.HomeFriendlyPct = 100 # warlock Corruption, priest Shadow Word: Pain, druid Moonfire, paladin Judgement / Hammer of Justice, shaman Earth # Shock / Lightning Bolt, hunter Serpent Sting, rogue from stealth (Cheap Shot / Ambush). AttackBots = 1: enemy world bots too. # Everyone else never starts a fight with a player; it fights back when attacked. -# Never a companion, hired bot or bot in a group; never in a battleground, dungeon, raid, capital or sanctuary. On free-for-all +# Never a companion or bot in a group; never in a battleground, dungeon, raid, capital or sanctuary. On free-for-all # realms hunters also jump bots and players of their own faction. Log lines: [world_pvp] in Playerbot.log. # BorderFriendlyPct / ContestedFriendlyPct: on those realms the share of the player's own faction among the bots around him in # border and contested zones is at most this (so enemies are about); home zones and capitals keep the numbers above. @@ -509,10 +509,6 @@ Playerbot.Bg.AutoSeed.Matches = 0 # Also auto-seed Arena matches (bot-only). 0 = off. Playerbot.Bg.AutoSeed.Arena = 0 -# Arena opponents: when a real party queues for a 2v2 or 3v3 arena, idle bots of the other faction in the same level -# bracket form a party of the same size and queue against it. 1 = on, 0 = off (the party then waits for another party). -Playerbot.Arena.BotOpponents = 0 - # Force a specific Arena bracket type for auto-seeding (0 = let the system # choose; otherwise an arena type id, e.g. 2 = 2v2, 3 = 3v3). Playerbot.Bg.AutoSeed.ForceType = 0 @@ -770,62 +766,6 @@ Playerbot.Gear.Owned.OwnerSlack = 6 # The choice is kept per owner account (table playerbot_v2_owner_gear). World and battleground bots # ignore it. Example for a server that keeps raid tiers to be earned: AllowedModes = "match,best" Playerbot.OwnedGear.AllowedModes = "" - -# Playerbot.Hire.Mode hired bots (an idea from Neylem): 0 = off (default; .bot add, Quick party and the Group finder make bots for -# free), 1 = on for everyone, 2 = each player chooses (`.bot hire on|off`, the add-on's Settings, or a broker's -# gossip). With hired bots on, nothing is made out of nothing: a companion you already have that is not out -# comes instead (the same role, the same class first), and standing next to a broker a Sellsword is hired for -# you. Brokers: a Sellsword Captain at the inns and in the capitals (Sellsword: your level, normal companion -# gear), a Veteran Recruiter in the capitals (Veteran: level cap only, raid gear up to Playerbot.Gear.MaxTier -# whatever you wear), a Black Market Broker in Gadgetzan, Booty Bay and Ratchet (Legend: level cap only, best -# in slot). Bots you owned before hired mode came on count as Sellswords with no upkeep. World bots are not -# affected, and a listed Group finder group you join plays with you without becoming yours. -# Hired bots only (Karrz 2026-11-03): with it on the ForeverBots add-on hides its "Add a bot" buttons (the server -# says so in HIRE_RESP). The Group finder and the dungeon finder (`.bot lfg`, `.bot dungeon`, a posted listing) -# still fill the group for free, but those bots are only lent: they cannot be called on their own and are -# deleted once they leave that group. -# Playerbot.Hire.GmBypass 1 = a GM account (security above player) makes bots for free as before. Default 0 (since 0.1.29: on a -# local realm the player's own account is a GM, and hired bots only must hold for them too). -# Playerbot.Hire.BrokerRange yards from a broker in which `.bot add` and Quick party hire. Default 15. -# Playerbot.Hire..PartyPrice / RaidPrice copper, at the level cap: what the 4 bots of a 5-man / the 39 bots of a 40-man cost -# together. One bot costs the party price / 4, or the raid price / 39 in a raid group or an instance for -# more than 5. A Sellsword below the cap costs (level / cap)^2 of that, never under 1 silver. -# Defaults: Sellsword 1g / 20g, Veteran 3g / 60g, Legend 5g / 100g. -# Playerbot.Hire.UpkeepPct a hired bot's wages: this share of what was paid for it, once for each day it is called (a day it stays -# home costs nothing). A bot whose owner cannot pay stays home. 0 = no upkeep. Default 25. -# Playerbot.Hire.MaxPerAccount the most bots one account may own while it hires (0 = no limit). Default 0. -# Playerbot.Hire.Legend.MaxPerAccount the most Legends one account may hire (0 = no limit). Default 0. -# Playerbot.Hire..Gear the gear a hired bot of that grade wears: match (normal gear for its level, up to your own), -# best (raid gear up to Playerbot.Gear.MaxTier), bis (best in slot), t1 / t2 / t3 (that tier set). -# The raid modes only work at the level cap; below it the bot wears match. -# Defaults: Sellsword match, Veteran best, Legend bis. -# Playerbot.Hire..HealthPct a hired bot's health, in percent of what its class, level and gear give it (25 to 1000). -# Default 100 (normal health) for every grade. -# Playerbot.Hire..Sells the grades each kind of broker sells: Inn (the Sellsword Captains at the inns), Capital (the -# Veteran Recruiters in the capitals), BlackMarket (Gadgetzan, Booty Bay, Ratchet). A list of -# sellsword, veteran, legend; "none" = sells nothing. Defaults: Inn "sellsword", Capital -# "sellsword, veteran", BlackMarket "legend". Veterans and Legends still only sign on at the level cap. -Playerbot.Hire.Mode = 0 -Playerbot.Hire.GmBypass = 0 -Playerbot.Hire.BrokerRange = 15 -Playerbot.Hire.Sellsword.PartyPrice = 10000 -Playerbot.Hire.Sellsword.RaidPrice = 200000 -Playerbot.Hire.Veteran.PartyPrice = 30000 -Playerbot.Hire.Veteran.RaidPrice = 600000 -Playerbot.Hire.Legend.PartyPrice = 50000 -Playerbot.Hire.Legend.RaidPrice = 1000000 -Playerbot.Hire.UpkeepPct = 25 -Playerbot.Hire.MaxPerAccount = 0 -Playerbot.Hire.Legend.MaxPerAccount = 0 -Playerbot.Hire.Sellsword.Gear = "match" -Playerbot.Hire.Veteran.Gear = "best" -Playerbot.Hire.Legend.Gear = "bis" -Playerbot.Hire.Sellsword.HealthPct = 100 -Playerbot.Hire.Veteran.HealthPct = 100 -Playerbot.Hire.Legend.HealthPct = 100 -Playerbot.Hire.Inn.Sells = "sellsword" -Playerbot.Hire.Capital.Sells = "sellsword, veteran" -Playerbot.Hire.BlackMarket.Sells = "legend" # Scenario.DummyEntry the creature the damage_parity scenarios hit (`.playerbot scenario run damage_parity_`, finisher_sweep_, # talent_audit_): a creature_template entry that can be attacked and does nothing; the runner makes it level 63, # 3731 armor, 2 billion health. 0 (default): the first "Training Dummy" / "Target Dummy" template without a script. diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index e66158b3eb..1ec563cdfa 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -33,7 +33,6 @@ if(NOT BUILD_PLAYERBOT_V2) ClassicGuildAskText.cpp ClassicBotLocale.cpp ClassicCompanionLeash.cpp - ClassicHirePolicy.cpp ClassicMeleeReach.cpp ClassicFalseCombatEscape.cpp ClassicFollowDrop.cpp diff --git a/tests/game/ClassicHirePolicy.cpp b/tests/game/ClassicHirePolicy.cpp deleted file mode 100644 index 5ce58e6f76..0000000000 --- a/tests/game/ClassicHirePolicy.cpp +++ /dev/null @@ -1,153 +0,0 @@ -/* - * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - */ - -#include "tc_catch2.h" - -#include "../../src/modules/PlayerbotV2/Fleet/HirePolicy.h" - -using namespace Playerbot::V2::Fleet::Hire; - -// Karrz 2026-10-29: a complete legendary 40-man costs 100g, a legendary 5-man 5g, a blue (Veteran) 5-man 3g. -TEST_CASE("Package prices add up to what the server owner set", "[ClassicHirePolicy]") -{ - Prices const p; - CHECK(PriceFor(p, Grade::Legend, 60, 60, true) * kRaidPlaces <= 1000000); - CHECK(PriceFor(p, Grade::Legend, 60, 60, true) * kRaidPlaces > 1000000 - kRaidPlaces); - CHECK(PriceFor(p, Grade::Legend, 60, 60, false) * kPartyPlaces == 50000); - CHECK(PriceFor(p, Grade::Veteran, 60, 60, false) * kPartyPlaces == 30000); - CHECK(PriceFor(p, Grade::Sellsword, 60, 60, false) * kPartyPlaces == 10000); -} - -TEST_CASE("A Sellsword below the cap costs less, never under a silver", "[ClassicHirePolicy]") -{ - Prices const p; - uint64_t const at60 = PriceFor(p, Grade::Sellsword, 60, 60, false); - uint64_t const at40 = PriceFor(p, Grade::Sellsword, 40, 60, false); - uint64_t const at20 = PriceFor(p, Grade::Sellsword, 20, 60, false); - CHECK(at40 < at60); - CHECK(at20 < at40); - CHECK(at20 == 277); // 2500 x 400 / 3600 - CHECK(PriceFor(p, Grade::Sellsword, 1, 60, false) == kMinPriceCopper); -} - -TEST_CASE("Veterans and Legends are for the level cap only", "[ClassicHirePolicy]") -{ - Prices const p; - CHECK(PriceFor(p, Grade::Veteran, 59, 60, false) == 0); - CHECK(PriceFor(p, Grade::Legend, 15, 60, true) == 0); - CHECK(PriceFor(p, Grade::None, 60, 60, false) == 0); - CHECK(GradeForLevel(Grade::Sellsword, 1, 60)); -} - -TEST_CASE("Brokers sell their own grades", "[ClassicHirePolicy]") -{ - CHECK(BrokerOfEntry(6110000) == Broker::Inn); - CHECK(BrokerOfEntry(6110105) == Broker::Capital); - CHECK(BrokerOfEntry(6110202) == Broker::BlackMarket); - CHECK(BrokerOfEntry(6110300) == Broker::None); - CHECK(BrokerOfEntry(295) == Broker::None); - CHECK(BrokerSells(Broker::Inn, Grade::Sellsword)); - CHECK_FALSE(BrokerSells(Broker::Inn, Grade::Veteran)); - CHECK(BrokerSells(Broker::Capital, Grade::Veteran)); - CHECK_FALSE(BrokerSells(Broker::Capital, Grade::Legend)); - CHECK(BrokerSells(Broker::BlackMarket, Grade::Legend)); - CHECK_FALSE(BrokerSells(Broker::BlackMarket, Grade::Sellsword)); -} - -TEST_CASE("Upkeep is a quarter of the price, only on a day the bot is called", "[ClassicHirePolicy]") -{ - Prices const p; - CHECK(UpkeepFor(p, 25000) == 6250); - CHECK(UpkeepFor(p, 0) == 0); // owned before hired mode: free - CHECK(UpkeepFor(p, 200) == kMinPriceCopper); - Prices off; - off.upkeep_pct = 0; - CHECK(UpkeepFor(off, 25000) == 0); - CHECK_FALSE(UpkeepDue(0, 1000)); - CHECK_FALSE(UpkeepDue(2000, 1999)); - CHECK(UpkeepDue(2000, 2000)); -} - -TEST_CASE("Who must hire", "[ClassicHirePolicy]") -{ - CHECK_FALSE(Required(Mode::Off, true, false, true)); - CHECK(Required(Mode::Everyone, false, false, true)); - CHECK_FALSE(Required(Mode::Everyone, false, true, true)); // a GM testing - CHECK(Required(Mode::Everyone, false, true, false)); - CHECK(Required(Mode::PlayerChoice, true, false, true)); - CHECK_FALSE(Required(Mode::PlayerChoice, false, false, true)); -} - -TEST_CASE("The grade sets the gear", "[ClassicHirePolicy]") -{ - CHECK(GearModeFor(Grade::Legend, true) == 5); - CHECK(GearModeFor(Grade::Veteran, false) == 1); - CHECK(GearModeFor(Grade::Sellsword, false) == 0); - CHECK(GearModeFor(Grade::None, true) == 0); - CHECK(GearModeFor(Grade::None, false) == -1); -} - -TEST_CASE("Default rules are the built-in ones", "[ClassicHirePolicy]") -{ - Rules const r; - for (Broker b : { Broker::Inn, Broker::Capital, Broker::BlackMarket, Broker::None }) - for (Grade g : { Grade::None, Grade::Sellsword, Grade::Veteran, Grade::Legend }) - CHECK(BrokerSells(r, b, g) == BrokerSells(b, g)); - for (Grade g : { Grade::None, Grade::Sellsword, Grade::Veteran, Grade::Legend }) - for (bool must : { false, true }) - CHECK(GearModeFor(r, g, must) == GearModeFor(g, must)); - CHECK(HealthPctFor(r, Grade::Legend) == 100); - CHECK(HealthBonusFor(4000, 100) == 0); -} - -TEST_CASE("The server owner sets what brokers sell, gear and health", "[ClassicHirePolicy]") -{ - CHECK(ParseGradeList("sellsword, veteran") == ((1u << 1) | (1u << 2))); - CHECK(ParseGradeList("Legend") == (1u << 3)); - CHECK(ParseGradeList("legends sellswords") == ((1u << 1) | (1u << 3))); - CHECK(ParseGradeList("none") == 0); - CHECK(ParseGradeList("") == 0); - CHECK(ParseGradeList("dragon") == 0); - - Rules r; - r.sells[uint8_t(Broker::Inn)] = ParseGradeList("sellsword, legend"); - CHECK(BrokerSells(r, Broker::Inn, Grade::Legend)); - CHECK_FALSE(BrokerSells(r, Broker::Inn, Grade::Veteran)); - CHECK_FALSE(BrokerSells(r, Broker::None, Grade::Legend)); - - r.gear_mode[uint8_t(Grade::Veteran)] = 3; // t2 - CHECK(GearModeFor(r, Grade::Veteran, false) == 3); - CHECK(GearModeFor(r, Grade::None, false) == -1); - CHECK(GearModeFor(r, Grade::None, true) == 0); - - r.health_pct[uint8_t(Grade::Legend)] = 150; - CHECK(HealthPctFor(r, Grade::Legend) == 150); - CHECK(HealthBonusFor(4000, 150) == 2000); - CHECK(HealthBonusFor(4000, 50) == -2000); - CHECK(HealthBonusFor(4000, 1) == -3000); // never under kMinHealthPct (25%) - r.health_pct[uint8_t(Grade::Legend)] = 99999; - CHECK(HealthPctFor(r, Grade::Legend) == kMaxHealthPct); - CHECK(HealthPctFor(r, Grade::None) == 100); -} - -TEST_CASE("Money reads like the game's", "[ClassicHirePolicy]") -{ - CHECK(MoneyText(12500) == "1g 25s"); - CHECK(MoneyText(7500) == "75s"); - CHECK(MoneyText(1250) == "12s 50c"); - CHECK(MoneyText(0) == "0c"); -}