From 956aff28349eb4e9e2606238b013a8efa6fc69a5 Mon Sep 17 00:00:00 2001 From: Karrz1 <127596890+Karrz1@users.noreply.github.com> Date: Tue, 20 Oct 2026 02:05:38 +0100 Subject: [PATCH] Bots: module update (raid tactics, group control, world-bot pool, riding, starter gear, combat fixes) (#71) * Bots: module update (raid tactics, instance entry, world-bot and combat fixes) * Bots: module update from the current build (follow-the-owner on drops, group-human instance entry, raid-ready and population fixes) * Bots: group control, pool balance at every level, starter outfit for low world bots, riding tiers and mount fallback * World bots: no quest hub for a bot that can take no quest there (#87) * World bots: no quest hub for a bot that can take none there (ring spot instead); move_abandon logs why the bot did not move * Starter outfit: wait while the bot casts or fights, and leave quivers and ammo out of the pieces that must be worn * Bots: seven small cleanups of the bot rules (#88) * Bots: one OwnerOrders struct holds the owner's orders (command, follow, stance, windows) and the cross-thread fields are now locked * Bots: one pet attack order per combat tick; drop the warlock and hunter duplicates, new victim ordered at once and the same one every 3 s * Raids: one script_names_target() test for the boss script's kill target, used by the raid dispatch and both generic pickers * Bots: idle:rest sits a solo bot under 50% health that has nothing to eat * Bots: remove the retail rotations of the nine vanilla classes (every spec is already overridden by the Classic rotation) * Group: one movement_owned_elsewhere test for the follow, slot move and recall gates * Bots: the threat drop spells and the 60/80 percent triggers live next to the other threat limits in ThreatLimits.h * Trade: reagents of a recipe the bot knows, from the owner or a group mate, are a gift; trade line in the command guide (#89) --- sql/playerbot_v2/0029_variable_pool.sql | 18 + sql/playerbot_v2/0030_companion_saved_by.sql | 15 + sql/playerbot_v2/0031_world_gear_pending.sql | 20 + sql/playerbot_v2/0032_world_gear_repair.sql | 16 + .../Addon/ForeverBots/ForeverBots.lua | 43 +- .../Addon/ForeverBots/ForeverBots.toc | 2 +- .../PlayerbotV2/Addon/ForeverBots/README.md | 5 +- src/modules/PlayerbotV2/Api/BotTrade.h | 15 +- src/modules/PlayerbotV2/Api/BotTradeShop.cpp | 25 +- src/modules/PlayerbotV2/Api/FollowDrop.h | 149 ++++ src/modules/PlayerbotV2/Api/PlayerbotAPI.cpp | 447 ++++++++++- src/modules/PlayerbotV2/Api/PlayerbotAPI.h | 20 +- .../PlayerbotV2/Api/PlayerbotMovement.cpp | 59 +- .../PlayerbotV2/Api/PlayerbotMovement.h | 11 + src/modules/PlayerbotV2/BOT_COMMANDS.md | 20 +- src/modules/PlayerbotV2/Bot/BotAI.cpp | 7 +- src/modules/PlayerbotV2/Bot/BotAI.h | 139 +++- .../PlayerbotV2/Bot/BotCommandParser.cpp | 109 +-- .../PlayerbotV2/Bot/BotCommandParser.h | 5 + src/modules/PlayerbotV2/Bot/BotIntent.h | 4 +- .../PlayerbotV2/Bot/BotIntentEmitter.cpp | 6 +- .../PlayerbotV2/Bot/BotIntentEmitter.h | 3 +- .../PlayerbotV2/Bot/BotIntentExecutor.cpp | 19 +- src/modules/PlayerbotV2/Bot/BotSnapshot.h | 19 + .../PlayerbotV2/Bot/BotSnapshotBuilder.cpp | 68 +- .../PlayerbotV2/Bot/BotSnapshotView.cpp | 28 +- src/modules/PlayerbotV2/Bot/BotSnapshotView.h | 5 + src/modules/PlayerbotV2/Bot/Dungeon/MarkCc.h | 9 +- .../Bot/Dungeon/PveGroupCoordinator.cpp | 117 ++- .../Bot/Dungeon/PveGroupCoordinator.h | 5 +- .../Bot/Dungeon/Scripts/NaxxramasScript.cpp | 8 +- .../PlayerbotV2/Bot/Gear/BotGearGenerator.cpp | 3 + .../PlayerbotV2/Bot/Gear/WorldGearStart.h | 17 + src/modules/PlayerbotV2/Bot/GroupControl.h | 51 ++ .../PlayerbotV2/Bot/GroupOrderText.cpp | 29 + src/modules/PlayerbotV2/Bot/GroupOrderText.h | 8 + src/modules/PlayerbotV2/Bot/IdleRule.cpp | 6 +- src/modules/PlayerbotV2/Bot/IdleWatch.h | 16 + .../PlayerbotV2/Bot/InstanceFullHold.h | 19 + .../PlayerbotV2/Bot/Raid/DispelWorth.h | 9 + src/modules/PlayerbotV2/Bot/Raid/KickRules.h | 46 ++ src/modules/PlayerbotV2/Bot/Raid/README.md | 12 + .../PlayerbotV2/Bot/Raid/RaidBrain.cpp | 337 +++++++- .../PlayerbotV2/Bot/Raid/RaidBrainInternal.h | 3 + .../PlayerbotV2/Bot/Raid/RaidCombat.cpp | 18 + .../Bot/Raid/RaidEncounterData_AQ40.cpp | 43 +- .../Bot/Raid/RaidEncounterData_BWL.cpp | 30 +- .../Bot/Raid/RaidEncounterData_MC.cpp | 38 +- .../Raid/RaidEncounterData_MC_Movement.cpp | 15 +- .../Bot/Raid/RaidEncounterData_NAXX.cpp | 33 +- .../Bot/Raid/RaidEncounterData_ONY.cpp | 57 +- .../PlayerbotV2/Bot/Raid/RaidEncounters.cpp | 16 +- .../PlayerbotV2/Bot/Raid/RaidEncounters.h | 113 ++- .../PlayerbotV2/Bot/Raid/RaidFightScript.cpp | 178 +++++ .../PlayerbotV2/Bot/Raid/RaidFightScript.h | 129 +++ .../PlayerbotV2/Bot/Raid/RaidGeometry.h | 21 + src/modules/PlayerbotV2/Bot/Raid/RaidOrder.h | 7 + .../PlayerbotV2/Bot/Raid/ShieldRules.h | 34 + .../PlayerbotV2/Bot/States/MaintainHelpers.h | 6 + .../Bot/States/Rules/AmbientRules.cpp | 41 +- .../Bot/States/Rules/CoreFlowRules.cpp | 22 + .../Bot/States/Rules/LootDrainRules.cpp | 7 + .../Bot/States/Rules/OocConsumableRules.cpp | 33 + .../Bot/States/Rules/VendorRules.cpp | 39 + .../PlayerbotV2/Bot/States/State_Idle.cpp | 49 ++ .../PlayerbotV2/Bot/States/State_InCombat.cpp | 60 +- .../PlayerbotV2/Bot/States/State_InGroup.cpp | 269 +++++-- .../PlayerbotV2/Bot/ThreatDiscipline.h | 6 +- src/modules/PlayerbotV2/Bot/ThreatLimits.h | 44 ++ src/modules/PlayerbotV2/Bot/TownLife.h | 2 +- src/modules/PlayerbotV2/CMakeLists.txt | 7 +- src/modules/PlayerbotV2/Combat/ApRegistry.cpp | 56 -- .../PlayerbotV2/Combat/Apl/ApClassicHeal.h | 16 +- .../PlayerbotV2/Combat/Apl/ApTankThreat.h | 5 + .../PlayerbotV2/Combat/Apl/ApThreatDump.h | 5 +- .../PlayerbotV2/Combat/Apl/AplPetThrottle.h | 30 +- .../PlayerbotV2/Combat/Apl/Apl_Baseline.cpp | 11 +- .../Combat/Apl/Apl_Baseline_Common.h | 11 +- .../Combat/Apl/Apl_Baseline_Druid.cpp | 347 -------- .../Combat/Apl/Apl_Baseline_Hunter.cpp | 290 ------- .../Combat/Apl/Apl_Baseline_Mage.cpp | 205 ----- .../Combat/Apl/Apl_Baseline_Paladin.cpp | 188 ----- .../Combat/Apl/Apl_Baseline_Priest.cpp | 76 -- .../Combat/Apl/Apl_Baseline_Rogue.cpp | 228 ------ .../Combat/Apl/Apl_Baseline_Shaman.cpp | 138 ---- .../Combat/Apl/Apl_Baseline_Warlock.cpp | 150 ---- .../Combat/Apl/Apl_Baseline_Warrior.cpp | 164 ---- .../Combat/Apl/Apl_Classic_Hunter.cpp | 13 - .../Combat/Apl/Apl_Classic_Warlock.cpp | 13 - .../Combat/Apl/Apl_Druid_Balance.cpp | 640 --------------- .../Combat/Apl/Apl_Druid_Feral.cpp | 742 ----------------- .../Combat/Apl/Apl_Druid_Guardian.cpp | 550 ------------- .../Combat/Apl/Apl_Druid_Restoration.cpp | 600 -------------- .../Combat/Apl/Apl_Hunter_BeastMastery.cpp | 562 ------------- .../Combat/Apl/Apl_Hunter_Marksmanship.cpp | 517 ------------ .../Combat/Apl/Apl_Hunter_Survival.cpp | 507 ------------ .../Combat/Apl/Apl_Mage_Arcane.cpp | 508 ------------ .../PlayerbotV2/Combat/Apl/Apl_Mage_Fire.cpp | 463 ----------- .../PlayerbotV2/Combat/Apl/Apl_Mage_Frost.cpp | 521 ------------ .../Combat/Apl/Apl_Paladin_Holy.cpp | 666 ---------------- .../Combat/Apl/Apl_Paladin_Protection.cpp | 528 ------------- .../Combat/Apl/Apl_Paladin_Retribution.cpp | 508 ------------ .../Combat/Apl/Apl_Priest_Discipline.cpp | 640 --------------- .../Combat/Apl/Apl_Priest_Holy.cpp | 665 ---------------- .../Combat/Apl/Apl_Priest_Shadow.cpp | 537 ------------- .../Combat/Apl/Apl_Rogue_Assassination.cpp | 592 -------------- .../Combat/Apl/Apl_Rogue_Outlaw.cpp | 579 -------------- .../Combat/Apl/Apl_Rogue_Subtlety.cpp | 586 -------------- .../Combat/Apl/Apl_Shaman_Elemental.cpp | 721 ----------------- .../Combat/Apl/Apl_Shaman_Enhancement.cpp | 622 --------------- .../Combat/Apl/Apl_Shaman_Restoration.cpp | 747 ------------------ .../Combat/Apl/Apl_Warlock_Affliction.cpp | 472 ----------- .../Combat/Apl/Apl_Warlock_Demonology.cpp | 395 --------- .../Combat/Apl/Apl_Warlock_Destruction.cpp | 517 ------------ .../Combat/Apl/Apl_Warrior_Arms.cpp | 586 -------------- .../Combat/Apl/Apl_Warrior_Fury.cpp | 513 ------------ .../Combat/Apl/Apl_Warrior_Protection.cpp | 653 --------------- .../PlayerbotV2/Commands/cs_playerbot_v2.cpp | 58 +- .../PlayerbotV2/Diagnostics/ScenarioDefs.h | 24 +- .../Diagnostics/ScenarioRunner.cpp | 77 +- .../Fleet/BotPopulationManager.cpp | 158 +++- .../PlayerbotV2/Fleet/BotPopulationManager.h | 20 +- .../PlayerbotV2/Fleet/BotSetupPipeline.cpp | 3 + src/modules/PlayerbotV2/Fleet/CityLayer.h | 74 ++ src/modules/PlayerbotV2/Fleet/LevelWindow.h | 29 + .../PlayerbotV2/Fleet/OwnerRegistry.cpp | 25 +- src/modules/PlayerbotV2/Fleet/OwnerRegistry.h | 6 +- src/modules/PlayerbotV2/Fleet/PoolBalance.h | 51 +- src/modules/PlayerbotV2/Fleet/PoolBudget.h | 70 ++ .../PlayerbotV2/Fleet/WorldBotSpawner.cpp | 378 +++++++-- .../PlayerbotV2/Fleet/WorldBotSpawner.h | 25 +- src/modules/PlayerbotV2/PlayerbotV2.cpp | 52 +- src/modules/PlayerbotV2/PlayerbotV2.h | 5 + src/modules/PlayerbotV2/Travel/ReachMemory.h | 161 ++++ .../PlayerbotV2/Travel/UnifiedTravelGraph.cpp | 196 +++++ .../PlayerbotV2/Travel/UnifiedTravelGraph.h | 3 + .../PlayerbotV2/Travel/WalkLinkTable.h | 144 ++++ src/modules/PlayerbotV2/Util/ConfigReader.cpp | 9 +- src/modules/PlayerbotV2/Util/ConfigReader.h | 12 +- src/modules/PlayerbotV2/WORLD_BOTS.md | 2 +- .../PlayerbotV2/conf/playerbot.conf.dist | 43 +- 141 files changed, 4439 insertions(+), 18558 deletions(-) create mode 100644 sql/playerbot_v2/0029_variable_pool.sql create mode 100644 sql/playerbot_v2/0030_companion_saved_by.sql create mode 100644 sql/playerbot_v2/0031_world_gear_pending.sql create mode 100644 sql/playerbot_v2/0032_world_gear_repair.sql create mode 100644 src/modules/PlayerbotV2/Api/FollowDrop.h create mode 100644 src/modules/PlayerbotV2/Bot/Gear/WorldGearStart.h create mode 100644 src/modules/PlayerbotV2/Bot/GroupControl.h create mode 100644 src/modules/PlayerbotV2/Bot/InstanceFullHold.h create mode 100644 src/modules/PlayerbotV2/Bot/Raid/KickRules.h create mode 100644 src/modules/PlayerbotV2/Bot/Raid/RaidFightScript.cpp create mode 100644 src/modules/PlayerbotV2/Bot/Raid/RaidFightScript.h create mode 100644 src/modules/PlayerbotV2/Bot/Raid/ShieldRules.h delete mode 100644 src/modules/PlayerbotV2/Combat/Apl/Apl_Baseline_Druid.cpp delete mode 100644 src/modules/PlayerbotV2/Combat/Apl/Apl_Baseline_Hunter.cpp delete mode 100644 src/modules/PlayerbotV2/Combat/Apl/Apl_Baseline_Mage.cpp delete mode 100644 src/modules/PlayerbotV2/Combat/Apl/Apl_Baseline_Paladin.cpp delete mode 100644 src/modules/PlayerbotV2/Combat/Apl/Apl_Baseline_Priest.cpp delete mode 100644 src/modules/PlayerbotV2/Combat/Apl/Apl_Baseline_Rogue.cpp delete mode 100644 src/modules/PlayerbotV2/Combat/Apl/Apl_Baseline_Shaman.cpp delete mode 100644 src/modules/PlayerbotV2/Combat/Apl/Apl_Baseline_Warlock.cpp delete mode 100644 src/modules/PlayerbotV2/Combat/Apl/Apl_Baseline_Warrior.cpp delete mode 100644 src/modules/PlayerbotV2/Combat/Apl/Apl_Druid_Balance.cpp delete mode 100644 src/modules/PlayerbotV2/Combat/Apl/Apl_Druid_Feral.cpp delete mode 100644 src/modules/PlayerbotV2/Combat/Apl/Apl_Druid_Guardian.cpp delete mode 100644 src/modules/PlayerbotV2/Combat/Apl/Apl_Druid_Restoration.cpp delete mode 100644 src/modules/PlayerbotV2/Combat/Apl/Apl_Hunter_BeastMastery.cpp delete mode 100644 src/modules/PlayerbotV2/Combat/Apl/Apl_Hunter_Marksmanship.cpp delete mode 100644 src/modules/PlayerbotV2/Combat/Apl/Apl_Hunter_Survival.cpp delete mode 100644 src/modules/PlayerbotV2/Combat/Apl/Apl_Mage_Arcane.cpp delete mode 100644 src/modules/PlayerbotV2/Combat/Apl/Apl_Mage_Fire.cpp delete mode 100644 src/modules/PlayerbotV2/Combat/Apl/Apl_Mage_Frost.cpp delete mode 100644 src/modules/PlayerbotV2/Combat/Apl/Apl_Paladin_Holy.cpp delete mode 100644 src/modules/PlayerbotV2/Combat/Apl/Apl_Paladin_Protection.cpp delete mode 100644 src/modules/PlayerbotV2/Combat/Apl/Apl_Paladin_Retribution.cpp delete mode 100644 src/modules/PlayerbotV2/Combat/Apl/Apl_Priest_Discipline.cpp delete mode 100644 src/modules/PlayerbotV2/Combat/Apl/Apl_Priest_Holy.cpp delete mode 100644 src/modules/PlayerbotV2/Combat/Apl/Apl_Priest_Shadow.cpp delete mode 100644 src/modules/PlayerbotV2/Combat/Apl/Apl_Rogue_Assassination.cpp delete mode 100644 src/modules/PlayerbotV2/Combat/Apl/Apl_Rogue_Outlaw.cpp delete mode 100644 src/modules/PlayerbotV2/Combat/Apl/Apl_Rogue_Subtlety.cpp delete mode 100644 src/modules/PlayerbotV2/Combat/Apl/Apl_Shaman_Elemental.cpp delete mode 100644 src/modules/PlayerbotV2/Combat/Apl/Apl_Shaman_Enhancement.cpp delete mode 100644 src/modules/PlayerbotV2/Combat/Apl/Apl_Shaman_Restoration.cpp delete mode 100644 src/modules/PlayerbotV2/Combat/Apl/Apl_Warlock_Affliction.cpp delete mode 100644 src/modules/PlayerbotV2/Combat/Apl/Apl_Warlock_Demonology.cpp delete mode 100644 src/modules/PlayerbotV2/Combat/Apl/Apl_Warlock_Destruction.cpp delete mode 100644 src/modules/PlayerbotV2/Combat/Apl/Apl_Warrior_Arms.cpp delete mode 100644 src/modules/PlayerbotV2/Combat/Apl/Apl_Warrior_Fury.cpp delete mode 100644 src/modules/PlayerbotV2/Combat/Apl/Apl_Warrior_Protection.cpp create mode 100644 src/modules/PlayerbotV2/Fleet/CityLayer.h create mode 100644 src/modules/PlayerbotV2/Fleet/LevelWindow.h create mode 100644 src/modules/PlayerbotV2/Fleet/PoolBudget.h create mode 100644 src/modules/PlayerbotV2/Travel/ReachMemory.h create mode 100644 src/modules/PlayerbotV2/Travel/WalkLinkTable.h diff --git a/sql/playerbot_v2/0029_variable_pool.sql b/sql/playerbot_v2/0029_variable_pool.sql new file mode 100644 index 0000000000..cb44818268 --- /dev/null +++ b/sql/playerbot_v2/0029_variable_pool.sql @@ -0,0 +1,18 @@ +-- Migration: 0029_variable_pool +-- Date: 2026-10-16 +-- Purpose: the world spawner keeps a core roster (Playerbot.World.PoolMax) and a variable pool (Playerbot.World.VariableMax) of +-- temporary residents created around a real player where the core has nobody fitting (a new character on Zephras Isle, +-- a new level 1-9 player). A temporary resident is flagged here and is deleted again after Playerbot.World.VariableTtlHours +-- offline with no owner, group or queue tag. Core rows, companions and every other row keep 0 and are never deleted by it. +-- +-- Columns: +-- variable_pool 0 = core / not temporary, 1 = temporary resident +-- Reverts: yes (DROP COLUMN variable_pool). + +ALTER TABLE playerbot_v2_character + ADD COLUMN variable_pool TINYINT UNSIGNED NOT NULL DEFAULT 0, + ADD KEY idx_variable_pool (variable_pool); + +INSERT INTO playerbot_v2_schema_version (version, sha256) VALUES + (29, REPEAT('0', 64)) +ON DUPLICATE KEY UPDATE applied_at = CURRENT_TIMESTAMP; diff --git a/sql/playerbot_v2/0030_companion_saved_by.sql b/sql/playerbot_v2/0030_companion_saved_by.sql new file mode 100644 index 0000000000..4ab68225d0 --- /dev/null +++ b/sql/playerbot_v2/0030_companion_saved_by.sql @@ -0,0 +1,15 @@ +-- Migration: 0030_companion_saved_by +-- Date: 2026-10-17 +-- Purpose: The saved companion roster is per character, not per account: a level 22 rogue's Raid ready called the level 60 +-- warlock's 39 bots. companion_saved_by is the character whose roster the bot is on. 0 = any character (kept for a +-- roster saved by an owner with no bound character). +-- Reverts: yes (DROP COLUMN companion_saved_by). + +ALTER TABLE playerbot_v2_character + ADD COLUMN companion_saved_by BIGINT UNSIGNED NOT NULL DEFAULT 0; + +UPDATE playerbot_v2_character SET companion_saved_by = owner_player_guid WHERE companion_saved = 1; + +INSERT INTO playerbot_v2_schema_version (version, sha256) VALUES + (30, REPEAT('0', 64)) +ON DUPLICATE KEY UPDATE applied_at = CURRENT_TIMESTAMP; diff --git a/sql/playerbot_v2/0031_world_gear_pending.sql b/sql/playerbot_v2/0031_world_gear_pending.sql new file mode 100644 index 0000000000..9986549f71 --- /dev/null +++ b/sql/playerbot_v2/0031_world_gear_pending.sql @@ -0,0 +1,20 @@ +-- Migration: 0031_world_gear_pending +-- Date: 2026-10-18 +-- Purpose: World bots made before this change wear a generated full set at level 1-9 (a level 1 wore rings, trinkets, neck and cloak). New world bots +-- under level 10 keep the outfit their character was created with. Each existing world bot under level 10 is marked here; the world +-- spawner strips it to its starter outfit once, on its next login, and clears the mark. +-- +-- Columns: +-- world_gear_pending 1 = this world bot still has to be set back to its starter outfit (a companion or a bot of level 10+ is never marked) +-- Reverts: yes (DROP COLUMN world_gear_pending). + +ALTER TABLE playerbot_v2_character + ADD COLUMN world_gear_pending TINYINT UNSIGNED NOT NULL DEFAULT 0; + +UPDATE playerbot_v2_character pv JOIN characters c ON c.guid = pv.character_guid_low + SET pv.world_gear_pending = 1 + WHERE c.level < 10 AND pv.owner_account_id = 0 AND pv.owner_player_guid = 0 AND pv.companion_saved = 0 AND pv.distribution_level > 0; + +INSERT INTO playerbot_v2_schema_version (version, sha256) VALUES + (31, REPEAT('0', 64)) +ON DUPLICATE KEY UPDATE applied_at = CURRENT_TIMESTAMP; diff --git a/sql/playerbot_v2/0032_world_gear_repair.sql b/sql/playerbot_v2/0032_world_gear_repair.sql new file mode 100644 index 0000000000..5f2a8846dd --- /dev/null +++ b/sql/playerbot_v2/0032_world_gear_repair.sql @@ -0,0 +1,16 @@ +-- Migration: 0032_world_gear_repair +-- Date: 2026-10-18 +-- Purpose: The first starter-outfit swap (0031) stripped some world bots under level 10 and could not put the outfit on (the pieces went through the +-- bags, which were full), clearing their mark. Every world bot under level 10 that carries neither a main-hand weapon nor a ranged weapon is +-- marked again; its next login puts the starter outfit on. A bot that wields something is left alone. +-- Reverts: no schema change (the mark is only cleared again by the swap). + +UPDATE playerbot_v2_character pv JOIN characters c ON c.guid = pv.character_guid_low + SET pv.world_gear_pending = 1 + WHERE c.level < 10 AND pv.owner_account_id = 0 AND pv.owner_player_guid = 0 AND pv.companion_saved = 0 AND pv.distribution_level > 0 + AND pv.world_gear_pending = 0 + AND NOT EXISTS (SELECT 1 FROM character_inventory ci WHERE ci.guid = pv.character_guid_low AND ci.bag = 0 AND ci.slot IN (15, 17)); + +INSERT INTO playerbot_v2_schema_version (version, sha256) VALUES + (32, 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 a5225d80ec..cd750b51c1 100644 --- a/src/modules/PlayerbotV2/Addon/ForeverBots/ForeverBots.lua +++ b/src/modules/PlayerbotV2/Addon/ForeverBots/ForeverBots.lua @@ -57,20 +57,19 @@ local function ServerCommand(text) SendChatMessage(text, "SAY") end --- Stance toggle of the panel: ForeverBotsDB.stance is "passive" or "aggressive" (nil = never picked: passive, the default while --- you lead a dungeon group). The pick is kept between sessions and re-sent to the group whenever it changes (new bots). +-- Stance toggle of the panel: ForeverBotsDB.stance is "passive" or "aggressive" (nil = never picked: passive, the server's start +-- stance for every bot in your group). The pick is kept between sessions and re-sent to the group whenever it changes (new bots). local function StanceIsAggressive() return ForeverBotsDB ~= nil and ForeverBotsDB.stance == "aggressive" end --- What the button shows: the pick; before one, "Passive" inside an instance (that is what is sent to the group there, see the group --- change timer below) and "Auto" elsewhere (nothing sent, the bots use their own default). +-- What the button shows: the pick; before one, "Passive" (nothing is sent until you pick, the server starts every grouped bot Passive). local function StanceLabel() local stance = ForeverBotsDB and ForeverBotsDB.stance if stance == "aggressive" then return "Aggressive" end if stance == "passive" then return "Passive" end - local okI, inInstance = pcall(IsInInstance) - if okI and inInstance then return "Passive" end - return "Auto" + -- Nothing picked yet: every bot in your group starts Passive on the server (it fights only what the group pulled or what + -- attacks the group, and follows you back), so the button says so. + return "Passive" end local stanceBtn local function RefreshStance() @@ -142,7 +141,7 @@ local tankMarker = 1 -- Follow distance (yards, 1..20): the stepper in the panel and /fb distance . The value is saved in ForeverBotsDB.distance -- and sent to the group as the order "distance ". Clicks are coalesced: the final value goes out after 0.4 s without a -- click and never more than one order per 0.3 s. It is re-sent silently on login and when the group changes size. -local DIST_MIN, DIST_MAX, DIST_START = 1, 20, 5 +local DIST_MIN, DIST_MAX, DIST_START = 2, 20, 5 local InGroupQuiet local distText -- value font string, filled by BuildFrame local distDirtyAt -- GetTime() of the last unsent change @@ -621,6 +620,13 @@ local function RaidReady() end end + -- Already in a group: it is the group that gets the orders and the ready check. The saved-roster call replaces the group with the + -- saved raid (a 10-man in a dungeon was dismissed), so it only runs when you are alone. + if MemberCount() > 1 then + Print("raid ready: using your current group (" .. MemberCount() .. ").") + Finish(MemberCount()) + return + end Print("raid ready: calling your saved bots...") ServerCommand(".bot summon saved") local lastN, stable, waited = -1, 0, 0 @@ -740,7 +746,7 @@ local function BuildFrame() y = y - 34 local raidReadyBtn = MakeButton(frame, "Raid ready", 298, RaidReady, 24) raidReadyBtn:SetPoint("TOPLEFT", 16, y) - Tip(raidReadyBtn, "Raid ready", "Calls your saved bots, makes the group a raid if it needs one, sets the formation and spacing, and starts a ready check once the bots have buffed. Target your main tank first to set the Main Tank flag too. Not in combat.") + Tip(raidReadyBtn, "Raid ready", "Alone: calls your saved bots. Already in a group: uses that group and never changes it. Makes the group a raid if it needs one, sets the formation and spacing, and starts a ready check once the bots have buffed. Target your main tank first to set the Main Tank flag too. Not in combat.") y = y - 32 ---------------------------------------------------------------------------------------------- order rows @@ -797,7 +803,7 @@ local function BuildFrame() local stanceRow = Row({ { "Come", 72, "Come", "Bots teleport to you.", function() GroupOrder("come") end, "come" }, { StanceLabel(), 98, "Stance", - "Auto: nothing sent yet outside an instance, the bots use their own default. Inside an instance the panel sends Passive until you pick. Passive: bots start nothing and only defend. Aggressive: they attack anything hostile within about 10 yards of you. Shows what you last sent; it is sent again to every bot that joins.", + "Passive (the start setting): bots start nothing, fight only what you pull or what attacks the group, and come back to follow you. Aggressive: they also attack anything hostile within about 10 yards of you. Shows what you last sent; it is sent again to every bot that joins.", function(self) ForeverBotsDB.stance = StanceIsAggressive() and "passive" or "aggressive" GroupOrder(ForeverBotsDB.stance) @@ -843,8 +849,8 @@ local function BuildFrame() distText:SetJustifyH("CENTER") local distPlus = MakeButton(frame, "+", 26, function() StepDistance(1) end) distPlus:SetPoint("TOPLEFT", 212, y) - Tip(distMinus, "Follow distance", "How far the bots follow you out of combat, 1 to 20 yards. Also sets the formation spacing.") - Tip(distPlus, "Follow distance", "How far the bots follow you out of combat, 1 to 20 yards. Also sets the formation spacing.") + Tip(distMinus, "Follow distance", "How far the bots follow you out of combat, 2 to 20 yards. Also sets the formation spacing.") + Tip(distPlus, "Follow distance", "How far the bots follow you out of combat, 2 to 20 yards. Also sets the formation spacing.") ShowDistance() y = y - 30 @@ -1048,7 +1054,18 @@ end for _, ev in ipairs({ "GROUP_ROSTER_UPDATE", "PARTY_MEMBERS_CHANGED", "RAID_ROSTER_UPDATE" }) do pcall(distFrame.RegisterEvent, distFrame, ev) end -distFrame:SetScript("OnEvent", OnGroupChanged) +-- A zone change or loading screen can re-create the bots on the server (their stance starts over), with the group size unchanged: +-- the stance is sent again then, so a pick of Aggressive or Passive is never lost. +for _, ev in ipairs({ "PLAYER_ENTERING_WORLD", "ZONE_CHANGED_NEW_AREA" }) do + pcall(distFrame.RegisterEvent, distFrame, ev) +end +distFrame:SetScript("OnEvent", function(self, event) + if event == "PLAYER_ENTERING_WORLD" or event == "ZONE_CHANGED_NEW_AREA" then + if GroupSize() > 0 then self.stanceAt = Now() + 2.5 end + return + end + OnGroupChanged() +end) local function Toggle() if not frame then BuildFrame() end diff --git a/src/modules/PlayerbotV2/Addon/ForeverBots/ForeverBots.toc b/src/modules/PlayerbotV2/Addon/ForeverBots/ForeverBots.toc index 8d03b6664f..9dfc1ded91 100644 --- a/src/modules/PlayerbotV2/Addon/ForeverBots/ForeverBots.toc +++ b/src/modules/PlayerbotV2/Addon/ForeverBots/ForeverBots.toc @@ -2,7 +2,7 @@ ## Title: WoW Forever Bots ## Notes: One-click PlayerbotV2 companions: add a bot of any class and role, call, dismiss and command your bots. ## Author: Karrz -## Version: 0.2.3 +## Version: 0.2.4 ## SavedVariables: ForeverBotsDB ForeverBots.lua diff --git a/src/modules/PlayerbotV2/Addon/ForeverBots/README.md b/src/modules/PlayerbotV2/Addon/ForeverBots/README.md index 8ec961aae2..cb4d30c351 100644 --- a/src/modules/PlayerbotV2/Addon/ForeverBots/README.md +++ b/src/modules/PlayerbotV2/Addon/ForeverBots/README.md @@ -6,7 +6,7 @@ does not depend on the addon-message protocol PlayerbotControl uses. Install: copy this folder to `\_classic_beta_\Interface\AddOns\ForeverBots` (the folder name must stay `ForeverBots`). If the character screen's AddOns list marks it out of date, tick "Load out of date AddOns". -In game: `/fb` opens the window. The Raid ready button (or `/fb raidready`) calls your saved bots (`.bot summon saved`), makes the group a raid if needed, sets formation and spacing, and starts a ready check once the bots have buffed. +In game: `/fb` opens the window. The Raid ready button (or `/fb raidready`) calls your saved bots (`.bot summon saved`) when you are alone (already in a group, it uses that group and never changes it), makes the group a raid if needed, sets formation and spacing, and starts a ready check once the bots have buffed. On login the add-on greets the server once (a self-whisper under the `FBOTS` prefix). A player whose client does not greet within 30 seconds gets one chat line with the download link (`Playerbot.AddonHint.*` in the module config). @@ -97,7 +97,8 @@ where the client offers `Menu.ModifyMenu` (untested here); the legacy UnitPopupM The window stays where you put it and stays open (it is not closed by Escape, clicks, combat or target changes; its open state survives /reload and relog). `/fb` toggles it, or use the X button. `/fb fallback`, `/fb pullback`, `/fb rally`, `/fb formation circle|arrow|line|none`, `/fb spacing tight|close|spread`, `/fb distance <1-20>` and `/fb maintank [name]` and `/fb tank |clear` work without the window. -The `.bot` commands need a GM account (gm level 3 on the realm). +The `.bot` commands for your own bots (add, call, dismiss, save, list, regear and the rest) work for every account; no GM account is needed. Only `.bot world`, `.bot bgstress`, `.bot bgsoak` and `.bot itemstats` are GM. Key bindings (0.2.2): Esc > Options > Key Bindings > AddOns > "WoW Forever Bots". Unbound by default; one entry each for Attack, Pull, Pull back, Follow, Stay, Resume, Stop attacking, Flee, Come, Fall back, Toggle stance and Show / hide the bot window. The order keys send the same line as the window buttons and work in combat. + Attack (mouseover) key: hover a mob and press it; the mob becomes your target and the bots attack it. Group pings (the ping wheel, if your client has one): an Attack ping on an enemy sends the bots in, an On my way ping on the ground sends them there. Needs a server with the ping hooks. diff --git a/src/modules/PlayerbotV2/Api/BotTrade.h b/src/modules/PlayerbotV2/Api/BotTrade.h index 7744cc7e89..16e1770a97 100644 --- a/src/modules/PlayerbotV2/Api/BotTrade.h +++ b/src/modules/PlayerbotV2/Api/BotTrade.h @@ -71,6 +71,7 @@ struct Line std::uint32_t count = 0; std::uint64_t value = 0; // fair price of the whole stack bool upgrade = false; // equippable and better than what the bot wears there (only meaningful on the player's side) + bool reagent = false; // a reagent of a recipe the bot knows: a gift from the owner or a group mate, so "trade them to me and ask again" works }; struct View @@ -119,17 +120,17 @@ struct Action Say say = Say::None; }; -inline bool AllUpgrades(std::vector const& v) +inline bool AllGifts(std::vector const& v) { for (Line const& l : v) - if (!l.upgrade) return false; + if (!l.upgrade && !l.reagent) return false; return true; } -inline bool AnyUpgrade(std::vector const& v) +inline bool AnyGift(std::vector const& v) { for (Line const& l : v) - if (l.upgrade) return true; + if (l.upgrade || l.reagent) return true; return false; } @@ -170,15 +171,15 @@ inline Action Decide(View const& v) return {}; } - // Gear that is an upgrade, from the owner or a group mate: a gift. - if (v.gift_partner && AllUpgrades(v.his) && v.mine.empty() && v.my_money == 0) + // Gear that is an upgrade, or reagents for a recipe the bot knows, from the owner or a group mate: a gift. + if (v.gift_partner && AllGifts(v.his) && v.mine.empty() && v.my_money == 0) { if (!v.his_accepted || v.my_accepted) return {}; return v.bot_has_room ? Action{ Act::Accept } : Action{ Act::Cancel, 0, Say::NoRoom }; } // A mix of gifts and goods, or goods and gold from the player at once, is not a deal the bot can price. - if (v.his_money > 0 || (v.gift_partner && AnyUpgrade(v.his))) + if (v.his_money > 0 || (v.gift_partner && AnyGift(v.his))) return { Act::Wait, 0, Say::OneWay }; // Buy from the player at the fair price. diff --git a/src/modules/PlayerbotV2/Api/BotTradeShop.cpp b/src/modules/PlayerbotV2/Api/BotTradeShop.cpp index ed33db869c..50d0e368f8 100644 --- a/src/modules/PlayerbotV2/Api/BotTradeShop.cpp +++ b/src/modules/PlayerbotV2/Api/BotTradeShop.cpp @@ -9,6 +9,8 @@ #include "Log.h" #include "ObjectMgr.h" #include "Player.h" +#include "SpellInfo.h" +#include "SpellMgr.h" #include "TradeData.h" #include "TradePackets.h" #include "WorldSession.h" @@ -211,6 +213,23 @@ std::vector Describe(std::vector const& list) namespace { +// Is `entry` a reagent of a recipe (a spell that makes an item) the bot knows? Reagents the owner hands over for a craft order are a gift. +bool IsRecipeReagent(Player const* bot, uint32 entry) +{ + for (auto const& [spell_id, ps] : bot->GetSpellMap()) + { + if (ps.state == PLAYERSPELL_REMOVED || !ps.active || ps.disabled) + continue; + SpellInfo const* si = sSpellMgr->GetSpellInfo(spell_id, DIFFICULTY_NONE); + if (!si || !si->HasEffect(SPELL_EFFECT_CREATE_ITEM)) + continue; + for (std::size_t i = 0; i < si->Reagent.size(); ++i) + if (si->Reagent[i] > 0 && si->ReagentCount[i] > 0 && uint32(si->Reagent[i]) == entry) + return true; + } + return false; +} + BotTrade::Line LineOf(Player const* viewer_for_price, Item* it, uint64 unit) { (void)viewer_for_price; @@ -235,7 +254,11 @@ std::vector Lines(Player* bot, TradeData* side, bool mark_upgrad for (size_t i = 0; i < items.size(); ++i) { BotTrade::Line l = LineOf(bot, items[i], unit[i]); - if (mark_upgrades) l.upgrade = IsUpgrade(bot, items[i]->GetTemplate()); + if (mark_upgrades) + { + l.upgrade = IsUpgrade(bot, items[i]->GetTemplate()); + l.reagent = IsRecipeReagent(bot, items[i]->GetEntry()); + } out.push_back(l); } if (items_out) *items_out = std::move(items); diff --git a/src/modules/PlayerbotV2/Api/FollowDrop.h b/src/modules/PlayerbotV2/Api/FollowDrop.h new file mode 100644 index 0000000000..fc1a70f9f7 --- /dev/null +++ b/src/modules/PlayerbotV2/Api/FollowDrop.h @@ -0,0 +1,149 @@ +// Following an owner who left the bot's level by dropping or jumping: where the bot leaves the ledge and where it lands. +// +// the owner: he jumped down into the Blackrock Stadium (about 11 y lower) and his bots stayed on the level above, 26 to 46 y +// away. The follow only knows the walking route, which here leads round through the Blackhand packs, so they walked into them and died. +// A player takes the short way: off the ledge. This is that decision as a pure function over a ground-height probe and a line-of-sight +// probe (templated, so tests/game/ClassicFollowDrop.cpp runs it on a plain height map). Used by API::move_to with follow_drop set. +// +// The caller has already found that the walking route to the owner is missing or a long detour (`walk_is_fine` false) and that the +// owner is within reach. The plan fans bearings from the bot toward the owner, walks each ray over ground that stays level until it +// drops off, then looks for a landing on the owner's floor just past that edge: +// Drop: the landing is 4 y or more below the edge (a committed drop, API::move_to drop=true). +// Leap: the landing is level with the edge but past a gap that is at most kLeapMax wide (a jump a player makes across a gap). +// Of all the candidates the one that ends nearest the owner (plus half the walk to its edge) wins. +#pragma once + +#include +#include +#include + +namespace Playerbot::FollowDrop +{ + struct Vec { float x = 0.f, y = 0.f, z = 0.f; }; + + enum class Mode : uint8_t { None, Walk, Drop, Leap }; + + inline char const* ModeName(Mode m) + { + switch (m) + { + case Mode::Walk: return "walk"; + case Mode::Drop: return "drop"; + case Mode::Leap: return "leap"; + default: return "none"; + } + } + + struct Plan + { + Mode mode = Mode::None; + Vec ledge; // where the bot leaves the ground (the last level point on the ray) + Vec land; // where it comes down + float walk = 0.f; // yards from the bot to the ledge + bool leap = false; // the crossing is a Leap (level jump over a gap), otherwise a Drop + }; + + constexpr float kMaxOwnerDistXY = 50.0f; // how far from the owner a bot still looks for a ledge + constexpr float kMaxRay = 30.0f; // how far the bot looks for an edge along a bearing + constexpr float kRayStep = 1.0f; + constexpr float kLedgeDrop = 3.0f; // ground this much lower than the last step is an edge + constexpr float kStepUp = 1.5f; // ground this much higher is a wall or a rail: the bearing is blocked + constexpr float kMinFall = 4.0f; // a Drop falls at least this far (API::move_to drop=true refuses less) + constexpr float kMaxFall = 40.0f; + constexpr float kOwnerFloorTol = 3.5f; // a landing counts as the owner's floor within this much height + constexpr float kLeapMax = 8.0f; // the widest gap a bot leaps (a player's jump) + constexpr float kLeapLevelTol = 3.0f; // a Leap lands within this much of the edge height + constexpr float kArriveYd = 2.5f; // this close to the ledge the bot leaves it + constexpr float kWalkWeight = 0.5f; + + // ground(x, y, z_hint, z_out) -> bool: the highest walkable surface at or a little above z_hint, searching down; false when none. + // clear(a, b) -> bool: the straight line from a to b is free of walls. + template + Plan PlanFollowDrop(Vec const& bot, Vec const& owner, bool walk_is_fine, GroundFn&& ground, ClearFn&& clear) + { + Plan best; + if (walk_is_fine) + return best; + float const odx = owner.x - bot.x, ody = owner.y - bot.y; + float const owner_dxy = std::sqrt(odx * odx + ody * ody); + if (owner_dxy > kMaxOwnerDistXY || owner_dxy < 1.0f) + return best; + + constexpr float kPi = 3.14159265358979f; + constexpr float kDeg = kPi / 180.0f; + float const base = std::atan2(ody, odx); + float offsets[15]; + { + int n = 0; + offsets[n++] = 0.f; + for (int k = 1; k <= 7; ++k) { offsets[n++] = float(k) * 15.f * kDeg; offsets[n++] = -float(k) * 15.f * kDeg; } + } + float const landing_d[] = { 2.f, 3.f, 4.f, 5.f, 6.f, 8.f, 10.f, 12.f, 15.f }; + float best_cost = 1e9f; + + for (float off : offsets) + { + float const b = base + off; + float const cx = std::cos(b), cy = std::sin(b); + float cz = bot.z; + Vec prev = bot; + bool edge = false; + int const steps = int(std::min(kMaxRay, owner_dxy + 6.0f) / kRayStep); + for (int i = 1; i <= steps; ++i) + { + float const qx = bot.x + cx * kRayStep * float(i); + float const qy = bot.y + cy * kRayStep * float(i); + float g = 0.f; + bool const ok = ground(qx, qy, cz, g); + if (!ok || cz - g > kLedgeDrop) { edge = true; break; } + if (g - cz > kStepUp) break; // a wall or a rail ahead + cz = g; + prev = { qx, qy, g }; + } + if (!edge) + continue; + Vec const ledge = prev; + float const wdx = ledge.x - bot.x, wdy = ledge.y - bot.y; + float const walk = std::sqrt(wdx * wdx + wdy * wdy); + // The way to the edge must be open (a wall between would have been a step up, but a thin one can slip between the samples). + if (walk > 0.5f && !clear(Vec{ bot.x, bot.y, bot.z + 1.5f }, Vec{ ledge.x, ledge.y, ledge.z + 1.5f })) + continue; + + for (float d : landing_d) + { + Vec land{ ledge.x + cx * d, ledge.y + cy * d, 0.f }; + float lz = 0.f; + if (!ground(land.x, land.y, owner.z + 1.0f, lz)) + continue; + if (std::fabs(lz - owner.z) > kOwnerFloorTol) + continue; // not the owner's floor + land.z = lz; + float const fall = ledge.z - lz; + bool leap = false; + if (fall >= kMinFall && fall <= kMaxFall) + leap = false; + else if (std::fabs(fall) <= kLeapLevelTol && d <= kLeapMax) + leap = true; + else + continue; + // The chord leaves the lip a little ahead of it so the edge itself does not count as a wall. + Vec const from{ ledge.x + cx * 0.5f, ledge.y + cy * 0.5f, ledge.z + 1.5f }; + if (!clear(from, Vec{ land.x, land.y, land.z + 1.5f })) + continue; + float const ldx = land.x - owner.x, ldy = land.y - owner.y; + float const cost = std::sqrt(ldx * ldx + ldy * ldy) + kWalkWeight * walk; + if (cost < best_cost) + { + best_cost = cost; + best.ledge = ledge; + best.land = land; + best.walk = walk; + best.leap = leap; + best.mode = walk <= kArriveYd ? (leap ? Mode::Leap : Mode::Drop) : Mode::Walk; + } + break; // the nearest valid landing on this bearing + } + } + return best; + } +} diff --git a/src/modules/PlayerbotV2/Api/PlayerbotAPI.cpp b/src/modules/PlayerbotV2/Api/PlayerbotAPI.cpp index 0cdf6c6f0c..8ccbcc9157 100644 --- a/src/modules/PlayerbotV2/Api/PlayerbotAPI.cpp +++ b/src/modules/PlayerbotV2/Api/PlayerbotAPI.cpp @@ -6,10 +6,12 @@ #include #include "PlayerbotAPI.h" #include "ClassicBotSkills.h" +#include "Travel/ReachMemory.h" #include "ClassicSpec.h" #include "ClassicTalentBuilds.h" #include "ClassicSupplies.h" #include "Bot/ClassicUpkeep.h" +#include "Bot/Raid/ShieldRules.h" #include "BotItemScorer.h" #include "Player.h" #include "Corpse.h" @@ -42,6 +44,9 @@ #include "DetourNavMeshQuery.h" #include "PlayerbotV2.h" // path-outcome telemetry, bot-leader battleground queue #include "PlayerbotMovement.h" // unified bot-movement helpers +#include "FollowDrop.h" // follow_drop: ledge plan toward an owner who dropped or jumped down +#include "Fleet/CityLayer.h" // same-level moves across a drop, NoPath storm +#include "Bot/World/ZonePicker.h" // IsVanillaCapitalZone #include "Fleet/InstanceEntry.h" // PrepareInstanceEntry: a stale raid lock must not keep a companion out of its owner's instance #include "PartialRouteStall.h" #include "NoMotionGuard.h" @@ -115,6 +120,106 @@ namespace Playerbot { // callers below read naturally. using BotMovement::SehSafeCalculatePath; +// Follow-drop planning (move_to follow_drop): the walking-route verdict, then the ledge plan (Api/FollowDrop.h). World thread. +namespace +{ + // Per bot: until when the follow is a ledge walk or a flight (API::follow_drop_acted), and until when a leap or drop is in the air. + std::unordered_map s_followDropActive; + std::unordered_map s_followDropAir; + std::unordered_map s_followDropFine; + + struct FollowDropPlan + { + FollowDrop::Mode mode = FollowDrop::Mode::None; + FollowDrop::Vec ledge, land; + bool route_fine = false; // the walking route to the owner is fine: the ordinary pathed move is the follow + }; + + FollowDropPlan PlanFollowDropFor(Player* p, float ox, float oy, float oz) + { + FollowDropPlan out; + if (!p->IsAlive() || p->IsFlying() || p->IsInFlight() || p->GetVehicle() || p->GetTransport() || p->IsInWater() || p->IsFalling() || + p->IsMounted()) + return out; + float const bx = p->GetPositionX(), by = p->GetPositionY(), bz = p->GetPositionZ(); + // Cheap gate: the owner is lower by a real drop, or about level (a gap). A bot already close to him just follows. + float const dxy = std::sqrt((ox - bx) * (ox - bx) + (oy - by) * (oy - by)); + if (dxy > FollowDrop::kMaxOwnerDistXY || dxy < 6.0f || bz - oz < -3.0f) + return out; + // The owner's floor is the ground under him, not his height now: a snapshot taken while he is still falling (his jump) put him + // 8 y above the arena floor, no landing matched, and four bots took "no ledge" and walked the long way. + { + float fg = 0.f; + if (BotMovement::ProbeGround(p, ox, oy, oz, fg) && fg < oz) + oz = fg; + } + + // The walking route is judged once a second per bot: fine (a normal path not much longer than the straight line) or not. + struct Verdict { uint32 at = 0; bool fine = true; }; + static std::unordered_map s_verdict; + uint32 const now = GameTime::GetGameTimeMS(); + Verdict& v = s_verdict[p->GetGUID().GetCounter()]; + if (v.at == 0 || now - v.at >= 1000u) + { + v.at = now ? now : 1u; + PathGenerator path(p); + path.SetDisableRoadBonus(true); + bool const ok = SehSafeCalculatePath(path, ox, oy, oz); + PathType const pt = path.GetPathType(); + bool fine = false; + if (ok && (pt & PATHFIND_NORMAL) && !(pt & PATHFIND_NOPATH) && !(pt & PATHFIND_INCOMPLETE) && !(pt & PATHFIND_SHORTCUT) && !(pt & PATHFIND_SHORT)) + { + float len = 0.f; + auto const& pts = path.GetPath(); + for (size_t i = 1; i < pts.size(); ++i) + len += std::sqrt((pts[i].x - pts[i - 1].x) * (pts[i].x - pts[i - 1].x) + (pts[i].y - pts[i - 1].y) * (pts[i].y - pts[i - 1].y) + + (pts[i].z - pts[i - 1].z) * (pts[i].z - pts[i - 1].z)); + float const straight = std::sqrt(dxy * dxy + (bz - oz) * (bz - oz)); + fine = len <= 2.0f * straight + 15.0f; + } + v.fine = fine; + } + if (v.fine) + { + out.route_fine = true; + return out; + } + + FollowDrop::Plan const plan = FollowDrop::PlanFollowDrop( + FollowDrop::Vec{ bx, by, bz }, FollowDrop::Vec{ ox, oy, oz }, false, + [p](float x, float y, float hint, float& z) { return BotMovement::ProbeGround(p, x, y, hint, z); }, + [p](FollowDrop::Vec const& a, FollowDrop::Vec const& b) { return BotMovement::LineIsClear(p, a.x, a.y, a.z, b.x, b.y, b.z); }); + if (plan.mode == FollowDrop::Mode::None) + { + static std::unordered_map s_noLedgeLog; + uint32& at = s_noLedgeLog[p->GetGUID().GetCounter()]; + if (at == 0 || now - at >= 10000u) + { + at = now ? now : 1u; + TC_LOG_INFO("playerbot.v2", "[follow_drop] {} found no ledge toward the owner: bot=({:.1f},{:.1f},{:.1f}) owner=({:.1f},{:.1f},{:.1f}) dist={:.1f}", + p->GetName(), bx, by, bz, ox, oy, oz, dxy); + } + return out; + } + if (plan.mode == FollowDrop::Mode::Walk) + { + static std::unordered_map s_walkLog; + uint32& at = s_walkLog[p->GetGUID().GetCounter()]; + if (at == 0 || now - at >= 3000u) + { + at = now ? now : 1u; + TC_LOG_INFO("playerbot.v2", "[follow_drop] {} walks to the ledge ({}): ledge=({:.1f},{:.1f},{:.1f}) {:.1f} y away, owner=({:.1f},{:.1f},{:.1f})", + p->GetName(), plan.leap ? "leap" : "drop", plan.ledge.x, plan.ledge.y, plan.ledge.z, plan.walk, ox, oy, oz); + } + } + out.mode = plan.mode; + out.ledge = plan.ledge; + out.land = plan.land; + return out; + } +} + + // Per-world-tick pathfinding budget (declared PlayerbotAPI.h). World-thread only, // no synchronization. g_active gates the window: outside a Begin/End pair (e.g. a // non-DrainIntents caller of move_to) HasBudget fails OPEN so nothing is throttled @@ -180,6 +285,23 @@ namespace { ring.head = (ring.head + 1) % kPathFailCap; } + // The shared memory of walks that cannot be done (Travel/ReachMemory.h): only for an ungrouped bot walking the open world, where a + // failed path is geometry; a group, a battleground or an instance has its own holding logic and its own off-mesh bridges. + bool ReachMemoryApplies(Player const* p) + { + return p && !p->GetGroup() && !p->InBattleground() && p->GetMap() && !p->GetMap()->IsDungeon(); + } + void NoteReachFail(Player const* p, float x, float y, uint32 now_ms) + { + if (ReachMemoryApplies(p)) + ::Playerbot::V2::Travel::ReachMemory::Instance().NoteFail(p->GetMapId(), p->GetPositionX(), p->GetPositionY(), x, y, now_ms); + } + void NoteReachOk(Player const* p, float x, float y) + { + if (ReachMemoryApplies(p)) + ::Playerbot::V2::Travel::ReachMemory::Instance().NoteOk(p->GetMapId(), p->GetPositionX(), p->GetPositionY(), x, y); + } + inline uint64 PathDestKey(uint32 map_id, float x, float y) { // 5y buckets — angle jitter within ~5y still re-tries; persistent @@ -497,6 +619,11 @@ static bool FaceUnitForCast(Player* p, Unit* tu) return p->HasInArc(static_cast(M_PI), tu); } +uint32 API::highest_known_rank(uint32 spell_id) const +{ + return p_ && spell_id ? HighestKnownRank(p_, spell_id) : spell_id; +} + uint32 API::cast_ready_in_ms(uint32 spell_id, bool exact_rank) const { if (!p_ || !spell_id || !p_->GetMap()) @@ -678,9 +805,14 @@ Result API::cast_spell(uint32 spell_id, ObjectGuid target, bool exact_rank) // Mob versions (Reflective Shield variants) trigger the same // SPELL_AURA_REFLECT_SPELLS aura type, so the type check below // catches everything without needing an ID allowlist. + // Only a spell the aura can send back is refused (Spell::m_canReflect): an ability such as Sunder Armor, Revenge or Taunt is never + // reflected, and refusing it cost the tanks their threat on Majordomo's Magic Reflection adds (ShieldRules.h). if (tu != p_ && p_->IsValidAttackTarget(tu, info) && !info->IsPositive() && - tu->HasAuraType(SPELL_AURA_REFLECT_SPELLS)) + tu->HasAuraType(SPELL_AURA_REFLECT_SPELLS) && + Playerbot::Raid::Shields::ReflectRefuses(info->DmgClass == SPELL_DAMAGE_CLASS_MAGIC, info->HasAttribute(SPELL_ATTR0_IS_ABILITY), + info->HasAttribute(SPELL_ATTR7_ALLOW_SPELL_REFLECTION), info->HasAttribute(SPELL_ATTR1_NO_REFLECTION), + info->HasAttribute(SPELL_ATTR0_NO_IMMUNITIES), info->IsPassive())) { TC_LOG_DEBUG("playerbot.api", "[API::cast_spell] spell {} target {} rejected: target has Spell Reflect aura", @@ -975,7 +1107,23 @@ float API::ground_z(float x, float y, float z_hint, char const* where) return BotMovement::GroundZ(p_, x, y, z_hint, where); } -Result API::move_to(float x, float y, float z, bool run, bool direct, bool drop) +bool API::follow_drop_route_fine() const +{ + if (!p_) + return false; + auto const it = s_followDropFine.find(p_->GetGUID().GetCounter()); + return it != s_followDropFine.end() && GameTime::GetGameTimeMS() < it->second; +} + +bool API::follow_drop_acted() const +{ + if (!p_) + return false; + auto const it = s_followDropActive.find(p_->GetGUID().GetCounter()); + return it != s_followDropActive.end() && GameTime::GetGameTimeMS() < it->second; +} + +Result API::move_to(float x, float y, float z, bool run, bool direct, bool drop, bool follow_drop) { if (!p_) return Result::Other; @@ -1078,6 +1226,60 @@ Result API::move_to(float x, float y, float z, bool run, bool direct, bool drop) FLIGHT_MOTION_TYPE) return Result::Locked; + // Follow the owner off a ledge. (x,y,z) is the owner. When his floor is only reached by a drop or a jump (he + // dropped 11 y into the arena and his bots, with only the walking route, went round through the Blackhand packs and died) and the walking + // route to him is missing or a long detour, walk to the nearest ledge and leave it; otherwise fall through to the ordinary pathed move. + if (follow_drop && !direct && !drop) + { + uint64 const fdg = p_->GetGUID().GetCounter(); + uint32 const fdnow = GameTime::GetGameTimeMS(); + // In the air after leaving a ledge: nothing may re-aim the bot until it lands. + if (auto it = s_followDropAir.find(fdg); it != s_followDropAir.end() && fdnow < it->second) + { + s_followDropActive[fdg] = fdnow + 500u; + return Result::Ok; + } + FollowDropPlan const fd = PlanFollowDropFor(p_, x, y, z); + s_followDropActive[fdg] = 0; + s_followDropFine[fdg] = fd.route_fine ? fdnow + 1000u : 0u; + if (fd.mode == FollowDrop::Mode::Walk) + { + s_followDropActive[fdg] = fdnow + 2500u; + p_->GetMotionMaster()->MovePoint(0, fd.ledge.x, fd.ledge.y, fd.ledge.z, /*generatePath*/ false); + return Result::Ok; + } + if (fd.mode == FollowDrop::Mode::Drop) + { + TC_LOG_INFO("playerbot.v2", "[follow_drop] {} drops to the owner's floor: ledge=({:.1f},{:.1f},{:.1f}) landing=({:.1f},{:.1f},{:.1f}) owner=({:.1f},{:.1f},{:.1f})", + p_->GetName(), fd.ledge.x, fd.ledge.y, fd.ledge.z, fd.land.x, fd.land.y, fd.land.z, x, y, z); + Result const dr = move_to(fd.land.x, fd.land.y, fd.land.z, true, false, /*drop*/ true); + if (dr == Result::Ok) + { + s_followDropActive[fdg] = fdnow + 2500u; + s_followDropAir[fdg] = fdnow + 3500u; + } + return dr; + } + if (fd.mode == FollowDrop::Mode::Leap) + { + static std::unordered_map s_leapUntil; + uint64 const lg = p_->GetGUID().GetCounter(); + uint32 const lnow = GameTime::GetGameTimeMS(); + if (auto it = s_leapUntil.find(lg); it != s_leapUntil.end() && lnow < it->second) + return Result::Locked; // already in the air + s_leapUntil[lg] = lnow + 2500u; + s_followDropActive[lg] = lnow + 2500u; + s_followDropAir[lg] = lnow + 2500u; + Position dest = p_->GetPosition(); + dest.Relocate(fd.land.x, fd.land.y, fd.land.z); + p_->SetFacingTo(std::atan2(fd.land.y - p_->GetPositionY(), fd.land.x - p_->GetPositionX())); + p_->GetMotionMaster()->MoveJump(/*id*/ 0, dest, /*speedXY*/ 7.0f); + TC_LOG_INFO("playerbot.v2", "[follow_drop] {} leaps the gap to the owner's side: ledge=({:.1f},{:.1f},{:.1f}) landing=({:.1f},{:.1f},{:.1f}) owner=({:.1f},{:.1f},{:.1f})", + p_->GetName(), fd.ledge.x, fd.ledge.y, fd.ledge.z, fd.land.x, fd.land.y, fd.land.z, x, y, z); + return Result::Ok; + } + } + // Already there. A rule holding a spot (raid/dungeon positioning, hold, // stand-at-NPC) keeps re-emitting the same destination after arrival; the // emitter dedup lets one through every ~1.5s and MovePoint then launches @@ -1167,7 +1369,39 @@ Result API::move_to(float x, float y, float z, bool run, bool direct, bool drop) // Ground height first, searched from above the hint: a slot built from the // owner's / mob's / anchor's Z next to a rock or ledge higher than the hint // would resolve to the terrain under the collision mesh (bot embedded). + float const z_ask = z; z = BotMovement::GroundZ(p_, x, y, z, "move_to"); + // A world bot in a capital asking for its own level (the chunked walks and the wanderers pass the bot's z) whose destination has its + // ground 20+ y lower: the capital stands on layers (Stormwind: the city floor at z 94 to 100, others at z 75 and z 59 under it, + // joined only by steep faces). The ground probe would put the goal on the lower layer and the path would take the bot down the + // face, where the town's hubs cannot be reached. The ask is + // refused like a blocked path, so the rule picks another bearing. + if (!p_->GetGroup() && !p_->IsInFlight() && !p_->GetTransport() && p_->GetMap() && !p_->GetMap()->IsDungeon() + && !p_->GetMap()->IsBattlegroundOrArena() && ::Playerbot::V2::World::IsVanillaCapitalZone(p_->GetZoneId()) + && ::Playerbot::V2::Fleet::AcrossDrop(p_->GetPositionZ(), z_ask, z) + && !([&] + { + // The ground probe sees terrain and static models, the mover walks the navmesh. Where the mesh has a walkable surface at the + // asked level the ask is a request for that surface (a balcony or a roof with open air under it, not a drop): keep the level. + Position np; + if (!::Playerbot::BotMovement::NearestNavPoint(p_, x, y, z_ask, 3.0f, 6.0f, np)) + return false; + z = np.GetPositionZ(); + return true; + }())) + { + static std::unordered_map s_guardAt; + uint32 const gnow = GameTime::GetGameTimeMS(); + uint32& gat = s_guardAt[p_->GetGUID().GetCounter()]; + if (gat == 0 || gnow - gat >= 10000u) + { + gat = gnow ? gnow : 1u; + TC_LOG_INFO("playerbot.v2", "[level_guard] {} refused a same-level move across a drop: z={:.1f} dst=({:.1f},{:.1f}) ground={:.1f}", + p_->GetName(), z_ask, x, y, z); + } + NotePathFail(p_, PathDestKey(p_->GetMapId(), x, y), GameTime::GetGameTimeMS()); + return Result::Locked; + } BotMovement::SnapToGround(p_, x, y, z); // Battleground start room (STATUS_WAIT_JOIN): the gates are shut and the bots only mill about their start area, so a @@ -1317,8 +1551,11 @@ Result API::move_to(float x, float y, float z, bool run, bool direct, bool drop) !Playerbot::BotMovement::NoMotionAllows(g_no_motion[p_->GetGUID().GetCounter()], move_goal_key, p_->GetPositionX(), p_->GetPositionY(), GameTime::GetGameTimeMS())) { - TC_LOG_INFO("playerbot.v2", "[move_abandon] {} asked for ({:.0f},{:.0f},{:.0f}) for over 30 s without moving; goal dropped", - p_->GetName(), x, y, z); + TC_LOG_INFO("playerbot.v2", "[move_abandon] {} asked for ({:.0f},{:.0f},{:.0f}) for over 30 s without moving; goal dropped " + "(at {:.0f},{:.0f},{:.0f} motion={} casting={} sitting={} rooted={} stunned={} combat={} path_fail_recent={})", + p_->GetName(), x, y, z, p_->GetPositionX(), p_->GetPositionY(), p_->GetPositionZ(), int(p_->GetMotionMaster()->GetCurrentMovementGeneratorType()), + p_->HasUnitState(UNIT_STATE_CASTING), p_->GetStandState() != UNIT_STAND_STATE_STAND, p_->HasUnitState(UNIT_STATE_ROOT), + p_->HasUnitState(UNIT_STATE_STUNNED), p_->IsInCombat(), PathFailedRecently(p_, PathDestKey(p_->GetMapId(), x, y), GameTime::GetGameTimeMS())); NotePathFail(p_, PathDestKey(p_->GetMapId(), x, y), GameTime::GetGameTimeMS(), kPathFailTtlLongMs); return Result::Locked; } @@ -1347,6 +1584,13 @@ Result API::move_to(float x, float y, float z, bool run, bool direct, bool drop) } return Result::Locked; } + // The same walk failed for other bots from this part of the map: no Detour call for it (Travel/ReachMemory.h). + if (ReachMemoryApplies(p_) && + ::Playerbot::V2::Travel::ReachMemory::Instance().KnownUnreachable(p_->GetMapId(), p_->GetPositionX(), p_->GetPositionY(), x, y, move_now_ms)) + { + NotePathFail(p_, dest_key, move_now_ms, kPathFailTtlLongMs); // this bot's own rules stop asking for it too + return Result::Locked; + } } // Per-world-tick pathfinding budget. Once this tick's bot-pathfinding window @@ -1650,10 +1894,47 @@ Result API::move_to(float x, float y, float z, bool run, bool direct, bool drop) p_->GetPositionY(), x, y, z); Playerbot::V2::Module::instance().OnPathOutcome(1 /*NoPath*/); log_path_fail("NoPath"); + BotMovement::NoteNoPath(p_); NotePathFail(p_, PathDestKey(p_->GetMapId(), x, y), GameTime::GetGameTimeMS(), kPathFailTtlLongMs); + NoteReachFail(p_, x, y, GameTime::GetGameTimeMS()); + NoteReachFail(p_, x, y, GameTime::GetGameTimeMS()); return Result::Locked; } + // Retry at the polygon found, for a destination that lies just off the mesh. A chunk step is aimed at a point on the bot's own level a + // stride ahead, so it often lands a few yards off a road, on a slope above or below it, or on another level of the same x,y. Detour then + // builds the corridor to the nearest polygon and flags the end as far from its polygon (6298 of these in; 1271 + // ended on the asked x,y at another height, 1250 within 3 to 30 y of it at much the same height). Where that polygon is within a + // stride's slack of the ask, walk to it: ask again at its x,y,z. A corridor that crosses a cliff face is still refused, and so are + // destinations whose nearest polygon is farther off (void, a wall, the far side of a gorge). + if (path_ok && (pt & PATHFIND_FARFROMPOLY_END) && !(pt & PATHFIND_NOPATH) && p_->GetMap() && !p_->GetMap()->IsDungeon() + && !p_->GetMap()->IsBattlegroundOrArena()) + { + G3D::Vector3 const ae = path.GetActualEndPosition(); + float const off_end = std::hypot(ae.x - x, ae.y - y); + float const dz_end = ae.z - z; + // In a capital the layers lie 20 to 40 y apart (Stormwind): a polygon that far from the asked height is another level, not a + // slope (Hellice, on a roof at z 148.6, was snapped to a polygon 20 to 35 y below it). + float const max_dz = ::Playerbot::V2::World::IsVanillaCapitalZone(p_->GetZoneId()) ? ::Playerbot::V2::Fleet::kCityDropYards : 60.0f; + if (off_end <= 12.0f && std::fabs(dz_end) < max_dz && !::Playerbot::V2::Fleet::PathHasCliff(path.GetPath())) + { + if (SehSafeCalculatePath(path, ae.x, ae.y, ae.z) && !(path.GetPathType() & (PATHFIND_NOPATH | PATHFIND_FARFROMPOLY_END))) + { + float const ox = x, oy = y, oz = z; + pt = path.GetPathType(); + x = ae.x; y = ae.y; z = ae.z; + static std::unordered_map s_snapAt; + uint32 const snow = GameTime::GetGameTimeMS(); + uint32& sat = s_snapAt[p_->GetGUID().GetCounter()]; + if (sat == 0 || snow - sat >= 10000u) + { + sat = snow ? snow : 1u; + TC_LOG_INFO("playerbot.v2", "[far_end_snap] {} asked ({:.1f},{:.1f},{:.1f}), mesh at ({:.1f},{:.1f},{:.1f}), {:.1f} y off", + p_->GetName(), ox, oy, oz, x, y, z, off_end); + } + } + } + } if (pt & PATHFIND_FARFROMPOLY_END) { if (dbg_gap1) @@ -1666,11 +1947,13 @@ Result API::move_to(float x, float y, float z, bool run, bool direct, bool drop) return Result::Ok; Playerbot::V2::Module::instance().OnPathOutcome(3 /*FarFromPolyEnd*/); log_path_fail("FarFromPolyEnd"); + BotMovement::NoteNoPath(p_); // Off-mesh destination (above terrain / inside geometry / a phantom POI // Z). Permanently unreachable until the data changes — suppress long so // the bot stops oscillating toward it and goal-selection moves on. NotePathFail(p_, PathDestKey(p_->GetMapId(), x, y), GameTime::GetGameTimeMS(), kPathFailTtlLongMs); + NoteReachFail(p_, x, y, GameTime::GetGameTimeMS()); return Result::Locked; } if (pt & PATHFIND_FARFROMPOLY_START) @@ -1806,10 +2089,15 @@ Result API::move_to(float x, float y, float z, bool run, bool direct, bool drop) x, y, z); float const forward_progress = cur_to_dst - end_to_dst; - log_path_fail("Incomplete"); - TC_LOG_INFO("playerbot.v2", - "[path_fail] {} Incomplete forward_progress={:.1f}y (cur_to_dst={:.1f} end_to_dst={:.1f})", - p_->GetName(), forward_progress, cur_to_dst, end_to_dst); + // A partial path that gets 5 y or more closer is the normal way a long or winding route is walked (74 polygons a call): 79000 such + // lines an hour in a long soak run, most of them not real stalls. Only the stalls are written at INFO. + if (forward_progress < kMinForwardProgressYards) + { + log_path_fail("Incomplete"); + TC_LOG_INFO("playerbot.v2", + "[path_fail] {} Incomplete forward_progress={:.1f}y (cur_to_dst={:.1f} end_to_dst={:.1f})", + p_->GetName(), forward_progress, cur_to_dst, end_to_dst); + } if (forward_progress < kMinForwardProgressYards) { @@ -1985,6 +2273,8 @@ Result API::move_to(float x, float y, float z, bool run, bool direct, bool drop) (cur_to_dst > 100.0f) ? kPathFailTtlMs : kPathFailTtlLongMs; NotePathFail(p_, PathDestKey(p_->GetMapId(), x, y), GameTime::GetGameTimeMS(), nonadv_ttl); + if (nonadv_ttl == kPathFailTtlLongMs) + NoteReachFail(p_, x, y, GameTime::GetGameTimeMS()); return Result::Locked; } // Advancing partial — drive to the REACHABLE endpoint Detour found, NOT @@ -2025,8 +2315,11 @@ Result API::move_to(float x, float y, float z, bool run, bool direct, bool drop) "[path_loop] {} {} partial routes toward ({:.0f},{:.0f},{:.0f}) without closing in " "(cur_to_dst={:.0f}); goal suppressed", p_->GetName(), Playerbot::BotMovement::kStallMaxPartials, x, y, z, cur_to_dst); + // The long window: a loop is geometry (Francoise, a goal in the Keep, 632 y and not one yard closer for an hour), and three + // seconds had the rule ask for the same goal again every ten. NotePathFail(p_, PathDestKey(p_->GetMapId(), x, y), - GameTime::GetGameTimeMS(), kPathFailTtlMs); + GameTime::GetGameTimeMS(), kPathFailTtlLongMs); + NoteReachFail(p_, x, y, GameTime::GetGameTimeMS()); return Result::Locked; } if (pts.size() >= 2) @@ -2110,7 +2403,10 @@ Result API::move_to(float x, float y, float z, bool run, bool direct, bool drop) } } else + { Playerbot::V2::Module::instance().OnPathOutcome(0 /*Ok*/); + NoteReachOk(p_, x, y); + } // Liquid safety gate. Classifies the destination POINT (not the tile/chunk // — a chunk is routinely half-water / half-dry) through the shared @@ -3759,8 +4055,13 @@ Result API::enter_area_trigger(uint32 area_trigger_id) WorldSession* sess = p_->GetSession(); if (!sess) return Result::Other; AreaTriggerTeleport const* dest = sObjectMgr->GetAreaTrigger(area_trigger_id); - if (dest && dest->Loc.GetMapId() != p_->GetMapId()) - V2::Fleet::PrepareInstanceEntry(p_, dest->Loc.GetMapId()); + last_instance_full_map_ = 0; + if (dest && dest->Loc.GetMapId() != p_->GetMapId() && + V2::Fleet::PrepareInstanceEntry(p_, dest->Loc.GetMapId()) == TRANSFER_ABORT_MAX_PLAYERS) + { + last_instance_full_map_ = dest->Loc.GetMapId(); + return Result::ServerRefused; + } WorldPackets::AreaTrigger::AreaTrigger packet{ WorldPacket(CMSG_AREA_TRIGGER) }; packet.AreaTriggerID = int32(area_trigger_id); packet.Entered = true; @@ -3833,8 +4134,15 @@ Result API::teleport_to(uint32 map_id, float x, float y, float z, float orientat if (p_->IsNonMeleeSpellCast(false, false, true)) return Result::Locked; // Into an instance (the owner's raid): the door checks run first so a refusal is logged with its reason, and a lock on // another instance is dropped for a companion that follows its owner in. - if (map_id != p_->GetMapId() && V2::Fleet::PrepareInstanceEntry(p_, map_id) != TRANSFER_ABORT_NONE) - return Result::ServerRefused; + last_instance_full_map_ = 0; + if (map_id != p_->GetMapId()) + { + TransferAbortReason const denied = V2::Fleet::PrepareInstanceEntry(p_, map_id); + if (denied == TRANSFER_ABORT_MAX_PLAYERS) + last_instance_full_map_ = map_id; + if (denied != TRANSFER_ABORT_NONE) + return Result::ServerRefused; + } // SafeTeleport probes the destination map (if loaded) for ground // height and snaps to ground+2 when the requested Z is >50y above // the queried floor (typical "stale POI / hand-curated coord" bug @@ -9078,6 +9386,15 @@ uint32 API::learn_riding_free() if (!p_ || p_->GetLevel() < 40) return 0; uint32 changed = 0; uint16 const target = p_->GetLevel() >= 60 ? 150 : 75; + // A bot a retail trainer pass raised past its level's tier (Journeyman at 40) goes back to the vanilla tier, tier spells included. + if (p_->GetSkillValue(SKILL_RIDING) > target) + { + p_->SetSkill(SKILL_RIDING, target / 75, target, target); + for (uint32 tier_spell : { 33391u, 34090u, 34091u, 90265u }) // Journeyman, Expert, Artisan, Master Riding + if (p_->HasSpell(tier_spell) && !(tier_spell == 33391u && target >= 150)) + p_->RemoveSpell(tier_spell, false, false); + ++changed; + } if (p_->GetSkillValue(SKILL_RIDING) < target) { if (!p_->HasSkill(SKILL_RIDING)) @@ -9097,19 +9414,113 @@ uint32 API::learn_riding_free() uint32 normal = 0, swift = 0; if (!RaceMountSpells(p_->GetRace(), normal, swift)) return changed; - uint32 const want = p_->GetLevel() >= 60 ? swift : normal; - if (known == want || (known && p_->GetLevel() < 60) || p_->HasSpell(swift)) + bool const epic = p_->GetLevel() >= 60; + uint32 want = epic ? swift : normal; + if (known == want || (known && !epic) || p_->HasSpell(swift)) return changed; if (!isMount(sSpellMgr->GetSpellInfo(want, DIFFICULTY_NONE))) { - TC_LOG_WARN("playerbot.api", "[API::riding] {}: mount spell {} for race {} is not a mount in this data", - p_->GetName(), want, uint32(p_->GetRace())); - return changed; + // The race's table spell is not a mount in this data: take the next mount of the race that is (the other vanilla ground mounts of the race, + // then its swift mount at 60). + std::vector alternatives; + switch (p_->GetRace()) + { + case RACE_HUMAN: alternatives = epic ? std::vector{ 23227, 23228 } : std::vector{ 472, 6648, 458 }; break; + case RACE_ORC: alternatives = epic ? std::vector{ 23251, 23252 } : std::vector{ 6653, 6654, 580 }; break; + case RACE_DWARF: alternatives = epic ? std::vector{ 23239, 23240 } : std::vector{ 6777, 6898, 6899 }; break; + case RACE_NIGHTELF: alternatives = epic ? std::vector{ 23219, 23338 } : std::vector{ 8394, 10789, 10792, 66847, 10793 }; break; + case RACE_UNDEAD_PLAYER: alternatives = epic ? std::vector{ 23246, 23247 } : std::vector{ 17463, 17464, 17462 }; break; + case RACE_TAUREN: alternatives = epic ? std::vector{ 23248, 23249 } : std::vector{ 18989, 18991, 18990 }; break; + case RACE_GNOME: alternatives = epic ? std::vector{ 23222, 23223 } : std::vector{ 17453, 10969, 10873 }; break; + case RACE_TROLL: alternatives = epic ? std::vector{ 23242, 23243 } : std::vector{ 10796, 10799, 8395 }; break; + default: break; + } + uint32 found = 0; + for (uint32 candidate : alternatives) + if (candidate != want && isMount(sSpellMgr->GetSpellInfo(candidate, DIFFICULTY_NONE))) + { + found = candidate; + break; + } + TC_LOG_WARN("playerbot.api", "[API::riding] {}: mount spell {} for race {} is not a mount in this data; {}", p_->GetName(), want, + uint32(p_->GetRace()), found ? fmt::format("using {}", found) : std::string("no other mount of the race is either")); + if (!found) + return changed; + want = found; } p_->LearnSpell(want, false); + if (!p_->HasSpell(want)) + { + TC_LOG_WARN("playerbot.api", "[API::riding] {}: learning mount spell {} did not take (race {} class {} level {})", p_->GetName(), want, + uint32(p_->GetRace()), uint32(p_->GetClass()), uint32(p_->GetLevel())); + return changed; + } return changed + 1; } +uint32 API::reset_to_starter_gear(bool& complete) +{ + complete = false; + if (!p_) return 0; + PlayerInfo const* info = sObjectMgr->GetPlayerInfo(p_->GetRace(), p_->GetClass()); + if (!info) return 0; + // Nothing is taken off before its replacement is known to fit: each starter item goes straight into its equipment slot (the swap check + // allows an occupied slot), the old piece in that slot is destroyed just before, and a piece that cannot be worn leaves the old one on. + // The slots the outfit does not use are cleared only when every piece went on, so a bot is never left bare. + uint32 removed = 0; + bool all = true; + std::array kept{}; + for (PlayerCreateInfoItem const& initial : info->item) + { + ItemTemplate const* tpl = sObjectMgr->GetItemTemplate(initial.item_id); + if (!tpl || tpl->GetClass() == ITEM_CLASS_CONTAINER || tpl->GetClass() == ITEM_CLASS_QUIVER) + continue; // the bot's bags and quivers stay as they are + if (tpl->GetInventoryType() == INVTYPE_NON_EQUIP || tpl->GetClass() == ITEM_CLASS_PROJECTILE) + { + ItemPosCountVec dest; + if (!p_->HasItemCount(initial.item_id, 1) && p_->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, initial.item_id, initial.item_amount) == EQUIP_ERR_OK) + p_->StoreNewItem(dest, initial.item_id, true); + continue; // food, drink and the like are a bonus, not part of the outfit + } + uint16 pos = 0; + InventoryResult const res = p_->CanEquipNewItem(NULL_SLOT, pos, initial.item_id, true); + uint8 const slot = uint8(pos & 0xFF); + if (res != EQUIP_ERR_OK || uint8(pos >> 8) != INVENTORY_SLOT_BAG_0 || slot >= EQUIPMENT_SLOT_END) + { + all = false; + TC_LOG_INFO("playerbot.v2", "[starter_outfit] {} cannot wear starter item {}: result {}", p_->GetName(), initial.item_id, uint32(res)); + continue; + } + if (Item* cur = p_->GetItemByPos(INVENTORY_SLOT_BAG_0, slot)) + { + if (cur->GetEntry() == initial.item_id) + { + kept[slot] = true; + continue; + } + p_->DestroyItem(INVENTORY_SLOT_BAG_0, slot, true); + ++removed; + } + if (p_->EquipNewItem(pos, initial.item_id, info->itemContext, true)) + kept[slot] = true; + else + { + all = false; + TC_LOG_INFO("playerbot.v2", "[starter_outfit] {} could not equip starter item {} in slot {}", p_->GetName(), initial.item_id, uint32(slot)); + } + p_->AutoUnequipOffhandIfNeed(); + } + if (all) + for (uint8 slot = EQUIPMENT_SLOT_START; slot < EQUIPMENT_SLOT_END; ++slot) + if (!kept[slot] && p_->GetItemByPos(INVENTORY_SLOT_BAG_0, slot)) + { + p_->DestroyItem(INVENTORY_SLOT_BAG_0, slot, true); + ++removed; + } + complete = all; + return removed; +} + Result API::trainer_buy_spell(ObjectGuid trainer_npc, uint32 spell_id) { if (!p_) return Result::Other; diff --git a/src/modules/PlayerbotV2/Api/PlayerbotAPI.h b/src/modules/PlayerbotV2/Api/PlayerbotAPI.h index 478d324732..39414e985d 100644 --- a/src/modules/PlayerbotV2/Api/PlayerbotAPI.h +++ b/src/modules/PlayerbotV2/Api/PlayerbotAPI.h @@ -157,6 +157,10 @@ public: CastRejectBeyondRange, }; uint32 last_cast_fail() const { return last_cast_fail_; } + // The instance map the last teleport_to / enter_area_trigger was refused for because it holds its most players (0: none). The + // rejoin rule waits for a slot instead of walking a full instance's entrance. + uint32 last_instance_full_map() const { return last_instance_full_map_; } + void clear_instance_full_map() { last_instance_full_map_ = 0; } static char const* CastFailName(uint32 code); // Why a mount spell would draw nothing on the client, nullptr when its model resolves: the display the aura picks (Mount @@ -171,6 +175,8 @@ public: // the spell's own cooldown and the global cooldown, read from the spell history. 0 when // nothing is running. Feeds the per-spell back-off after SPELL_FAILED_NOT_READY. uint32 cast_ready_in_ms(uint32 spell_id, bool exact_rank = false) const; + // The rank of `spell_id` cast_spell() would use: the highest one the player knows (spell_id itself when it knows none). + uint32 highest_known_rank(uint32 spell_id) const; // Cast a ground-target spell (Death and Decay, Blizzard, Ring of Frost, // Healing Rain, Ursol's Vortex). Bot's facing/position constraints still // apply server-side; OutOfRange / InvalidTarget will return through Result. @@ -186,7 +192,14 @@ public: // split would NoPath and refuse. Distance-capped; movement-lock guards apply. // drop=true: a committed one-way drop off a ledge (BG ledge-to-landing legs recorded by hand): a low jump move from the ledge to the // landing, with the fall damage a player would take applied on arrival. Refused unless the landing is 4..40 y below within 40 y. - Result move_to(float x, float y, float z, bool run = true, bool direct = false, bool drop = false); + // follow_drop=true: (x,y,z) is the owner. When he stands lower (or across a gap) and the walking route to him is missing or a long detour, + // the bot walks to the nearest ledge and drops or leaps to his floor ([follow_drop] logs); otherwise this is the ordinary pathed move. + Result move_to(float x, float y, float z, bool run = true, bool direct = false, bool drop = false, bool follow_drop = false); + // After a follow_drop move_to: the bot is walking to a ledge, or in the air after leaving one (the follow is committed), as against + // the ordinary pathed move it fell back to. + bool follow_drop_acted() const; + // After a follow_drop move_to: the walking route to the owner was judged fine (as against no ledge found). + bool follow_drop_route_fine() const; // Ground height at (x,y) searched from above `z_hint` (Playerbot.Behavior.GroundSnap); returns z_hint when none found. float ground_z(float x, float y, float z_hint, char const* where = "api"); // clear_generators=true pops all MotionMaster generators (Clear + MoveIdle) @@ -1055,6 +1068,10 @@ public: // Classic riding for a bot: Riding skill 75 from level 40 and 150 at 60 (what MountCapability's ReqRidingSkill // checks), and its race's vanilla mount (the swift one at 60) when it knows no mount at all. Returns what changed. uint32 learn_riding_free(); + // Puts a bot into the outfit its character was created with (playercreateinfo_item): each piece straight into its slot, the old piece in that + // slot destroyed just before; a piece that cannot be worn leaves the old one on. The slots the outfit does not use are cleared only when + // every piece went on (`complete`). Returns the number of equipped items removed. For a world bot under level 10 that wears a generated set. + uint32 reset_to_starter_gear(bool& complete); Result trainer_buy_all_available(ObjectGuid trainer_npc, uint32* out_learned = nullptr, uint32* out_already = nullptr, @@ -1124,6 +1141,7 @@ private: Player* p_; uint32 last_cast_fail_ = 0; // see last_cast_fail() + uint32 last_instance_full_map_ = 0; // see last_instance_full_map() }; } // namespace Playerbot diff --git a/src/modules/PlayerbotV2/Api/PlayerbotMovement.cpp b/src/modules/PlayerbotV2/Api/PlayerbotMovement.cpp index 5083e08f85..bad7bd9a9e 100644 --- a/src/modules/PlayerbotV2/Api/PlayerbotMovement.cpp +++ b/src/modules/PlayerbotV2/Api/PlayerbotMovement.cpp @@ -21,6 +21,7 @@ #include "Log.h" #include "Config.h" #include "GameTime.h" +#include "Fleet/CityLayer.h" #include #include "DetourCommon.h" @@ -267,6 +268,31 @@ float GroundZ(Player* p, float x, float y, float zHint, char const* where, bool* return g; } +bool ProbeGround(Player* p, float x, float y, float zHint, float& out) +{ + if (!p) + return false; + Map* m = p->GetMap(); + if (!m) + return false; + constexpr float kProbeUp = 3.0f; + constexpr float kProbeDown = 40.0f; + m->LoadGrid(x, y); + float g = INVALID_HEIGHT; + try + { + g = m->GetHeight(p->GetPhaseShift(), x, y, zHint + kProbeUp, /*vmap*/ true, kProbeUp + kProbeDown); + } + catch (...) + { + g = INVALID_HEIGHT; // BIH churn race (see SnapToGround) + } + if (g <= INVALID_HEIGHT) + return false; + out = g; + return true; +} + // ---- NearestNavPoint -------------------------------------------------------- bool NearestNavPoint(Player* p, float tx, float ty, float tz, @@ -422,7 +448,12 @@ bool SafeNearTeleport(Player* p, float x, float y, float z, float o, bool navmes LiquidData ld; ZLiquidStatus const st = p->GetMap()->GetLiquidStatus( p->GetPhaseShift(), px, py, pz, - map_liquidHeaderTypeFlags::Magma | map_liquidHeaderTypeFlags::Slime, &ld); + map_liquidHeaderTypeFlags::AllLiquids, &ld); + // The vmap filters on the model's raw liquid type, before the area table's override (the Majordomo dais is lava only after it), + // so ask for all liquids and test the flags that come back. + if (st != LIQUID_MAP_NO_WATER && !ld.type_flags.HasFlag(map_liquidHeaderTypeFlags::Magma) && + !ld.type_flags.HasFlag(map_liquidHeaderTypeFlags::Slime)) + return false; // A point ON the surface reads WATER_WALK (delta > -0.1) and one just above it ABOVE_WATER, and the bot falls in at // once: the Molten Core entrance snap lands exactly on the lava surface (z 168.5, ground 165.2), so only IN / UNDER // let Cornelia and Cassanny die there on arrival (2026-10-11, killer=self). Anything within a yard of the surface @@ -701,4 +732,30 @@ LiquidVerdict ClassifyDestinationLiquid(Player* p, float x, float y, float z, return LiquidVerdict::Wadeable; } +// ---- NoPath storm ------------------------------------------------------------ + +namespace { +std::unordered_map g_noPathRun; +} + +void NoteNoPath(Player const* p) +{ + if (p) + ::Playerbot::V2::Fleet::NoteNoPath(g_noPathRun[p->GetGUID().GetCounter()], GameTime::GetGameTimeMS()); +} + +bool NoPathStorm(Player const* p) +{ + if (!p) + return false; + auto it = g_noPathRun.find(p->GetGUID().GetCounter()); + return it != g_noPathRun.end() && ::Playerbot::V2::Fleet::NoPathStorm(it->second, GameTime::GetGameTimeMS()); +} + +void ClearNoPath(Player const* p) +{ + if (p) + g_noPathRun.erase(p->GetGUID().GetCounter()); +} + } // namespace Playerbot::BotMovement diff --git a/src/modules/PlayerbotV2/Api/PlayerbotMovement.h b/src/modules/PlayerbotV2/Api/PlayerbotMovement.h index 4efcf4ba60..c7a01adb84 100644 --- a/src/modules/PlayerbotV2/Api/PlayerbotMovement.h +++ b/src/modules/PlayerbotV2/Api/PlayerbotMovement.h @@ -83,6 +83,10 @@ bool SnapToGround(Player* p, float x, float y, float& z); // Playerbot.Behavior.GroundSnap = 0 restores the plain hint passthrough. float GroundZ(Player* p, float x, float y, float zHint, char const* where, bool* ok = nullptr); +// GroundZ without the [ground] log and without touching `out` on a miss: the highest surface at or 3 y above zHint, searched 40 y down. +// For callers that sample many points (the follow-drop ray walk); false when there is none. +bool ProbeGround(Player* p, float x, float y, float zHint, float& out); + // Snap target (tx,ty,tz) to the nearest WALKABLE navmesh polygon point as // seen from `p` (its map / instance / phase), searching a box of half-extents // `hxy` horizontal and `hz` vertical around the target. Unlike SnapToGround @@ -199,4 +203,11 @@ constexpr bool IsLiquidImpassableForWalk(LiquidVerdict v) // Null = LiquidPolicy::None. extern LiquidPolicy (*g_LiquidPathPolicy)(Player* p); +// How often the path calls from a bot's spot have failed with no route (NoPath, or a destination off the mesh), per window of three +// minutes (Fleet/CityLayer.h). The stranded watch reads it: a bot in a pocket with void all round it fails once a second and never +// moves far enough for the idle watch to see it stand still. World thread. +void NoteNoPath(Player const* p); +bool NoPathStorm(Player const* p); +void ClearNoPath(Player const* p); + } // namespace Playerbot::BotMovement diff --git a/src/modules/PlayerbotV2/BOT_COMMANDS.md b/src/modules/PlayerbotV2/BOT_COMMANDS.md index 1816fcbd59..dce715846c 100644 --- a/src/modules/PlayerbotV2/BOT_COMMANDS.md +++ b/src/modules/PlayerbotV2/BOT_COMMANDS.md @@ -38,7 +38,10 @@ Rules worth knowing: - Only words on the group allow-list are picked up from party/raid chat. Ordinary chatter is ignored. Words that are not on the list (for example `inv`, `repair_all`) work by whisper only. -- A `;` in front of a party line (`;tank: attack`) sends it through the full whisper parser, including address +- A line that starts with the name of a bot in your group, or with `all`, is that bot's order (every bot's for `all`) + with no prefix needed: `Lentha use altar`, `Baxter, follow`, `all use altar`. Anything that is not an order after the + name is ignored, so talking about a bot in chat does nothing. +- A `;` in front of a party line (`;tank: attack`) still sends it through the full whisper parser, including address prefixes. - **Address prefixes** (whisper or `;`): `all:`, `squad:`, `here:`, `tank:`, `healer:`, `dps:`, `:` (for example `mage:`), `:`, `:` before the order. ike3-style selectors also work with @@ -50,7 +53,7 @@ Rules worth knowing: ## 2. Getting bots: add, call, save, dismiss -`.bot` commands need a GM account (level 3 on the realm). The addon buttons run the same commands. +The `.bot` commands for your own bots work for every account, no GM needed; each one only touches bots owned by your account. `.bot world`, `.bot bgstress`, `.bot bgsoak` and `.bot itemstats` need GM (level 3). The addon buttons run the same commands. | Command | What it does | |---|---| @@ -74,7 +77,7 @@ Install the `ForeverBots` folder into `Interface\AddOns` (the folder name must s out of date AddOns"). The addon only sends ordinary chat, so it needs nothing else on the client. - `/fb` opens or closes the window (it stays open across relog). The window has: - - **Raid ready** (also `/fb raidready`): calls your saved bots (`.bot summon saved`), waits until the group stops growing, + - **Raid ready** (also `/fb raidready`): calls your saved bots (`.bot summon saved`) when you are alone (already in a group it uses that group and never changes it), waits until the group stops growing, makes it a raid when it holds more than five, sets formation circle and spacing close, sends `resume` and the crowd-control switch, sets the Main Tank flag when you target a group member, and starts a ready check about twenty seconds later while the bots buff themselves. Not in combat; a new click or combat cancels it. @@ -211,7 +214,7 @@ A group chat order reaches every bot of yours; to address only some, whisper the ## 8. Instance rules -- **Open world**: you have at most `Playerbot.Behavior.OpenWorldGroupCap` (default 5) of your own companions out at +- **Open world**: you have at most `Playerbot.Behavior.OpenWorldGroupCap` (default 40: no limit beyond the raid; 5 = a normal party) of your own companions out at once (`.bot add`, `.bot call`, saved roster, buttons). For more, find world bots and invite them: invited world bots are not counted. Companions above the cap (called inside an instance) are dismissed 10 s after you walk out; the ones grouped with you stay. Needs `InstanceGroupCap = 1`. @@ -298,8 +301,8 @@ Defaults are those of `conf/playerbot.conf.dist`. Behaviour switches are read wh | Key | Default | |---|---| -| `Playerbot.Behavior.InstanceGroupCap` | 0 (off; 1 limits the companions to what the map holds) | -| `Playerbot.Behavior.OpenWorldGroupCap` | 5 | +| `Playerbot.Behavior.InstanceGroupCap` | 1 (on; 0 lifts the limit of companions to what the map holds) | +| `Playerbot.Behavior.OpenWorldGroupCap` | 40 (no limit beyond the raid; 5 = a normal party) | | `Playerbot.Pve.Coordinator.Enable` | 1 | | `Playerbot.Raid.Enable` | 1 | | `Playerbot.Raid.BossWarnings` | 1 | @@ -348,7 +351,8 @@ The module logs nothing unless `Logger.playerbot.v2=3` is set. Grep the server l ## 14. Known gaps -- `trade`, and the ike3 strategy toggles `co`/`nc`/`ss` (+/- strategy lists), are **not implemented**. The +- The ike3 strategy toggles `co`/`nc`/`ss` (+/- strategy lists) are **not implemented**. Trade is: the bot takes + gifts from its owner or a group mate (see Gifts by trade) and a free world bot buys what you put in. The nearest equivalents are `max dps` / `save mana` / `normal`, `aoe`, `hold`/`defensive`/`aggressive`. - `sell grey` and `repair` act at once only when the vendor is within interaction reach; from up to 60 yards the bot walks over and you repeat the order. There is no standing "go and sell, then come back" order; the bots' @@ -386,7 +390,7 @@ Level-60 (level-cap) companions are geared for raiding by role (`Playerbot.Behav | `Playerbot.Gear.RaidIlvlCap` | 0 | Explicit item level ceiling; above 0 it overrides `MaxTier`. | | `Playerbot.Behavior.AcceptOwnerTrade` | 1 | A companion accepts a trade its owner opens, once the owner has accepted (gear and money gifts). The bot never offers anything, so nothing can be taken back through the window. Anyone else's trade is declined. Mail is not read by bots, so gifts go by trade. | -Gifts by trade: open a trade with the bot, put the items in, accept. The bot accepts, then its auto-equip rules wear what is an upgrade for its role (within a few minutes in the open world, at once in a dungeon, or say `equip upgrades`); the rest stays in its bags. +Gifts by trade: open a trade with the bot, put the items in, accept. Gold, gear that is an upgrade and reagents of a recipe the bot knows are gifts; anything else the bot buys at a fair price. The bot accepts, then its auto-equip rules wear what is an upgrade for its role (within a few minutes in the open world, at once in a dungeon, or say `equip upgrades`); the rest stays in its bags. | Say or whisper | What the bot does | |---|---| diff --git a/src/modules/PlayerbotV2/Bot/BotAI.cpp b/src/modules/PlayerbotV2/Bot/BotAI.cpp index 47e36497c6..faccf204bf 100644 --- a/src/modules/PlayerbotV2/Bot/BotAI.cpp +++ b/src/modules/PlayerbotV2/Bot/BotAI.cpp @@ -7,6 +7,7 @@ #include "BotActivityTier.h" #include "Group/GroupSnapshot.h" #include "States/StateBase.h" +#include "States/MaintainHelpers.h" #include "fmt/format.h" #include "GameTime.h" #include "SharedDefines.h" // SPELL_FAILED_NO_AMMO @@ -629,6 +630,10 @@ void BotAI::tick(BotSnapshotView snapshot, // state reads dungeon_active() this tick. update_dungeon_autopilot_hold(snapshot, group); + // Follow-drop: the owner dropped or jumped to a floor 4+ y below; the walk to the ledge and the flight are not interruptible. + if (States::HonorFollowDrop(snapshot, *this, group, emit)) + return; + // 2. Primary state dispatch. dispatch_primary(snapshot, group, emit); @@ -691,7 +696,7 @@ void BotAI::update_dungeon_autopilot_hold(BotSnapshotView s, GroupSnapshotView g bool const present = human_seen_ms_ != 0 && now_ms - human_seen_ms_ < 30000u; int64_t const steady = std::chrono::duration_cast( std::chrono::steady_clock::now().time_since_epoch()).count(); - lead_hold = present && steady >= human_release_until_.load(std::memory_order_relaxed); + lead_hold = present && steady >= orders_.release_until.load(std::memory_order_relaxed); } else human_seen_ms_ = 0; diff --git a/src/modules/PlayerbotV2/Bot/BotAI.h b/src/modules/PlayerbotV2/Bot/BotAI.h index 05258745b5..d76f8e801c 100644 --- a/src/modules/PlayerbotV2/Bot/BotAI.h +++ b/src/modules/PlayerbotV2/Bot/BotAI.h @@ -8,6 +8,7 @@ #include "IdleWatch.h" #include "WalkOrder.h" +#include "Travel/ReachMemory.h" #include "BotTypes.h" #include "BotSnapshot.h" // CurrencyEntry — cached_currencies_ member needs full type #include "Battleground/BgTactics.h" // BgTactics::StallWatch (bg_stall_ member) @@ -271,6 +272,13 @@ public: uint32 direct_tries = 0; static constexpr uint32 kDirectTries = 3; }; + // The instance map a companion was last refused for being full, and when: the rejoin rule holds still for kInstanceFullHoldMs + // and asks again (idle:rejoin_instance_full), instead of walking to an entrance it cannot use. + void note_instance_full(uint32 map_id, uint32 now_ms) { instance_full_map_ = map_id; instance_full_ms_ = now_ms ? now_ms : 1u; } + uint32 instance_full_map() const { return instance_full_map_; } + uint32 instance_full_ms() const { return instance_full_ms_; } + void clear_instance_full() { instance_full_map_ = 0; instance_full_ms_ = 0; } + static constexpr uint32 kInstanceFullHoldMs = 30000u; RejoinRun& rejoin_run() { return rejoin_run_; } RejoinRun const& rejoin_run() const { return rejoin_run_; } // The release order is not among these (see release_order_ms above). @@ -571,13 +579,14 @@ public: None = 0, Follow, Hold, Stay, Engage, Disengage, Action }; - OwnerCommand owner_command() const { return owner_command_; } - ObjectGuid owner_target() const { return owner_target_; } - uint32 manual_mode_until_ms() const { return manual_mode_until_ms_; } + OwnerCommand owner_command() const { std::lock_guard lk(orders_.mtx); return orders_.command; } + ObjectGuid owner_target() const { std::lock_guard lk(orders_.mtx); return orders_.target; } + uint32 manual_mode_until_ms() const { std::lock_guard lk(orders_.mtx); return orders_.until_ms; } bool is_manual_mode(uint32 now_ms) const { - return owner_command_ != OwnerCommand::None && - now_ms < manual_mode_until_ms_; + std::lock_guard lk(orders_.mtx); + return orders_.command != OwnerCommand::None && + now_ms < orders_.until_ms; } // Enter manual mode with the given command + target. Pass `ttl_ms` @@ -586,19 +595,57 @@ public: void enter_manual(OwnerCommand cmd, ObjectGuid target, uint32 now_ms, uint32 ttl_ms = 30000) { - owner_command_ = cmd; - owner_target_ = target; - manual_mode_until_ms_ = now_ms + (ttl_ms == 0 ? 30000u : ttl_ms); - last_owner_command_ms_ = now_ms; + std::lock_guard lk(orders_.mtx); + orders_.command = cmd; + orders_.target = target; + orders_.until_ms = now_ms + (ttl_ms == 0 ? 30000u : ttl_ms); + orders_.last_ms = now_ms; } // Owner said stay/hold: the bot keeps its spot and must not be pulled back into a follow. bool holding_position(uint32 now_ms) const { - return is_manual_mode(now_ms) && - (owner_command_ == OwnerCommand::Stay || owner_command_ == OwnerCommand::Hold); + std::lock_guard lk(orders_.mtx); + return orders_.command != OwnerCommand::None && now_ms < orders_.until_ms && + (orders_.command == OwnerCommand::Stay || orders_.command == OwnerCommand::Hold); } + // Follow-drop commitment (HonorFollowDrop, run at the top of every tick). The owner dropped or jumped to a floor 4+ y below and the + // bot is walking to a ledge, or is in the air after leaving it: nothing else may run until it lands (a + // warlock's buff cast stopped the walk, then a combat escape took it round the rim the long way). Set by the intent executor when + // API::move_to follow_drop took a ledge, cleared on landing or when the way is no longer wanted. The values are written on the + // world thread (executor) and read by the bot worker, hence atomics. + static constexpr uint32 kFollowDropHoldMs = 2500; // a commit lasts this long past the last ledge move + static constexpr uint32 kFollowDropMaxMs = 15000; // a walk to a ledge that takes longer is given up + static constexpr uint32 kFollowDropFineMs = 3000; // after the walking route was judged fine, no new attempt for this long + static constexpr uint32 kFollowDropBlockMs = 8000; + bool follow_drop_committed(uint32 now_ms) const { return now_ms < follow_drop_until_ms_.load(std::memory_order_relaxed); } + uint32 follow_drop_since_ms() const { return follow_drop_since_ms_.load(std::memory_order_relaxed); } + void commit_follow_drop(uint32 now_ms) + { + if (!follow_drop_committed(now_ms)) + follow_drop_since_ms_.store(now_ms ? now_ms : 1u, std::memory_order_relaxed); + follow_drop_until_ms_.store(now_ms + kFollowDropHoldMs, std::memory_order_relaxed); + } + void clear_follow_drop() + { + follow_drop_until_ms_.store(0, std::memory_order_relaxed); + follow_drop_since_ms_.store(0, std::memory_order_relaxed); + } + // The walking route to the owner is fine: no ledge attempt for a while. + void note_follow_drop_fine(uint32 now_ms) + { + follow_drop_fine_until_ms_.store(now_ms + kFollowDropFineMs, std::memory_order_relaxed); + clear_follow_drop(); + } + bool follow_drop_fine(uint32 now_ms) const { return now_ms < follow_drop_fine_until_ms_.load(std::memory_order_relaxed); } + void block_follow_drop(uint32 now_ms) + { + follow_drop_block_until_ms_.store(now_ms + kFollowDropBlockMs, std::memory_order_relaxed); + clear_follow_drop(); + } + bool follow_drop_blocked(uint32 now_ms) const { return now_ms < follow_drop_block_until_ms_.load(std::memory_order_relaxed); } + // Owner said flee: run to them without fighting back until the window ends (DispatchInCombat). static constexpr uint32 kFleeMs = 8000; void start_flee(ObjectGuid to, uint32 now_ms) { flee_to_ = to; flee_until_ms_ = now_ms + kFleeMs; } @@ -613,9 +660,10 @@ public: // disturb manual mode (they're settings, not movement orders). void refresh_manual(uint32 now_ms, uint32 ttl_ms = 30000) { - if (owner_command_ != OwnerCommand::None) - manual_mode_until_ms_ = now_ms + (ttl_ms == 0 ? 30000u : ttl_ms); - last_owner_command_ms_ = now_ms; + std::lock_guard lk(orders_.mtx); + if (orders_.command != OwnerCommand::None) + orders_.until_ms = now_ms + (ttl_ms == 0 ? 30000u : ttl_ms); + orders_.last_ms = now_ms; } // Drop manual mode — autonomous rules resume. Also called when the @@ -623,12 +671,13 @@ public: // ttl in is_manual_mode, but a /resume should clear immediately). void exit_manual() { - owner_command_ = OwnerCommand::None; - owner_target_ = ObjectGuid::Empty; - manual_mode_until_ms_ = 0; + std::lock_guard lk(orders_.mtx); + orders_.command = OwnerCommand::None; + orders_.target = ObjectGuid::Empty; + orders_.until_ms = 0; } - uint32 last_owner_command_ms() const { return last_owner_command_ms_; } + uint32 last_owner_command_ms() const { std::lock_guard lk(orders_.mtx); return orders_.last_ms; } // The owner's "attack" word reached this bot (whether or not the bot may open on the target): PveGroupCoordinator releases the raid's // marks and DPS wait for it. A Pull never sets it. 0 = never. void note_owner_attack(uint32 now_ms) { owner_attack_ms_ = now_ms ? now_ms : 1u; } @@ -746,9 +795,9 @@ public: // run (or follow stop), or engages a mob himself. Unlike the 30s manual-mode window it lasts // until released. Written by the chat handlers (world thread), read and released by the bot logic // worker. Returns true when the value changed (callers log [owner_order] on change). - bool owner_follow_order() const { return owner_follow_order_.load(std::memory_order_relaxed); } + bool owner_follow_order() const { return orders_.follow.load(std::memory_order_relaxed); } bool set_owner_follow_order(bool on) - { return owner_follow_order_.exchange(on, std::memory_order_relaxed) != on; } + { return orders_.follow.exchange(on, std::memory_order_relaxed) != on; } // A companion's small party (not a raid group) inside a raid map: never advance or pull, // follow the owner and defend. Recomputed each tick (update_dungeon_autopilot_hold). bool raid_map_party_hold() const { return raid_map_party_hold_; } @@ -764,17 +813,17 @@ public: // Written by the chat handlers (world thread), read by the bot worker. enum class OwnerStance : uint8_t { Auto = 0, Passive = 1, Aggressive = 2 }; static constexpr float kAggressiveRadiusYd = 10.0f; // Aggressive: hostiles this close to the owner are attacked - OwnerStance owner_stance() const { return OwnerStance(owner_stance_.load(std::memory_order_relaxed)); } - bool set_owner_stance(OwnerStance st) { return owner_stance_.exchange(uint8_t(st), std::memory_order_relaxed) != uint8_t(st); } + OwnerStance owner_stance() const { return OwnerStance(orders_.stance.load(std::memory_order_relaxed)); } + bool set_owner_stance(OwnerStance st) { return orders_.stance.exchange(uint8_t(st), std::memory_order_relaxed) != uint8_t(st); } bool owner_passive() const { return owner_stance() == OwnerStance::Passive; } // The owner's last attack / pull / assist order is fresh (15 s): a passive bot fights during it. bool owner_order_window_open() const { return std::chrono::duration_cast(std::chrono::steady_clock::now().time_since_epoch()).count() < - owner_order_until_.load(std::memory_order_relaxed); + orders_.order_until.load(std::memory_order_relaxed); } // "passive" ends the window an Attack / Pull opened, so the stance holds at once and not after 15 s. - void close_owner_order_window() { owner_order_until_.store(0, std::memory_order_relaxed); } + void close_owner_order_window() { orders_.order_until.store(0, std::memory_order_relaxed); } // Starts no fight on its own right now (stance Passive, or Auto in an instance led by a human), outside an order window. bool passive_now(bool human_led_instance) const { @@ -838,9 +887,9 @@ public: end_owner_use(); int64_t const now_ms = std::chrono::duration_cast( std::chrono::steady_clock::now().time_since_epoch()).count(); - owner_order_until_.store(now_ms + 15000, std::memory_order_relaxed); + orders_.order_until.store(now_ms + 15000, std::memory_order_relaxed); if (autopilot_window) - human_release_until_.store(now_ms + 15000, std::memory_order_relaxed); + orders_.release_until.store(now_ms + 15000, std::memory_order_relaxed); return a || b || c; } @@ -1969,7 +2018,9 @@ public: if (quest_id == 0) return false; std::lock_guard lk(quest_mem_mtx_); auto const it = quest_blacklist_until_ms_.find(quest_id); - if (it == quest_blacklist_until_ms_.end()) return false; + if (it == quest_blacklist_until_ms_.end()) + // Not this bot's own drop: other bots may have given up on the walk to its goal (Travel/ReachMemory.h). + return ::Playerbot::V2::Travel::QuestGoalMemory::Instance().KnownUnreachable(quest_id, now_ms); return now_ms < it->second; } // Drop expired entries. Called periodically from State_Idle (every ~5min) @@ -2905,6 +2956,7 @@ public: bag_recovery_free_seen_ = 255; bag_recovery_backoff_until_ms_ = 0; // futile episode over (bags cleared) capital_run_futile_until_ms_ = 0; // and any capital-run suppression + bag_hearth_used_ = false; // and the one hearth this episode may take } // Capital-bag-run futility. When the in-city walk to the banker/AH/vendor // cluster proves UNREACHABLE (ChunkedWalkToward gives up after its strike @@ -2913,6 +2965,9 @@ public: // bags) instead of looping the unreachable walk above the quest funnel forever // (live 2026-06-22: Durnan/Velruun pinned in Stormwind, 200+ path_fail on the // same 55y path ending 6.5y short). Retries after the cooldown. + // One hearthstone ride to the bound town per full-bag episode (idle:bag_hearth): a bot far from any vendor goes where the vendors are. + bool bag_hearth_used() const { return bag_hearth_used_; } + void set_bag_hearth_used() { bag_hearth_used_ = true; } bool capital_run_in_futility(uint32 now_ms) const { return capital_run_futile_until_ms_ != 0 && now_ms < capital_run_futile_until_ms_; } void capital_run_note_futile(uint32 now_ms) @@ -3353,10 +3408,20 @@ private: uint8 last_train_level_ = 0; bool aoe_preference_ = false; // Owner-squad-control state (Phase C of OWNER_SQUAD_CONTROL_PLAN.md). - OwnerCommand owner_command_ = OwnerCommand::None; - ObjectGuid owner_target_; - uint32 manual_mode_until_ms_ = 0; - uint32 last_owner_command_ms_ = 0; + // The owner's orders to this bot, all in one place. Written by the chat handlers (world thread), read by the bot worker. + struct OwnerOrders + { + mutable std::mutex mtx; // guards command / target / until_ms / last_ms + OwnerCommand command = OwnerCommand::None; // manual mode (enter_manual): 30 s, or 30 min for stay / hold + ObjectGuid target; + uint32 until_ms = 0; + uint32 last_ms = 0; // last time any order reached the bot + std::atomic follow{false}; // owner_follow_order(): lasts until released + std::atomic stance{0}; // OwnerStance + std::atomic order_until{0}; // steady-clock ms: an order is fresh until then (passive bots assist) + std::atomic release_until{0}; // steady-clock ms: the dungeon autopilot is allowed until then + }; + OwnerOrders orders_; uint32 owner_attack_ms_ = 0; uint32 owner_pull_ms_ = 0; std::string last_owner_name_; @@ -3369,14 +3434,14 @@ private: std::atomic tactic_save_mana_{false}; std::atomic loot_all_{false}; DungeonRunMode dungeon_run_mode_ = DungeonRunMode::Off; - std::atomic owner_follow_order_{false}; - std::atomic owner_stance_{0}; // OwnerStance + std::atomic follow_drop_until_ms_{0}; + std::atomic follow_drop_since_ms_{0}; + std::atomic follow_drop_fine_until_ms_{0}; + std::atomic follow_drop_block_until_ms_{0}; bool raid_map_party_hold_ = false; bool owner_hold_ = false; // an owner Stay / Hold is on: the autopilot walks nobody (update_dungeon_autopilot_hold) bool human_lead_hold_ = false; // see human_lead_hold() uint32 human_seen_ms_ = 0; // last tick a leading human was in range (0 = never) - std::atomic human_release_until_{0}; // steady-clock ms: autopilot allowed until then - std::atomic owner_order_until_{0}; // steady-clock ms: an owner order is fresh until then (passive bots assist) BgRunMode bg_run_mode_ = BgRunMode::Off; // Edge-tracker for BG entry/exit. Auto-activate fires on the // false→true transition of `in_battleground()`, not while the bot @@ -4746,6 +4811,7 @@ public: uint32 last_progress_ms = 0; uint32 fallback_until_ms = 0; uint32 last_log_ms = 0; + uint32 last_stuck_log_ms = 0; uint8 last_action = 0; }; FormationTrack& formation_track() { return formation_track_; } @@ -4806,6 +4872,7 @@ private: uint32 crit_repair_backoff_until_ms_ = 0; // suppress critical_repair until this time (too poor) // bag-recovery futility backoff — see bag_recovery_note_and_check_futile() above. uint32 bag_recovery_backoff_until_ms_ = 0; // suppress bags_full_recover until this time + bool bag_hearth_used_ = false; uint32 capital_run_futile_until_ms_ = 0; // suppress capital_bag_run after an unreachable-city give-up RpgState rpg_; // RpgRules: town NPC visits + city / AH trips uint32 bag_recovery_first_ms_ = 0; // first tick of the current no-progress window (0 = none) @@ -5372,6 +5439,8 @@ private: std::atomic release_order_ms_{0}; std::atomic died_at_ms_{0}; RejoinRun rejoin_run_; + uint32 instance_full_map_ = 0; + uint32 instance_full_ms_ = 0; uint32 death_log_ms_ = 0; bool wipe_logged_ = false; uint32 owner_wait_since_ms_ = 0; diff --git a/src/modules/PlayerbotV2/Bot/BotCommandParser.cpp b/src/modules/PlayerbotV2/Bot/BotCommandParser.cpp index cdd54ae0d3..c063e08a5a 100644 --- a/src/modules/PlayerbotV2/Bot/BotCommandParser.cpp +++ b/src/modules/PlayerbotV2/Bot/BotCommandParser.cpp @@ -1,4 +1,5 @@ #include "BotCommandParser.h" +#include "GroupControl.h" #include "BotIntent.h" #include "BotIntentEmitter.h" #include "BotRegistry.h" @@ -754,7 +755,7 @@ void ReportRaidRoster(Player* sender, Player* bot) // a recognised value. // Owner "distance " / "follow distance " (Playerbot.Behavior.DistanceOrder; the /fb Distance stepper): pins the bot's // follow distance (BotAI::follow_distance, persisted with the squad state) and the formation spacing yards together, so -// the plain follow, the formation slots and the recall slack all agree. Clamped to 1..20 yards; the group's lowest-guid +// the plain follow, the formation slots and the recall slack all agree. Clamped to 2..20 yards; the group's lowest-guid // bot whispers the confirmation. The spacing yards are memory only (as the spacing presets are); the addon re-sends // the value on login. World thread. `rest` is the text after the verb. bool OrderDistance(Player* sender, Player* bot, std::string const& rest) @@ -764,7 +765,7 @@ bool OrderDistance(Player* sender, Player* bot, std::string const& rest) return false; float yd = 0.f; try { yd = std::stof(rest); } catch (...) { return false; } - yd = std::clamp(yd, 1.0f, 20.0f); + yd = std::clamp(yd, 2.0f, 20.0f); BotAI* ai = Services::Registry().ai(bot->GetGUID().GetCounter()); if (!ai) return true; ai->set_follow_distance(yd); @@ -1473,7 +1474,7 @@ bool OwnerWordOrder(Player* sender, Player* bot, std::string const& n) if (bid != lowest) return true; } - say("Orders (whisper me, or say it in party / raid chat): follow, stay, come, summon, attack, flee, hold, resume, passive, defensive, aggressive."); + say("Orders (whisper me, or say it in party / raid chat): follow, stay, come, summon, attack, flee, hold, resume, passive, aggressive."); say("Ask: who, stats, gear, quests, inv, money. Quests: accept [all], drop , turn in, share."); say("Town and loot: sell grey, repair, loot / loot all. Raid: pull, pull back, fall back, rally here, formation , spacing , distance , assign, rti."); say("The whole verb index: 'commands'. Address several bots: all: / tank: / healer: / dps: / : / : before the order."); @@ -1607,23 +1608,12 @@ bool OwnerWordOrder(Player* sender, Player* bot, std::string const& n) if (n == "summon") { auto refuse = [&](char const* why) { say(fmt::format("{}: can't be summoned, {}", me, why)); return true; }; - if (!bot->IsAlive()) - return refuse("I am dead - release or revive me first"); - if (bot->IsInCombat()) - return refuse("I am in combat"); if (sender->IsInCombat()) return refuse("you are in combat"); - Map const* sm = sender->GetMap(); - Map const* bm = bot->GetMap(); - if (sm && sm->IsBattlegroundOrArena() && bot->GetMapId() != sender->GetMapId()) - return refuse("you are in a battleground"); - if (bm && bm->Instanceable() && bot->GetMapId() != sender->GetMapId()) - return refuse("I am inside an instance - walk out first"); - // Into the owner's instance only as a member of the owner's group (the door checks and their log are API::teleport_to's). - if (sm && sm->Instanceable() && bot->GetMapId() != sender->GetMapId() && !(bot->GetGroup() && bot->GetGroup() == sender->GetGroup())) - return refuse("you are inside an instance - invite me and walk in with the group"); - Push(bot, TeleportToIntent{sender->GetMapId(), sender->GetPositionX(), sender->GetPositionY(), - sender->GetPositionZ(), sender->GetOrientation()}); + // Wherever the bot is, inside the owner's instance too: it is put in the group, revived if dead elsewhere and ported to the owner + // (BotPopulationManager::BringToOwner logs every refusal as [summon]). + if (std::string const why = Services::Population().BringToOwner(sender, bot, "summon order"); !why.empty()) + return refuse(why.c_str()); if (BotAI* ai = Services::Registry().ai(bid)) { ai->enter_manual(BotAI::OwnerCommand::Follow, sender->GetGUID(), GameTime::GetGameTimeMS()); @@ -1636,7 +1626,7 @@ bool OwnerWordOrder(Player* sender, Player* bot, std::string const& n) // Passive: the bot starts nothing (no autopilot pull, no assist on the owner's target) and defends itself and the group // until attack / pull (a 15 s window) or aggressive. A fight already under way is not dropped. The stance is the panel's // Aggressive / Passive toggle and stays on the bot until changed. - if (n == "passive") + if (n == "passive" || n == "defensive") // "defensive" is the retired third stance: it now means passive { if (BotAI* ai = Services::Registry().ai(bid)) { @@ -1657,7 +1647,7 @@ bool OwnerWordOrder(Player* sender, Player* bot, std::string const& n) { if (ai->set_owner_stance(BotAI::OwnerStance::Aggressive)) TC_LOG_INFO("playerbot.v2", "[owner_order] {} <- {}: aggressive (attacks hostiles within {:.0f} yd of the owner)", me, - sender->GetName(), BotAI::kAggressiveRadiusYd); + sender->GetName(), Services::Config().behavior_aggressive_radius_yd()); // A Stay / Hold stays: aggressive changes the stance only (it used to cancel the Stay silently). if (!ai->holding_position(GameTime::GetGameTimeMS())) { @@ -1665,24 +1655,9 @@ bool OwnerWordOrder(Player* sender, Player* bot, std::string const& n) ai->release_owner_lead(false); } } - say(fmt::format("{}: aggressive, attacking anything hostile within {:.0f} yards of you", me, BotAI::kAggressiveRadiusYd)); + say(fmt::format("{}: aggressive, attacking anything hostile within {:.0f} yards of you", me, Services::Config().behavior_aggressive_radius_yd())); return true; } - if (n == "defensive") - { - Push(bot, StopMovementIntent{/*clear_generators*/ true}); - if (BotAI* ai = Services::Registry().ai(bid)) - { - ai->enter_manual(BotAI::OwnerCommand::Hold, ObjectGuid::Empty, GameTime::GetGameTimeMS(), BotAI::kHoldPositionTtlMs); - // Defensive replaces an Aggressive stance (a Passive one already fights only what attacks); the Hold does the rest. - if (ai->owner_stance() == BotAI::OwnerStance::Aggressive) - ai->set_owner_stance(BotAI::OwnerStance::Auto); - ai->set_last_owner_name(sender->GetName()); - } - say(me + ": defensive, holding here and fighting only what attacks"); - return true; - } - // ---- invite (whispered: the bot invites its owner) -------------------------------------------------------------- if (n == "invite" && t_direct_whisper) { @@ -1875,6 +1850,26 @@ static void ConfirmWhisperOrder(Player* sender, Player* bot, std::string const& Push(bot, WhisperIntent{sender->GetName(), std::move(text)}); } +bool BotCommandParser::ControlsForGroupOrder(Player const* sender, Player const* bot) +{ + if (!sender || !bot || sender == bot || !sender->GetSession()) + return false; + BotId const bot_id = bot->GetGUID().GetCounter(); + if (Services::Owners().GetOwner(bot_id).account_id != 0) + return Services::Owners().IsOwner(bot_id, sender->GetSession()->GetAccountId(), sender->GetGUID().GetCounter()); + Group const* g = bot->GetGroup(); + if (!g || g != sender->GetGroup() || (sender->GetSession() && sender->GetSession()->IsBot())) + return false; + std::vector> members; + for (GroupReference const& itr : g->GetMembers()) + { + Player const* m = itr.GetSource(); + if (!m || m == bot) continue; + members.push_back({ m->GetGUID(), !(m->GetSession() && m->GetSession()->IsBot()) }); + } + return GroupControl::ResolveController(g->GetLeaderGUID(), members) == sender->GetGUID(); +} + bool BotCommandParser::DispatchSingle(Player* sender, Player* bot, std::string const& msg, char const* via) { if (!sender || !bot) return false; @@ -2636,6 +2631,8 @@ bool BotCommandParser::DispatchSingleImpl(Player* sender, Player* bot, std::stri if (BotAI* ai = Services::Registry().ai(bot->GetGUID().GetCounter())) { AutoAssignFormationSlot(bot, *ai); + ai->close_owner_order_window(); // a follow ends the attack / pull window: nothing it opened starts a fight again + Push(bot, PetSetCommandStateIntent{1}); // and the pet comes along instead of staying on its target ai->enter_manual(BotAI::OwnerCommand::Follow, sender->GetGUID(), GameTime::GetGameTimeMS()); ai->set_last_owner_name(sender->GetName()); @@ -2702,13 +2699,14 @@ bool BotCommandParser::DispatchSingleImpl(Player* sender, Player* bot, std::stri } if (cmd == "come" || cmd == "summon") { - // Teleport the bot to the sender. The API guards against in-combat - // and casting bots — caller can re-issue when the bot reports back. - Push(bot, TeleportToIntent{sender->GetMapId(), - sender->GetPositionX(), - sender->GetPositionY(), - sender->GetPositionZ(), - sender->GetOrientation()}); + // Bring the bot to the sender, in the open world or inside an instance (BotPopulationManager::BringToOwner: group, revive, + // door check, ring spot). A refusal is logged as [summon] and told to the sender, so no bot goes missing without a reason. + if (std::string const why = Services::Population().BringToOwner(sender, bot, "come"); !why.empty()) + { + if (why != "in combat with you") // a bot in your own fight answers when it is over; no line per fighter + ChatHandler(sender->GetSession()).PSendSysMessage("%s cannot come: %s.", bot->GetName().c_str(), why.c_str()); + return true; + } // After /come the owner usually wants the bot to stay nearby — // enter Follow manual mode so the bot doesn't immediately // resume questing across the map. @@ -2725,13 +2723,9 @@ bool BotCommandParser::DispatchSingleImpl(Player* sender, Player* bot, std::stri // Teleport all registered group-mate bots to the sender. Each bot // may individually refuse (in-combat / casting) — same gates as the // single-bot variant. Bot dispatching the command is included. - TeleportToIntent tp{sender->GetMapId(), - sender->GetPositionX(), - sender->GetPositionY(), - sender->GetPositionZ(), - sender->GetOrientation()}; - Push(bot, tp); - uint32 broadcast_count = 1; + uint32 broadcast_count = 0; + if (Services::Population().BringToOwner(sender, bot, "come all").empty()) + ++broadcast_count; if (Group const* grp = bot->GetGroup()) { for (GroupReference const& itr : grp->GetMembers()) @@ -2740,8 +2734,8 @@ bool BotCommandParser::DispatchSingleImpl(Player* sender, Player* bot, std::stri if (!member || member == bot) continue; const BotId mid = member->GetGUID().GetCounter(); if (!Services::Registry().has(mid)) continue; - Push(member, tp); - ++broadcast_count; + if (Services::Population().BringToOwner(sender, member, "come all").empty()) + ++broadcast_count; } } Push(bot, WhisperIntent{sender->GetName(), @@ -4325,6 +4319,15 @@ bool BotCommandParser::DispatchSingleImpl(Player* sender, Player* bot, std::stri if (cmd == "stop" || cmd == "passive" || cmd == "disengage") { Push(bot, StopAttackIntent{}); + // Stop is stop for the pet too (a pet left on its target keeps pulling), and ends the attack / pull window and an engage order + // so nothing in the bot's rules starts the fight again. + Push(bot, PetSetCommandStateIntent{1}); + if (BotAI* ai = Services::Registry().ai(bot->GetGUID().GetCounter())) + { + ai->close_owner_order_window(); + if (ai->owner_command() == BotAI::OwnerCommand::Engage) + ai->exit_manual(); + } // /disengage clears manual mode entirely (vs /stop which is a // single-shot break-combat). Cleanly returning to autonomous // is the right semantic when the owner says "back off". @@ -5901,7 +5904,7 @@ bool BotCommandParser::DispatchSingleImpl(Player* sender, Player* bot, std::stri { // "use ": the nearest matching game object within 30 y of the bot (an altar, brazier, lever, orb). // The bot walks over, uses it once and stays there (idle:owner_use); "follow" releases it. A ritual such as the UBRS - // Blackrock Altar (3 users) completes once enough different players have used it: the owner plus ";Name:use altar" to two bots. + // Blackrock Altar (3 users) completes once enough different players have used it: the owner plus "Name use altar" in party chat to two bots. // A selected game object still works for clients that can select one. ObjectGuid selection = sender->GetTarget(); std::string want = parsed.tail; // lower case (Normalize) diff --git a/src/modules/PlayerbotV2/Bot/BotCommandParser.h b/src/modules/PlayerbotV2/Bot/BotCommandParser.h index 83a3d349fa..42e60af989 100644 --- a/src/modules/PlayerbotV2/Bot/BotCommandParser.h +++ b/src/modules/PlayerbotV2/Bot/BotCommandParser.h @@ -34,6 +34,11 @@ public: // command needs to run, and by tests that bypass the prefix layer. static bool DispatchSingle(Player* sender, Player* bot_player, std::string const& msg, char const* via = "whisper"); + // May `sender` give this bot a group order (the panel, a party / raid line)? Its owner, or for a bot with no owner a player + // who is its controller in the group they share (GroupControl.h): the group leader when human, else the first human + // member. An invited world bot obeys the leader exactly like a companion. + static bool ControlsForGroupOrder(Player const* sender, Player const* bot_player); + // The bot's role as its owner set it (`.bot add tank`, setrole), else as its spec reads. static Role BotRole(Player* bot_player); diff --git a/src/modules/PlayerbotV2/Bot/BotIntent.h b/src/modules/PlayerbotV2/Bot/BotIntent.h index 0b7a12bce5..c349712b57 100644 --- a/src/modules/PlayerbotV2/Bot/BotIntent.h +++ b/src/modules/PlayerbotV2/Bot/BotIntent.h @@ -83,7 +83,9 @@ struct SetStandStateIntent { uint8 stand_state; }; // endpoints are human-verified ground truth (playerbot_nav_links); a pathfound // move toward the far side of a real navmesh split would NoPath and refuse. // drop = a committed one-way drop off a ledge (a jump move to the landing, fall damage applied on arrival); see API::move_to. -struct MoveToIntent { float x, y, z; bool run; bool direct = false; bool drop = false; }; +// follow_drop = a move toward the owner that leaves a ledge when the walking route to him is missing or a long detour (he dropped or jumped +// down); see API::move_to. Otherwise it is the ordinary pathed move. +struct MoveToIntent { float x, y, z; bool run; bool direct = false; bool drop = false; bool follow_drop = false; }; struct TeleportToIntent { uint32 map_id; float x, y, z, o; }; // clear_generators=false (default) only halts the active spline (Player:: // StopMoving). clear_generators=true pops EVERY MotionMaster generator back to diff --git a/src/modules/PlayerbotV2/Bot/BotIntentEmitter.cpp b/src/modules/PlayerbotV2/Bot/BotIntentEmitter.cpp index 6ff95a29eb..9820e68395 100644 --- a/src/modules/PlayerbotV2/Bot/BotIntentEmitter.cpp +++ b/src/modules/PlayerbotV2/Bot/BotIntentEmitter.cpp @@ -341,7 +341,7 @@ bool BotIntentEmitter::move_already_emitted(float x, float y, float z) const return ai_ && ai_->move_to_recently_emitted(x, y, z, GameTime::GetGameTimeMS()); } -bool BotIntentEmitter::move_to(float x, float y, float z, bool run, bool direct, bool drop) +bool BotIntentEmitter::move_to(float x, float y, float z, bool run, bool direct, bool drop, bool follow_drop) { // Per-bot dedup: skip if the previous move_to went to ~the same XYZ // within the lockout window. See BotAI::kMoveToEmitLockoutMs / the long @@ -393,7 +393,7 @@ bool BotIntentEmitter::move_to(float x, float y, float z, bool run, bool direct, } return false; } - const bool pushed = emit(MoveToIntent{x, y, z, run, direct, drop}); + const bool pushed = emit(MoveToIntent{x, y, z, run, direct, drop, follow_drop}); if (pushed) ai_->note_move_to_emitted(x, y, z, now_ms); else @@ -405,7 +405,7 @@ bool BotIntentEmitter::move_to(float x, float y, float z, bool run, bool direct, } return pushed; } - return emit(MoveToIntent{x, y, z, run, direct, drop}); + return emit(MoveToIntent{x, y, z, run, direct, drop, follow_drop}); } // The global cooldown a cast of this spell starts, in ms (0 = off the GCD: stances, diff --git a/src/modules/PlayerbotV2/Bot/BotIntentEmitter.h b/src/modules/PlayerbotV2/Bot/BotIntentEmitter.h index d0402e5305..35707d4921 100644 --- a/src/modules/PlayerbotV2/Bot/BotIntentEmitter.h +++ b/src/modules/PlayerbotV2/Bot/BotIntentEmitter.h @@ -102,7 +102,8 @@ public: // When ai_ is null (test harness) the dedup is a no-op. // direct=true = straight MovePoint spline, no pathfinding (committed // traversal-link crossings only — see MoveToIntent). - bool move_to(float x, float y, float z, bool run = true, bool direct = false, bool drop = false); + // follow_drop=true: a pathed move toward the owner that takes the ledge when his floor is only reachable by a drop or a jump (API::move_to). + bool move_to(float x, float y, float z, bool run = true, bool direct = false, bool drop = false, bool follow_drop = false); // A move_to to ~(x,y,z) was already emitted in the last 1.5 s (the one move_to dedups, returning false). That is a move under way, // not a refusal: callers that count false results as path refusals ask this first. bool move_already_emitted(float x, float y, float z) const; diff --git a/src/modules/PlayerbotV2/Bot/BotIntentExecutor.cpp b/src/modules/PlayerbotV2/Bot/BotIntentExecutor.cpp index 181f2da697..c1e60620ee 100644 --- a/src/modules/PlayerbotV2/Bot/BotIntentExecutor.cpp +++ b/src/modules/PlayerbotV2/Bot/BotIntentExecutor.cpp @@ -220,7 +220,20 @@ struct IntentVisitor return r; } Result operator()(GroundTargetSpellIntent const& i) { return api.cast_spell_at_position(i.spell_id, i.x, i.y, i.z); } - Result operator()(MoveToIntent const& i) { return api.move_to(i.x, i.y, i.z, i.run, i.direct, i.drop); } + Result operator()(MoveToIntent const& i) + { + Result const r = api.move_to(i.x, i.y, i.z, i.run, i.direct, i.drop, i.follow_drop); + if (i.follow_drop && bot_ai && r != Result::Locked) + { + // A ledge walk or flight commits the follow; an ordinary pathed move means the walking route is fine (State_InGroup HonorFollowDrop). + // No ledge found is neither: the bot tries again at the next attempt (a ledge may come in reach, the owner may land). + if (api.follow_drop_acted()) + bot_ai->commit_follow_drop(GameTime::GetGameTimeMS()); + else if (api.follow_drop_route_fine()) + bot_ai->note_follow_drop_fine(GameTime::GetGameTimeMS()); + } + return r; + } Result operator()(TeleportToIntent const& i) { return api.teleport_to(i.map_id, i.x, i.y, i.z, i.o); } Result operator()(StopMovementIntent const& i) { return api.stop_movement(i.clear_generators); } Result operator()(JumpIntent const& i) { return api.jump(i.forward); } @@ -708,6 +721,10 @@ size_t V2::Module::DrainIntents() try { Result r = std::visit(IntentVisitor{api, entry.ai.get()}, intent.body); + // A full instance is not a failed port to retry at once: the rejoin rule waits and asks again. + if (r == Result::ServerRefused && api.last_instance_full_map() != 0 && entry.ai) + entry.ai->note_instance_full(api.last_instance_full_map(), GameTime::GetGameTimeMS()); + api.clear_instance_full_map(); Services::Perf().record_intent_executed(); Services::Perf().record_intent_result(static_cast(r)); if (r != Result::Ok) diff --git a/src/modules/PlayerbotV2/Bot/BotSnapshot.h b/src/modules/PlayerbotV2/Bot/BotSnapshot.h index 49507b936b..02bd879717 100644 --- a/src/modules/PlayerbotV2/Bot/BotSnapshot.h +++ b/src/modules/PlayerbotV2/Bot/BotSnapshot.h @@ -432,6 +432,8 @@ struct NearbyUnit // CC'd by their own teammates so the CC duration isn't wasted. bool is_cc_locked = false; ObjectGuid cc_caster; + // Milliseconds left on the aura that set cc_caster (0 = unknown or permanent): lets a mage renew a sheep before it runs out. + uint32_t cc_ms_left = 0; // Caster of a root aura on the unit (empty = none). Roots are not CC-locks (mobs stay targets), but the MarkCc // druid must see its own Entangling Roots to not recast them every tick. ObjectGuid root_caster; @@ -1553,6 +1555,9 @@ struct MovementState bool is_flying = false; bool is_mounted = false; bool is_moving = false; + // Terrain height under the bot (INVALID_HEIGHT when not measured: only a grouped bot that stands still is measured). Diagnostics only: the + // [formation_stuck] line compares it with the bot's z (a bot standing on a model is higher than the ground). + float ground_z = -100000.0f; // True while the CORE is flying the bot on a taxi path (UNIT_STATE_IN_ // FLIGHT). The bot logic must do NOTHING during a taxi flight — the // FlightPathMovementGenerator owns movement; any idle rule that emits a @@ -2664,6 +2669,16 @@ struct BotSnapshot // The owner is in the bot's group: the bot is a companion and does what its owner's party does, not world-bot // errands (questing, vendors, gathering, travel). See IdleRuleRegistry::tick. bool owner_in_group = false; + // The bot is in a group with a player who controls it although it has no owner in that group: a world bot the player invited + // (or a companion whose owner is not in the group). Same duty as a companion: it does what the group does, no errands, and the + // controller's orders reach it. controller_guid is that player (the group leader when human, else the first human member). + bool led_by_player = false; + ObjectGuid controller_guid; + // The bot starts no fight of its own and must not tag a pack with an AoE (stance Passive, or no stance picked while led by a + // player): mirrored from BotAI by the builder. Read by the AoE gate (ThreatDiscipline FindAoeHazard). + bool no_tag_stance = false; + // The controller told the bot to Stay / Hold: a tank does not walk after a loose mob (a taunt, which moves nobody, still works). + bool holding_position = false; // Flat distance to the owner when it is on the bot's map, else -1. nearby_friends keeps only the 12 nearest friends, so in a raid // the owner is rarely in it (companion_may_sit). float owner_dist = -1.0f; @@ -2946,6 +2961,10 @@ struct BotSnapshot owner_name.clear(); owner_guid = ObjectGuid::Empty; owner_in_group = false; + led_by_player = false; + controller_guid = ObjectGuid::Empty; + no_tag_stance = false; + holding_position = false; owner_dist = -1.0f; tactic_burn = false; tactic_save_mana = false; diff --git a/src/modules/PlayerbotV2/Bot/BotSnapshotBuilder.cpp b/src/modules/PlayerbotV2/Bot/BotSnapshotBuilder.cpp index 4b0091a71f..d6e8c860e7 100644 --- a/src/modules/PlayerbotV2/Bot/BotSnapshotBuilder.cpp +++ b/src/modules/PlayerbotV2/Bot/BotSnapshotBuilder.cpp @@ -1,5 +1,6 @@ #include "BotSnapshotBuilder.h" #include "BotRegistry.h" +#include "GroupControl.h" #include "Bot/SpellFamily.h" #include "ClassicSpec.h" #include "BotAI.h" @@ -1815,6 +1816,8 @@ std::shared_ptr BotSnapshotBuilder::Build(Player* p, BotAI* b else if (mc_ai) mc_ai->clear_move_corroborate(); snap->movement.is_moving = moving; + if (!moving && p->GetGroup() && p->GetMap()) + snap->movement.ground_z = p->GetMap()->GetHeight(p->GetPhaseShift(), p->GetPositionX(), p->GetPositionY(), p->GetPositionZ() + 2.0f, true, 10.0f); } // UNIT_STATE_IN_FLIGHT — the core is flying the bot on a taxi path. The bot logic // must stand down entirely (DispatchIdle bails) so no idle/unstick/watchdog @@ -1887,7 +1890,8 @@ std::shared_ptr BotSnapshotBuilder::Build(Player* p, BotAI* b // has feet wet, but it's burning, not drowning. snap->environment.is_underwater = (liquid & LIQUID_MAP_UNDER_WATER) != 0 && !is_magma && !is_slime; - snap->environment.is_in_damaging_liquid = in_liquid && (is_magma || is_slime); + // The core burns on any contact, floor within a tenth of the surface included (WATER_WALK): the Majordomo dais. + snap->environment.is_in_damaging_liquid = (liquid & MAP_LIQUID_STATUS_IN_CONTACT) != 0 && (is_magma || is_slime); if (snap->environment.is_underwater && lqmap) snap->environment.water_surface_z = lqmap->GetWaterLevel( p->GetPhaseShift(), p->GetPositionX(), p->GetPositionY()); @@ -3323,9 +3327,36 @@ std::shared_ptr BotSnapshotBuilder::Build(Player* p, BotAI* b { snap->group.group_guid = g->GetGUID(); snap->owner_in_group = !snap->owner_guid.IsEmpty() && g->IsMember(snap->owner_guid); + // No owner in this group: a human member still commands the bot (GroupControl.h). A world bot a player invited gets the + // companion's duties and obeys the group leader; a bot with only bots around it stays autonomous. + if (!snap->owner_in_group && Services::Initialized()) + { + std::vector> members; + for (GroupReference const& itr : g->GetMembers()) + { + Player const* m = itr.GetSource(); + if (!m || m == p) continue; + members.push_back({ m->GetGUID(), !(m->GetSession() && m->GetSession()->IsBot()) }); + } + ObjectGuid const controller = GroupControl::ResolveController(g->GetLeaderGUID(), members); + if (!controller.IsEmpty()) + { + snap->led_by_player = true; + snap->controller_guid = controller; + if (Player const* c = ObjectAccessor::FindConnectedPlayer(controller); c && c->GetMapId() == p->GetMapId()) + snap->owner_dist = p->GetExactDist2d(c); + } + } if (snap->owner_in_group) if (Player const* owner = ObjectAccessor::FindConnectedPlayer(snap->owner_guid); owner && owner->GetMapId() == p->GetMapId()) snap->owner_dist = p->GetExactDist2d(owner); + if (bot_ai) + { + snap->holding_position = bot_ai->holding_position(snap->published_at_ms); + auto const stance = bot_ai->owner_stance(); + snap->no_tag_stance = stance == BotAI::OwnerStance::Passive || + (stance == BotAI::OwnerStance::Auto && (snap->owner_in_group || snap->led_by_player)); + } } // ---- Spellbook (sorted, binary-searchable in BotSnapshotView::knows_spell) ---- @@ -4039,6 +4070,7 @@ std::shared_ptr BotSnapshotBuilder::Build(Player* p, BotAI* b best_cc_pri = pri; u.is_cc_locked = true; u.cc_caster = abase->GetCasterGUID(); + u.cc_ms_left = abase->GetDuration() > 0 ? uint32(abase->GetDuration()) : 0u; } } } @@ -4717,7 +4749,9 @@ std::shared_ptr BotSnapshotBuilder::Build(Player* p, BotAI* b // Healers seven times and never the shield). bool const shield = asi->Id == 20619 || asi->Id == 21075; bool const shield_held = u.magic_buff_spell == 20619 || u.magic_buff_spell == 21075; - if (shield || (!shield_held && (u.magic_buff_age_ms < 0 || age < u.magic_buff_age_ms))) + // Both shields can stand at once; Magic Reflection (which sends a sheep back at the mage) is the one that must stay + // visible, whichever aura the walk meets last. + if ((shield && u.magic_buff_spell != 20619) || (!shield_held && (u.magic_buff_age_ms < 0 || age < u.magic_buff_age_ms))) { u.magic_buff_age_ms = age; u.magic_buff_spell = asi->Id; @@ -4763,6 +4797,7 @@ std::shared_ptr BotSnapshotBuilder::Build(Player* p, BotAI* b best_cc_pri = pri; u.is_cc_locked = true; u.cc_caster = abase->GetCasterGUID(); + u.cc_ms_left = abase->GetDuration() > 0 ? uint32(abase->GetDuration()) : 0u; } } fill_threat(u, t); @@ -4967,6 +5002,7 @@ std::shared_ptr BotSnapshotBuilder::Build(Player* p, BotAI* b best_cc_pri = pri; u.is_cc_locked = true; u.cc_caster = abase->GetCasterGUID(); + u.cc_ms_left = abase->GetDuration() > 0 ? uint32(abase->GetDuration()) : 0u; } } } @@ -5920,12 +5956,15 @@ std::shared_ptr BotSnapshotBuilder::Build(Player* p, BotAI* b bool has_complete = false; for (auto const& dq : snap->quest_log.quests) if (dq.state == 1) { has_complete = true; break; } - // At most one dump per bot per minute (per build thread): a bot parked on a complete quest wrote it on every build, which + // At most one dump per bot per minute: a bot parked on a complete quest wrote it on every build, which // made [picker_none] 79% of the log at 85-150 bots and pushed every other diagnostic out of the rotation. if (has_complete) { - thread_local std::unordered_map s_picker_none_ms; + // One table for all build threads (a table per thread let each thread log the same bot once a minute). + static std::mutex s_picker_none_mx; + static std::unordered_map s_picker_none_ms; uint32 const pn_now = snap->published_at_ms ? snap->published_at_ms : 1u; + std::lock_guard pn_lock(s_picker_none_mx); uint32& pn_last = s_picker_none_ms[snap->guid.GetCounter()]; if (pn_last && pn_now - pn_last < 60000u) has_complete = false; @@ -5941,10 +5980,25 @@ std::shared_ptr BotSnapshotBuilder::Build(Player* p, BotAI* b best_breadcrumb_sm_set ? 1 : 0, best_breadcrumb_set ? 1 : 0, bot_map); for (auto const& dq : snap->quest_log.quests) + { + // Which of the picker's skip gates (in loop order) drops this quest. + char const* skip = "none"; + Quest const* dqt = sObjectMgr->GetQuestTemplate(dq.quest_id); + if (dqt && dqt->GetRequiredSkill() && const_cast(p)->GetSkillValue(dqt->GetRequiredSkill()) == 0) + skip = "skill"; + else if (bot_ai && bot_ai->quest_blacklisted(dq.quest_id, now_ms)) + skip = "quest_blacklist"; + else if (dqt && !const_cast(p)->SatisfyQuestMinLevel(dqt, false)) + skip = "min_level"; + else if (bot_ai && bot_ai->objective_blacklisted(dq.quest_id, 0u, now_ms)) + skip = "turnin_blacklist"; + else if (!QuestHasAnyEnder(dq.quest_id)) + skip = "no_ender"; TC_LOG_INFO("playerbot.v2", - "[picker_none] q{} state={} objs={} ender_resolved={} ender_map={}", + "[picker_none] q{} state={} objs={} ender_resolved={} ender_map={} skip={}", dq.quest_id, uint32(dq.state), uint32(dq.objectives.size()), - dq.ender_resolved ? 1 : 0, dq.ender_map_id); + dq.ender_resolved ? 1 : 0, dq.ender_map_id, skip); + } } } } @@ -7494,7 +7548,7 @@ std::shared_ptr BotSnapshotBuilder::Build(Player* p, BotAI* b const bool truly_stuck = snap->quest_discovery.quest_offers.empty() && snap->quest_log.quests.empty(); - if (truly_stuck && p->GetLevel() < 20) + if (truly_stuck && p->GetLevel() < 20 && !snap->owner_in_group && !snap->led_by_player) // a led bot has no quest autopilot to diagnose { uint32 giver_npc_count = 0; uint32 giver_go_count = 0; diff --git a/src/modules/PlayerbotV2/Bot/BotSnapshotView.cpp b/src/modules/PlayerbotV2/Bot/BotSnapshotView.cpp index 13302977f3..099fea1cab 100644 --- a/src/modules/PlayerbotV2/Bot/BotSnapshotView.cpp +++ b/src/modules/PlayerbotV2/Bot/BotSnapshotView.cpp @@ -878,8 +878,8 @@ static bool BeyondHealerLeash(BotSnapshot const& s, float x, float y) // A loose mob nobody was assigned goes to ONE tank: the nearest idle one that this bot's friend sweep shows (a tank busy with a // mob of its own is no contender; ties go to the lower guid). Without it every tank without an assignment ran at the same mob and // they taunted it back and forth (MC 2026-10-11: [tank_loose] from several tanks on one Firewalker, "claimed by another tank 0"). -// The nearer tank counts only while it can take the mob: within the pickup reach (n24 mc_garr: an idle tank 40 y off was the "nearest", every -// other idle tank deferred to it and a Firesworn stood 7 y from Mctankwb on a healer for a minute). +// The nearer tank counts only while it can take the mob: within the pickup reach (an idle tank 40 y off was the "nearest", every +// other idle tank deferred to it and a Firesworn stood 7 y from a tank on a healer for a minute). static constexpr float kOtherTankReachYd = 30.0f; static bool OtherTankTakesLoose(BotSnapshot const& s, NearbyUnit const& mob) @@ -927,15 +927,22 @@ static uint32 LooseOnMemberMs(ObjectGuid mob, uint32 now) return now - it->second.since; } -static NearbyUnit const* UnclaimedLooseAttacker(BotSnapshot const& s, float range, bool target_reach = false, bool leash = false) +// controller_leash: the same distance rule without the healer leash (a taunt moves nobody, but it must not drag in a mob the group is +// nowhere near). Both measure from the controller's live position: the owner, else the player leading the group. +static NearbyUnit const* UnclaimedLooseAttacker(BotSnapshot const& s, float range, bool target_reach = false, bool leash = false, + bool controller_leash = false) { NearbyUnit const* best = nullptr; float best_d2 = std::numeric_limits::max(); int best_prio = -1; NearbyUnit const* owner_unit = nullptr; - if (leash && s.owner_in_group && s.instance_ctx.is_in_instance && !s.owner_guid.IsEmpty()) + ObjectGuid const controller = s.owner_in_group ? s.owner_guid : s.controller_guid; + float ctl_leash = Services::Config().behavior_passive_leash_yd(); + if (ctl_leash <= 0.f && s.instance_ctx.is_in_instance) + ctl_leash = kPickupLeashYd; + if ((leash || controller_leash) && ctl_leash > 0.f && !controller.IsEmpty()) for (auto const& f : s.combat.nearby_friends) - if (f.guid == s.owner_guid) { owner_unit = &f; break; } + if (f.guid == controller) { owner_unit = &f; break; } for (auto const& e : s.combat.nearby_enemies) { if (e.hp <= 0 || e.is_player || e.untargetable || e.is_pacified) continue; @@ -954,13 +961,13 @@ static NearbyUnit const* UnclaimedLooseAttacker(BotSnapshot const& s, float rang if (owner_unit) { const float ox = e.x - owner_unit->x, oy = e.y - owner_unit->y; - if (ox * ox + oy * oy > kPickupLeashYd * kPickupLeashYd) + if (ox * ox + oy * oy > ctl_leash * ctl_leash) { static std::atomic s_leash_log{ 0 }; uint32 last = s_leash_log.load(std::memory_order_relaxed); if (s.published_at_ms - last >= 5000u && s_leash_log.compare_exchange_strong(last, s.published_at_ms)) TC_LOG_INFO("playerbot.v2", "[tank_leash] {} leaves entry {} alone: {:.0f} y from its owner (leash {:.0f} y); no pickup chase", - s.identity.name, e.entry, std::sqrt(ox * ox + oy * oy), kPickupLeashYd); + s.identity.name, e.entry, std::sqrt(ox * ox + oy * oy), ctl_leash); continue; } } @@ -1007,7 +1014,7 @@ NearbyUnit const* BotSnapshotView::taunt_candidate(float range) const // 79 [tank_loose] lines, Taunt ready, mobs 3-4 y away, no Taunt). } } - return UnclaimedLooseAttacker(*s_, range, /*target_reach=*/true); + return UnclaimedLooseAttacker(*s_, range, /*target_reach=*/true, /*leash=*/false, /*controller_leash=*/true); } bool BotSnapshotView::claim_blocks(NearbyUnit const& u) const @@ -1028,7 +1035,10 @@ NearbyUnit const* BotSnapshotView::pickup_candidate() const { if (NearbyUnit const* a = assigned_tank_mob()) return a; - return UnclaimedLooseAttacker(*s_, 30.f, /*target_reach=*/false, /*leash=*/true); + // Stay / Hold win over a chase: the tank keeps its spot (a taunt, which moves nobody, is still thrown by taunt_candidate). + if (s_->holding_position) + return nullptr; + return UnclaimedLooseAttacker(*s_, 30.f, /*target_reach=*/false, /*leash=*/true, /*controller_leash=*/true); } bool BotSnapshotView::has_item(uint32 entry) const diff --git a/src/modules/PlayerbotV2/Bot/BotSnapshotView.h b/src/modules/PlayerbotV2/Bot/BotSnapshotView.h index ee972809ba..8573863da4 100644 --- a/src/modules/PlayerbotV2/Bot/BotSnapshotView.h +++ b/src/modules/PlayerbotV2/Bot/BotSnapshotView.h @@ -91,6 +91,11 @@ public: std::string const& owner_name() const { return s_->owner_name; } bool has_owner_character() const { return !s_->owner_name.empty(); } bool is_companion_with_owner() const { return s_->owner_in_group; } + // In a group with a player who commands it: a companion, or a world bot a player invited. Neither runs world errands. + bool is_led_by_player() const { return s_->owner_in_group || s_->led_by_player; } + bool no_tag_stance() const { return s_->no_tag_stance; } + bool holding_position() const { return s_->holding_position; } + ObjectGuid controller_guid() const { return s_->owner_in_group ? s_->owner_guid : s_->controller_guid; } bool tactic_burn() const { return s_->tactic_burn; } // owner "max dps" bool tactic_save_mana() const { return s_->tactic_save_mana; } // owner "save mana" // A companion may sit down to eat or drink only when its owner has stopped next to it: otherwise the group follow diff --git a/src/modules/PlayerbotV2/Bot/Dungeon/MarkCc.h b/src/modules/PlayerbotV2/Bot/Dungeon/MarkCc.h index ac502e8e14..e55faadfc0 100644 --- a/src/modules/PlayerbotV2/Bot/Dungeon/MarkCc.h +++ b/src/modules/PlayerbotV2/Bot/Dungeon/MarkCc.h @@ -33,6 +33,7 @@ constexpr uint32 kAnyType = (1u << 1) | (1u << 2) | (1u << 3) | (1u << 4) | (1u (1u << 8) | (1u << 9) | (1u << 10); constexpr uint32 kStealth = 1784; +constexpr uint32 kRenewMs = 5000; // a hold of ours with less than this left is cast again constexpr uint32 kFreezingTrap = 1499, kEnslaveDemon = 1098, kEntanglingRoots = 339; struct Option @@ -157,7 +158,10 @@ bool TryCast(View const& s, Emit& emit, ObjectGuid target) return LogRefusal(low, now, s.name().c_str(), "mob not in view", target.GetEntry(), -1, 0.f), false; if (u->hp <= 0 || u->untargetable) return false; - if (u->is_cc_locked) + // Our own hold about to run out: a Polymorph lasts 50 s and the four Healers of Majordomo woke together, then stood loose + // for the 10 s the mages needed to start again. A renewal cast on the held mob resets it (vanilla mages did exactly this). + bool const renew = s.cls() == CLASS_MAGE && u->is_cc_locked && u->cc_caster == s.guid() && u->cc_ms_left > 0 && u->cc_ms_left < kRenewMs; + if (u->is_cc_locked && !renew) return false; // held (by us or another): the goal if (CasterHoldsAnother(s, target)) return LogRefusal(low, now, s.name().c_str(), "this caster's crowd control already holds another mob", u->entry, TypeOf(*u), 0.f), false; @@ -167,6 +171,9 @@ bool TryCast(View const& s, Emit& emit, ObjectGuid target) return LogRefusal(low, now, s.name().c_str(), "the raid's kill target", u->entry, TypeOf(*u), 0.f), false; if (u->max_hp > 0 && u->hp * 2 < u->max_hp) return LogRefusal(low, now, s.name().c_str(), "mob under half health, being killed", u->entry, TypeOf(*u), 0.f), false; + // Magic Reflection (Majordomo's adds): the spell comes back onto the caster. + if (u->magic_buff_spell == 20619 && s.cls() != CLASS_ROGUE) + return LogRefusal(low, now, s.name().c_str(), "the mob reflects spells", u->entry, TypeOf(*u), 0.f), false; if (u->root_caster == s.guid()) return false; // our own Entangling Roots still holds it (a root is not a CC lock) bool const ooc = !s.in_combat() && !u->unit_in_combat; diff --git a/src/modules/PlayerbotV2/Bot/Dungeon/PveGroupCoordinator.cpp b/src/modules/PlayerbotV2/Bot/Dungeon/PveGroupCoordinator.cpp index 6edb08c78e..9ba2b50937 100644 --- a/src/modules/PlayerbotV2/Bot/Dungeon/PveGroupCoordinator.cpp +++ b/src/modules/PlayerbotV2/Bot/Dungeon/PveGroupCoordinator.cpp @@ -11,9 +11,11 @@ #include "../ClassTables.h" #include "../Raid/RaidBrain.h" #include "../Raid/RaidEncounters.h" +#include "../Raid/KickRules.h" #include "../Raid/RaidHealSlots.h" #include "../Raid/RaidHealGroups.h" #include "../ClassicUpkeep.h" +#include "../ThreatLimits.h" #include "MarkCc.h" #include "PrePullCc.h" #include "Combat/Apl/ApInterrupt.h" @@ -241,7 +243,9 @@ void PveGroupCoordinator::Update(uint32 now_ms) uint32& started = fight_start_[bkey]; if (!started) started = now_ms; - uint32 const wait_ms = Services::Config().raid_dps_wait_timeout_ms(); + // A raid waits as long as configured (up to eight seconds: the tank takes a while to run in); a party keeps its six. + uint32 const wait_ms = gs->is_raid ? Services::Config().raid_dps_wait_timeout_ms() + : std::min(Services::Config().raid_dps_wait_timeout_ms(), kPartyDpsWaitTimeoutMs); if (wait_ms && now_ms - started >= wait_ms && !(mark_release_until_.count(bkey) && now_ms < mark_release_until_[bkey])) { mark_release_until_[bkey] = now_ms + 10000u; @@ -534,7 +538,7 @@ void PveGroupCoordinator::Update(uint32 now_ms) // and the hunter tranq order. See PlanInterrupts / PlanTranq. // The Felhunter duty goes first: it is pet choice, not live state. PlanFelhunters(bkey, mem, snaps, plan); - PlanInterrupts(mem, snaps, plan); + PlanInterrupts(bkey, mem, snaps, plan); PlanTranq(bkey, mem, snaps, plan); // Soak duty: assigned UNCONDITIONALLY every plan (the fields cost @@ -794,6 +798,8 @@ void PveGroupCoordinator::Update(uint32 now_ms) it = buckets.count(it->first) ? std::next(it) : cc_held_.erase(it); for (auto it = mark_release_until_.begin(); it != mark_release_until_.end();) it = buckets.count(it->first) ? std::next(it) : mark_release_until_.erase(it); + for (auto it = kick_plan_logged_.begin(); it != kick_plan_logged_.end();) + it = buckets.count(it->first) ? std::next(it) : kick_plan_logged_.erase(it); for (auto it = fight_start_.begin(); it != fight_start_.end();) it = buckets.count(it->first) ? std::next(it) : fight_start_.erase(it); for (auto it = defend_since_.begin(); it != defend_since_.end();) @@ -833,7 +839,7 @@ void PveGroupCoordinator::Update(uint32 now_ms) last_dump_ = "no coordinated dungeon/raid groups"; } -void PveGroupCoordinator::PlanInterrupts(std::vector const& mem, +void PveGroupCoordinator::PlanInterrupts(uint64 bkey, std::vector const& mem, std::vector> const& snaps, std::unordered_map& plan) { @@ -871,8 +877,10 @@ void PveGroupCoordinator::PlanInterrupts(std::vector const& mem, struct Kicker { uint64 low = 0; + std::string name; Kick::Ability a; bool ready = false; + bool busy = false; // mid own cast: cannot kick before it finishes (a pet's Spell Lock does not wait for its master) float x = 0.f, y = 0.f, z = 0.f; ObjectGuid victim; PveOrder* o = nullptr; @@ -891,8 +899,10 @@ void PveGroupCoordinator::PlanInterrupts(std::vector const& mem, o->interrupt_rank = irank < 0xFF ? irank++ : 0xFF; Kicker k; k.low = e.guid_low; + k.name = e.src ? e.src->name : std::to_string(e.guid_low); k.a = a; k.ready = Kick::Ready(v, a); + k.busy = !a.pet && it->second->cast.is_casting && it->second->cast.current_cast_remaining.count() > 0; k.x = it->second->position.x; k.y = it->second->position.y; k.z = it->second->position.z; k.victim = v.victim(); k.o = o; @@ -902,11 +912,11 @@ void PveGroupCoordinator::PlanInterrupts(std::vector const& mem, return; // Per casting mob: the union of every bot's view of interruptible casts - // on mobs engaged with the group, most urgent first. Each gets the - // nearest interrupters with their kick ready and the mob in range: + // on mobs engaged with the group, most urgent first (Raid::Kicks::CastBefore). Each gets the + // nearest free interrupters with their kick ready and the mob in range: // rank 0 kicks on sight, rank 1 backs it up (BotSnapshotView:: // interrupt_window_open). One mob per interrupter. - struct CastingMob { ObjectGuid guid; float x, y, z; int64 rem; NearbyUnit const* u; bool first; }; + struct CastingMob { ObjectGuid guid; float x, y, z; int64 rem; NearbyUnit const* u; size_t order; }; std::vector casts; for (auto const& sp : snaps) for (NearbyUnit const& u : sp->combat.nearby_enemies) @@ -914,24 +924,23 @@ void PveGroupCoordinator::PlanInterrupts(std::vector const& mem, if (!Kick::Casting(u) || !Kick::EngagedWithGroup(u) || u.cast_remaining.count() < 350) continue; if (std::any_of(casts.begin(), casts.end(), [&](CastingMob const& c) { return c.guid == u.guid; })) continue; - // A raid rule can name casts that go first (Dark Mending, Healing Circle, Greater Polymorph). + // A raid rule names casts that go first, in order (Dark Mending before Shadow Bolt; Healing Circle, Greater Polymorph). casts.push_back({ u.guid, u.x, u.y, u.z, int64(u.cast_remaining.count()), &u, - Raid::InterruptFirst(sp->position.map_id, u.casting_spell_id) }); + Raid::InterruptOrder(sp->position.map_id, u.casting_spell_id) }); } if (casts.empty()) return; std::sort(casts.begin(), casts.end(), [](CastingMob const& a, CastingMob const& b) { - if (a.first != b.first) return a.first; - if (a.rem != b.rem) return a.rem < b.rem; - return a.guid.GetCounter() < b.guid.GetCounter(); + return Raid::Kicks::CastBefore({ a.order, a.rem, a.guid.GetCounter() }, { b.order, b.rem, b.guid.GetCounter() }); }); + auto& logged = kick_plan_logged_[bkey]; std::array claimed{}; size_t n_claimed = 0; for (CastingMob const& c : casts) { if (n_claimed >= claimed.size()) break; - std::vector> cand; + std::vector> cand; for (Kicker& k : kickers) { if (!k.ready || !k.o->interrupt_target.IsEmpty()) continue; @@ -939,14 +948,29 @@ void PveGroupCoordinator::PlanInterrupts(std::vector const& mem, const float dx = c.x - k.x, dy = c.y - k.y, dz = c.z - k.z; const float d = std::sqrt(dx * dx + dy * dy + dz * dz); const bool reach = (k.a.melee && k.victim == c.guid) || d <= k.a.range + (k.a.melee ? 2.5f : 0.f); - if (reach) cand.emplace_back(d, &k); + if (reach) cand.emplace_back(Raid::Kicks::Kicker{ k.busy, d, k.low }, &k); + } + std::sort(cand.begin(), cand.end(), [](auto const& a, auto const& b) { return Raid::Kicks::KickerBefore(a.first, b.first); }); + // A listed cast (the Healers' Dark Mending) is logged once per cast with who takes it, or that nobody can: the kick + // rotation is the Majordomo fight's key, and only a log line says whether it happened. + if (c.order != Raid::kNotInterruptFirst) + { + const uint64 state = (uint64(c.u->casting_spell_id) << 32) | (cand.empty() ? 0xFFFFFFFFull : (cand[0].second->low & 0xFFFFFFFFull)); + if (uint64& was = logged[c.guid.GetCounter()]; was != state) + { + was = state; + CreatureTemplate const* ct = sObjectMgr->GetCreatureTemplate(c.u->entry); + if (cand.empty()) + TC_LOG_INFO("playerbot.v2", "[raid_interrupt] plan: {} ({}) casts {} ({}ms left), no kicker ready in reach ({} kickers)", + ct ? ct->Name : std::string("?"), c.guid.GetCounter(), c.u->casting_spell_id, c.rem, kickers.size()); + else + TC_LOG_INFO("playerbot.v2", "[raid_interrupt] plan: {} ({}) casts {} ({}ms left) -> {} kicks (spell {}, {:.0f}y{}){}", + ct ? ct->Name : std::string("?"), c.guid.GetCounter(), c.u->casting_spell_id, c.rem, + cand[0].second->name, cand[0].second->a.spell, cand[0].first.dist, cand[0].first.busy ? ", mid-cast" : "", + cand.size() > 1 ? ", " + cand[1].second->name + " backs up" : std::string(", no backup")); + } } if (cand.empty()) continue; - std::sort(cand.begin(), cand.end(), [](auto const& a, auto const& b) - { - if (a.first != b.first) return a.first < b.first; - return a.second->low < b.second->low; - }); for (size_t r = 0; r < cand.size() && r < 2; ++r) { cand[r].second->o->interrupt_target = c.guid; @@ -1231,6 +1255,13 @@ void PveGroupCoordinator::PlanMarkOrders(uint64 group_low, uint32 map_id, bool i for (auto const& e : mem) if (e.alive && e.src->max_hp > 0 && Pct(e.src->hp, e.src->max_hp) < 40) { emergency = true; break; } + // An enemy the raid's data never holds (Raid::NoControl): neither an icon nor the automatic pick sends a caster to it. + auto never_controlled = [&](uint32 entry) -> bool + { + if (!is_raid) return false; + Raid::RaidRules const* rr = Raid::RulesForMap(map_id); + return rr && std::any_of(rr->noControl.begin(), rr->noControl.end(), [&](Raid::NoControl const& n) { return n.enemy == entry; }); + }; std::vector cc_taken; bool moon_is_tank_mark = false; for (auto const& [tank_low, marker] : Services::Owners().TankMarks(group_low)) @@ -1292,7 +1323,7 @@ void PveGroupCoordinator::PlanMarkOrders(uint64 group_low, uint32 map_id, bool i for (uint8 sym : order) { NearbyUnit const* u = mob_of(sym); - if (!u || Classic::IsBossUnit(*u)) continue; + if (!u || Classic::IsBossUnit(*u) || never_controlled(u->entry)) continue; if (u->guid == icon[7] || u->guid == icon[6]) continue; // marked skull / cross: killed, never crowd-controlled if (u->max_hp > 0 && u->hp * 2 < u->max_hp) continue; // under half health: being killed, not held again if (std::find(cc_taken.begin(), cc_taken.end(), u->guid) != cc_taken.end()) continue; @@ -1346,7 +1377,7 @@ void PveGroupCoordinator::PlanMarkOrders(uint64 group_low, uint32 map_id, bool i // the owner put on a caster sends that caster to hold it (the loop above). for (ObjectGuid const& marked : icon) if (u.guid == marked) return false; - if (kill_focus_of(u.guid)) return false; + if (kill_focus_of(u.guid) || never_controlled(u.entry)) return false; // Nor the mob the owner (any human) or a tank is hitting: a sheep on it breaks at once and is recast, over and over. for (auto const& m : mem) if ((!m.is_bot || m.tank) && m.src && m.src->victim == u.guid) return false; @@ -1752,6 +1783,7 @@ void PveGroupCoordinator::PlanRaidTanks(uint64 bkey, uint64 group_low, uint32 ma if (!t || !t->is_bot) continue; Mob const* mm = find_mob(mk_grp->GetTargetIcon(mkr)); if (!mm) continue; + if (Raid::OffTankMob(map_id, mm->u->entry)) continue; // the second tank's, whatever tank the icon was given to if (auto sit = sticky.find(tl); sit != sticky.end() && sit->second == mm->u->guid) continue; for (auto it = sticky.begin(); it != sticky.end();) it = it->second == mm->u->guid ? sticky.erase(it) : std::next(it); @@ -1880,6 +1912,32 @@ void PveGroupCoordinator::PlanRaidTanks(uint64 bkey, uint64 group_low, uint32 ma return true; return false; }; + // A boss the rules give the second tank (Majordomo): the off tank holds him whatever it held, and whoever held him takes a + // free mob below. The owner's plan: off tank on him, the other tanks one Elite each, the main tank the skull. + if (off_tank) + if (auto ot = by_low.find(off_tank); ot != by_low.end() && ot->second->is_bot && ot->second->alive && !user_sym.count(off_tank)) + for (auto const& m : mobs) + { + if (!Raid::OffTankMob(map_id, m.u->entry)) continue; + if (auto sit = sticky.find(off_tank); sit != sticky.end() && sit->second == m.u->guid) break; + if (auto sit = sticky.find(off_tank); sit != sticky.end()) + { + taken.erase(std::remove(taken.begin(), taken.end(), sit->second), taken.end()); + sticky.erase(sit); + } + for (auto it = sticky.begin(); it != sticky.end();) + { + if (it->second == m.u->guid) + { + taken.erase(std::remove(taken.begin(), taken.end(), it->second), taken.end()); + it = sticky.erase(it); + } + else + ++it; + } + assign(ot->second, m, "off_tank_mob"); + break; + } // The main tank chooses first: the mob it already hits (its pull), else the mob engaged with it, else the // nearest. Without this a spare tank that ran at the pull target before the main tank had a victim of its own // would be handed the main tank's mob, and the main tank the next one. @@ -1909,7 +1967,8 @@ void PveGroupCoordinator::PlanRaidTanks(uint64 bkey, uint64 group_low, uint32 ma if (!t->is_bot || sticky.count(t->guid_low)) continue; for (auto const& m : mobs) if (auto const hold = cc_held.find(m.u->guid.GetCounter()); - hold != cc_held.end() && hold->second.tank_low == t->guid_low && !is_taken(m.u->guid) && !Raid::NoTank(map_id, m.u->entry)) + hold != cc_held.end() && hold->second.tank_low == t->guid_low && !is_taken(m.u->guid) && !Raid::NoTank(map_id, m.u->entry) && + !cc_owned(m)) // a sheep the owner gave a mage broke: the mage recasts it, the tank does not hit it { assign(t, m, "cc_released"); break; @@ -1918,7 +1977,7 @@ void PveGroupCoordinator::PlanRaidTanks(uint64 bkey, uint64 group_low, uint32 ma for (Member const* t : tanks) { if (!t->is_bot || sticky.count(t->guid_low)) continue; - if (Mob const* cur = find_mob(t->src->victim); cur && !is_taken(cur->u->guid) && !Raid::NoTank(map_id, cur->u->entry) && + if (Mob const* cur = find_mob(t->src->victim); cur && !is_taken(cur->u->guid) && !Raid::NoTank(map_id, cur->u->entry) && !cc_owned(*cur) && !(Raid::TankLast(map_id, cur->u->entry) && other_free_mob(cur->u->guid))) assign(t, *cur, "already_on_it"); } @@ -1950,6 +2009,10 @@ void PveGroupCoordinator::PlanRaidTanks(uint64 bkey, uint64 group_low, uint32 ma for (Member const* t : tanks) { if (!t->is_bot || !t->alive || user_sym.count(t->guid_low)) continue; + // The tank on a boss the rules give the second tank keeps him. + if (auto sit = sticky.find(t->guid_low); sit != sticky.end()) + if (Mob const* held = find_mob(sit->second); held && Raid::OffTankMob(map_id, held->u->entry)) + continue; // A tank already on the other kill mark keeps it. if (auto sit = sticky.find(t->guid_low); sit != sticky.end() && (sit->second == mk_grp->GetTargetIcon(7) || sit->second == mk_grp->GetTargetIcon(6))) @@ -1984,10 +2047,12 @@ void PveGroupCoordinator::PlanRaidTanks(uint64 bkey, uint64 group_low, uint32 ma bool const tank_last = Raid::TankLast(map_id, m.u->entry); bool const adds_up = tank_last && std::any_of(mobs.begin(), mobs.end(), [&](Mob const& o) { return o.u->guid != m.u->guid && !Raid::NoTank(map_id, o.u->entry) && !Raid::TankLast(map_id, o.u->entry); }); - // No tank leaves an add for him while an add is loose: the adds are the threat. Once every add is held he goes to the tank with - // the fewest mobs on it, not to whichever tank is left (n44 mc_majordomo: nobody held him, he stood on a healer all fight and - // killed two by melee). - if (adds_up && std::any_of(mobs.begin(), mobs.end(), [&](Mob const& o) { return o.loose && !Raid::NoTank(map_id, o.u->entry) && !Raid::TankLast(map_id, o.u->entry); })) + // No free tank leaves an add for him while an add is loose: the adds are the threat. Once every bot tank holds something he goes to + // the tank with the fewest mobs on it, loose add or not (Majordomo: nobody held him, he stood on a healer all fight and + // killed two by melee; with eight adds one is always loose, so he stood on one add after the other for 30 s). + bool const free_tank = std::any_of(tanks.begin(), tanks.end(), [&](Member const* t) + { return t->is_bot && t->alive && !user_sym.count(t->guid_low) && !sticky.count(t->guid_low); }); + if (adds_up && free_tank && std::any_of(mobs.begin(), mobs.end(), [&](Mob const& o) { return o.loose && !Raid::NoTank(map_id, o.u->entry) && !Raid::TankLast(map_id, o.u->entry); })) continue; Member const* best = nullptr; size_t best_load = SIZE_MAX; diff --git a/src/modules/PlayerbotV2/Bot/Dungeon/PveGroupCoordinator.h b/src/modules/PlayerbotV2/Bot/Dungeon/PveGroupCoordinator.h index f641e065db..843a7fdec1 100644 --- a/src/modules/PlayerbotV2/Bot/Dungeon/PveGroupCoordinator.h +++ b/src/modules/PlayerbotV2/Bot/Dungeon/PveGroupCoordinator.h @@ -181,12 +181,15 @@ private: // raid icons on mobs nobody fights yet may start the fight (PveOrder::marks_released). std::unordered_map mark_release_until_; std::unordered_map fight_start_; // first ms of the current fight (Playerbot.Raid.DpsWaitTimeoutMs) + // Per-(group, map): mob guid counter -> the last logged kick assignment on a listed cast (RaidRules::interruptFirst), spell and + // rank-0 kicker packed, so [raid_interrupt] plan lines come once per cast and not once per 500 ms plan. + std::unordered_map> kick_plan_logged_; std::unordered_map defend_since_; // first ms a mob has stood on a non-tank member this fight (0 = none now) std::unordered_map fight_log_; // Interrupt rotation (Classic: live-ability ranks + per-casting-mob // assignment) and the hunter Tranquilizing Shot order. World thread, // inside Update(); write interrupt_* / tranq_rank into `plan`. - void PlanInterrupts(std::vector const& mem, + void PlanInterrupts(uint64 bkey, std::vector const& mem, std::vector> const& snaps, std::unordered_map& plan); void PlanTranq(uint64 bkey, std::vector const& mem, diff --git a/src/modules/PlayerbotV2/Bot/Dungeon/Scripts/NaxxramasScript.cpp b/src/modules/PlayerbotV2/Bot/Dungeon/Scripts/NaxxramasScript.cpp index 4a272f3b52..b6b1e01c93 100644 --- a/src/modules/PlayerbotV2/Bot/Dungeon/Scripts/NaxxramasScript.cpp +++ b/src/modules/PlayerbotV2/Bot/Dungeon/Scripts/NaxxramasScript.cpp @@ -25,17 +25,17 @@ public: DungeonAdvice get_advice(BotSnapshotView const& /*s*/) const override { DungeonAdvice a; + // The raid rules (Raid/RaidEncounterData_NAXX.cpp) replace this list below (ApplyRaidAdvice); it stays in step with them: + // Faerlina's Worshippers (16506) are mind-controlled and sacrificed, Razuvious' Understudies (16803) are the tanks, Kel'Thuzad's + // Guardians (16441) are shackled, and Thaddius himself (15928) is the boss, not an add. None of them is a kill target. a.high_priority_kill_entries = { 16573, // Crypt Guard (Anub'Rekhan) 17055, // Spiderling 16486, // Web Wrap (Maexxna — frees trapped player) - 16506, // Naxxramas Worshipper (Faerlina) 16505, // Naxxramas Follower (Faerlina) - 16803, // Death Knight Understudy (Razuvious — MC target) 16360, // Zombie Chow (Gluth) - 15928, // Feugen (Thaddius) + 15930, // Feugen (Thaddius) 15929, // Stalagg (Thaddius) - 16441, // Guardian of Icecrown (Kel'Thuzad) }; a.mandatory_interrupt_spells = { // Patchwerk diff --git a/src/modules/PlayerbotV2/Bot/Gear/BotGearGenerator.cpp b/src/modules/PlayerbotV2/Bot/Gear/BotGearGenerator.cpp index f189eaec68..02cfa6abad 100644 --- a/src/modules/PlayerbotV2/Bot/Gear/BotGearGenerator.cpp +++ b/src/modules/PlayerbotV2/Bot/Gear/BotGearGenerator.cpp @@ -1,6 +1,7 @@ #include "BotGearGenerator.h" #include "BotItemScorer.h" #include "OwnedGearPolicy.h" +#include "WorldGearStart.h" #include "Bot/ClassTables.h" // MaxPlayerLevel() #include "ObjectMgr.h" #include "DB2Stores.h" // sItemSetStore: tier set pieces @@ -700,6 +701,8 @@ std::vector GenerateGearFor(GearGenerationContext const& ctx) { std::vector out; if (!g_initialized || ctx.cls < 1 || ctx.cls >= MAX_CLASSES) return out; + // A world bot below level 10 keeps its starting outfit (WorldGearStart.h). + if (!::Playerbot::Gear::GeneratesGear(ctx.world_bot(), ctx.level)) return out; uint16 const target_ilvl = TargetIlvlForLevel(ctx.level); auto const& pool = g_pools[ctx.cls]; diff --git a/src/modules/PlayerbotV2/Bot/Gear/WorldGearStart.h b/src/modules/PlayerbotV2/Bot/Gear/WorldGearStart.h new file mode 100644 index 0000000000..47fef8ab6c --- /dev/null +++ b/src/modules/PlayerbotV2/Bot/Gear/WorldGearStart.h @@ -0,0 +1,17 @@ +#pragma once +// A world bot below this level keeps the outfit its character was created with, as a vanilla level 1-9 does: no gear is generated for +// it (a level 1 wore rings, trinkets, neck and cloak). Companions of a player are not world bots and are not +// affected. Pure: tested in tests/game/ClassicWorldGearStart.cpp. + +#include + +namespace Playerbot::Gear { + +constexpr std::uint8_t kWorldGearMinLevel = 10; + +constexpr bool GeneratesGear(bool world_bot, std::uint8_t level) +{ + return !world_bot || level >= kWorldGearMinLevel; +} + +} // namespace Playerbot::Gear diff --git a/src/modules/PlayerbotV2/Bot/GroupControl.h b/src/modules/PlayerbotV2/Bot/GroupControl.h new file mode 100644 index 0000000000..b68b279e1f --- /dev/null +++ b/src/modules/PlayerbotV2/Bot/GroupControl.h @@ -0,0 +1,51 @@ +// GroupControl - who commands a bot that is in a group with players, and how far a stance lets it go. +// +// Pure functions on plain values (templated on the guid type), so the rules are unit-tested without a server. +// +// A bot in a group with a player is "led": it has a controller, and it does what the group does (no world errands, orders +// reach it). The controller is its owner when the owner is in the group (handled by the snapshot builder, not here); with no +// owner in the group it is the group leader when that is a player, else the first player in the group. A group of bots only +// has none and the bots stay autonomous. + +#pragma once + +#include + +namespace Playerbot::GroupControl { + +template +struct Member +{ + Guid guid; + bool human = false; // a player (not a bot session) +}; + +// `others` are the group's members other than the bot itself, in group order. +template +Guid ResolveController(Guid const& leader, std::vector> const& others) +{ + for (auto const& m : others) + if (m.human && m.guid == leader) + return leader; + for (auto const& m : others) + if (m.human) + return m.guid; + return Guid{}; +} + +// Passive: a mob already on the bot is always fought (it cannot be ignored); a mob on someone else is taken only while it is +// within `leash` yards of the controller, so a bot never leaves the group to chase one. leash <= 0 switches the leash off. +inline bool PassiveMayDefend(bool mob_on_self, float mob_to_controller, float leash) +{ + if (mob_on_self || leash <= 0.f) + return true; + return mob_to_controller <= leash; +} + +// Aggressive: any hostile within `radius` yards of the controller, nothing beyond it. +inline bool AggressiveMayAttack(float mob_to_controller, float radius) +{ + return mob_to_controller <= radius; +} + +} // namespace Playerbot::GroupControl diff --git a/src/modules/PlayerbotV2/Bot/GroupOrderText.cpp b/src/modules/PlayerbotV2/Bot/GroupOrderText.cpp index 38bae8322a..fe851676ea 100644 --- a/src/modules/PlayerbotV2/Bot/GroupOrderText.cpp +++ b/src/modules/PlayerbotV2/Bot/GroupOrderText.cpp @@ -62,6 +62,35 @@ std::optional ClassifyGroupOrder(std::string_view msg, bool owner_w return order; } +std::optional AddressedGroupOrder(std::string_view msg, std::function const& is_group_bot) +{ + if (msg.empty() || msg.front() == ';') + return std::nullopt; + auto const begin = msg.find_first_not_of(" \t"); + if (begin == std::string_view::npos) + return std::nullopt; + msg.remove_prefix(begin); + auto const sep = msg.find_first_of(" \t"); + if (sep == std::string_view::npos) + return std::nullopt; + std::string_view name = msg.substr(0, sep); + while (!name.empty() && (name.back() == ',' || name.back() == ':')) + name.remove_suffix(1); + std::string_view rest = msg.substr(sep + 1); + auto const rest_begin = rest.find_first_not_of(" \t"); + if (name.empty() || rest_begin == std::string_view::npos) + return std::nullopt; + rest.remove_prefix(rest_begin); + rest = rest.substr(0, rest.find_last_not_of(" \t") + 1); + std::string lower(name); + std::transform(lower.begin(), lower.end(), lower.begin(), [](unsigned char c) { return char(std::tolower(c)); }); + if (lower == "all" || lower == "everyone" || lower == "everybody") + return "squad:" + std::string(rest); + if (!is_group_bot(name)) + return std::nullopt; + return std::string(name) + ":" + std::string(rest); +} + std::optional ClassifyAddonOrder(std::string_view prefix, std::string_view text, bool owner_words) { if (prefix != kAddonOrderPrefix) diff --git a/src/modules/PlayerbotV2/Bot/GroupOrderText.h b/src/modules/PlayerbotV2/Bot/GroupOrderText.h index 60eec82ff6..a007644fd3 100644 --- a/src/modules/PlayerbotV2/Bot/GroupOrderText.h +++ b/src/modules/PlayerbotV2/Bot/GroupOrderText.h @@ -3,6 +3,7 @@ // Pure text: no Player, no Group, no config singleton (the owner-word switch is passed in). #pragma once +#include #include #include #include @@ -17,6 +18,13 @@ inline constexpr std::string_view kAddonOrderPrefix = "FBOTS"; // path). owner_words enables the plain-language owner commands (Playerbot.Behavior.OwnerCommands). std::optional ClassifyGroupOrder(std::string_view msg, bool owner_words); +// A party or raid line addressed to one bot or to all of them without the ';' prefix: "Lentha use altar", "Baxter, follow", +// "all use altar". The first word must be the name of a bot in the sender's group (is_group_bot, case-insensitive; a +// trailing ',' or ':' is allowed) or "all" / "everyone"; the rest is the order. Returns the whisper-parser form +// ("Lentha:use altar", "squad:use altar") or nullopt for chatter. Whether the rest is a real order is the parser's call, +// and an unknown one stays silent, so "Lentha nice heals" does nothing. +std::optional AddressedGroupOrder(std::string_view msg, std::function const& is_group_bot); + // The same for an addon message: only the fixed prefix counts, the text is classified as party chat would be. std::optional ClassifyAddonOrder(std::string_view prefix, std::string_view text, bool owner_words); diff --git a/src/modules/PlayerbotV2/Bot/IdleRule.cpp b/src/modules/PlayerbotV2/Bot/IdleRule.cpp index b6691cb378..b486f3f264 100644 --- a/src/modules/PlayerbotV2/Bot/IdleRule.cpp +++ b/src/modules/PlayerbotV2/Bot/IdleRule.cpp @@ -38,7 +38,7 @@ namespace bool IsWorldErrand(std::string_view name) { static constexpr std::string_view kPrefixes[] = { - "idle:ah_", "idle:autoact_dispatch", "idle:bags_full_recover", "idle:bank_deposit", + "idle:ah_", "idle:autoact_dispatch", "idle:bag_hearth", "idle:bags_full_recover", "idle:bank_deposit", "idle:calendar_", "idle:capital_bag_run", "idle:craft_order_", "idle:critical_repair", "idle:dual_spec_switch", "idle:dungeon_loop_requeue", "idle:dungeon_quest_approach", "idle:far_same_map_travel", "idle:gather", "idle:guild_", "idle:homebind", "idle:invite_nearby_player", "idle:legacy_vendor_dispatch", @@ -46,6 +46,7 @@ bool IsWorldErrand(std::string_view name) "idle:pet_swap_from_stable", "idle:pursue_quest_", "idle:pvp_help_callout", "idle:assist_friend_pvp", "idle:quest_", "idle:react_to_passerby", "idle:resolve_junk_quests", "idle:swim_stuck_hearth", "idle:swim_stuck_walk_to_hub", "idle:tame_beast", "idle:taxi_discover", "idle:transport_ride", "idle:vendor_visit", + "idle:bag_hearth", "idle:fidget", "idle:inn_rest", "idle:mailbox", "idle:town_duel", "idle:wander", "idle:walk_", "idle:wq_", "idle:yell_lfg", "idle:ambient_sit", "idle:rpg_", }; @@ -97,7 +98,8 @@ std::string_view IdleRuleRegistry::tick(BotSnapshotView const& s, BotAI& ai, if (r.priority < min_priority) break; // rules_ sorted desc — bail early if (!r.enabled) continue; if (!r.gate) continue; - if (r.world_errand && s.is_companion_with_owner()) continue; + // A bot in a group with a player (its owner, or the player who invited it) never runs world errands. + if (r.world_errand && s.is_led_by_player()) continue; // Per-rule gate-throttle, kept per bot: a rule with min_interval_ms > 0 is looked at by a given bot no more than once per interval // (low-urgency rules such as mail, calendar, auction and charter do not need every tick). The first look is spread over the // interval by a hash of bot and rule, so a fleet does not look in the same second. diff --git a/src/modules/PlayerbotV2/Bot/IdleWatch.h b/src/modules/PlayerbotV2/Bot/IdleWatch.h index 79c56cef72..498b1dade9 100644 --- a/src/modules/PlayerbotV2/Bot/IdleWatch.h +++ b/src/modules/PlayerbotV2/Bot/IdleWatch.h @@ -19,8 +19,24 @@ struct IdleWatch std::uint32_t forced_until_ms = 0; // the new activity runs until then float tx = 0.f, ty = 0.f, tz = 0.f; // the place it was sent to bool has_target = false; + char const* prev_rule = nullptr; // the last rule other than the watch's own walk that moved or held the bot }; +// The rules that walk a bot toward its quest objective. A bot found standing again and again while one of them was the last to hold +// it cannot close that objective from here. +inline bool IsObjectiveRule(char const* rule) +{ + if (!rule) return false; + for (char const* name : { "idle:pursue_quest_goal", "idle:far_same_map_travel" }) + { + char const* a = rule; + char const* b = name; + while (*a && *a == *b) { ++a; ++b; } + if (!*b) return true; + } + return false; +} + constexpr float kIdleMoveYards = 3.0f; // less than this is still standing constexpr float kIdleResetStrikesYards = 20.0f; // really went somewhere: the next stall starts from the first activity constexpr std::uint32_t kIdleStuckMs = 45000u; // standing this long with no reason is stuck diff --git a/src/modules/PlayerbotV2/Bot/InstanceFullHold.h b/src/modules/PlayerbotV2/Bot/InstanceFullHold.h new file mode 100644 index 0000000000..d5d88c7081 --- /dev/null +++ b/src/modules/PlayerbotV2/Bot/InstanceFullHold.h @@ -0,0 +1,19 @@ +// InstanceFullHold - a companion refused at an instance door because the instance holds its most players waits where it is and asks +// again later, instead of walking to an entrance it cannot use. Plain function so it is tested without a world +// (tests/game/ClassicInstanceFullHold.cpp). A 15-bot raid in a 10-player dungeon: a bot refused 'instance full' for +// minutes, walked the open world to the entrance and died to the Scarshield Sentries, outside the instance where nobody could raise him. + +#pragma once + +#include + +namespace Playerbot::V2 { + +// True while the full refusal for `anchor_map` is younger than `hold_ms`. `full_map` 0 = no refusal on record. +constexpr bool InstanceFullHolds(std::uint32_t full_map, std::uint32_t full_ms, std::uint32_t anchor_map, std::uint32_t now_ms, + std::uint32_t hold_ms) +{ + return full_map != 0 && full_map == anchor_map && static_cast(now_ms - full_ms) < hold_ms; +} + +} // namespace Playerbot::V2 diff --git a/src/modules/PlayerbotV2/Bot/Raid/DispelWorth.h b/src/modules/PlayerbotV2/Bot/Raid/DispelWorth.h index 758b33531c..c794be3925 100644 --- a/src/modules/PlayerbotV2/Bot/Raid/DispelWorth.h +++ b/src/modules/PlayerbotV2/Bot/Raid/DispelWorth.h @@ -14,6 +14,15 @@ constexpr int kNonUrgentDispelHealerManaPct = 40; // A non-urgent dispel rule hands out at most this many orders per plan: an aura on forty members is not forty casts in a tick. constexpr unsigned kNonUrgentDispelOrdersPerPlan = 2; +// How many orders a rule may hand out per plan. maxOrders (RaidEncounters.h Dispel) caps a rule that has its own limit, urgent or not; +// 0 = the rule has none, so an urgent rule is uncapped and a non-urgent one gets kNonUrgentDispelOrdersPerPlan. +inline bool DispelOrderAllowed(bool urgent, unsigned maxOrders, unsigned given) +{ + if (maxOrders > 0) + return given < maxOrders; + return urgent || given < kNonUrgentDispelOrdersPerPlan; +} + // A rule with hurtBelowPct > 0 (RaidEncounters.h Dispel) is only cast once the carrier is at or under that health: the debuff then // really costs the raid something. 0 = always (curses and other debuffs that do harm at full health). Urgent rules always. inline bool DispelWorthIt(bool urgent, int hurtBelowPct, int carrierHpPct) diff --git a/src/modules/PlayerbotV2/Bot/Raid/KickRules.h b/src/modules/PlayerbotV2/Bot/Raid/KickRules.h new file mode 100644 index 0000000000..c3478ec285 --- /dev/null +++ b/src/modules/PlayerbotV2/Bot/Raid/KickRules.h @@ -0,0 +1,46 @@ +// KickRules - the pure part of the PvE coordinator's kick election (PveGroupCoordinator::PlanInterrupts): which cast the ready kickers go on +// first, and which kicker goes first on it. No world access, so tests/game/ClassicRaidFightScript.cpp covers it. + +#pragma once + +#include +#include + +namespace Playerbot::Raid::Kicks { + +// One interruptible cast the election saw. order: its place on the map's interruptFirst list (RaidEncounters.h InterruptOrder), the +// not-listed value for every other cast. +struct Cast +{ + size_t order; + int64_t remainingMs; + uint64_t guid; +}; + +// Listed casts first, in the list's order (Dark Mending before Shadow Bolt: a Healer's heal is never left to the late backups while +// the ready kickers go on a bolt); then the cast nearest to landing; then the lowest guid, so two plans agree. +inline bool CastBefore(Cast const& a, Cast const& b) +{ + if (a.order != b.order) return a.order < b.order; + if (a.remainingMs != b.remainingMs) return a.remainingMs < b.remainingMs; + return a.guid < b.guid; +} + +// One kicker in reach of a cast. busy: in the middle of its own cast (a mage's Frostbolt), so it cannot kick before that finishes. +struct Kicker +{ + bool busy; + float dist; + uint64_t low; +}; + +// The free kickers first (rank 0 kicks on sight, which a bot mid-cast cannot: Majordomo fights showed most kicks landed +// in the last 550 ms by the backups), then the nearest, then the lowest guid. +inline bool KickerBefore(Kicker const& a, Kicker const& b) +{ + if (a.busy != b.busy) return !a.busy; + if (a.dist != b.dist) return a.dist < b.dist; + return a.low < b.low; +} + +} // namespace Playerbot::Raid::Kicks diff --git a/src/modules/PlayerbotV2/Bot/Raid/README.md b/src/modules/PlayerbotV2/Bot/Raid/README.md index fd896a9677..e2f0bf28d5 100644 --- a/src/modules/PlayerbotV2/Bot/Raid/README.md +++ b/src/modules/PlayerbotV2/Bot/Raid/README.md @@ -76,3 +76,15 @@ whether a possessed creature follows MoveChase for a bot controller and whether Panic - fear! Tremor Totem / Fear Ward in about 5 sec"). Instant abilities are predicted from the script timers (earliest time minus lead) and re-anchored when the aura lands on the boss or the raid. Config: `Playerbot.Raid.BossWarnings` (default 1). Add a boss by adding rows to the table; tests in tests/game/ClassicBossWarnings.cpp. + +## Boss fight scripts (RaidFightScript.h / .cpp) + +A fight script owns the DPS side of one boss and nothing else. Today: Lucifron (map 409). Tank assignment, healing, dispels and the hazard +rules are the generic ones and are not touched. +- Target: the kill order is data (`Script::kFights`: Protectors, then Lucifron). Every DPS bot gets the same enemy, one at a time (the most + hurt of the current rank, kept until it dies). The owner's skull, else cross, wins. Written to `RaidOrder::script_focus`. +- Start: DPS attack `startWaitMs` (8 s, `kRaidBossOpenWaitMs`, the same wait as the generic boss opening) after the first engaged enemy of the fight, then there are no threat holds at all. The combat + state's `EvaluateThreatHold`, `combat:follow_skull` and `combat:pve_kill_focus` stand down for a bot with `script_owns`. +- Crowd control: the brain's CC election is dropped for the fight's own enemies. +- Log: `[fight_script]` on a focus change and at the start; bot rule names `raid:script_focus` / `raid:script_wait` in /history. +- Adding a boss: one row in `kFights`. Run the `mc_lucifron` scenario (Diagnostics/ScenarioDefs.h) first. diff --git a/src/modules/PlayerbotV2/Bot/Raid/RaidBrain.cpp b/src/modules/PlayerbotV2/Bot/Raid/RaidBrain.cpp index 33221f8c35..de60f107f3 100644 --- a/src/modules/PlayerbotV2/Bot/Raid/RaidBrain.cpp +++ b/src/modules/PlayerbotV2/Bot/Raid/RaidBrain.cpp @@ -16,6 +16,7 @@ #include "RaidIncoming.h" #include "RaidManaLedger.h" #include "RaidRoster.h" +#include "ShieldRules.h" #include "../../Fleet/BotPopulationManager.h" #include "../../Fleet/OwnerRegistry.h" #include "../BotRegistry.h" @@ -42,6 +43,7 @@ #include "Map.h" #include "MapManager.h" #include "MotionMaster.h" +#include "MoveSpline.h" #include "ObjectAccessor.h" #include "ObjectMgr.h" #include "PathGenerator.h" @@ -111,9 +113,7 @@ Ranks const kHammerOfJustice = { 853, 5588, 5589, 10308 }; // Paladin stun Ranks const kGouge = { 1776, 1777, 8629, 11285, 11286 }; // Rogue incapacitate Ranks const kBash = { 5211, 6798, 8983 }; // Druid (bear) stun -// Majordomo Executus' adds: Magic Reflection / Damage Shield (mc/boss_majordomo_executus.cpp). Hitting them hurts. -constexpr uint32_t kMagicReflection = 20619; -constexpr uint32_t kDamageShield = 21075; +// Majordomo Executus' adds' shields (Magic Reflection / Damage Shield) and who stays off them: ShieldRules.h. std::vector DispelSpellsFor(DispelKind kind) { @@ -513,6 +513,47 @@ void ApplyKeepOut(Plan const& plan, Member const& self, std::vector cons } } +AvoidFrontal const* FrontRule(RaidRules const& rules, Plan const& plan, Member const& self, Unit const* enemy); + +// No raid move walks through the front arc of an enemy with a cone rule (Onyxia's Flame Breath, 120 degrees): a bot back from a fear stands +// anywhere, and the straight walk to a slot, a post or a target may run through the breath (all eight deaths of a 405 s kill +// came 3-27 s after a roar). A move whose straight line crosses the widened arc is dropped, and the bot waits on its flank; the ways out of +// the arc itself (leave cone, leave hazard) and a bot that already stands inside it are not touched. At most one log line a bot every 10 s. +std::unordered_map g_lastArcGuardLog; + +void ApplyFrontArcGuard(Plan const& plan, Member const& self, uint32_t now, RaidOrder& out) +{ + if (!out.move || !out.move_reason || plan.rules->avoidFrontal.empty()) + return; + if (std::strcmp(out.move_reason, "leave hazard") == 0 || std::strcmp(out.move_reason, "leave cone") == 0 || + std::strcmp(out.move_reason, "wipe retreat") == 0) + return; + float const bx = self.p->GetPositionX(), by = self.p->GetPositionY(); + for (Unit* enemy : plan.enemies) + { + if (!enemy->IsAlive() || enemy->IsFlying()) + continue; + AvoidFrontal const* front = FrontRule(*plan.rules, plan, self, enemy); + if (!front) + continue; + float const ex = enemy->GetPositionX(), ey = enemy->GetPositionY(), facing = enemy->GetOrientation(); + float const half = ConeEdgeDeg(*front) * (float(M_PI) / 180.0f); + if (geo::InFrontSector(ex, ey, facing, bx, by, half, front->radius)) + continue; + if (!geo::PathCrossesFrontSector(ex, ey, facing, half, front->radius, bx, by, out.move_x, out.move_y)) + continue; + uint32_t& at = g_lastArcGuardLog[self.p->GetGUID().GetCounter()]; + if (now - at > 10000) + { + at = now; + TC_LOG_INFO("playerbot.v2.raid", "[raid_arc] {}: move ({}) would cross {}'s front arc, dropped", self.p->GetName(), out.move_reason, + enemy->GetName()); + } + out.move = false; + return; + } +} + bool SetMove(RaidOrder& out, float x, float y, float z, char const* reason) { out.move = true; @@ -786,6 +827,10 @@ std::unordered_map g_breath; // The breath spell a fixed-path rule saw cast (AvoidBreath::fixedPath) and until when its corridor stays open. struct BreathSpellLatch { uint32_t spell = 0, until = 0; }; std::unordered_map g_breathSpell; +// An airborne enemy hovers "at" a path's first point when it, or the end of its spline, is within this many yards of it. (A cast breath's +// corridor stays open kBreathCorridorOpenMs from the first sighting of the cast; it used to be 11 s after the last sighting, 16 s from the +// start, which kept the bots from walking out of the Heated Ground the pass leaves behind.) +constexpr float kBreathHoverReach = 12.0f; bool IsCasting(Unit* enemy, uint32_t spell) { @@ -872,6 +917,7 @@ std::unordered_map g_auraCircleLeaveLogged; // bot -> g_aur std::unordered_map g_auraCircleOrigin; uint32_t g_breathEnemy = 0, g_breathCast = 0; // the fixed-path breath whose corridor HazardsFor just opened for this member (0 for none) +size_t g_breathCircleFrom = 0; // where that corridor's circles start in the member's circle list; the ones before it are other hazards (Heated Ground) // Every avoid-circle that applies to this member right now. std::vector HazardsFor(Plan const& plan, Member const& self, uint32_t now) @@ -880,6 +926,7 @@ std::vector HazardsFor(Plan const& plan, Member const& self, uint32_t no Player* bot = self.p; std::vector circles; g_breathCast = 0; + g_breathCircleFrom = 0; for (AvoidEnemyAura const& rule : rules.avoidEnemyAura) if (Matches(rule.who, self, plan.mainTank)) for (Unit* enemy : plan.enemies) @@ -1000,6 +1047,12 @@ std::vector HazardsFor(Plan const& plan, Member const& self, uint32_t no // casters across the room). The bot stays for a tank's taunt instead. if (enemy->GetEntry() == rule.enemy && enemy->GetVictim() != bot && InPhase(enemy, rule.hpMax, rule.hpMin)) circles.push_back({ enemy->GetPositionX(), enemy->GetPositionY(), rule.radius }); + for (AvoidOnStacks const& rule : rules.avoidOnStacks) + if (Matches(rule.who, self, plan.mainTank)) + if (Aura const* carried = bot->GetAura(rule.aura); carried && carried->GetStackAmount() >= rule.stacks) + for (Unit* enemy : plan.enemies) + if (enemy->GetEntry() == rule.enemy && enemy->GetVictim() != bot && circles.size() < 64) + circles.push_back({ enemy->GetPositionX(), enemy->GetPositionY(), rule.radius }); if (!rules.avoidBreath.empty()) { std::vector breathAdded; // one corridor per enemy, however many breath spells are listed for it @@ -1031,20 +1084,37 @@ std::vector HazardsFor(Plan const& plan, Member const& self, uint32_t no continue; BreathSpellLatch& latch = g_breathSpell[boss->GetGUID().GetCounter()]; if (uint32_t const cast = CastingBreath(boss, spells)) - { if (latch.spell != cast || now > latch.until) + { TC_LOG_INFO("playerbot.v2.raid", "[raid_breath] {} breath spell {} corridor opened", boss->GetName(), cast); - latch.spell = cast; - latch.until = now + 11000; + latch.spell = cast; + latch.until = now + kBreathCorridorOpenMs; + } + uint32_t active = (latch.spell && now <= latch.until) ? latch.spell : 0u; + // Not casting yet: the corridor of the waypoint she hovers at or flies to (AvoidBreath::hover). A breath can start any time + // she is there, and the cast is all the warning there is. + if (!active && boss->IsFlying()) + { + float hx = boss->GetPositionX(), hy = boss->GetPositionY(); + if (!boss->movespline->Finalized()) + { + G3D::Vector3 const& end = boss->movespline->FinalDestination(); + hx = end.x; + hy = end.y; + } + if (AvoidBreath const* hover = HoverBreath(rules, rule.enemy, hx, hy, kBreathHoverReach)) + if (Matches(hover->who, self, plan.mainTank)) + active = hover->castSpell; } - if (!latch.spell || now > latch.until) + if (!active) continue; for (AvoidBreath const& path : rules.avoidBreath) - if (path.enemy == rule.enemy && path.fixedPath && path.castSpell == latch.spell && Matches(path.who, self, plan.mainTank)) + if (path.enemy == rule.enemy && path.fixedPath && path.castSpell == active && Matches(path.who, self, plan.mainTank)) { breathAdded.push_back(rule.enemy); g_breathEnemy = rule.enemy; g_breathCast = path.castSpell; + g_breathCircleFrom = circles.size(); float const dx = path.bx - path.ax, dy = path.by - path.ay; float const len = std::sqrt(dx * dx + dy * dy); float const step = std::max(path.halfWidth * 0.8f, 2.0f); @@ -1118,7 +1188,7 @@ Brain::MoveContext BuildMoveContext(Plan const& plan, Member const& self, std::v { if (!Matches(rule.who, self, plan.mainTank)) continue; - float const s = std::sin(std::min(rule.halfAngleDeg, 89.0f) * (float(M_PI) / 180.0f)); + float const s = std::sin(std::min(ConeEdgeDeg(rule), 89.0f) * (float(M_PI) / 180.0f)); for (Unit* enemy : plan.enemies) { // A flying enemy has no ground cone (Onyxia's phase 2: she circles the cave and turns every waypoint). @@ -1194,6 +1264,54 @@ std::unordered_map g_faceAxis; constexpr float kAxisDrift = 8.0f; constexpr uint32_t kAxisStaleMs = 30000; +// The spot a fight began at and the bearing from the raid's centre to it, locked for the fight (TankSpot): tanks stand relative to this, not to +// mobs that move with them. +struct TankSpotLock { float x = 0, y = 0, bearing = 0; uint32_t seenMs = 0; }; +std::unordered_map g_tankSpot; +std::unordered_map g_lastTankSpot; + +bool TankSpotFor(Plan const& plan, TankSpot const& rule, Player* bot, uint32_t now, float& outX, float& outY) +{ + uint64_t const key = (plan.groupLow << 32) ^ rule.anchor; + TankSpotLock& lock = g_tankSpot[key]; + if (!lock.seenMs || now - lock.seenMs >= kAxisStaleMs) + { + Unit* anchor = nullptr; + for (Unit* enemy : plan.enemies) + if (enemy->GetEntry() == rule.anchor && enemy->IsAlive()) + anchor = enemy; + if (!anchor) + return false; + float sx = 0.0f, sy = 0.0f; + int n = 0; + for (Member const& m : plan.members) + { + if (m.tank || Dist2D(m.p->GetPositionX(), m.p->GetPositionY(), anchor->GetPositionX(), anchor->GetPositionY()) > 60.0f) + continue; + sx += m.p->GetPositionX(); sy += m.p->GetPositionY(); + ++n; + } + if (n < 4) + return false; + lock = { anchor->GetPositionX(), anchor->GetPositionY(), geo::Bearing(sx / float(n), sy / float(n), anchor->GetPositionX(), anchor->GetPositionY()), now ? now : 1u }; + } + lock.seenMs = now ? now : 1u; + // The holders of , in guid order: this tank's slot in the row. + std::vector holders; + for (Unit* enemy : plan.enemies) + if (enemy->GetEntry() == rule.enemy && enemy->IsAlive() && enemy->GetVictim() && enemy->GetVictim()->GetTypeId() == TYPEID_PLAYER) + holders.push_back(enemy->GetVictim()->GetGUID().GetCounter()); + std::sort(holders.begin(), holders.end()); + holders.erase(std::unique(holders.begin(), holders.end()), holders.end()); + auto const at = std::find(holders.begin(), holders.end(), bot->GetGUID().GetCounter()); + if (at == holders.end()) + return false; + float const lateral = (float(at - holders.begin()) - float(holders.size() - 1) * 0.5f) * rule.spacing; + outX = lock.x + rule.reach * std::cos(lock.bearing) + lateral * std::cos(lock.bearing + float(M_PI) * 0.5f); + outY = lock.y + rule.reach * std::sin(lock.bearing) + lateral * std::sin(lock.bearing + float(M_PI) * 0.5f); + return true; +} + bool FaceAxisFor(Plan const& plan, Unit* enemy, uint32_t now, float& axis, float fixedBearingDeg = kNoBearing) { if (fixedBearingDeg != kNoBearing) @@ -1228,6 +1346,34 @@ bool FaceAxisFor(Plan const& plan, Unit* enemy, uint32_t now, float& axis, float return true; } +// Whether (x,y) lies inside a frontal cone of as it faces now, widened by the rule's margin, for a bot like . The same sector test +// the cone step (2b) uses, so a stand point this rejects is one that step would walk the bot out of again. +bool InAnyLiveCone(RaidRules const& rules, Plan const& plan, Member const& self, Unit const* enemy, float x, float y) +{ + for (AvoidFrontal const& rule : rules.avoidFrontal) + { + if (rule.enemy != enemy->GetEntry() || !Matches(rule.who, self, plan.mainTank) || !InPhase(enemy, rule.hpMax, rule.hpMin)) + continue; + if (Dist2D(x, y, enemy->GetPositionX(), enemy->GetPositionY()) > rule.radius) + continue; + float const facing = enemy->GetOrientation() + rule.facingOffsetDeg * (float(M_PI) / 180.0f); + float const toPoint = geo::NormalizeAngle(geo::Bearing(enemy->GetPositionX(), enemy->GetPositionY(), x, y) - facing); + if (std::fabs(toPoint) < ConeEdgeDeg(rule) * (float(M_PI) / 180.0f)) + return true; + } + return false; +} + +// The front-cone rule of that applies to a bot like in the enemy's current phase (the cone with no facing offset), or null. +AvoidFrontal const* FrontRule(RaidRules const& rules, Plan const& plan, Member const& self, Unit const* enemy) +{ + for (AvoidFrontal const& rule : rules.avoidFrontal) + if (rule.enemy == enemy->GetEntry() && rule.facingOffsetDeg == 0.0f && Matches(rule.who, self, plan.mainTank) && + InPhase(enemy, rule.hpMax, rule.hpMin)) + return &rule; + return nullptr; +} + // A bot standing in lava or slime leaves it for the nearest dry navmesh point. The Ragnaros fight (live 2026-10-12) had bots standing in // the lava round the platform and not moving out; the log line says whether the core even applies the liquid to them (z against the // surface), the move takes them out. "In" is the core's own contact test (MAP_LIQUID_STATUS_IN_CONTACT: in, under, or on the surface within @@ -1239,9 +1385,14 @@ std::unordered_map g_lastLavaLog; bool MagmaAt(Map* map, PhaseShift const& phase, float x, float y, float z, float& surfaceZ) { LiquidData ld; - ZLiquidStatus const st = map->GetLiquidStatus(phase, x, y, z, map_liquidHeaderTypeFlags::Magma | map_liquidHeaderTypeFlags::Slime, &ld); + // All liquids, then the flags of what came back: the vmap filters on the model's raw liquid type, before the area table swaps it for + // its own (the Majordomo hall's dais is a water-typed model liquid the area turns into lava). A Magma|Slime filter never saw it and the + // core, which asks for all liquids, burned bots there for 10% a second. + ZLiquidStatus const st = map->GetLiquidStatus(phase, x, y, z, map_liquidHeaderTypeFlags::AllLiquids, &ld); if (!(st & MAP_LIQUID_STATUS_IN_CONTACT)) return false; + if (!ld.type_flags.HasFlag(map_liquidHeaderTypeFlags::Magma) && !ld.type_flags.HasFlag(map_liquidHeaderTypeFlags::Slime)) + return false; surfaceZ = ld.level; return true; } @@ -1429,6 +1580,17 @@ void DecideMove(Plan const& plan, Member const& self, uint32_t now, std::vector< for (BreathSafe const* s : spots) { float pz = 0.0f; + // Not into other hazards (the fire the breath leaves round the pits: the listed points lie in it): the corridor's own circles + // start at g_breathCircleFrom, the ones before are the others. + bool burning = false; + for (size_t i = 0; i < g_breathCircleFrom && i < circles.size(); ++i) + if (Dist2D(s->x, s->y, circles[i].x, circles[i].y) < circles[i].r) + { + burning = true; + break; + } + if (burning) + continue; if (!Usable(bot, s->x, s->y, bot->GetPositionZ(), pz, /*urgent*/ true, /*hazard*/ true)) continue; SetMove(out, s->x, s->y, pz, "leave hazard"); @@ -1487,7 +1649,7 @@ void DecideMove(Plan const& plan, Member const& self, uint32_t now, std::vector< float const distance = Dist2D(bot->GetPositionX(), bot->GetPositionY(), enemy->GetPositionX(), enemy->GetPositionY()); if (distance > rule.radius) continue; - float const half = rule.halfAngleDeg * (float(M_PI) / 180.0f); + float const half = ConeEdgeDeg(rule) * (float(M_PI) / 180.0f); float const facing = enemy->GetOrientation() + rule.facingOffsetDeg * (float(M_PI) / 180.0f); float toBot = std::atan2(bot->GetPositionY() - enemy->GetPositionY(), bot->GetPositionX() - enemy->GetPositionX()) - facing; while (toBot > float(M_PI)) toBot -= 2.0f * float(M_PI); @@ -1640,6 +1802,26 @@ void DecideMove(Plan const& plan, Member const& self, uint32_t now, std::vector< return; } + // 3b2. Tank spots (Majordomo): a player that holds a ruled enemy walks to its place in the row, every 3 s at most. + for (TankSpot const& rule : rules.tankSpot) + { + float tx = 0.0f, ty = 0.0f, tz = 0.0f; + if (!TankSpotFor(plan, rule, bot, now, tx, ty) || Dist2D(bot->GetPositionX(), bot->GetPositionY(), tx, ty) < 3.0f) + continue; + uint32_t& at = g_lastTankSpot[bot->GetGUID().GetCounter()]; + if (now - at < 3000) + continue; + at = now; + if (!circles.empty() && InsideAny(circles, tx, ty, 0.5f)) + continue; + if (Usable(bot, tx, ty, bot->GetPositionZ(), tz, /*urgent*/ true)) + { + TC_LOG_INFO("playerbot.v2.raid", "[raid_tank_spot] {} walks to its place for entry {} ({:.0f},{:.0f})", bot->GetName(), rule.enemy, tx, ty); + SetMove(out, tx, ty, tz, "tank spot"); + return; + } + } + // 3c. Stand behind (Magmadar): matching bots stand in the sector behind the enemy, wherever the tank has turned it. // At most one step per bot every 4 s, so a boss that turns a little does not make the raid hop. for (StandBehind const& rule : rules.standBehind) @@ -1693,7 +1875,18 @@ void DecideMove(Plan const& plan, Member const& self, uint32_t now, std::vector< if (enemy->GetEntry() != rule.enemy || !enemy->IsAlive() || enemy->IsFlying() || !InPhase(enemy, rule.hpMax, rule.hpMin)) continue; float const ex = enemy->GetPositionX(), ey = enemy->GetPositionY(); - float const eo = enemy->GetOrientation(); + // The wedge is measured from the line the tank holds her on (the locked FaceAway axis), not from her live facing: that swings with + // every step the tank takes, flipped the flank a bot counted itself on and sent it across the cone to the other wedge. The cones + // themselves (2b) still read the live facing, which is where the breath goes. + float eo = enemy->GetOrientation(); + for (FaceAway const& fa : rules.faceAway) + if (fa.enemy == rule.enemy && InPhase(enemy, fa.hpMax, fa.hpMin)) + { + float axis; + if (FaceAxisFor(plan, enemy, now, axis, fa.bearingDeg)) + eo = axis; + break; + } float const half = rule.halfAngleDeg * (float(M_PI) / 180.0f), centre = rule.centerDeg * (float(M_PI) / 180.0f); // Which flank: the side of its facing the bot is on. The rear-sector helpers measure from the line straight behind a facing, so the // flank is handed to them as the "rear" of a facing turned a quarter round the other way. @@ -1719,14 +1912,37 @@ void DecideMove(Plan const& plan, Member const& self, uint32_t now, std::vector< uint32_t const row = index % rows, col = index / rows; float const angle = centre - half + (float(col) + 0.5f) / float(cols) * 2.0f * half; float const dist = rule.minDist + (float(row) + 0.5f) / float(rows) * depth; - float const px = ex + dist * std::cos(eo + side * angle), py = ey + dist * std::sin(eo + side * angle); + float const slotAngle = eo + side * angle; + // A slot is only a slot where nothing would move the bot out again: no hazard circle, no whelp-cave circle (a move that ends in one is + // pushed out to its rim, which at her spawn spot put the casters in front of her) and no cone as she faces right now + // (the cone step would walk the bot straight out: 180 flank and 140 cone steps in 70 s). The same bearing at another distance inside + // the band is tried before the bot gives up and stays where it is. + auto const validAt = [&](float d, float& vx, float& vy) + { + vx = ex + d * std::cos(slotAngle); + vy = ey + d * std::sin(slotAngle); + return !(!circles.empty() && InsideAny(circles, vx, vy, 1.0f)) && !InsideAny(g_keepOut, vx, vy, 0.0f) && + !InAnyLiveCone(rules, plan, self, enemy, vx, vy); + }; + float px = 0.0f, py = 0.0f; + bool found = validAt(dist, px, py); + for (int k = 1; !found && k <= 4; ++k) + for (float sign : { -1.0f, 1.0f }) + { + float const d = dist + sign * 2.0f * float(k); + if (d >= rule.minDist && d <= rule.maxDist && validAt(d, px, py)) + { + found = true; + break; + } + } + if (!found) + break; if (Dist2D(bot->GetPositionX(), bot->GetPositionY(), px, py) <= 3.0f) break; uint32_t& at = g_lastRearStep[bot->GetGUID().GetCounter()]; if (now - at < 4000) break; - if (!circles.empty() && InsideAny(circles, px, py, 1.0f)) - break; float pz = 0.0f; if (!Usable(bot, px, py, enemy->GetPositionZ(), pz)) break; @@ -2228,7 +2444,7 @@ void ElectDispels(Election& e) uint32_t given = 0; for (Member* m : carriers) { - if (!rule.urgent && given >= kNonUrgentDispelOrdersPerPlan) + if (!DispelOrderAllowed(rule.urgent, rule.maxOrders, given)) break; bool const ok = e.Assign(m->p, families, false, RaidOrder::CastKind::Dispel, "dispel", !rule.urgent, rule.urgent ? 0 : kNonUrgentDispelHealerManaPct); @@ -2279,10 +2495,23 @@ void ElectDispels(Election& e) } } -void ElectPurges(Election& e) +void ElectPurges(Election& e, ObjectGuid killFocus) { Plan& plan = e.plan; - for (Unit* enemy : plan.enemies) + // The kill focus first, then the enemies a tank holds, then the rest: Majordomo shields all eight adds at once and the purgers take a few + // passes, so the add the raid is burning and the ones the tanks need their abilities on lose theirs first. + auto const rank = [&](Unit* enemy) + { + if (!killFocus.IsEmpty() && enemy->GetGUID() == killFocus) + return 0; + Unit* held = enemy->GetVictim(); + Player* holder = held ? held->ToPlayer() : nullptr; + Member* hm = holder ? FindMember(plan, holder) : nullptr; + return hm && hm->tank ? 1 : 2; + }; + std::vector order(plan.enemies.begin(), plan.enemies.end()); + std::stable_sort(order.begin(), order.end(), [&](Unit* a, Unit* b) { return rank(a) < rank(b); }); + for (Unit* enemy : order) for (PurgeEnemy const& rule : plan.rules->purge) if (enemy->HasAura(rule.aura)) e.Assign(enemy, { &kPurge, &kDispelMagic }, true, RaidOrder::CastKind::Purge, "purge", true); @@ -2394,9 +2623,11 @@ void PublishTargets(Plan& plan, std::unordered_map& orders, RaidRules const& rules = *plan.rules; std::vector forbiddenAll; // nobody attacks these std::vector forbiddenDps; // non-tanks do not attack these + std::vector forbiddenCasters; // Magic Reflection: the spell casters do not attack these (ShieldRules.h) + std::vector forbiddenMelee; // Damage Shield: the melee DPS do not attack these // Packs that die together: downed members are left alone by everybody, members trailing the healthiest one by more than // the rule's spread are left alone by DPS, and only the healthiest one can become the DPS fallback or the group focus. - std::vector packHolders; // per pack rule with a member up: the healthiest member + std::vector> packHolders; // per pack rule with a member up: the healthiest member for (KillTogether const& rule : rules.killTogether) { // Molten Core's hounds only feign and rise when Instance.MoltenCoreHoundsLinked is on (default off: they die one by one). @@ -2405,7 +2636,7 @@ void PublishTargets(Plan& plan, std::unordered_map& orders, std::vector up; for (Unit* enemy : plan.enemies) { - if (enemy->GetEntry() != rule.enemy) + if (!InPack(rule, enemy->GetEntry())) continue; if (enemy->GetHealth() <= 1 || (rule.downAura && enemy->HasAura(rule.downAura))) forbiddenAll.push_back(enemy->GetGUID()); @@ -2419,15 +2650,26 @@ void PublishTargets(Plan& plan, std::unordered_map& orders, for (Unit* enemy : up) if (enemy->GetHealthPct() < healthiest->GetHealthPct() - rule.spreadPct) forbiddenDps.push_back(enemy->GetGUID()); - packHolders.push_back(healthiest); + packHolders.emplace_back(healthiest, &rule); // The group kill focus too: the coordinator's generic pick (lowest health first) would chase a downed or trailing one. if (plan.ruleFocus.IsEmpty()) plan.ruleFocus = healthiest->GetGUID(); } + // Spare rules: an add near death is left alone by everybody while its boss lives. + for (Spare const& rule : rules.spare) + { + bool gateAlive = false; + for (Unit* enemy : plan.enemies) + if (enemy->GetEntry() == rule.gateEnemy && enemy->IsAlive()) + gateAlive = true; + for (Unit* enemy : plan.enemies) + if (enemy->GetEntry() == rule.enemy && SpareNow(rule, enemy->GetHealthPct(), gateAlive)) + forbiddenAll.push_back(enemy->GetGUID()); + } auto const trailsHolder = [&packHolders](Unit* enemy) { - for (Unit* holder : packHolders) - if (holder->GetEntry() == enemy->GetEntry() && holder != enemy) + for (auto const& [holder, rule] : packHolders) + if (holder != enemy && InPack(*rule, enemy->GetEntry())) return true; return false; }; @@ -2441,14 +2683,20 @@ void PublishTargets(Plan& plan, std::unordered_map& orders, continue; // a downed or trailing pack member if (trailsHolder(enemy)) continue; // within the spread but not the healthiest: no focus on it - bool const reflecting = enemy->HasAura(kMagicReflection) || enemy->HasAura(kDamageShield); // The owner's skull on a sheeped mob is the call to kill it (Majordomo: he rotates the skull onto each sheeped Healer). bool const skulled_hold = Controlled(enemy) && !coordFocus.IsEmpty() && enemy->GetGUID() == coordFocus; - if ((Controlled(enemy) && !skulled_hold) || reflecting) + if (Controlled(enemy) && !skulled_hold) { forbiddenAll.push_back(enemy->GetGUID()); continue; } + // Majordomo's shields, 10 s on all eight adds every 30 s: Magic Reflection takes the casters off the add, Damage Shield the melee DPS. + // The other half keeps attacking, the tanks keep their swings, hunters are hit by neither (either shield used to stop + // everybody, a third of the fight idle for the whole raid: 3200-4500 raid damage a second). + if (enemy->HasAura(Shields::kMagicReflection)) + forbiddenCasters.push_back(enemy->GetGUID()); + if (enemy->HasAura(Shields::kDamageShield)) + forbiddenMelee.push_back(enemy->GetGUID()); if (PriorityFor(rules, enemy->GetEntry()) < 0) { forbiddenDps.push_back(enemy->GetGUID()); @@ -2478,12 +2726,24 @@ void PublishTargets(Plan& plan, std::unordered_map& orders, } return 1; }; + // The shield that keeps this member off an enemy, by role (ShieldRules.h): a melee DPS off a Damage Shield, a caster off Magic Reflection. + auto const shieldForbids = [&](Member const& m, Unit* enemy) + { + bool const melee = Matches(Who::Melee, m, plan.mainTank); + bool const caster = Matches(Who::Caster, m, plan.mainTank); + if (!melee && !caster) + return false; + auto const in = [&](std::vector const& v) { return std::find(v.begin(), v.end(), enemy->GetGUID()) != v.end(); }; + return (melee && in(forbiddenMelee)) || (caster && in(forbiddenCasters)); + }; auto const bestFor = [&](Member const& m) -> Unit* { Unit* best = nullptr; int bestPriority = 0; for (Unit* enemy : candidates) { + if (shieldForbids(m, enemy)) + continue; int const priority = priorityFor(m, enemy); if (priority < 0) continue; @@ -2506,6 +2766,10 @@ void PublishTargets(Plan& plan, std::unordered_map& orders, o.forbidden_targets.insert(o.forbidden_targets.end(), forbiddenAll.begin(), forbiddenAll.end()); if (!m.tank) o.forbidden_targets.insert(o.forbidden_targets.end(), forbiddenDps.begin(), forbiddenDps.end()); + if (Matches(Who::Melee, m, plan.mainTank)) + o.forbidden_targets.insert(o.forbidden_targets.end(), forbiddenMelee.begin(), forbiddenMelee.end()); + if (Matches(Who::Caster, m, plan.mainTank)) + o.forbidden_targets.insert(o.forbidden_targets.end(), forbiddenCasters.begin(), forbiddenCasters.end()); if (!m.tank) for (OnlyAttackers const& rule : rules.onlyAttackers) if (!Matches(rule.who, m, plan.mainTank)) @@ -2520,7 +2784,7 @@ void PublishTargets(Plan& plan, std::unordered_map& orders, Unit* pick = nullptr; if (!focus.IsEmpty()) for (Unit* enemy : candidates) - if (enemy->GetGUID() == focus) + if (enemy->GetGUID() == focus && !shieldForbids(m, enemy)) pick = enemy; if (!pick) pick = bestFor(m); @@ -2553,6 +2817,9 @@ struct OverHold { uint32_t first = 0, last = 0; }; std::unordered_map g_overHold; std::unordered_map g_holdFight; // bot -> when its opening wait of this fight began (one wait per fight, not per enemy) constexpr uint32_t kOverHoldMaxMs = 3000, kOverHoldGapMs = 4000, kFightGapMs = 8000; +// Past the hard limit the hold waits for the tank's threat to rise; a stunned, feared, dead or out-of-reach tank never raises it, so that +// wait is bounded by the tank standing still for kStalledTankHoldMs (Bot/ThreatLimits.h), the same clock as the generic hold. +std::unordered_map g_stalledHold; void PublishThreatHolds(Plan& plan, std::unordered_map& orders, uint32_t now) { @@ -2619,8 +2886,9 @@ void PublishThreatHolds(Plan& plan, std::unordered_map& ord fight.last = now; // A boss gets the tank's time to arrive and build its lead: mc_geddon 09a8ff07 had Geddon on a mage 6 s in (the tank, 40 y off at the // pull, still short of the 900 lead when the 6 s opening wait ran out), loose in the middle of the raid when Inferno came. - // Never longer than six seconds from the tank's first hit (playtest 2026-10-15), the same cap as the combat state's wait. - uint32_t const capMs = boss ? 6000u : (tankThreat <= 0.0f ? 1000u : 2000u); + // Never longer than eight seconds from the tank's first hit in a raid, the + // same wait as the combat state's (kRaidBossOpenWaitMs). + uint32_t const capMs = boss ? uint32_t(kRaidBossOpenWaitMs) : (tankThreat <= 0.0f ? 1000u : 2000u); hold = now - std::min(since, fight.first) < capMs; } else @@ -2646,8 +2914,11 @@ void PublishThreatHolds(Plan& plan, std::unordered_map& ord if (!oh.first || now - oh.last > kOverHoldGapMs) oh.first = now; oh.last = now; - if (myThreat < tankThreat * hard && now - oh.first >= kOverHoldMaxMs) + bool const pastHard = myThreat >= tankThreat * hard; + if (!pastHard && now - oh.first >= kOverHoldMaxMs) hold = false; + else if (pastHard && StalledTankHoldExpired(g_stalledHold[key], now, tankThreat, kOverHoldGapMs)) + hold = false; // the tank has not built threat for kStalledTankHoldMs: nothing to wait for } } if (hold) @@ -2660,6 +2931,9 @@ void PublishThreatHolds(Plan& plan, std::unordered_map& ord if (map->size() > 1024) for (auto it = map->begin(); it != map->end();) it = (now - it->second.last > 120000) ? map->erase(it) : std::next(it); + if (g_stalledHold.size() > 1024) + for (auto it = g_stalledHold.begin(); it != g_stalledHold.end();) + it = (now - it->second.last_ms > 120000) ? g_stalledHold.erase(it) : std::next(it); } // Which spell schools to prefer / avoid on each engaged enemy, from its live immunities, damage-taken auras and spell @@ -2821,7 +3095,6 @@ constexpr BossNeed kBossNeeds[] = { { 12264, "purge (Deaden Magic)", kPurgers, 1 }, { 12098, "interrupt (Dark Mending)", kKickers, 3 }, { 12098, "purge (Inspire)", kPurgers, 1 }, - { 12018, "polymorph (Flamewaker Healers)", kPolymorphers, 2 }, { 12018, "purge (Magic Reflection / Damage Shield)", kPurgers, 2 }, { 12018, "interrupt (Flamewaker Healers)", kKickers, 3 }, { 11502, "banish (Sons of Flame)", kBanishers, 2 }, @@ -3657,6 +3930,7 @@ void Brain::Update(uint32_t now_ms) if (!m.p->HasUnitState(UNIT_STATE_ROOT | UNIT_STATE_STUNNED | UNIT_STATE_CONFUSED | UNIT_STATE_FLEEING)) DecideMove(plan, m, now_ms, circles, o); ApplyKeepOut(plan, m, circles, o); + ApplyFrontArcGuard(plan, m, now_ms, o); if (o.move) dump << " " << m.p->GetName() << ": move (" << o.move_reason << ")\n"; for (NoAoe const& rule : plan.rules->noAoe) @@ -3704,7 +3978,7 @@ void Brain::Update(uint32_t now_ms) ElectRetaunt(e); ElectBerserkerDance(e); ElectDispels(e); - ElectPurges(e); + ElectPurges(e, CoordinatorFocus(plan.groupLow, plan.mapId)); ElectCrowdControl(e, tankTargets, CoordinatorFocus(plan.groupLow, plan.mapId)); PublishTargets(plan, next, CoordinatorFocus(plan.groupLow, plan.mapId)); if (std::vector hints = SchoolHints(plan, dump); !hints.empty()) @@ -3715,6 +3989,7 @@ void Brain::Update(uint32_t now_ms) dump << " rule kill focus: " << plan.ruleFocus.GetCounter() << "\n"; } PublishThreatHolds(plan, next, now_ms); + ApplyFightScript(plan, next, now_ms, dump); PublishMeleeSoak(plan, next); PublishAuraReactions(plan, next); } diff --git a/src/modules/PlayerbotV2/Bot/Raid/RaidBrainInternal.h b/src/modules/PlayerbotV2/Bot/Raid/RaidBrainInternal.h index 83a5fe7c58..7d3531262a 100644 --- a/src/modules/PlayerbotV2/Bot/Raid/RaidBrainInternal.h +++ b/src/modules/PlayerbotV2/Bot/Raid/RaidBrainInternal.h @@ -97,6 +97,9 @@ bool NaxxMechanicsMove(Plan const& plan, Member const& self, uint32_t now, RaidO void NaxxMechanicsElect(Election& e, uint32_t now); void BwlMechanicsElect(Election& e, uint32_t now); void BwlPrePull(Plan& plan, std::unordered_map& orders, std::ostringstream& dump, uint32_t now); +// A boss fight script (RaidFightScript.h): after the rule passes, overwrites the DPS bots' target and start wait for the scripted boss. +void ApplyFightScript(Plan& plan, std::unordered_map& orders, uint32_t now, std::ostringstream& dump); + bool Aq40MechanicsMove(Plan const& plan, Member const& self, uint32_t now, RaidOrder& out); void Aq40MechanicsElect(Election& e, uint32_t now); diff --git a/src/modules/PlayerbotV2/Bot/Raid/RaidCombat.cpp b/src/modules/PlayerbotV2/Bot/Raid/RaidCombat.cpp index 2e844fc3f5..af02f8b93b 100644 --- a/src/modules/PlayerbotV2/Bot/Raid/RaidCombat.cpp +++ b/src/modules/PlayerbotV2/Bot/Raid/RaidCombat.cpp @@ -135,6 +135,24 @@ bool DispatchRaidOrder(BotAI& ai, BotSnapshotView const& s, BotIntentEmitter& em return true; } + // 3b. A boss fight script owns this DPS bot's target (RaidFightScript.h): during its start wait nothing is attacked, afterwards the one + // enemy the script names, whatever the bot was on. The skull / kill-focus pickers in the combat state stand down for it. + if (o.script_names_target()) + { + if (!held.IsEmpty()) + { + if (!s.victim().IsEmpty()) + emit.stop_attack(); + ai.set_last_rule_fired("raid:script_wait"); + return true; + } + if (s.victim() != o.script_focus && emit.start_attack(o.script_focus)) + { + ai.set_last_rule_fired("raid:script_focus"); + return true; + } + } + // 4. Never-target / crowd-controlled / reflecting enemies, and the swap enemy for a debuffed tank. ObjectGuid const victim = s.victim(); bool const forbidden = !victim.IsEmpty() && diff --git a/src/modules/PlayerbotV2/Bot/Raid/RaidEncounterData_AQ40.cpp b/src/modules/PlayerbotV2/Bot/Raid/RaidEncounterData_AQ40.cpp index 7384b66d64..e4a204b10d 100644 --- a/src/modules/PlayerbotV2/Bot/Raid/RaidEncounterData_AQ40.cpp +++ b/src/modules/PlayerbotV2/Bot/Raid/RaidEncounterData_AQ40.cpp @@ -10,12 +10,20 @@ namespace Playerbot::Raid { { r.name = "Temple of Ahn'Qiraj"; - // Kick-first casts (VMaNGOS creature_spells): Qiraji Brainwasher Cause Insanity 26079 (mind control) and Mana Burn 26046, - // Obsidian Nullifier / Destroyer Drain Mana 25671 / 25755. + // Kick-first casts (vanilla spell ids): Qiraji Brainwasher Cause Insanity 26079 (mind control), Princess Yauj's Great + // Heal 25807 on the trio (classic_boss_bug_trio.cpp SPELL_YAUJ_HEAL), Skeram's Arcane Explosion 26192 (30 yd, only when more + // than 4 stand in his melee range, classic_boss_skeram.cpp:94), Mana Burn 26046, Obsidian Nullifier / Destroyer Drain Mana + // 25671 / 25755, the Anubisath Warder's Silence 26069, Fear 26070 and Entangling Roots 26071 (1.5 s casts), Mind Flay 26143. r.interruptFirst.push_back(26079); + r.interruptFirst.push_back(25807); + r.interruptFirst.push_back(26192); r.interruptFirst.push_back(26046); r.interruptFirst.push_back(25671); r.interruptFirst.push_back(25755); + r.interruptFirst.push_back(26069); + r.interruptFirst.push_back(26070); + r.interruptFirst.push_back(26071); + r.interruptFirst.push_back(26143); r.bosses = { 15263, // The Prophet Skeram 15543, 15511, 15544, // Bug trio: Yauj, Kri, Vem @@ -64,6 +72,8 @@ namespace Playerbot::Raid { // Nullify 26552 (stun, 45 yd). Nothing to dodge: they die before they fill up. r.priority.push_back({ 15262, 5 }); r.priority.push_back({ 15312, 5 }); + // Hive'Zara Tail Lasher 15336: Poison 25645 (vanilla data: poison). + r.dispel.push_back({ 25645, DispelKind::Poison }); // Anubisath Defender 15277: Meteor 26558 (14250 fire split among everybody within 8 yd of the target) and Shadow Storm // 26555 (only hits between 25 and 45 yd). The raid stacks on it: the more share the Meteor, the less each takes. r.stayNear.push_back({ 15277, 8.0f, Who::NonTank }); @@ -73,10 +83,12 @@ namespace Playerbot::Raid { // --------------------------------------------------------------------------------------------------------------- // THE PROPHET SKERAM (15263): True Fulfillment 785 mind-controls a raider (aq40/classic_boss_skeram.cpp); Arcane - // Explosion 26192 around him (the PvE coordinator kicks it). His images share his entry. + // Explosion 26192 around him (kicked first, see above). His images share his entry. He Blinks every 10-18 s + // (classic_boss_skeram.cpp:340-343) and lands on whoever he likes: a tank taunts him back. r.controlledMember.push_back({ 785 }); r.avoidEnemy.push_back({ 15263, 15.0f, Who::Ranged }); r.avoidEnemy.push_back({ 15263, 15.0f, Who::Healer }); + r.retaunt.push_back(15263); // --------------------------------------------------------------------------------------------------------------- // BUG TRIO (aq40/classic_boss_bug_trio.cpp): Yauj heals the others (25807, kicked) and fears (19408); Kri's Toxic Volley 25812 is a @@ -87,6 +99,9 @@ namespace Playerbot::Raid { r.priority.push_back({ 15544, 2 }); // Vem r.dispel.push_back({ 25812, DispelKind::Poison }); r.dispel.push_back({ 19408, DispelKind::Magic }); + // Yauj's fear and Vem's Charge 26561 / Knock Away leave the two on whoever is left: a tank taunts them back. + r.retaunt.push_back(15543); + r.retaunt.push_back(15544); // Kri leaves a Toxic Vapors cloud 25786 where he dies (classic_boss_bug_trio.cpp:261-265): keep off his corpse. r.avoidCreature.push_back({ 15511, 12.0f, Who::Anyone, true }); @@ -96,12 +111,20 @@ namespace Playerbot::Raid { r.avoidEnemyAura.push_back({ 15516, 26083, 10.0f, Who::NonTank }); r.avoidEnemyAura.push_back({ 15984, 26038, 10.0f, Who::NonTank }); r.priority.push_back({ 15984, 3 }); + // Casters and healers never stand in Whirlwind reach of any of them (the step-out above is for the melee). + r.avoidEnemy.push_back({ 15516, 11.0f, Who::Ranged }); + r.avoidEnemy.push_back({ 15516, 11.0f, Who::Healer }); + r.avoidEnemy.push_back({ 15984, 9.0f, Who::Ranged }); + r.avoidEnemy.push_back({ 15984, 9.0f, Who::Healer }); // --------------------------------------------------------------------------------------------------------------- // FANKRISS THE UNYIELDING (15510): Mortal Wound 25646 on the tank (aq40/classic_boss_fankriss.cpp): swap at 5. Spawns of // Fankriss (15630) enrage if left alone. r.tankSwap.push_back({ 15510, 25646, 5 }); r.priority.push_back({ 15630, 6 }); + // Vekniss Hatchlings (15962) come 2-4 at a time out of the webs he ports raiders into (classic_boss_fankriss.cpp:351): killed + // before the spawns. + r.priority.push_back({ 15962, 5 }); // --------------------------------------------------------------------------------------------------------------- // VISCIDUS (15299): Poison Bolt Volley 25991 (aq40/classic_boss_viscidus.cpp). Globs (15667) walk back to him when he @@ -125,6 +148,12 @@ namespace Playerbot::Raid { r.onlyAttackers.push_back({ 15275, Who::Physical }); r.onlyAttackers.push_back({ 15276, Who::Caster }); r.avoidGroundEffect.push_back({ 15276, 26607, 2.0f, Who::Anyone }); + // They swap places every 30-40 s (SPELL_TWIN_TELEPORT 799/800): after each teleport a tank taunts the twin that landed on him. + r.retaunt.push_back(15275); + r.retaunt.push_back(15276); + // Vek'lor's Arcane Burst 568 hits and throws everybody within 10 yd (vanilla data, radius index 13): his casters keep 13. + r.avoidEnemy.push_back({ 15276, 13.0f, Who::Ranged }); + r.avoidEnemy.push_back({ 15276, 13.0f, Who::Healer }); // --------------------------------------------------------------------------------------------------------------- // OURO (15517): Sand Blast 26102 to the front, Sweep 26103 around him; while submerged he chases from under a Dirt Mound @@ -132,6 +161,8 @@ namespace Playerbot::Raid { r.avoidFrontal.push_back({ 15517, 30.0f, 45.0f, Who::NonTank }); r.avoidCreature.push_back({ 15712, 10.0f, Who::Anyone }); r.priority.push_back({ 15718, 3 }); + // He comes back up on whoever is nearest: a tank taunts him back. + r.retaunt.push_back(15517); // --------------------------------------------------------------------------------------------------------------- // C'THUN (15589 Eye of C'Thun, 15727 C'Thun; aq40/classic_boss_cthun.cpp): Eye Beam 26134 chains between players @@ -143,6 +174,12 @@ namespace Playerbot::Raid { r.priority.push_back({ 15725, 4 }); // Claw Tentacle r.priority.push_back({ 15334, 6 }); // Giant Eye Tentacle r.priority.push_back({ 15728, 5 }); // Giant Claw Tentacle + // Ground Rupture when a claw tentacle comes up (classic_boss_cthun.cpp:83-86): 26139 within 10 yd of a Claw Tentacle, 26478 + // within 6 yd of a Giant Claw Tentacle (vanilla data, radius indexes 13 / 18). Casters and healers keep out of it. + r.avoidEnemy.push_back({ 15725, 13.0f, Who::Ranged }); + r.avoidEnemy.push_back({ 15725, 13.0f, Who::Healer }); + r.avoidEnemy.push_back({ 15728, 9.0f, Who::Ranged }); + r.avoidEnemy.push_back({ 15728, 9.0f, Who::Healer }); // Not ruled: Twin Emperors' teleport tank pickup (the PvE coordinator's per-tank assignment re-picks after the swap). } diff --git a/src/modules/PlayerbotV2/Bot/Raid/RaidEncounterData_BWL.cpp b/src/modules/PlayerbotV2/Bot/Raid/RaidEncounterData_BWL.cpp index 9362f386f6..8cec65a93a 100644 --- a/src/modules/PlayerbotV2/Bot/Raid/RaidEncounterData_BWL.cpp +++ b/src/modules/PlayerbotV2/Bot/Raid/RaidEncounterData_BWL.cpp @@ -29,6 +29,13 @@ namespace Playerbot::Raid { // Phase 2: Conflagration 23023 is cast on himself every 15-25s (classic_boss_razorgore.cpp:345-349) and disorients whoever stands // in melee, the tank included: a tank without it takes him over. r.tankSwap.push_back({ 12435, 23023, 1 }); + // Conflagration is a cone: vanilla data gives 23023 the front-cone target (24) with a 30 yd radius, so everybody but the tank + // stays out of the sector in front of him (the tank takes it and hands him over, above). + r.avoidFrontal.push_back({ 12435, 30.0f, 50.0f, Who::NonTank }); + // War Stomp 24375 (classic_boss_razorgore.cpp:49), the same stun as the Wyrmguard's below: casters and healers keep 18 yards + // (in phase 1 that also keeps them off the possessed Razorgore). + r.avoidEnemy.push_back({ 12435, 18.0f, Who::Ranged }); + r.avoidEnemy.push_back({ 12435, 18.0f, Who::Healer }); r.priority.push_back({ 14456, 2 }); // Blackwing Guardsman: Strike 15580 only (DB event 1445601) // --------------------------------------------------------------------------------------------------------------- @@ -54,7 +61,9 @@ namespace Playerbot::Raid { // boss_broodlord_lashlayer.cpp:105-106). The trash around him is made unattackable while he lives (:109-143), so no add rules. // Blast Wave keep-away for ranged/healers: see RegisterBlackwingMovement (avoidEnemy, boss_broodlord_lashlayer.cpp:172). // No tank swap: Mortal Strike is cast only every 20-30s (:178-182) and the script gives no aura/stack condition, so a swap would - // only thrash against Knock Away's -50% threat (:105-106); the tanks keep the boss. + // only thrash against Knock Away's -50% threat (:105-106); the tanks keep the boss. Knock Away can still drop the tank + // below a DPS on his list: a tank taunts him back at once. + r.retaunt.push_back(12017); // --------------------------------------------------------------------------------------------------------------- // FIREMAW (11983) / EBONROC (14601) / FLAMEGOR (11981) @@ -64,6 +73,10 @@ namespace Playerbot::Raid { // Flamegor has no tank debuff in his script (boss_flamegor.cpp:71-121): only Wing Buffet / Shadow Flame / Frenzy. Tank facing cannot be // a stand rule: no justified coordinates (the dragons are pulled to wherever the tank stands). r.tankSwap.push_back({ 14601, 23340, 1 }); // Ebonroc: Shadow of Ebonroc (boss_ebonroc.cpp:24,106) + // Wing Buffet halves the victim's threat (boss_firemaw.cpp:71-77) on all three: the tank that lost the drake taunts it back. + r.retaunt.push_back(11983); + r.retaunt.push_back(14601); + r.retaunt.push_back(11981); // Frenzy 23342: Tranquilizing Shot is the PvE coordinator's (PlanTranq, any aura the shot removes). Flamegor Frenzy, periodically fire novas (boss_flamegor.cpp:26,105-113) // --------------------------------------------------------------------------------------------------------------- @@ -72,7 +85,9 @@ namespace Playerbot::Raid { // A player holding all five becomes a "Chromatic Mutation" (:318-340). Red Affliction deaths heal him for 150k (:349-366). // DISPEL KIND of every entry below is UNVERIFIED (no spell_template in the extracts); Magic is the default requested by the lead. // The debuff ids ARE the cast ids: effect1 of each is 6 = APPLY_AURA (migration 20200515174239), so the player carries that id. - r.dispel.push_back({ 23170, DispelKind::Magic }); // Brood Affliction: Bronze (boss_chromaggus.cpp:47), dispel type magic (ike3) + // Brood Affliction: Bronze 23170 (boss_chromaggus.cpp:47) has no dispel type in the vanilla data (only Hourglass Sand 19183 + // removes it): no dispeller spends a cast on it. + r.noDispel.push_back(23170); r.dispel.push_back({ 23153, DispelKind::Magic }); // Brood Affliction: Blue (boss_chromaggus.cpp:44) UNVERIFIED kind r.dispel.push_back({ 23154, DispelKind::Curse }); // Brood Affliction: Black (boss_chromaggus.cpp:45) UNVERIFIED kind r.dispel.push_back({ 23155, DispelKind::Disease }); // Brood Affliction: Red (boss_chromaggus.cpp:46) UNVERIFIED kind; dying with it heals the boss @@ -89,6 +104,8 @@ namespace Playerbot::Raid { // Immune behind Nefarius Barrier 22663 (boss_victor_nefarius.cpp:44,321) and rooted: never target him. // Two drakonid types (random pair) spawn every 6-7s, a Chromatic Drakonid pair every 35s, until 40 are dead (:373-443). r.priority.push_back({ 10162, -1 }); // barrier immunity in phase 1 (boss_victor_nefarius.cpp:44) + // Shadow Command 22667 charms the second on his threat list for 15 s (details: scripts-bwl): sheep or stun, never kill. + r.controlledMember.push_back({ 22667 }); r.priority.push_back({ 14302, 6 }); // Chromatic Drakonid (24k hp) (boss_victor_nefarius.cpp:394) r.priority.push_back({ 14263, 5 }); // Bronze Drakonid (boss_victor_nefarius.cpp:58) r.priority.push_back({ 14261, 5 }); // Blue Drakonid (:59) @@ -100,6 +117,9 @@ namespace Playerbot::Raid { // Shadow Flame 22539 cone, Bellowing Roar 22686 fear, Veil of Shadow 22687 on the tank, Tail Lash 23364, class calls every 25-35s // (boss_nefarian.cpp:348-368), at 20% he raises every dead drakonid as a Bone Construct (:371-376, summon spell 23363 on drakonid death). r.priority.push_back({ 11583, 3 }); // the boss must beat the constructs (boss_nefarian.cpp:371-376) + // Bone Constructs (phase 3): 6k hp each, up to 42. Every second caster clears them with area + // damage (first matching row wins, so this one comes first); everybody else stays on Nefarian while the tanks hold them. + r.priority.push_back({ 14605, 8, Who::AoeShare }); r.priority.push_back({ 14605, 0 }); // Bone Construct: up to 40 of them, 6k hp each; tanks hold them, DPS burn Nefarian (DB 14605) r.priority.push_back({ 14668, 6 }); // Corrupted Infernal (warlock call: 2 per warlock, stun+damage) (boss_nefarian.cpp:63,609-624) // Corrupted totems (shaman call, boss_nefarian.cpp:398-557): 200-2000 hp, root themselves, give Nefarian/drakonids Windfury, Stoneskin, @@ -109,9 +129,9 @@ namespace Playerbot::Raid { r.priority.push_back({ 14663, 5 }); // Corrupted Stoneskin Totem VI (boss_nefarian.cpp:437) r.priority.push_back({ 14664, 4 }); // Corrupted Healing Stream Totem V (boss_nefarian.cpp:440) // Fire Nova totem 14662 removes itself after one cast (boss_nefarian.cpp:527-533): no rule. - // Class-call debuffs on bots: Wild Polymorph 23603 (mage call, boss_nefarian.cpp:58,726). UNVERIFIED dispel kind. - r.dispel.push_back({ 23603, DispelKind::Magic }); // Nefarian Polymorph (boss_nefarian.cpp:58) UNVERIFIED kind - r.dispel.push_back({ 22687, DispelKind::Curse }); // Veil of Shadow on the tank, -healing (boss_nefarian.cpp:41,324) UNVERIFIED kind + // Class-call debuffs on bots: Wild Polymorph 23603 (mage call, boss_nefarian.cpp:58,726). Dispel kinds from the vanilla data. + r.dispel.push_back({ 23603, DispelKind::Magic }); // Nefarian Polymorph (boss_nefarian.cpp:58), magic + r.dispel.push_back({ 22687, DispelKind::Curse }); // Veil of Shadow on the tank, -healing (boss_nefarian.cpp:41,324), curse // Priest call: Corrupted Healing 23401 is put on every priest (classic_boss_nefarian.cpp HandleClassCall, AddAura) and turns // their heals into damage over time on the target: healing priests stop until it fades (dispels still run). r.holdByAura.push_back({ 23401, Who::Healer }); diff --git a/src/modules/PlayerbotV2/Bot/Raid/RaidEncounterData_MC.cpp b/src/modules/PlayerbotV2/Bot/Raid/RaidEncounterData_MC.cpp index faf6c00ec9..30a58d6823 100644 --- a/src/modules/PlayerbotV2/Bot/Raid/RaidEncounterData_MC.cpp +++ b/src/modules/PlayerbotV2/Bot/Raid/RaidEncounterData_MC.cpp @@ -17,7 +17,8 @@ namespace Playerbot::Raid { // on the healers it is the difference between a sustained kill and an out-of-mana wipe, so it is urgent (healers and tanks first, // even while the raid is in an emergency), like Gehennas' Curse. r.dispel.push_back({ 19703, DispelKind::Curse, true }); // Lucifron's Curse (mc/boss_lucifron.cpp:19) - r.dispel.push_back({ 19702, DispelKind::Magic, true }); // Impending Doom, 2000 shadow after 10s within 40 yd (mc/boss_lucifron.cpp:18); kind UNVERIFIED + r.dispel.push_back({ 19702, DispelKind::Magic, true, 0, kImpendingDoomDispelOrders }); // Impending Doom, 2000 shadow after 10s within 40 yd (mc/boss_lucifron.cpp:18); kind UNVERIFIED + r.noControl.push_back({ 12119 }); // the Protectors are killed, not sheeped r.priority.push_back({ 12119, 4 }); // Flamewaker Protector (MCRaidPolicy.h:100) r.controlledMember.push_back({ 20604 }); // Protector's Dominate Mind (vanilla_smartai, VMaNGOS spell list 121190) @@ -45,10 +46,12 @@ namespace Playerbot::Raid { r.crowdControl.push_back({ 12099, CcKind::Banish, 0, 0, true }); // Firesworn is an elemental (type 4) (MoltenCoreDungeonActions.cpp:201) r.priority.push_back({ 12099, 0 }); // see correction above // (removed) noAoe on Garr himself: nothing in the script justifies it. - // A Firesworn that dies explodes (Massive Eruption 19497, radius 15, mc/boss_garr.cpp:232-249): the tank beside it dies to it - // (MC Garr 2026-10-10: Kaido at 203 s) and casters standing 14-28 y out went with earlier wipes. Ranged and healers keep outside. - r.avoidEnemy.push_back({ 12099, 17.0f, Who::Ranged }); - r.avoidEnemy.push_back({ 12099, 17.0f, Who::Healer }); + // A Firesworn that dies explodes (Massive Eruption 19497, radius 15, mc/boss_garr.cpp:232-249) and hastens Garr. None dies before Garr: + // at 25 percent nobody attacks it, the tank that holds it included (scenario run: the holding tanks killed five of eight + // before Garr fell). With no eruption in the fight there is no reason for ranged and healers to keep 17 y from every live add; the + // old Ranged / Healer rule made them run, and the Movement table keeps the one rule + // for a dying add (healers, under 15 percent). Fight script: Bot/Raid/RaidFightScript.h. + r.spare.push_back({ 12099, kGarrFireswornSparePct, 12057 }); // BARON GEDDON - boss 12056 r.dispel.push_back({ 19659, DispelKind::Magic }); // Ignite Mana (mc/boss_baron_geddon.cpp:30); kind UNVERIFIED @@ -58,13 +61,23 @@ namespace Playerbot::Raid { // (mc/boss_golemagg.cpp:275-284, 113): never a target. r.priority.push_back({ 11672, -1 }); // Core Rager (mc/boss_golemagg.cpp:275-284) r.noAoe.push_back({ 11672 }); // no AoE on the Ragers: they heal to full at 50% and only die with Golemagg (ike3) + // Earthquake (19798): below 10 percent he casts it every 3 s (mc/boss_golemagg.cpp:80), instant, 1500 physical to everything within 18 y + //. Everyone but the tanks leaves his 22 y and the ranged finish him; the bot he is hitting is never moved. + r.avoidEnemy.push_back({ 11988, kGolemaggEarthquakeLeave, Who::NonTank, kGolemaggEarthquakePct }); + // Magma Splash (13880): a melee hit on him procs it (25 percent), up to 50 stacks for 30 s, 50 fire a tick and -250 resistance per stack. + // A bot carrying 20 stacks stays 12 y off until it fades. No tank swap on it: the swap takes the nearest clean tank, which could be the + // off tank holding the Core Ragers at the far camp; that waits for a log of the fight. + r.avoidOnStacks.push_back({ 11988, 13880, kGolemaggSplashStacks, kGolemaggSplashBackoff, Who::NonTank }); // SULFURON HARBINGER - boss 12098 r.priority.push_back({ 11662, 5 }); // Flamewaker Priest (MCRaidPolicy.h:99) // Inspire 19779: Sulfuron buffs himself and his priests (mc/classic_boss_sulfuron_harbinger.cpp:95-109), a magic buff the priests and shamans take off. r.purge.push_back({ 19779 }); + // The list is in kick order (InterruptOrder): Dark Mending 19775, the heal, goes before everything else on the map. Sulfuron's + // Flamewaker Priests cast it (spell list 116620), and so do Majordomo's Flamewaker Healers since the world SQL + // 2026_10_16_00_world_classic_flamewaker_healer_dark_mending (every 5-10 s on an ally under 80%, 27750-32250 healed). r.interruptFirst.push_back(19775); - r.interruptFirst.push_back(20603); // Flamewaker Healer: Shadow Shock (VMaNGOS creature_spells 116630; it has no heal) // Flamewaker Priest: Dark Mending, the heal on Sulfuron and his priests (spell list 116620) + r.interruptFirst.push_back(20603); // Flamewaker Healer: Shadow Shock (vanilla spell id) r.dispel.push_back({ 19776, DispelKind::Magic }); // Flamewaker Priest: Shadow Word: Pain (vanilla_smartai, VMaNGOS spell list 116620) r.dispel.push_back({ 20294, DispelKind::Magic }); // Flamewaker Priest: Immolate (same list) @@ -72,9 +85,12 @@ namespace Playerbot::Raid { // He surrenders when the adds are dead and cannot be killed (mc/boss_majordomo_executus.cpp:335,379): never a target. // Every 30s one of Magic Reflection / Damage Shield is cast on ALL living adds (:485-501): dispel them off before attacking. r.priority.push_back({ 12018, -1 }); // Majordomo Executus (mc/boss_majordomo_executus.cpp:335) - // One plan (n71 wipe): one tank holds Majordomo, away from the raid, and the other tanks take the four Elites. Mages sheep up to - // three Healers; the raid kills Healers first, then Elites (the owner's marks first). Casters stop on Magic Reflection, melee on - // Damage Shield. He surrenders when all eight adds are dead. + // The owner's plan: the second tank holds Majordomo from the first second, the other tanks take one Elite each (the Healers last), the + // main tank takes the owner's skull Healer. Mages sheep the Healers the owner marks; only the skull is attacked (RaidFightScript.h). + r.offTankMob.push_back(12018); + // Healer Shadow Shock 20603 (instant, 20 yards, no kick): casters and healers stay out of it; Polymorph reaches 30. + r.avoidEnemy.push_back({ 11663, 21.0f, Who::Ranged }); + r.avoidEnemy.push_back({ 11663, 21.0f, Who::Healer }); // The adds' casts go first for the kickers: Shadow Bolt (Healer) and Fireball (Elite) were interrupted four times in 95 s (n38). r.interruptFirst.push_back(21077); r.interruptFirst.push_back(20420); @@ -82,7 +98,6 @@ namespace Playerbot::Raid { // rogues, a healer and a warrior beside the tanks holding the Elites). Casters, hunters and healers keep 13 yards from them. r.avoidEnemy.push_back({ 11664, 13.0f, Who::Ranged }); r.avoidEnemy.push_back({ 11664, 13.0f, Who::Healer }); - r.tankOrder.push_back(12018); r.tankOrder.push_back(11664); r.tankOrder.push_back(11663); // The brain already refuses to hit an add under either shield (Raid::kMagicReflection / kDamageShield) but nothing took @@ -91,7 +106,8 @@ namespace Playerbot::Raid { r.purge.push_back({ 21075 }); // Damage Shield (classic_boss_majordomo_executus.cpp:51) r.priority.push_back({ 11664, 4 }); // Flamewaker Elite (MCRaidPolicy.h:100) r.priority.push_back({ 11663, 5 }); // Flamewaker Healer (MCRaidPolicy.h:99) - // No raid-chosen sheep here: the owner marks the Healers and gives each to a mage; skull moves onto them in turn (n71). + // The Elites cannot be sheeped; the Healers are the owner's to sheep with his icons (no automatic crowd control). + r.noControl.push_back({ 11664 }); // Flamewaker Elite (polymorph-immune anyway) // RAGNAROS - boss 11502 // Submerged phase: it ends early when every Son of Flame is banished (mc/boss_ragnaros.cpp:347-363). diff --git a/src/modules/PlayerbotV2/Bot/Raid/RaidEncounterData_MC_Movement.cpp b/src/modules/PlayerbotV2/Bot/Raid/RaidEncounterData_MC_Movement.cpp index a917fb9e0f..58343d9925 100644 --- a/src/modules/PlayerbotV2/Bot/Raid/RaidEncounterData_MC_Movement.cpp +++ b/src/modules/PlayerbotV2/Bot/Raid/RaidEncounterData_MC_Movement.cpp @@ -33,12 +33,23 @@ namespace Playerbot::Raid { // margin (RaidRangedApproachTank), so the circle and the stand slots are the same number. Heal range to the tank is 40 y. r.avoidEnemy.push_back({ 12056, 24.0f, Who::Ranged }); r.avoidEnemy.push_back({ 12056, 24.0f, Who::Healer }); + // Armageddon (20479, 8000 fire, radius 20 y) fires when his health crosses 2 percent (mc/boss_baron_geddon.cpp:70). The last of his health goes + // in seconds, so the melee are gone before it: below kGeddonMeleeLeavePct they stand outside the same 24 y as the casters and let the ranged + // finish him (Molten Core: a rogue, a warrior, a retribution paladin and the main tank, all 5 y from him and still on + // auto_attack, died to it at once). The tank stays: he follows it. + r.avoidEnemy.push_back({ 12056, 24.0f, Who::Melee, kGeddonMeleeLeavePct }); + // Armageddon is an 8 s aura on Geddon: he cannot move while it runs, + // so everyone, the tank too, leaves the same circle as for Inferno until it ends. The tick period is not in the spell audit; whether the first + // tick lands before a bot is clear is what the next mc_geddon run shows. + r.avoidEnemyAura.push_back({ 12056, 20478, 24.0f, Who::Anyone }); // Threat resets and teleports that leave the boss on a non-tank: Lucifron, Magmadar (Panic), Gehennas, Shazzrah (Gate), Ragnaros (Wrath // 20566 runs ResetThreatList, boss_ragnaros.cpp:198). A tank taunts the boss back at once; with no one in melee reach he casts Magma Blast // (6000 fire, range unlimited) on whoever holds threat: three casters died to it in the last fight. Geddon, Garr, Golemagg and Sulfuron are // on the list too: a boss that walks onto a mage takes the whole raid with it (mc_geddon 09a8ff07: Geddon on a mage 6 s in, loose in the - // casters' block when Inferno came, 8 dead). - for (uint32_t boss : { 12118u, 11982u, 12259u, 12264u, 11502u, 12056u, 12057u, 11988u, 12098u }) + // casters' block when Inferno came, 8 dead). Majordomo: his Teleport resets his threat list every 20-30 s + // (classic_boss_majordomo_executus.cpp:553-571); nobody hits him (Priority -1), so after each one he stood on a healer (on + // one healer after the other for 30 s; he killed 10 raiders over three fights, all healers and casters). + for (uint32_t boss : { 12118u, 11982u, 12259u, 12264u, 11502u, 12056u, 12057u, 11988u, 12098u, 12018u }) r.retaunt.push_back(boss); // Ragnaros: Elemental Fire (20564, 2400 fire a tick for 8 s) is reapplied by every swing on the current victim. The tank who carries it // hands over to a clean one (taunt 10 s), so each tank takes one application per turn; the holder with it stops attacking while a clean diff --git a/src/modules/PlayerbotV2/Bot/Raid/RaidEncounterData_NAXX.cpp b/src/modules/PlayerbotV2/Bot/Raid/RaidEncounterData_NAXX.cpp index da8198d874..57bb9855bd 100644 --- a/src/modules/PlayerbotV2/Bot/Raid/RaidEncounterData_NAXX.cpp +++ b/src/modules/PlayerbotV2/Bot/Raid/RaidEncounterData_NAXX.cpp @@ -12,11 +12,13 @@ namespace Playerbot::Raid { r.name = "Naxxramas"; // Kick-first casts (VMaNGOS creature_spells): Mad Scientist Mana Burn 28301, Living Monstrosity Chain Lightning 28293, - // Acolyte / Necropolis Acolyte Shadow Bolt Volley 28448, Unholy Staff Polymorph 29848. + // Acolyte / Necropolis Acolyte Shadow Bolt Volley 28448, Unholy Staff Polymorph 29848, Kel'Thuzad's Frostbolt 28478 + // (classic_boss_kelthuzad.cpp:84). r.interruptFirst.push_back(28301); r.interruptFirst.push_back(28293); r.interruptFirst.push_back(28448); r.interruptFirst.push_back(29848); + r.interruptFirst.push_back(28478); // Encounter order (progression advice): Arachnid, Plague, Military, Construct quarter, then Sapphiron and Kel'Thuzad. r.bosses = { 15956, 15953, 15952, // Anub'Rekhan, Faerlina, Maexxna @@ -37,20 +39,26 @@ namespace Playerbot::Raid { r.dispel.push_back({ 28796, DispelKind::Poison }); r.avoidGroundEffect.push_back({ 15953, 28794, 3.0f, Who::Anyone }); r.priority.push_back({ 16505, 3 }); // Naxxramas Follower (classic_boss_faerlina.cpp:53): silence, charge + // The Follower's Silence 30225 reaches 10 yd around it (SAI 16505, vanilla data radius index 13): healers keep 13. + r.avoidEnemy.push_back({ 16505, 13.0f, Who::Healer }); // Worshippers are the enrage counter: after each Enrage 28798 a priest mind-controls one and sacrifices it with Widow's // Embrace 28732 on her (RaidMechanics_Naxx.cpp). They have no bot logic; never a DPS target. r.priority.push_back({ 16506, -1 }); // --------------------------------------------------------------------------------------------------------------- // MAEXXNA (15952): Web Wrap cocoons (16486) hold players until killed; Necrotic Poison 28776 on the tank (-90% healing, - // "Dispelllable" per the script comment); spiderlings 17055 (naxx/classic_boss_maexxna.cpp). + // "Dispelllable" per the script comment: a tank that cannot be healed is dispelled before anything else); Poison Shock 28741 + // hits everything in front of her within 30 yd (vanilla data, radius index 10); spiderlings 17055 (naxx/classic_boss_maexxna.cpp). r.priority.push_back({ 16486, 7 }); // Web Wrap: free the wrapped player r.priority.push_back({ 17055, 4 }); // Maexxna Spiderling - r.dispel.push_back({ 28776, DispelKind::Poison }); + r.dispel.push_back({ 28776, DispelKind::Poison, true }); + r.avoidFrontal.push_back({ 15952, 30.0f, 60.0f, Who::NonTank }); // --------------------------------------------------------------------------------------------------------------- - // NOTH THE PLAGUEBRINGER (15954): Curse of the Plaguebringer 29213; balcony phase adds (naxx/classic_boss_noth.cpp). - r.dispel.push_back({ 29213, DispelKind::Curse }); + // NOTH THE PLAGUEBRINGER (15954): Curse of the Plaguebringer 29213 turns into Wrath of the Plaguebringer (4,000 shadow to + // everybody near the carrier) when it runs out, so it is dispelled before anything else; balcony phase adds + // (naxx/classic_boss_noth.cpp). + r.dispel.push_back({ 29213, DispelKind::Curse, true }); r.priority.push_back({ 16983, 3 }); // Plagued Champion r.priority.push_back({ 16981, 3 }); // Plagued Guardian r.priority.push_back({ 16984, 2 }); // Plagued Warrior @@ -75,7 +83,9 @@ namespace Playerbot::Raid { r.priority.push_back({ 16803, -1 }); // --------------------------------------------------------------------------------------------------------------- - // GOTHIK THE HARVESTER (16060): waves on both sides (naxx/classic_naxxramas.h:114-120). Riders hit hardest. + // GOTHIK THE HARVESTER (16060): waves on both sides (naxx/classic_naxxramas.h:114-120). Riders hit hardest. He teleports + // between the sides once he comes down: a tank taunts him back each time. + r.retaunt.push_back(16060); r.priority.push_back({ 16126, 4 }); // Unrelenting Rider r.priority.push_back({ 16125, 3 }); // Unrelenting Deathknight r.priority.push_back({ 16124, 2 }); // Unrelenting Trainee @@ -136,8 +146,8 @@ namespace Playerbot::Raid { // --------------------------------------------------------------------------------------------------------------- // SAPPHIRON (15989): Life Drain 28542, Blizzard creatures 16474 that drift around (naxx/classic_boss_sapphiron.cpp), - // Cleave / Tail Sweep front and back. - r.dispel.push_back({ 28542, DispelKind::Curse }); + // Cleave / Tail Sweep front and back. Life Drain heals him for what it takes, so it goes before any other dispel. + r.dispel.push_back({ 28542, DispelKind::Curse, true }); r.avoidCreature.push_back({ 16474, 8.0f, Who::Anyone }); r.avoidFrontal.push_back({ 15989, 25.0f, 50.0f, Who::NonTank }); r.avoidFrontal.push_back({ 15989, 20.0f, 45.0f, Who::NonTank, 180.0f }); // Tail Sweep 15847 behind him @@ -157,8 +167,13 @@ namespace Playerbot::Raid { r.priority.push_back({ 16429, 4 }); // Soul Weaver r.priority.push_back({ 16427, 3 }); // Soldier of the Frozen Wastes r.priority.push_back({ 16428, 2 }); // Unstoppable Abomination + // Soul Weaver: Wail of Souls 28459, damage and a knockback in front of it within 30 yd (vanilla data, radius index 10). + r.avoidFrontal.push_back({ 16429, 30.0f, 60.0f, Who::NonTank }); // Shackle at most 3 Guardians: a 4th frees them all (classic_boss_kelthuzad.cpp:1027-1100). r.crowdControl.push_back({ 16441, CcKind::Shackle, 0, 3 }); + // A Guardian that is tanked stacks Blood Tap 28470 on its tank (+damage, +size per stack, classic_boss_kelthuzad.cpp:104): + // another tank takes it at 4. + r.tankSwap.push_back({ 16441, 28470, 4 }); // Chains of Kel'Thuzad 28410 mind-controls a raider (:690-704): sheep or stun, never kill. r.controlledMember.push_back({ 28410 }); @@ -233,7 +248,7 @@ namespace Playerbot::Raid { // * Thaddius: Forever's port gives every player Negative Charge (classic_boss_thaddius.cpp:851-858), so the charge // sides above all resolve to one side; harmless. Magnetic Pull tank swap of Stalagg/Feugen relies on pvecoord. // * Noth's balcony phase (immune 29230, adds) and blink: the generic tank pickup handles both. - // * Kel'Thuzad: Frost Blast 27808 (heal through), Frostbolt 28478 interrupt (pvecoord's kicks if it owns it). + // * Kel'Thuzad: Frost Blast 27808 (heal through). // * Loatheb Inevitable Doom 29204 (heal through); Anub'Rekhan Impale (random line, nothing to dodge in time). // * Trash: Plague Slime 16243 changes school immunity with its colour (needs the casters' rotations to pick a school); // Plague Beast 16034 Mutated Spores (radius not in the spell data); Gargoyle Stoneskin needs an interrupt (pvecoord). diff --git a/src/modules/PlayerbotV2/Bot/Raid/RaidEncounterData_ONY.cpp b/src/modules/PlayerbotV2/Bot/Raid/RaidEncounterData_ONY.cpp index 477e44bf02..523c060a0b 100644 --- a/src/modules/PlayerbotV2/Bot/Raid/RaidEncounterData_ONY.cpp +++ b/src/modules/PlayerbotV2/Bot/Raid/RaidEncounterData_ONY.cpp @@ -63,17 +63,32 @@ namespace Playerbot::Raid { { 18596u, -58.2509f, -189.020f, 10.2191f, -247.912f }, // south-west to north-east { 18617u, 10.2191f, -247.912f, -58.2509f, -189.020f }, // north-east to south-west }; + // hover = true: the corridor of the waypoint she hovers at (or flies to) is a hazard for everybody from the moment she arrives, tanks and + // healers too. The breath damage is one instant at the end of the 5 s cast (scenario run: 16 dead in the same second, all + // three waves 4-5 s after the cast began), a raid that starts to leave when the cast starts has 35 y of running and the hall needs 34 from + // its middle. The corridor closes again 8 s after the cast began (RaidBrain kBreathOpenMs): the old 11 s after the last sighting kept it shut + // while Heated Ground burned and the bots could not leave the fire. for (BreathPath const& path : kPaths) - r.avoidBreath.push_back({ 10184, path.spell, 34.0f, 0.0f, Who::Anyone, false, true, path.ax, path.ay, path.bx, path.by }); + r.avoidBreath.push_back({ 10184, path.spell, 34.0f, 0.0f, Who::Anyone, false, true, path.ax, path.ay, path.bx, path.by, true }); + + // Heated Ground (22191..22202): the fire the breath leaves round the two egg pits, a dynamic object of 13 y per spell, 300-550 a tick + // (scenario run: eleven raiders died in it, all at 5-16 percent after the breath, standing on the AzerothCore safe points, + // which lie in it). Everybody keeps out of every zone that exists. + for (uint32_t spell = 22191u; spell <= 22202u; ++spell) + r.avoidGroundEffect.push_back({ 10184, spell, 1.0f, Who::Anyone }); // Phase 1 on the ground: Flame Breath 18435, Wing Buffet 18500 and Cleave 19983 hit the front, Tail Sweep 15847 the back // (classic_boss_onyxia.cpp:20-25). Only the tank stands in front, nobody stands behind her; melee and casters take the // flanks. The cones skip her while she flies (phase 2), where her facing changes at every waypoint. Lengths are the spells' radii // from the spell audit (research/pc-2026-10-11/SpellAudit.tsv): Flame Breath 45 y (3500 fire, 2 s cast), Tail Sweep 30 y (800), - // Wing Buffet 20 y. The cone angle (45 degrees either side) is still the engine's default for a front cone, UNVERIFIED. + // Wing Buffet 20 y. Angles from the client's SpellTargetRestrictions: Flame Breath and Wing Buffet a 120 degree cone in + // front (60 either side), Tail Sweep -120, the rear arc (60 either side of straight behind her). The 45 degrees this rule had was the + // engine default and wrong: the third live pull lost 27 of 38 to Flame Breath, raiders 55-77 degrees off her facing. The front and + // tail arcs, their margin and the wedges between them are the kOny* constants of RaidEncounters.h. // onyxia_full n17 2026-10-14: casters died to hits of 2000-3900 from 19-38 y away, outside the 25 y this rule had. - r.avoidFrontal.push_back({ 10184, 45.0f, 45.0f, Who::NonTank, 0.0f, 100.0f, 0.0f, false }); - r.avoidFrontal.push_back({ 10184, 30.0f, 80.0f, Who::NonTank, 180.0f, 100.0f, 0.0f, false }); + // A cast lands up to two seconds after she turns, so the cones carry a margin: nobody stands, or leaves to stand, inside the widened edge. + r.avoidFrontal.push_back({ 10184, 45.0f, kOnyFrontHalfDeg, Who::NonTank, 0.0f, 100.0f, 0.0f, false, kOnyConeMarginDeg }); + r.avoidFrontal.push_back({ 10184, 30.0f, kOnyTailHalfDeg, Who::NonTank, 180.0f, 100.0f, 0.0f, false, kOnyConeMarginDeg }); // Where to stand for each breath, the AzerothCore bots' safe zones (mod-playerbots Ai/Raid/Ony/OnyActions.h): two points per breath, // 32-53 y off its line, at the hall's ends. A member inside a corridor walks to the nearer one. @@ -102,29 +117,37 @@ namespace Playerbot::Raid { r.faceAway.push_back({ 10184, 100.0f, 65.0f, 0.0f }); r.faceAway.push_back({ 10184, 40.0f, 0.0f, 0.0f }); - // Melee DPS stand on her flank, in the wedge between the front cones (45 degrees) and the tail sweep (everything behind, from 90): - // 55..85 degrees off her facing, 3-8 yards out. Phases 1 and 3 only; she flies in phase 2 (the rule skips a flying enemy too). + // Melee DPS stand on her flank, in the wedge between the widened front cone and the widened tail sweep (kOnyWedgeLoDeg..kOnyWedgeHiDeg + // off her facing: 75..105 with the arcs at 60 either side and a 12 degree margin), 2-9 yards out. Phases 1 and 3 only; she flies in phase 2 (the rule skips a + // flying enemy too). The wedge is measured from the tank's locked axis (RaidBrain 3d), not from her live facing, which swings with + // every step of the tank and flipped the side a bot stood on. // Onyxia n7 2026-10-14: six melee DPS died to one tail sweep at 19 s while alternating "leave cone" and attack. - r.standFlank.push_back({ 10184, Who::Melee, 2.0f, 9.0f, 70.0f, 20.0f, 100.0f, 65.0f }); - r.standFlank.push_back({ 10184, Who::Melee, 2.0f, 9.0f, 70.0f, 20.0f, 40.0f, 0.0f }); + r.standFlank.push_back({ 10184, Who::Melee, 2.0f, 9.0f, kOnyWedgeCentreDeg, kOnyWedgeHalfDeg, 100.0f, 65.0f }); + r.standFlank.push_back({ 10184, Who::Melee, 2.0f, 9.0f, kOnyWedgeCentreDeg, kOnyWedgeHalfDeg, 40.0f, 0.0f }); // Each bot has its own slot in the wedge (RaidBrain 3d: the matching members on its side share a grid of rows and columns) and that is - // the only position rule for it in phases 1 and 3; healers take the inner band (20-26 y), ranged the outer one (26-34 y), melee 2-9 y. - // Ranged DPS and healers take the same side wedges, out of Wing Buffet (20 y) and the tail sweep, 22-30 y from her. Her facing follows + // the only position rule for it in phases 1 and 3; healers take the inner band (21-25 y), ranged the outer one (23-29 y), melee 2-9 y. + // The outer band ends inside the casters' 30 y reach: the old 26-34 y band put half of them out of range, and the range step walked them + // back toward her while the wedge sent them out. + // Ranged DPS and healers take the same side wedges, out of Wing Buffet (20 y) and the tail sweep, 21-29 y from her. Her facing follows // whoever she is hitting; with the ranged massed on one bearing a single Flame Breath (45 y) took ten of them at once, in the first // minute of n38 run 5 (all ten stood 48-68 degrees off her facing, 8-30 y out) and in a dozen breaths of run 6's phase 3, where the // whole raid stood round her. In the wedges only the side she turns to is exposed, and the other side is clear. Phases 1 and 3. - r.standFlank.push_back({ 10184, Who::Ranged, 26.0f, 34.0f, 70.0f, 20.0f, 100.0f, 65.0f }); - r.standFlank.push_back({ 10184, Who::Ranged, 26.0f, 34.0f, 70.0f, 20.0f, 40.0f, 0.0f }); - r.standFlank.push_back({ 10184, Who::Healer, 20.0f, 26.0f, 70.0f, 20.0f, 100.0f, 65.0f }); - r.standFlank.push_back({ 10184, Who::Healer, 20.0f, 26.0f, 70.0f, 20.0f, 40.0f, 0.0f }); + r.standFlank.push_back({ 10184, Who::Ranged, 23.0f, 29.0f, kOnyWedgeCentreDeg, kOnyWedgeHalfDeg, 100.0f, 65.0f }); + r.standFlank.push_back({ 10184, Who::Ranged, 23.0f, 29.0f, kOnyWedgeCentreDeg, kOnyWedgeHalfDeg, 40.0f, 0.0f }); + r.standFlank.push_back({ 10184, Who::Healer, 21.0f, 25.0f, kOnyWedgeCentreDeg, kOnyWedgeHalfDeg, 100.0f, 65.0f }); + r.standFlank.push_back({ 10184, Who::Healer, 21.0f, 25.0f, kOnyWedgeCentreDeg, kOnyWedgeHalfDeg, 40.0f, 0.0f }); // The two cave alcoves (-30.1,-254.5 and -30.8,-177.1, ony/boss_onyxia.cpp whelp spawn points) are out of bounds: static whelps lie in // them, and raiders sent there (the off-tanks stood 6 y inside each mouth, the casters' AoE share behind them) and raiders pushed there by // a flank, spacing or dodge move pulled out dozens of whelps, 38 loose at 3 min (n58 live 2026-10-15). No move target may end within - // 22 y of either centre; the whelps the script sends out come to the raid, which fights them where it stands. - r.keepOut.push_back({ 10184, -30.1f, -254.5f, 22.0f }); - r.keepOut.push_back({ 10184, -30.8f, -177.1f, 22.0f }); + // kOnyCaveKeepOutRadius of either centre; the whelps the script sends out come to the raid, which fights them where it stands. + // The circle is the whelps' own pull range, not a wide berth: the core's aggro radius is 15 y less the creature's combat reach plus the + // level difference (Creature::GetAggroRange), about 10-13 y for a level 56-59 whelp against a level 60 raider. The 22 y it had put both + // flank wedges inside the circles whenever she stands at her spawn spot (x -34.6: the wedge's slots are 7-19 y from the cave centres), the + // brain pushed every casters' move out to the rim in front of her and 945 cone steps followed. + r.keepOut.push_back({ 10184, -30.1f, -254.5f, kOnyCaveKeepOutRadius }); + r.keepOut.push_back({ 10184, -30.8f, -177.1f, kOnyCaveKeepOutRadius }); // Phase 2 range. In n50 run 1 she went 56% -> 54% in 36 s with 20 DPS "hitting": the ranged stood 54-78 y from her (dps_idle_reason // "target out of range" with the flying Onyxia, moving=1 for whole minutes) and the casters on the whelp share ran 36-71 y after diff --git a/src/modules/PlayerbotV2/Bot/Raid/RaidEncounters.cpp b/src/modules/PlayerbotV2/Bot/Raid/RaidEncounters.cpp index 24e1e421d0..575d68908b 100644 --- a/src/modules/PlayerbotV2/Bot/Raid/RaidEncounters.cpp +++ b/src/modules/PlayerbotV2/Bot/Raid/RaidEncounters.cpp @@ -73,9 +73,17 @@ bool OwnsAura(uint32_t mapId, uint32_t aura) } bool InterruptFirst(uint32_t mapId, uint32_t spell) +{ + return InterruptOrder(mapId, spell) != kNotInterruptFirst; +} + +size_t InterruptOrder(uint32_t mapId, uint32_t spell) { RaidRules const* rules = RulesForMap(mapId); - return rules && std::find(rules->interruptFirst.begin(), rules->interruptFirst.end(), spell) != rules->interruptFirst.end(); + if (!rules) + return kNotInterruptFirst; + auto const it = std::find(rules->interruptFirst.begin(), rules->interruptFirst.end(), spell); + return it == rules->interruptFirst.end() ? kNotInterruptFirst : size_t(it - rules->interruptFirst.begin()); } bool NoTank(uint32_t mapId, uint32_t entry) @@ -99,6 +107,12 @@ bool TankLast(uint32_t mapId, uint32_t entry) return rules && std::find(rules->tankLast.begin(), rules->tankLast.end(), entry) != rules->tankLast.end(); } +bool OffTankMob(uint32_t mapId, uint32_t entry) +{ + RaidRules const* rules = RulesForMap(mapId); + return rules && std::find(rules->offTankMob.begin(), rules->offTankMob.end(), entry) != rules->offTankMob.end(); +} + bool Retaunts(uint32_t mapId, uint32_t entry) { RaidRules const* rules = RulesForMap(mapId); diff --git a/src/modules/PlayerbotV2/Bot/Raid/RaidEncounters.h b/src/modules/PlayerbotV2/Bot/Raid/RaidEncounters.h index b3320d5e7a..70c4ac68a5 100644 --- a/src/modules/PlayerbotV2/Bot/Raid/RaidEncounters.h +++ b/src/modules/PlayerbotV2/Bot/Raid/RaidEncounters.h @@ -6,7 +6,7 @@ // so the creature entries and spell ids carry over unchanged. // // A rule set is registered per MAP ID (409 Molten Core, 469 Blackwing Lair, -// 249 Onyxia's Lair, 533 Naxxramas). RaidBrain.cpp reads these tables on the +// 249 Onyxia's Lair, 531 Temple of Ahn'Qiraj, 533 Naxxramas). RaidBrain.cpp reads these tables on the // world thread and turns them into per-bot raid orders (move out of hazards, // spread, stand at role positions, taunt swaps, dispels, purges, crowd // control, forbidden targets). The data files (RaidEncounterData_*.cpp) @@ -19,6 +19,9 @@ #pragma once +#include +#include +#include #include #include #include @@ -61,7 +64,27 @@ struct CarrierRun { uint32_t aura; float clearDistance; Who who = Who::NonTank; // tankTurns: when three or more non-tanks stand in the cone, the tank holding the enemy steps to the far side of it to turn it away from the raid // (Magmadar). Off for a boss whose raid stands on fixed flank wedges (Onyxia): there the turn sends her breath across the wedges, the whole // ranged group has to re-position each time, and onyxia_full n57 run 1 saw the main tank do it every 9 s for four minutes (1880 "leave cone" steps). -struct AvoidFrontal { uint32_t enemy; float radius; float halfAngleDeg; Who who; float facingOffsetDeg = 0.0f; float hpMax = 100.0f; float hpMin = 0.0f; bool tankTurns = true; }; +// marginDeg: the bot leaves, and no stand point may lie, inside the cone widened by this many degrees. A cast that lands 2 s after the enemy +// turns a few degrees cannot be dodged from inside the exact edge. +struct AvoidFrontal { uint32_t enemy; float radius; float halfAngleDeg; Who who; float facingOffsetDeg = 0.0f; float hpMax = 100.0f; float hpMin = 0.0f; bool tankTurns = true; float marginDeg = 0.0f; }; + +// Onyxia's ground phases (RaidEncounterData_ONY.cpp): the front cone and the tail sweep, in degrees off her facing, the margin both carry, and +// the wedge on each flank between them where the raid stands. The wedge is derived, so that a change to either arc moves it too. +// Client spell data: Flame Breath 18435 and Wing Buffet 18500 are a 120 degree cone in front (the core's +// HasInArc takes the whole arc: 60 either side), Tail Sweep 15847 is -120, the rear arc (60 either side of straight behind her). +constexpr float kOnyFrontHalfDeg = 60.0f; // Flame Breath, Wing Buffet: each side of her facing +constexpr float kOnyTailHalfDeg = 60.0f; // Tail Sweep: each side of the line straight behind her +constexpr float kOnyConeMarginDeg = 12.0f; // a cast lands up to 2 s after she turns, and the deaths seen sat right on the edge (+60, -57) +constexpr float kOnyWedgeGapDeg = 3.0f; // between the widened cone edge and the first row of the wedge +constexpr float kOnyCaveKeepOutRadius = 12.0f; // the static whelps' pull range (see the data file), no wider +constexpr float kOnyWedgeLoDeg =kOnyFrontHalfDeg + kOnyConeMarginDeg + kOnyWedgeGapDeg; +constexpr float kOnyWedgeHiDeg = 180.0f - kOnyTailHalfDeg - kOnyConeMarginDeg - kOnyWedgeGapDeg; +constexpr float kOnyWedgeCentreDeg = 0.5f * (kOnyWedgeLoDeg + kOnyWedgeHiDeg); +constexpr float kOnyWedgeHalfDeg = 0.5f * (kOnyWedgeHiDeg - kOnyWedgeLoDeg); + +// Where a bot stands to be clear of a frontal cone: the bearing (degrees off the enemy's facing) from which the cone, with its margin, is +// left behind. Used by the flank wedges' tests and by the data that builds them. +constexpr float ConeEdgeDeg(AvoidFrontal const& rule) { return rule.halfAngleDeg + rule.marginDeg; } // Ground effects created by through (dynamic objects such as Rain of Fire): stay out of them, plus . struct AvoidGroundEffect { uint32_t enemy; uint32_t spell; float margin; Who who; }; @@ -98,7 +121,15 @@ struct StandByAura { uint32_t enemy; uint32_t aura; float bearing; float distanc // the carriers that heal or tank are cleansed first. // hurtBelowPct: dispel only while the carrier is at or under this health (a weak damage-over-time that costs more mana to remove // than it does harm); 0 = always. See DispelWorth.h. -struct Dispel { uint32_t aura; DispelKind kind; bool urgent = false; int hurtBelowPct = 0; }; +// Impending Doom: three healers per plan are enough, the rest keep healing (live kill: up to 11 orders a round, 27 rounds). +constexpr uint32_t kImpendingDoomDispelOrders = 3; +// maxOrders: at most this many dispel orders per plan for the aura (each cast costs the mana a heal would); 0 = no cap of its own. +struct Dispel { uint32_t aura; DispelKind kind; bool urgent = false; int hurtBelowPct = 0; uint32_t maxOrders = 0; }; + +// The group coordinator's crowd control (icon marks, the automatic picks) never holds this enemy in this raid. For an enemy the fight is +// better off killed than held (Lucifron's Flamewaker Protectors: the mage sheep, the raid loses a target and the Protector's Dominate +// Mind still lands). +struct NoControl { uint32_t enemy; }; // An enemy carrying should be purged (priest Dispel Magic / shaman Purge). Tranquilizing Shot is not a raid rule: // the PvE coordinator's PlanTranq ranks the hunters for any aura the shot removes. @@ -125,6 +156,18 @@ struct ThreatDrop { uint32_t enemy; float percent; }; // Do not use area damage while this enemy is alive within 40 yards (adds that explode or must not be pulled). struct NoAoe { uint32_t enemy; }; +// While a living stands, nobody (tanks included) attacks a at or under health: an add that must not die before +// its boss (Garr's Firesworn: each one that dies hastens Garr by 9 percent, stacking, and erupts). The tank holding it keeps the threat +// and stops swinging; every other order (banish, dispel, heals) is unchanged. +constexpr float kGolemaggEarthquakePct = 10.0f; // Golemagg health under which Earthquake (1500 physical, 18 y, every 3 s) starts +constexpr float kGolemaggEarthquakeLeave = 22.0f; // 18 y plus the victim's reach and a margin +constexpr uint32_t kGolemaggSplashStacks = 20; // Magma Splash stacks (50 fire a tick each, cap 50) at which a melee bot backs off +constexpr float kGolemaggSplashBackoff = 12.0f; +constexpr float kGeddonMeleeLeavePct = 8.0f; // Geddon health under which the melee leave him (Armageddon fires at 2) +constexpr float kGarrFireswornSparePct = 25.0f; // Firesworn health at which the raid stops hitting it while Garr lives +struct Spare { uint32_t enemy; float belowPct; uint32_t gateEnemy; }; +inline bool SpareNow(Spare const& rule, float enemyHpPct, bool gateAlive) { return gateAlive && enemyHpPct <= rule.belowPct; } + // Tank swap: while 's current victim is a tank that carries at least stacks of , ONE other tank // that does not carry the aura (the lowest-GUID one whose taunt is ready) taunts the enemy. A tank carrying the aura stops // attacking that enemy while a clean tank exists, so the swap is not undone. Paladins have no taunt in 1.12, so only @@ -135,6 +178,10 @@ struct TankSwap { uint32_t enemy; uint32_t debuffAura; uint32_t stacks; }; // Do not use Who::Tank / Anyone for melee-range bosses: only bots that do not have to stand next to the enemy. struct AvoidEnemy { uint32_t enemy; float radius; Who who; float hpMax = 100.0f; float hpMin = 0.0f; }; +// While a matching bot carries at least stacks of (a debuff the enemy puts on whoever hits it: Golemagg's Magma Splash), it stays +// yards from every that is not hitting it, until the aura falls off. The bot the enemy is hitting (its tank) is never moved. +struct AvoidOnStacks { uint32_t enemy; uint32_t aura; uint32_t stacks; float radius; Who who; }; + // Line hazard for a breath that sweeps a straight corridor (Onyxia's Deep Breath). When is casting (or carries // it as an aura), or is flying at >= 2.5x run speed (the breath pass itself), the corridor is latched for about 10 seconds: it // starts 10 yards behind the enemy's position and facing at that moment, runs yards straight ahead and is @@ -151,8 +198,12 @@ struct AvoidEnemy { uint32_t enemy; float radius; Who who; float hpMax = 100.0f; // corridor of walks to the nearest of these instead of searching for a way out. struct BreathSafe { uint32_t enemy; uint32_t castSpell; float x, y; }; +// hover (fixedPath only): the corridor is open while is airborne and stands at, or flies to, the path's first point (ax,ay), not only +// while the spell is being cast. Onyxia starts a breath wherever she hovers when her movement timer runs out, from the waypoint she stands at, so +// the line she may breathe along next is known the moment she arrives; the 5 s cast is too short a warning for a raid standing in the middle of +// a hall 70 y across. struct AvoidBreath { uint32_t enemy; uint32_t castSpell; float halfWidth; float length; Who who; bool windup = false; - bool fixedPath = false; float ax = 0.0f, ay = 0.0f, bx = 0.0f, by = 0.0f; }; + bool fixedPath = false; float ax = 0.0f, ay = 0.0f, bx = 0.0f, by = 0.0f; bool hover = false; }; // Melee soak (Patchwerk's Hateful Strike hits the highest-health player in melee among his top four on threat): up to // matching bots (never the main tank) keep attacking in melee so the strike lands on them instead of a DPS. @@ -178,7 +229,13 @@ struct CancelAura { uint32_t enemy; uint32_t aura; Who who; }; // hound of the pack is still up 10 seconds later the downed ones rise again at full health). Damage is spread instead of // focused: a downed member (carrying , or at 1 hp) is never attacked, DPS bots leave members that are more than // health percent below the healthiest one alone, and the healthiest one is the DPS fallback target. -struct KillTogether { uint32_t enemy; uint32_t downAura; float spreadPct; }; +// pack: further entries that belong to the same pack when its members differ (Zul'Gurub's Thekal, Zath and Lor'Khan: each one feigns death +// at 1 hp and a standing one resurrects the fallen within 10 s, so all three have to go down together). +struct KillTogether { uint32_t enemy; uint32_t downAura; float spreadPct; std::vector pack = {}; }; +inline bool InPack(KillTogether const& rule, uint32_t entry) +{ + return entry == rule.enemy || std::find(rule.pack.begin(), rule.pack.end(), entry) != rule.pack.end(); +} // While is alive and fighting, matching bots stay within yards of it (an Anubisath Defender's Meteor is // split among everybody within 8 yards, its Shadow Storm only hits beyond 25). A bot further out walks back to 60% of the @@ -194,6 +251,10 @@ struct StayNear { uint32_t enemy; float radius; Who who; float hpMax = 100.0f; f constexpr float kNoBearing = 1000.0f; struct FaceAway { uint32_t enemy; float hpMax = 100.0f; float hpMin = 0.0f; float bearingDeg = kNoBearing; }; +// While is fighting, the players that hold an stand yards past the spot the anchor stood on when the fight began, away from the +// raid's centre at that moment, side by side yards apart (Majordomo: his tank drags him out, each Elite tank one Elite, all visibly apart). +struct TankSpot { uint32_t anchor; uint32_t enemy; float reach; float spacing; }; + // While is alive and fighting, matching bots stand in the sector behind it: either side of the line // straight behind where it faces, between and yards. A bot outside walks to the nearest such spot on its // own side. Pair with FaceAway so the tank decides which way "behind" is. @@ -202,8 +263,9 @@ struct StandBehind { uint32_t enemy; Who who; float minDist; float maxDist; floa // While is alive and fighting (in the hp window), matching bots stand on its flank: either side of the line // off where it faces, on the side they are already on, between and yards. For a boss that hits the // front (breath, Wing Buffet, Cleave) and the whole back half (Tail Sweep): melee reach it from the flank wedge between the two cones -// (Onyxia: centre 70, half 15, so 55..85 degrees off her facing; the tail sweep starts at 90). Uses her live facing, so the tank keeps -// her still; a bot already inside the wedge does not move, so there is no leave / come back cycle. +// (Onyxia: kOnyWedgeCentreDeg / kOnyWedgeHalfDeg, 75..105 degrees off her facing). Measured from the tank's locked FaceAway axis when the enemy has +// one (her live facing otherwise); a bot already inside the wedge does not move, and none walks to a slot inside a cone as she faces now, so +// there is no leave / come back cycle. struct StandFlank { uint32_t enemy; Who who; float minDist; float maxDist; float centerDeg; float halfAngleDeg; float hpMax = 100.0f; float hpMin = 0.0f; }; // A resistance potion a matching bot drinks when is engaged, without the global Playerbot.Raid.ResistPotions switch (Ragnaros' @@ -238,10 +300,13 @@ struct RaidRules std::vector dispel; std::vector purge; std::vector crowdControl; + std::vector noControl; std::vector priority; std::vector noAoe; + std::vector spare; std::vector tankSwap; std::vector avoidEnemy; + std::vector avoidOnStacks; std::vector avoidBreath; std::vector breathSafe; std::vector meleeSoak; @@ -252,6 +317,7 @@ struct RaidRules std::vector killTogether; std::vector stayNear; std::vector faceAway; + std::vector tankSpot; std::vector standBehind; std::vector standFlank; std::vector resistPotion; @@ -262,9 +328,35 @@ struct RaidRules std::vector noTank; // summoned adds the DPS burns down: tanks hold every other mob first and never count them as a roster need std::vector tankOrder; // mobs the tanks take in this order, first listed first (Majordomo: Healers, then Elites); unlisted mobs come after std::vector tankLast; // a mob the tanks take only when no other free mob is left (Majordomo: he does little damage and cannot die) + std::vector offTankMob; // a boss the second tank holds from the first second (Majordomo); no area taunt while he is up, the tanks keep their mobs std::vector interruptFirst; // casts the PvE coordinator's kick election takes before any other (heals, sheep) }; +// How long the corridor of a cast breath stays open from the first sighting of the cast. Onyxia's damage is one instant at the end of the 5 s cast +// (three live waves, all 4-5 s after the cast began); the flight along the line afterwards hurts nobody, and a corridor held longer shuts the +// bots in while Heated Ground burns. +constexpr uint32_t kBreathCorridorOpenMs = 8000; + +// The hover breath (AvoidBreath::hover) whose first point lies nearest to (x, y) and within yards: the line an airborne at or +// flying to that point breathes along next. nullptr when none. +inline AvoidBreath const* HoverBreath(RaidRules const& rules, uint32_t enemy, float x, float y, float reach) +{ + AvoidBreath const* best = nullptr; + float nearest = reach; + for (AvoidBreath const& path : rules.avoidBreath) + { + if (path.enemy != enemy || !path.fixedPath || !path.hover) + continue; + float const d = std::hypot(x - path.ax, y - path.ay); + if (d < nearest) + { + nearest = d; + best = &path; + } + } + return best; +} + // Registry. Returns nullptr when the map has no rules. RaidRules const* RulesForMap(uint32_t mapId); @@ -275,6 +367,10 @@ bool OwnsAura(uint32_t mapId, uint32_t aura); // True when the map's rules say this cast is kicked before any other cast in reach (an enemy heal, a polymorph). Rules are // static data, so the PvE coordinator may call it from its planning pass. bool InterruptFirst(uint32_t mapId, uint32_t spell); +// Where the cast stands on the map's interruptFirst list (0 = taken before everything else; Molten Core: Dark Mending), kNotInterruptFirst +// when the list does not name it. The kick election sorts the casts it sees by this (KickRules.h CastBefore). +constexpr size_t kNotInterruptFirst = SIZE_MAX; +size_t InterruptOrder(uint32_t mapId, uint32_t spell); // True when the map's rules list as an add the tanks do not hold (Firelord's Lava Spawns): the tank assignment gives a // tank such a mob only when no other engaged mob is free, and the tank roster does not grow for it. @@ -286,6 +382,9 @@ uint32_t TankOrder(uint32_t mapId, uint32_t entry); // True when the map's rules list in RaidRules::tankLast. bool TankLast(uint32_t mapId, uint32_t entry); +// True when the map's rules list in RaidRules::offTankMob. +bool OffTankMob(uint32_t mapId, uint32_t entry); + // True when the map's rules list as a boss whose threat a scripted reset or a Blink can leave on a non-tank (RaidRules::retaunt): a // tank taunts it back at once, so the raid's wait for that tank is short. bool Retaunts(uint32_t mapId, uint32_t entry); diff --git a/src/modules/PlayerbotV2/Bot/Raid/RaidFightScript.cpp b/src/modules/PlayerbotV2/Bot/Raid/RaidFightScript.cpp new file mode 100644 index 0000000000..61c5f573db --- /dev/null +++ b/src/modules/PlayerbotV2/Bot/Raid/RaidFightScript.cpp @@ -0,0 +1,178 @@ +// A boss fight script's brain pass. See RaidFightScript.h. +// +// Runs after the generic rule passes of a plan. For the DPS bots of a scripted boss it replaces the threat hold with a fixed start wait, +// names one kill target for everybody, and drops any crowd-control job aimed at the fight's own enemies. Tanks and healers are not touched: +// their assignment, pick-up and healing rules are the generic ones. + +#include "RaidBrainInternal.h" +#include "RaidFightScript.h" + +#include "Creature.h" +#include "Group.h" +#include "Log.h" +#include "Player.h" + +#include +#include + +namespace Playerbot::Raid::detail { + +namespace { + +struct FightState +{ + uint32_t since = 0; // first plan pass with an engaged enemy of the fight + uint32_t last = 0; // last plan pass with one + ObjectGuid focus; // last pick (hysteresis, change-only log) + uint32_t startLogged = 0; +}; +std::unordered_map g_fights; // (group, map) + +constexpr uint32_t kFightGapMs = 8000; // no engaged enemy for this long: the next pull starts a new fight +constexpr uint8_t kSkullIcon = 7, kCrossIcon = 6; + +} // namespace + +void ApplyFightScript(Plan& plan, std::unordered_map& orders, uint32_t now, std::ostringstream& dump) +{ + Script::Fight const* fight = nullptr; + for (Unit* enemy : plan.enemies) + if ((fight = Script::FightFor(plan.mapId, enemy->GetEntry()))) + break; + if (!fight) + return; + + // Only enemies the fight names count (a stray pack mob near the room does not start the clock or become the focus). + std::vector mine; + for (Unit* enemy : plan.enemies) + if (Script::FightFor(plan.mapId, enemy->GetEntry()) == fight && enemy->GetVictim()) + mine.push_back(enemy); + if (mine.empty()) + return; + + uint64_t const key = (plan.groupLow << 16) ^ uint64_t(plan.mapId); + FightState& st = g_fights[key]; + if (!st.since || now - st.last > kFightGapMs) + { + st.since = now; + st.focus = ObjectGuid::Empty; + st.startLogged = 0; + } + st.last = now; + bool const wait = Script::StartWait(st.since, now, fight->startWaitMs); + + // The owner's skull, else cross. + Group const* grp = nullptr; + for (Member const& m : plan.members) + if (m.p && (grp = m.p->GetGroup())) + break; + ObjectGuid ownerMark; + if (grp) + for (uint8_t icon : { kSkullIcon, kCrossIcon }) + { + if (fight->skullOnly && icon != kSkullIcon) + continue; + ObjectGuid const g = grp->GetTargetIcon(icon); + if (g.IsEmpty()) + continue; + for (Unit* enemy : mine) + if (enemy->GetGUID() == g) + ownerMark = g; + if (!ownerMark.IsEmpty()) + break; + } + + ObjectGuid chosen; // what the DPS were given this pass (log) + size_t dps = 0; + for (Member const& m : plan.members) + { + if (!m.bot) + continue; + auto it = orders.find(m.p->GetGUID().GetCounter()); + if (it == orders.end()) + continue; + RaidOrder& o = it->second; + + // A crowd-control job on the fight's own enemies: nobody sheeps a Protector (no source says it works), and the mark orders are the + // owner's. Everything else the election chose stays. + if (o.cast_kind == RaidOrder::CastKind::CrowdControl) + for (Unit* enemy : mine) + if (enemy->GetGUID() == o.cast_target) + { + o.cast_kind = RaidOrder::CastKind::None; + o.cast_spell = 0; + o.cast_target = ObjectGuid::Empty; + break; + } + + if (m.tank || m.healer) + continue; + + // Skull only: everything else of the fight, marked or sheeped or not, is off limits for this bot. + if (fight->skullOnly) + for (Unit* enemy : mine) + if (enemy->GetGUID() != ownerMark) + o.forbidden_targets.push_back(enemy->GetGUID()); + + std::vector view; + view.reserve(mine.size()); + for (Unit* enemy : mine) + { + Script::Enemy e; + e.guid = enemy->GetGUID().GetCounter(); + e.entry = enemy->GetEntry(); + e.hpPct = enemy->GetHealthPct(); + bool const forbidden = std::find(o.forbidden_targets.begin(), o.forbidden_targets.end(), enemy->GetGUID()) != o.forbidden_targets.end(); + Creature const* c = enemy->ToCreature(); + e.eligible = enemy->IsAlive() && !forbidden && !(c && c->IsInEvadeMode()); + view.push_back(e); + } + uint64_t const pick = Script::PickFocus(*fight, view.data(), view.size(), ownerMark.IsEmpty() ? 0 : ownerMark.GetCounter(), + st.focus.IsEmpty() ? 0 : st.focus.GetCounter()); + ObjectGuid focus; + for (Unit* enemy : mine) + if (pick && enemy->GetGUID().GetCounter() == pick) + focus = enemy->GetGUID(); + if (focus.IsEmpty()) + { + // The skull carries a shield this bot must not strike (Damage Shield for melee, Magic Reflection for casters): it stands, the + // generic pickers would start an attack on the skull each tick and every swing is reflected. + if (fight->skullOnly && !ownerMark.IsEmpty() && + std::find(o.forbidden_targets.begin(), o.forbidden_targets.end(), ownerMark) != o.forbidden_targets.end()) + { + o.script_owns = true; + o.script_focus = ownerMark; + o.hold_target = ownerMark; + } + continue; // nothing the script can name for this bot: the generic rules keep it + } + + o.script_owns = true; + o.script_focus = focus; + o.fallback_target = focus; + // The one hold of a scripted fight: the start wait. No threat ratio, no over-threat release clocks. + o.hold_target = wait ? focus : ObjectGuid::Empty; + chosen = focus; + ++dps; + } + + if (chosen != st.focus) + { + st.focus = chosen; + std::string name = "-"; + for (Unit* enemy : mine) + if (enemy->GetGUID() == chosen) + name = enemy->GetName(); + TC_LOG_INFO("playerbot.v2", "[fight_script] group={} map={} {}: DPS focus -> {} ({}) owner mark {} dps bots {}", plan.groupLow, plan.mapId, + fight->name, name, chosen.GetCounter(), ownerMark.IsEmpty() ? "none" : "set", dps); + } + if (wait && !st.startLogged) + { + st.startLogged = now; + TC_LOG_INFO("playerbot.v2", "[fight_script] group={} map={} {}: fight starts, DPS wait {} ms", plan.groupLow, plan.mapId, fight->name, + fight->startWaitMs); + } + dump << " fight script " << fight->name << ": focus " << chosen.GetCounter() << (wait ? " (start wait)" : "") << "\n"; +} + +} // namespace Playerbot::Raid::detail diff --git a/src/modules/PlayerbotV2/Bot/Raid/RaidFightScript.h b/src/modules/PlayerbotV2/Bot/Raid/RaidFightScript.h new file mode 100644 index 0000000000..f18874b7a9 --- /dev/null +++ b/src/modules/PlayerbotV2/Bot/Raid/RaidFightScript.h @@ -0,0 +1,129 @@ +// RaidFightScript - a boss script that owns the DPS side of one fight. +// +// Not a second rule engine: the raid rule tables, the tank assignment (PveGroupCoordinator::PlanRaidTanks) and the healing stay +// exactly as they are. A fight script only decides two things for the DPS bots of its boss, and switches off the rules that would +// decide them a second time: +// 1. WHICH enemy every DPS bot attacks: the kill order, one enemy at a time, the same one for everybody. +// 2. WHEN the DPS start: a fixed wait after the fight begins, then no threat holds at all. +// The owner's skull (else cross) always wins over the script's pick. +// Pure functions only (no world access), so tests/game/ClassicRaidFightScript.cpp covers them. + +#pragma once + +#include "../ThreatLimits.h" + +#include +#include + +namespace Playerbot::Raid::Script { + +struct Fight +{ + uint32_t map; + uint32_t boss; // creature entry that names the fight + uint32_t killOrder[4]; // creature entries, first dies first, 0 ends the list + uint32_t startWaitMs; // DPS wait this long from the first engaged enemy, then attack + char const* name; // log only + bool skullOnly = false; // the owner's skull is the only enemy the DPS hit; no skull, no damage (the kill order is not used) +}; + +// Lucifron (MC 409): the two Flamewaker Protectors first, then Lucifron. The start wait is the raid's one boss opening wait (Playerbot::kRaidBossOpenWaitMs, 8 s: the main tank takes a while to run in); there is no threat cap after +// that (a bot that pulls a Protector is taunted back by the loose-mob rule). +// Majordomo Executus (MC 409): the owner's skull is the only thing the DPS hit (skullOnly). The owner sheeps with his icons, so nothing else is +// attacked, marked or not; with no skull the DPS stand. He is never the focus (he cannot be killed, he yields when the eight are dead). +// Golemagg (MC 409): Golemagg only. The Core Ragers are not on the list: they stay off every DPS bot's target (Priority -1) and the off tank keeps them. +// Sulfuron Harbinger (MC 409): the four Flamewaker Priests one at a time, then Sulfuron. The priests are immune to every crowd control, so the script +// dropping CC on its own enemies changes nothing here. +// Shazzrah (MC 409): one boss. After his Gate he stands on a non-tank for a moment; the DPS stay on him and the retaunt rule gives him back. +// Baron Geddon (MC 409): one boss, no adds. The script's worth here is the one start wait in place of the threat hold (four DPS were held for 20 s). +// Garr (MC 409): Garr only. The Firesworn are not on the list, so the warlocks' Banish jobs on them stay, and the Spare rule (RaidEncounters.h) +// keeps them alive until he falls; once he is dead the generic rules finish them. +inline constexpr Fight kFights[] = { + { 409, 12118, { 12119, 12118, 0, 0 }, kRaidBossOpenWaitMs, "Lucifron" }, + { 409, 12057, { 12057, 0, 0, 0 }, kRaidBossOpenWaitMs, "Garr" }, + { 409, 12056, { 12056, 0, 0, 0 }, kRaidBossOpenWaitMs, "Baron Geddon" }, + { 409, 12264, { 12264, 0, 0, 0 }, kRaidBossOpenWaitMs, "Shazzrah" }, + { 409, 12098, { 11662, 12098, 0, 0 }, kRaidBossOpenWaitMs, "Sulfuron Harbinger" }, + { 409, 11988, { 11988, 0, 0, 0 }, kRaidBossOpenWaitMs, "Golemagg" }, + { 409, 12018, { 11663, 11664, 0, 0 }, kRaidBossOpenWaitMs, "Majordomo Executus", true }, +}; + +// The fight an engaged enemy belongs to on this map (nullptr: none). +inline Fight const* FightFor(uint32_t map, uint32_t entry) +{ + for (Fight const& f : kFights) + { + if (f.map != map) + continue; + if (f.boss == entry) + return &f; + for (uint32_t e : f.killOrder) + if (e && e == entry) + return &f; + } + return nullptr; +} + +// Where an entry stands in the kill order (0 = first); a large number when it is not on the list. +inline size_t RankOf(Fight const& f, uint32_t entry) +{ + for (size_t i = 0; i < 4; ++i) + if (f.killOrder[i] && f.killOrder[i] == entry) + return i; + return 99; +} + +struct Enemy +{ + uint64_t guid = 0; + uint32_t entry = 0; + float hpPct = 100.f; + bool eligible = false; // alive, engaged, not crowd-controlled or reflecting, not forbidden for this bot +}; + +// The enemy every DPS bot attacks now, 0 = none (the generic rules pick). +// ownerMark: the owner's skull or cross, when it is an eligible enemy it wins. +// previous : last pick, kept while it is still eligible and still the best rank (no flip-flop between two equal Protectors). +// Lowest rank first; inside a rank the most hurt one (finish what was started), then the lowest guid. +inline uint64_t PickFocus(Fight const& f, Enemy const* enemies, size_t n, uint64_t ownerMark, uint64_t previous) +{ + if (f.skullOnly) + { + for (size_t i = 0; i < n; ++i) + if (ownerMark && enemies[i].eligible && enemies[i].guid == ownerMark) + return ownerMark; + return 0; + } + if (ownerMark) + for (size_t i = 0; i < n; ++i) + if (enemies[i].eligible && enemies[i].guid == ownerMark) + return ownerMark; + size_t bestRank = 99; + for (size_t i = 0; i < n; ++i) + if (enemies[i].eligible) + bestRank = bestRank < RankOf(f, enemies[i].entry) ? bestRank : RankOf(f, enemies[i].entry); + if (bestRank == 99) + return 0; + if (previous) + for (size_t i = 0; i < n; ++i) + if (enemies[i].eligible && enemies[i].guid == previous && RankOf(f, enemies[i].entry) == bestRank) + return previous; + Enemy const* best = nullptr; + for (size_t i = 0; i < n; ++i) + { + Enemy const& e = enemies[i]; + if (!e.eligible || RankOf(f, e.entry) != bestRank) + continue; + if (!best || e.hpPct < best->hpPct || (e.hpPct == best->hpPct && e.guid < best->guid)) + best = &e; + } + return best ? best->guid : 0; +} + +// True while the DPS still wait for the tank to get in: from the first engaged enemy (sinceMs, 0 = none yet) for waitMs. +inline bool StartWait(uint32_t sinceMs, uint32_t nowMs, uint32_t waitMs) +{ + return sinceMs != 0 && nowMs >= sinceMs && nowMs - sinceMs < waitMs; +} + +} // namespace Playerbot::Raid::Script diff --git a/src/modules/PlayerbotV2/Bot/Raid/RaidGeometry.h b/src/modules/PlayerbotV2/Bot/Raid/RaidGeometry.h index 48dc0d0ef9..c28cd042a0 100644 --- a/src/modules/PlayerbotV2/Bot/Raid/RaidGeometry.h +++ b/src/modules/PlayerbotV2/Bot/Raid/RaidGeometry.h @@ -87,4 +87,25 @@ inline bool TankOpposesRaid(float bossX, float bossY, float tankX, float tankY, return std::fabs(NormalizeAngle(toTank - toRaid)) >= kPi - tolerance; } +// The point lies inside the sector in front of the boss: within yards and radians either side of its facing. +inline bool InFrontSector(float bossX, float bossY, float bossFacing, float px, float py, float halfAngle, float radius) +{ + return std::hypot(px - bossX, py - bossY) <= radius && std::fabs(NormalizeAngle(Bearing(bossX, bossY, px, py) - bossFacing)) < halfAngle; +} + +// The straight walk from (fx,fy) to (tx,ty) passes through the front sector. Samples every 2 yards, both ends excluded: a bot that stands +// inside the sector is the cone step's business, and a target inside it is refused before this is asked. +inline bool PathCrossesFrontSector(float bossX, float bossY, float bossFacing, float halfAngle, float radius, float fx, float fy, float tx, float ty) +{ + float const length = std::hypot(tx - fx, ty - fy); + int const steps = std::max(1, int(std::ceil(length / 2.0f))); + for (int i = 1; i < steps; ++i) + { + float const t = float(i) / float(steps); + if (InFrontSector(bossX, bossY, bossFacing, fx + (tx - fx) * t, fy + (ty - fy) * t, halfAngle, radius)) + return true; + } + return false; +} + } // namespace Playerbot::Raid::geo diff --git a/src/modules/PlayerbotV2/Bot/Raid/RaidOrder.h b/src/modules/PlayerbotV2/Bot/Raid/RaidOrder.h index 2266e64956..47ac3e1ad3 100644 --- a/src/modules/PlayerbotV2/Bot/Raid/RaidOrder.h +++ b/src/modules/PlayerbotV2/Bot/Raid/RaidOrder.h @@ -79,6 +79,13 @@ struct RaidOrder // Pause the rotation (Nefarian's priest call). Movement and elected jobs still run. bool hold_rotation = false; + // A boss fight script (RaidFightScript.h) owns this DPS bot's target and start: the tank-first threat holds and the skull / kill-focus + // pickers stand down, the bot attacks script_focus (empty: the generic rules pick). Never set on tanks or healers. + bool script_owns = false; + ObjectGuid script_focus; + // The boss script names this bot's kill target: it wins over every generic picker (skull, kill focus, fallback). + bool script_names_target() const { return active && script_owns && !script_focus.IsEmpty(); } + // Snapshot buffers are recycled: clear everything but keep the vector's capacity. void reset() { diff --git a/src/modules/PlayerbotV2/Bot/Raid/ShieldRules.h b/src/modules/PlayerbotV2/Bot/Raid/ShieldRules.h new file mode 100644 index 0000000000..1916b51ca5 --- /dev/null +++ b/src/modules/PlayerbotV2/Bot/Raid/ShieldRules.h @@ -0,0 +1,34 @@ +// ShieldRules - what a bot does about an enemy that carries a shield, as pure rules (tests/game/ClassicRaidFightScript.cpp). +// +// Majordomo Executus puts one of two shields on all eight of his adds every 30 s for 10 s (classic_boss_majordomo_executus.cpp:541-548): +// Magic Reflection sends spells back at the caster, Damage Shield hurts whoever strikes the add in melee. Until now either shield took the +// add off everybody's target list and the cast API refused every harmful spell at it, abilities included, so the whole raid idled for a third +// of the fight and the tanks lost Taunt, Sunder Armor, Revenge, Heroic Strike and Shield Slam for the same 10 s (Majordomo: +// "API_TARGET_REFLECTS x4 (78 6572 7386 23922)" on three tanks while their adds walked onto the healers). + +#pragma once + +#include + +namespace Playerbot::Raid::Shields { + +constexpr uint32_t kMagicReflection = 20619; // the adds reflect spells: the casters stop +constexpr uint32_t kDamageShield = 21075; // the adds hurt melee strikes: the melee DPS stop + +// Whether a DPS member keeps off an enemy that carries . melee: a melee DPS; caster: a ranged spell caster. A hunter is neither (shots +// are physical and not a melee strike) and a tank is never asked: its swings are its threat and it has a healer. +inline bool ShieldForbids(uint32_t aura, bool melee, bool caster) +{ + return (aura == kMagicReflection && caster) || (aura == kDamageShield && melee); +} + +// Whether the cast API refuses a harmful spell at a target with a spell-reflect aura: only a spell the aura can send back. The core's own +// rule (Spell::m_canReflect, Spell.cpp:592): a magic-class spell that is not an ability, or one flagged to allow reflection, and never a spell +// that pierces reflection or immunities, nor a passive. Sunder Armor, Heroic Strike, Revenge, Shield Slam and Taunt are abilities: they go +// through, so a tank keeps its threat on a Magic Reflection add. +inline bool ReflectRefuses(bool magicDamageClass, bool isAbility, bool allowReflection, bool noReflection, bool noImmunities, bool passive) +{ + return ((magicDamageClass && !isAbility) || allowReflection) && !noReflection && !noImmunities && !passive; +} + +} // namespace Playerbot::Raid::Shields diff --git a/src/modules/PlayerbotV2/Bot/States/MaintainHelpers.h b/src/modules/PlayerbotV2/Bot/States/MaintainHelpers.h index b88a7397df..ea7c35652c 100644 --- a/src/modules/PlayerbotV2/Bot/States/MaintainHelpers.h +++ b/src/modules/PlayerbotV2/Bot/States/MaintainHelpers.h @@ -78,6 +78,12 @@ bool DungeonRouteStepTowardPos(BotSnapshotView const& s, bool DungeonHonorCross(BotSnapshotView const& s, BotAI& ai, BotIntentEmitter& emit, uint32 now_ms); +// Following an owner who dropped or jumped to a floor 4+ y below (API::move_to follow_drop). Run at the top of every tick, whatever the +// bot's state: starts the follow when the owner is that far below and near, and while the bot is walking to a ledge or in the air it +// returns true so nothing else (a buff cast, a combat escape, the follow generator) can stop it. Clears itself on landing. Definition in +// State_InGroup.cpp. +bool HonorFollowDrop(BotSnapshotView const& s, BotAI& ai, GroupSnapshotView const& g, BotIntentEmitter& emit); + // Stranded-follower recovery (shared idle / InGroup / InCombat). Relocates a // non-tank follower that cannot rejoin the group on foot — a navmesh-disconnected // perch, a void pocket, or a death that respawns it at the far in-instance entrance diff --git a/src/modules/PlayerbotV2/Bot/States/Rules/AmbientRules.cpp b/src/modules/PlayerbotV2/Bot/States/Rules/AmbientRules.cpp index baaf3e6a70..f1c660ed07 100644 --- a/src/modules/PlayerbotV2/Bot/States/Rules/AmbientRules.cpp +++ b/src/modules/PlayerbotV2/Bot/States/Rules/AmbientRules.cpp @@ -12,6 +12,7 @@ // Added in pass 12 after IdleRule signature was // extended to thread GroupSnapshotView. +#include #include "Bot/IdleRule.h" #include "Group/GroupSnapshot.h" #include "Bot/BotAI.h" @@ -30,6 +31,7 @@ #include "Bot/BotRegistry.h" #include "Fleet/OwnerRegistry.h" #include "Util.h" +#include "Log.h" #include "Config.h" #include "Bot/World/ZonePicker.h" #include "GameTime.h" @@ -739,6 +741,24 @@ bool LeaveWaterFire(BotSnapshotView const& s, BotAI& ai, GroupSnapshotView const constexpr float kInnSearchYards = 150.0f; constexpr float kInnStandYards = 5.0f; +// One line per bot and outcome every five minutes, so a soak shows which bots reached the inn and which found no innkeeper (the counters +// above are bot-ticks and a few bots dominate them). +static void InnLog(BotSnapshotView const& s, char const* what, float x, float y) +{ + static std::mutex mx; + static std::unordered_map last; + uint32 const now = s.published_at_ms() ? s.published_at_ms() : 1u; + uint64 const key = (uint64(s.bot_id()) << 1) | (what[0] == 'r' ? 1u : 0u); + { + std::lock_guard lock(mx); + uint32& at = last[key]; + if (at && now - at < 300000u) + return; + at = now; + } + TC_LOG_INFO("playerbot.v2", "[inn] {} {} (zone {}, {:.0f},{:.0f})", s.raw().identity.name, what, s.zone_id(), x, y); +} + bool InnRestGate(BotSnapshotView const& s, BotAI&, GroupSnapshotView const&, uint32) { if (!TownLifeEnabled()) return false; @@ -756,16 +776,31 @@ bool InnRestFire(BotSnapshotView const& s, BotAI& ai, GroupSnapshotView const&, s.position(bx, by, bz); auto const* inn = ::Playerbot::V2::Travel::TownNpcIndex::Instance().Nearest( s.map_id(), bx, by, bz, UNIT_NPC_FLAG_INNKEEPER, s.is_alliance(), kInnSearchYards); - if (!inn) return false; + if (!inn) + { + V2::TownLife::Counters().inn_none.fetch_add(1, std::memory_order_relaxed); + InnLog(s, "no innkeeper within reach", bx, by); + return false; + } // Stand a few yards from the innkeeper, on the side the bot comes from, so a crowd does not stack on one point. float const dx = bx - inn->x, dy = by - inn->y, len = std::hypot(dx, dy); float const ux = len > 0.5f ? dx / len : 1.0f, uy = len > 0.5f ? dy / len : 0.0f; float const stand = kInnStandYards + float(s.bot_id() % 5u); float const tx = inn->x + ux * stand, ty = inn->y + uy * stand; - if (std::hypot(bx - tx, by - ty) > 4.0f) - return States::ChunkedWalkToward(s, ai, emit, tx, ty, inn->z, "idle:inn_rest", now_ms); + // The stand point is a straight line from the innkeeper and can sit behind a wall; the inn is the goal, so a bot that is within a + // few yards of the innkeeper, or that cannot get closer than a room's width, rests where it is. + float const to_inn = std::hypot(bx - inn->x, by - inn->y); + if (to_inn > kInnStandYards + 6.0f && std::hypot(bx - tx, by - ty) > 4.0f) + { + V2::TownLife::Counters().inn_walk.fetch_add(1, std::memory_order_relaxed); + if (States::ChunkedWalkToward(s, ai, emit, tx, ty, inn->z, "idle:inn_rest", now_ms)) + return true; + V2::TownLife::Counters().inn_stuck.fetch_add(1, std::memory_order_relaxed); + if (to_inn > 20.0f) return false; + } V2::TownLife::Counters().inn_ticks.fetch_add(1, std::memory_order_relaxed); if (s.is_moving()) return false; + InnLog(s, "rests at the inn", bx, by); emit.sit(); ai.set_last_rule_fired("idle:inn_rest"); return true; diff --git a/src/modules/PlayerbotV2/Bot/States/Rules/CoreFlowRules.cpp b/src/modules/PlayerbotV2/Bot/States/Rules/CoreFlowRules.cpp index 2052719d30..771e697ba9 100644 --- a/src/modules/PlayerbotV2/Bot/States/Rules/CoreFlowRules.cpp +++ b/src/modules/PlayerbotV2/Bot/States/Rules/CoreFlowRules.cpp @@ -13,6 +13,7 @@ // top-of-tick dispatch in `State_Idle::DispatchIdle`. #include "Bot/IdleRule.h" +#include "Bot/InstanceFullHold.h" #include "Group/GroupSnapshot.h" #include "Bot/BotAI.h" #include "Bot/BotSnapshotView.h" @@ -808,6 +809,27 @@ bool RejoinInstanceFire(BotSnapshotView const& s, BotAI& ai, return false; } + // The door refused the bot because the instance holds its most players: it + // stays where it is, safe, instead of walking the open world to an entrance it cannot use (a bot died to the Scarshield Sentries on + // that walk, outside the instance where Raul could not raise him), and asks again every kInstanceFullHoldMs for a free slot. + if (ai.instance_full_map() == anchor->map_id) + { + if (V2::InstanceFullHolds(ai.instance_full_map(), ai.instance_full_ms(), anchor->map_id, now_ms, BotAI::kInstanceFullHoldMs)) + { + if (rr.log_ms == 0 || now_ms - rr.log_ms >= 60000u) + { + rr.log_ms = now_ms ? now_ms : 1u; + TC_LOG_INFO("playerbot.v2", "[rejoin] {} waits on map {}: {} in map {} is full, it asks again in {}s", + s.name(), s.map_id(), anchor->name, anchor->map_id, + (BotAI::kInstanceFullHoldMs - (now_ms - ai.instance_full_ms())) / 1000u); + } + ai.set_last_rule_fired("idle:rejoin_instance_full"); + return true; + } + ai.clear_instance_full(); + rr.direct_tries = 0; + } + float bx, by, bz; s.position(bx, by, bz); // Walking range with hysteresis: switching mode resets the rejoin (the far diff --git a/src/modules/PlayerbotV2/Bot/States/Rules/LootDrainRules.cpp b/src/modules/PlayerbotV2/Bot/States/Rules/LootDrainRules.cpp index 453548fa21..d38546e6e2 100644 --- a/src/modules/PlayerbotV2/Bot/States/Rules/LootDrainRules.cpp +++ b/src/modules/PlayerbotV2/Bot/States/Rules/LootDrainRules.cpp @@ -68,6 +68,13 @@ uint32 ResolveSkinningSpell(Player* p) bool LootDrainGate(BotSnapshotView const& s, BotAI& ai, GroupSnapshotView const& g, uint32 now_ms) { + // A bot a player leads or owns does not loot: the player loots, so no bot runs off to a corpse. The queue is emptied so the corpses + // are not walked to after the group is left. Bots with no player around them keep looting. + if (s.is_led_by_player()) + { + Services::Registry().with_loot(s.bot_id(), [](std::deque& q) { q.clear(); }); + return false; + } // Told to stay: the corpse can wait until it is released. if (ai.is_manual_mode(s.published_at_ms()) && ai.owner_command() == BotAI::OwnerCommand::Stay) return false; diff --git a/src/modules/PlayerbotV2/Bot/States/Rules/OocConsumableRules.cpp b/src/modules/PlayerbotV2/Bot/States/Rules/OocConsumableRules.cpp index db52ec322a..3027d4d11e 100644 --- a/src/modules/PlayerbotV2/Bot/States/Rules/OocConsumableRules.cpp +++ b/src/modules/PlayerbotV2/Bot/States/Rules/OocConsumableRules.cpp @@ -253,6 +253,31 @@ bool OocEatFoodFire(BotSnapshotView const& s, BotAI& ai, return true; } +// ---------- idle:rest ---------- +// A solo bot under half health with nothing to eat (or nothing the eat rule may use right now) sits and regenerates, instead of +// standing up for 30-90 s until ambient_sit. The walking rules yield below 50 % (Classic::RecoverBeforeWalking), so this is the +// other half of that yield. Grouped bots follow their group and never sit here. +bool RestGate(BotSnapshotView const& s, BotAI&, GroupSnapshotView const& g, uint32) +{ + if (!s.is_alive() || s.in_combat() || s.is_casting()) return false; + if (s.in_group() || s.raw().movement.is_mounted || s.is_moving()) return false; + if (s.recently_in_combat(5000) || s.is_encounter_in_progress()) return false; + if (s.hp_pct() >= 50) return false; + return Classic::SafeToRecover(s, &g); +} + +bool RestFire(BotSnapshotView const& s, BotAI& ai, GroupSnapshotView const&, BotIntentEmitter& emit, uint32) +{ + uint32 const now_ms = s.published_at_ms(); + if (!ai.action_recently_tried(BotAI::ActionKind::AmbientSit, 0, now_ms)) + { + emit.emit(SetStandStateIntent{1}); + ai.note_action_retry(BotAI::ActionKind::AmbientSit, 0, now_ms); + } + ai.set_last_rule_fired("idle:rest"); + return true; +} + // ---------- idle:ooc_bandage ---------- // Self-bandage below 50% health (the owner: out-of-combat bandages when no // healer is near). Bandages need First Aid at the item's rank (the supplies @@ -534,6 +559,14 @@ void RegisterOocConsumableRules(IdleRuleRegistry& r) rule.fire = &OocEatFoodFire; r.register_rule(std::move(rule)); } + { + IdleRule rule; + rule.name = "idle:rest"; + rule.priority = 662; + rule.gate = &RestGate; + rule.fire = &RestFire; + r.register_rule(std::move(rule)); + } { IdleRule rule; rule.name = "idle:ooc_bandage"; diff --git a/src/modules/PlayerbotV2/Bot/States/Rules/VendorRules.cpp b/src/modules/PlayerbotV2/Bot/States/Rules/VendorRules.cpp index 796c45a14b..28f7328c2c 100644 --- a/src/modules/PlayerbotV2/Bot/States/Rules/VendorRules.cpp +++ b/src/modules/PlayerbotV2/Bot/States/Rules/VendorRules.cpp @@ -883,10 +883,49 @@ bool CapitalBagRunFire(BotSnapshotView const& s, BotAI& ai, GroupSnapshotView co return true; } +// ---------- idle:bag_hearth ---------- +// Full bags in the field, no vendor in sight and the vendor walk given up (or no town near enough for the capital run): what a player +// does is hearth to the town they are bound in, sell, and come back. Once per full-bag episode; the hearthstone's own cooldown bounds it. +constexpr float kBagHearthMinYards = 1200.0f; // nearer than this the walk to the bound town is the better way + +bool BagHearthGate(BotSnapshotView const& s, BotAI& ai, GroupSnapshotView const&, uint32 now_ms) +{ + constexpr uint8 kVvBagFull = 1u << 1; + if ((s.vendor_visit_phases_pending() & kVvBagFull) == 0) return false; + if (s.in_combat() || s.is_casting() || s.raw().movement.is_mounted || s.has_owner_character()) return false; + if (s.in_group() || s.is_in_dungeon() || s.in_battleground() || s.is_in_instance() || s.on_transport()) return false; + if (ai.bag_hearth_used() || ai.bag_recovery_backoff_until() == 0) return false; // only once local recovery has proved futile + if (!s.can_hearth() || s.homebind_map_id() != s.map_id()) return false; + if (s.nearest_npc_with_flag(UNIT_NPC_FLAG_VENDOR) != nullptr) return false; + float bx, by, bz; s.position(bx, by, bz); + if (std::hypot(s.homebind_x() - bx, s.homebind_y() - by) < kBagHearthMinYards) return false; + // A capital near enough for the bank-and-sell run is that rule's. + using ::Playerbot::V2::World::NearestCapital; + auto const* cap = NearestCapital(s.map_id(), bx, by, s.raw().identity.race); + return !cap || std::hypot(cap->x - bx, cap->y - by) > 800.0f; +} + +bool BagHearthFire(BotSnapshotView const&, BotAI& ai, GroupSnapshotView const&, BotIntentEmitter& emit, uint32) +{ + emit.hearth(); + ai.set_bag_hearth_used(); + ai.set_last_rule_fired("idle:bag_hearth"); + return true; +} + } // anonymous namespace void RegisterVendorRules(IdleRuleRegistry& r) { + { + IdleRule rule; + rule.name = "idle:bag_hearth"; + rule.priority = 709; // above the capital run (705) and the quest funnel, below the vendor recovery it follows (710) + rule.gate = &BagHearthGate; + rule.fire = &BagHearthFire; + rule.min_interval_ms = 5000; + r.register_rule(std::move(rule)); + } { IdleRule rule; rule.name = "idle:critical_repair"; diff --git a/src/modules/PlayerbotV2/Bot/States/State_Idle.cpp b/src/modules/PlayerbotV2/Bot/States/State_Idle.cpp index c68b01afcd..52669d3d7f 100644 --- a/src/modules/PlayerbotV2/Bot/States/State_Idle.cpp +++ b/src/modules/PlayerbotV2/Bot/States/State_Idle.cpp @@ -9,6 +9,7 @@ #include "Bot/BotRegistry.h" #include "Bot/IdleRule.h" #include "Bot/QuestDoable.h" +#include "Travel/ReachMemory.h" #include "Bot/ClassTables.h" #include "Bot/Gear/BotGearGenerator.h" // RaidGearActive / RaidEquipUpgrade (raid-gear upgrade test) #include "Bot/RecipeDifficulty.h" @@ -90,6 +91,28 @@ namespace Playerbot::States { // GetIdleConsumeThresholds, ClassOocRez) get `static` for internal // linkage instead of an anonymous namespace. +// True when a recipe can be cast where the bot stands: it needs no spell focus, or a game object of that focus (cooking fire, forge, +// anvil) is within its radius among the bot's nearby objects. +static bool RecipeFocusNear(BotSnapshotView const& s, uint32 spell_id) +{ + SpellInfo const* si = sSpellMgr->GetSpellInfo(spell_id, DIFFICULTY_NONE); + if (!si || !si->RequiresSpellFocus) + return true; + float bx = 0.f, by = 0.f, bz = 0.f; + s.position(bx, by, bz); + for (auto const& go : s.raw().world_objects.nearby_objects) + { + GameObjectTemplate const* info = sObjectMgr->GetGameObjectTemplate(go.entry); + if (!info || info->type != GAMEOBJECT_TYPE_SPELL_FOCUS || info->GetSpellFocusType() != uint32(si->RequiresSpellFocus)) + continue; + float const dx = go.x - bx, dy = go.y - by, dz = go.z - bz; + float const r = float(info->GetSpellFocusRadius()); + if (dx * dx + dy * dy + dz * dz <= r * r) + return true; + } + return false; +} + // The mana wait before a pull. A party with a player in it has none (playtest 2026-10-15: the player watches the mana); a raid keeps it, // and so does a group of bots alone, where nobody else would hold the pull for the healer's drink (deadmines_full n57: the priest // went into every fight at 1-5 % mana). @@ -17723,6 +17746,15 @@ bool AutoactDispatch(BotSnapshotView const& s, BotAI& ai, // to actually change maps. (Mirrors the swim_stuck same-map guard.) if (h->mapId != s.map_id()) continue; + // Other bots already found this walk impossible from around here (a hub on another tier of a mountain island, across + // a gap): choose the next hub now instead of walking at the gap and wedging (Travel/ReachMemory.h). + if (::Playerbot::V2::Travel::ReachMemory::Instance().KnownUnreachable( + s.map_id(), s.raw().position.x, s.raw().position.y, h->location.GetPositionX(), h->location.GetPositionY(), hub_now_ms)) + { + ai.note_hub_tried(h->hubId, hub_now_ms); + continue; + } + // FIX 5a: skip any hub with no doable quest left for this bot — // the SAME shared predicate the builder uses, so the rule and the // builder agree about which hubs are exhausted (no oscillation). @@ -19187,6 +19219,7 @@ bool AutoactDispatch(BotSnapshotView const& s, BotAI& ai, if (t.goal_is_quest && s.current_quest_id() != 0) { ai.blacklist_quest(s.current_quest_id(), now_ms); + ::Playerbot::V2::Travel::QuestGoalMemory::Instance().NoteDropped(s.current_quest_id(), now_ms); tw.last_recovery_ms = now_ms; tw.recovery_tier = 3; ai.set_last_rule_fired("idle:unstick:drop_goal"); @@ -19772,6 +19805,9 @@ bool AutoactDispatch(BotSnapshotView const& s, BotAI& ai, const uint16 cur = s.skill_value(meta->skill_line_id); const RecipeColor c = ResolveRecipeColor(spell_id, cur); if (c == RecipeColor::Gray || c == RecipeColor::Unknown) continue; + // A recipe that needs a fire, forge or anvil is only cast beside one: away from it the cast fails with + // REQUIRES_SPELL_FOCUS, the bot stands still, and the idle watch counts it stuck (935 fails in one soak run). + if (!RecipeFocusNear(s, spell_id)) continue; // Color rank: Orange=1, Yellow=2, Green=3 — lower is better. // Replace if: better color, OR same color but lower skill. const bool better_color = (best_spell == 0) || (uint8(c) < uint8(best_color)); @@ -20475,8 +20511,21 @@ void DispatchIdle(BotAI& ai, || (ai.last_rule_fired() && (std::strcmp(ai.last_rule_fired(), "idle:inn_rest") == 0 // resting at the inn is a reason to stand || std::strcmp(ai.last_rule_fired(), "idle:mailbox") == 0 // and standing at a mailbox || std::strcmp(ai.last_rule_fired(), "idle:res_sick_wait") == 0)); // so is waiting out Resurrection Sickness + // The watch's own forced walk overwrites the last rule; keep the one before it, which is what held the bot. + if (char const* lr = ai.last_rule_fired(); lr && std::strcmp(lr, "idle:watch_walk") != 0) + w.prev_rule = lr; if (V2::IdleStuck(w, px, py, now, exempt)) { + // Found standing again and again while the quest approach (it only runs more than 80 y from the goal) was the last thing + // to move it: the goal cannot be closed from here (Derno and Phili, Burning Steppes, strikes 1..5 for 45 minutes: a forced walk + // to a hub ends and the quest rule walks them back to the same goal). Give that objective up so the picker takes another; + // the same answer an unreachable objective already gets from the fast NoPath blacklist. + if (w.strikes >= 3 && V2::IsObjectiveRule(w.prev_rule)) + { + ai.blacklist_current_objective(now + 10u * 60u * 1000u); + TC_LOG_INFO("playerbot.v2", "[idle] bot={} lvl={} zone={} cannot close the quest goal (strikes={}), objective given up for 10 minutes", + s.name(), uint32(s.level()), s.zone_id(), w.strikes); + } float tx = 0.f, ty = 0.f, tz = pz; char const* what = "wander"; if (w.strikes >= 2) diff --git a/src/modules/PlayerbotV2/Bot/States/State_InCombat.cpp b/src/modules/PlayerbotV2/Bot/States/State_InCombat.cpp index d52df5ff47..ebce928f92 100644 --- a/src/modules/PlayerbotV2/Bot/States/State_InCombat.cpp +++ b/src/modules/PlayerbotV2/Bot/States/State_InCombat.cpp @@ -27,6 +27,7 @@ #include "Combat/ApRegistry.h" #include "Combat/ApRotation.h" #include "Combat/Apl/ApClassicHeal.h" // ClassicHeal::RankHeal - raid overheal cancel +#include "Combat/Apl/AplPetThrottle.h" // one pet_attack order per target per 3 s #include "Combat/Apl/ApTankThreat.h" // TankThreat::TauntReach - [tank_loose] logs the reach the Taunt rule uses #include "SpellInfo.h" #include "SpellMgr.h" @@ -635,6 +636,23 @@ bool PartyOverThreatExpired(BotSnapshotView const& s, ObjectGuid target) return HoldClockExpired(g_party_hold_mu, g_party_hold, s, target, kPartyOverThreatMaxMs, kPartyOverThreatGapMs); } +// Past the hard limit the hold has no timed release: it waits for the tank's threat to rise (Bot/ThreatLimits.h, StalledTankHoldExpired). +// One clock per bot and target, polled with the tank's threat; it expires after kStalledTankHoldMs at a standstill. +constexpr uint32 kStalledTankHoldGapMs = 4000; +std::mutex g_stalled_hold_mu; +std::unordered_map g_stalled_hold; + +bool TankStalledUnderHold(BotSnapshotView const& s, ObjectGuid target, float tank_threat) +{ + const uint32 now = s.published_at_ms(); + const uint64 key = (uint64(s.raw().guid.GetCounter()) << 32) | uint64(uint32(target.GetCounter())); + std::lock_guard lock(g_stalled_hold_mu); + if (g_stalled_hold.size() > 1024) + for (auto it = g_stalled_hold.begin(); it != g_stalled_hold.end();) + it = (now - it->second.last_ms > 60'000u) ? g_stalled_hold.erase(it) : std::next(it); + return StalledTankHoldExpired(g_stalled_hold[key], now, tank_threat, kStalledTankHoldGapMs); +} + // Majordomo Executus' Damage Shield, on himself and his Flamewakers (the Magic Reflection twin, 20619, is refused by the cast API). constexpr uint32 kDamageShieldAura = 21075; @@ -646,6 +664,8 @@ ThreatHold EvaluateThreatHold(BotAI& ai, BotSnapshotView const& s, ObjectGuid ta if (!cfg.threat_hold_enabled() || s.in_battleground()) return ThreatHold::None; if (!s.is_in_instance() && !cfg.threat_hold_open_world()) return ThreatHold::None; if (ai.effective_role(s) == Role::Tank) return ThreatHold::None; + // A boss fight script owns this bot's start and target (RaidFightScript.h): its start wait is the only hold. + if (s.raw().raid_order.active && s.raw().raid_order.script_owns) return ThreatHold::None; NearbyUnit const* u = s.hostile_unit(target); if (!u) return ThreatHold::None; @@ -718,6 +738,17 @@ ThreatHold EvaluateThreatHold(BotAI& ai, BotSnapshotView const& s, ObjectGuid ta s.name(), u->entry, target.GetCounter(), kPartyOverThreatMaxMs, u->my_threat, u->tank_threat); h = ThreatHold::None; } + // Past the hard limit the hold waits for the tank to build; a tank that is stunned, feared, dead or out of reach never does, and the + // bot sat idle for the whole stun or Inferno. After kStalledTankHoldMs with the tank's threat at a standstill the + // hold releases and plain fighting takes over (the class threat drop has run during the hold, TryThreatDrop). + if (h == ThreatHold::OverThreat && past_hard_limit && TankStalledUnderHold(s, target, u->tank_threat)) + { + if (RaidLogDue(RaidLogKey(s, RaidLogKind::ThreatHold), s.published_at_ms(), 5000u)) + TC_LOG_INFO("playerbot.v2", + "[raid_threat] {} stops holding on entry {} ({}): tank threat stalled at {:.0f} for {} ms, mine={:.0f}", + s.name(), u->entry, target.GetCounter(), u->tank_threat, kStalledTankHoldMs, u->my_threat); + h = ThreatHold::None; + } if (h == ThreatHold::OverThreat && s.is_in_raid() && RaidLogDue(RaidLogKey(s, RaidLogKind::ThreatHold), s.published_at_ms(), 5000u)) TC_LOG_INFO("playerbot.v2", @@ -783,8 +814,11 @@ ThreatHold EvaluateThreatHold(BotAI& ai, BotSnapshotView const& s, ObjectGuid ta // A party's DPS wait for the owner's Attack after a Pull / Pull back and open by themselves this long after the tank's first hit // (playtest 2026-10-15: six seconds, in case the owner forgets). constexpr uint32 kPartyOpenWaitMs = 6000; + // A raid's boss: eight seconds from the tank's first hit, because the tank takes a while to run in; the config wait + // is honoured when longer. A party's boss keeps the six-second bound. uint32 wait_ms = !u->unit_in_combat ? kMaxUnpulledOwnerWaitMs - : boss ? std::min(kMaxOpenWaitBossMs, cfg.threat_opening_wait_boss_ms()) + : boss ? (s.is_in_raid() ? std::max(kRaidBossOpenWaitMs, cfg.threat_opening_wait_boss_ms()) + : std::min(kMaxOpenWaitBossMs, cfg.threat_opening_wait_boss_ms())) : (s.is_in_raid() ? std::max(kMaxOpenWaitTrashMs, cfg.threat_opening_wait_trash_ms()) : kPartyOpenWaitMs); // A raid trash mob a tank already holds (it is the mob's victim) needs no long lead wait: its // threat only has to start building, so DPS opens ~2 s after the tank has it (MC 2026-10-06: @@ -842,14 +876,7 @@ ThreatHold EvaluateThreatHold(BotAI& ai, BotSnapshotView const& s, ObjectGuid ta // one is ready (the owner's bots used the same set). Returns true on an emit. bool TryThreatDrop(BotSnapshotView const& s, ObjectGuid target, BotIntentEmitter& emit) { - struct Drop { uint8 cls; uint32 spell; uint32 needs_aura; bool on_target; }; - static constexpr Drop kDrops[] = { - { CLASS_PRIEST, 586, 0, false }, // Fade - { CLASS_HUNTER, 5384, 0, false }, // Feign Death - { CLASS_ROGUE, 1966, 0, true }, // Feint - { CLASS_DRUID, 8998, 768, true }, // Cower (Cat Form) - }; - for (Drop const& d : kDrops) + for (ThreatDrop const& d : kThreatDrops) // Bot/ThreatLimits.h: the one table of class threat drops { if (d.cls != s.cls() || !s.knows_spell(d.spell) || !s.is_ready(d.spell)) continue; if (d.needs_aura && !s.has_aura(d.needs_aura)) continue; @@ -2611,8 +2638,10 @@ void DispatchInCombat(BotAI& ai, if (alive) { skull = mark; break; } } Role const sk_role = ai.effective_role(snapshot); + // A boss fight script picks the target (it already honours the skull): this rule would be a second voice. + bool const script_target = snapshot.raw().raid_order.script_names_target(); if (!skull.IsEmpty() && snapshot.victim() != skull && sk_role != Role::Tank && sk_role != Role::Healer && - !HeldByOwner(ai, snapshot)) + !HeldByOwner(ai, snapshot) && !script_target) for (auto const& u : snapshot.nearby_enemies()) { if (u.guid != skull) continue; @@ -2644,7 +2673,8 @@ void DispatchInCombat(BotAI& ai, auto const& kf_po = snapshot.raw().pve_order; if (kf_po.active && !kf_po.kill_focus.IsEmpty() && snapshot.is_alive() && !snapshot.is_casting() && !on_owner_attack && - snapshot.victim() != kf_po.kill_focus) + snapshot.victim() != kf_po.kill_focus && + !snapshot.raw().raid_order.script_names_target()) // a boss fight script picks the target { for (auto const& u : snapshot.nearby_enemies()) { @@ -3687,10 +3717,16 @@ void DispatchInCombat(BotAI& ai, // zero behavioral gain. pet_victim() lags by one snapshot (~250ms) after // the pet switches, so at most 1-2 duplicate emits slip through per // target change. + // This is the only pet_attack site (the warlock / hunter rotation rules are gone): a new victim is ordered at once, the same + // one again after 3 s (AplPetThrottle.h), so a pet that cannot take the order does not flood the queue. if (snapshot.has_pet() && !snapshot.victim().IsEmpty() && snapshot.pet_victim() != snapshot.victim() && - !ThreatHoldActive(ai, snapshot, snapshot.victim(), &group)) // threat discipline: no pet on a held mob + !ThreatHoldActive(ai, snapshot, snapshot.victim(), &group) && // threat discipline: no pet on a held mob + Playerbot::AplPet::PetAttackDue(snapshot.raw().guid.GetCounter(), snapshot.victim(), snapshot.published_at_ms())) + { + Playerbot::AplPet::NotePetAttack(snapshot.raw().guid.GetCounter(), snapshot.victim(), snapshot.published_at_ms()); emit.pet_attack(snapshot.victim()); + } // Battle-rez: cast a class-appropriate combat-castable rez on the first // dead group member. Spells: diff --git a/src/modules/PlayerbotV2/Bot/States/State_InGroup.cpp b/src/modules/PlayerbotV2/Bot/States/State_InGroup.cpp index 1b1a15c49f..007ad8e31c 100644 --- a/src/modules/PlayerbotV2/Bot/States/State_InGroup.cpp +++ b/src/modules/PlayerbotV2/Bot/States/State_InGroup.cpp @@ -15,6 +15,7 @@ #include "Bot/BotRegistry.h" #include "Bot/MarkGate.h" // Playerbot.Behavior.MarksNeedOrder #include "Services.h" +#include "GroupControl.h" #include "Util/ConfigReader.h" // full type for Services::Config() (Playerbot.Behavior.Formation) #include #include "Travel/UnifiedTravelGraph.h" @@ -22,6 +23,7 @@ #include "Bot/ThreatDiscipline.h" // ThreatOpeningLead (passive, tank first) #include "Bot/ClassicUpkeep.h" // IsEating / IsDrinking (stand to defend) #include "Log.h" +#include "GameTime.h" #include #include @@ -63,6 +65,62 @@ bool IsMeleeClass(uint8 cls, uint32 spec) } // anonymous +// A ready check is answered by every grouped bot, dead or busy rezzing or not: a bot that skips it holds the whole check open until it times out. +static void AnswerReadyCheck(BotAI& ai, BotSnapshotView const& snapshot, GroupSnapshotView const& group, BotIntentEmitter& emit) +{ + // Auto-respond ready when the leader starts a ready check. Bots that don't + // answer block the rest of the group from pulling. Edge-triggered: emit + // exactly once per active window (cleared when the snapshot reports the + // check no longer active). Server-side response is idempotent but the + // intent still costs queue slots, so dedup is worth it. + if (group.ready_check_active()) + { + if (!ai.ready_check_acked()) + { + // Real information (the owner's ReadyCheckAction): badly low health, a mana + // user badly low on mana or broken gear answers not ready and says why + // in party chat; the out-of-combat recovery rules then drink / eat + // / repair. The check is advisory, nothing else waits on the answer. + // A bot a little under (just arrived, a buff cast) is ready: the whole raid answering + // "not ready" after a call-up read as broken. + bool ready = true; + char const* why = nullptr; + if (!snapshot.is_alive()) + { ready = false; why = "dead"; } + else if (Services::Config().behavior_ready_check_info()) + { + if (snapshot.hp_pct() < 35) + { ready = false; why = "low hp, eating first"; } + else if (snapshot.max_power(POWER_MANA) > 0 && snapshot.power_pct(POWER_MANA) < 35) + { ready = false; why = "low on mana, drinking first"; } + else if (snapshot.lowest_equipped_durability_pct() < 15) + { ready = false; why = "my gear is broken, need a repair"; } + } + emit.emit(GroupReadyResponseIntent{ready}); + TC_LOG_INFO("playerbot.v2", "[ready_check] {} answers {}{}{}", snapshot.name(), ready ? "ready" : "not ready", why ? ": " : "", why ? why : ""); + if (why) + { + if (snapshot.is_alive()) + emit.say(why); + } + else if (ready) + { + // Now and then a plain "ready" in chat, like a person (Playerbot.Behavior.PartyBanter). + std::string line = BotChatter::BanterLine(BotChatter::Banter::Ready, ai, snapshot); + if (!line.empty()) + emit.say(std::move(line)); + } + ai.set_ready_check_acked(true); + ai.set_last_rule_fired("ingroup:ready_check_ack"); + } + } + else if (ai.ready_check_acked()) + { + ai.set_ready_check_acked(false); + } +} + + void DispatchInGroup(BotAI& ai, BotSnapshotView snapshot, GroupSnapshotView group, @@ -70,6 +128,8 @@ void DispatchInGroup(BotAI& ai, { if (!group.exists()) return; + AnswerReadyCheck(ai, snapshot, group, emit); + // Raid: raise the dead (the owner first) before anything else; out of combat the raid never reaches the idle cascade's ooc_rez. if (RaidOocRez(snapshot, ai, group, emit)) return; @@ -307,51 +367,6 @@ void DispatchInGroup(BotAI& ai, if (!snapshot.is_alive()) return; - // Auto-respond ready when the leader starts a ready check. Bots that don't - // answer block the rest of the group from pulling. Edge-triggered: emit - // exactly once per active window (cleared when the snapshot reports the - // check no longer active). Server-side response is idempotent but the - // intent still costs queue slots, so dedup is worth it. - if (group.ready_check_active()) - { - if (!ai.ready_check_acked()) - { - // Real information (the owner's ReadyCheckAction): badly low health, a mana - // user badly low on mana or broken gear answers not ready and says why - // in party chat; the out-of-combat recovery rules then drink / eat - // / repair. The check is advisory, nothing else waits on the answer. - // A bot a little under (just arrived, a buff cast) is ready: the whole raid answering - // "not ready" after a call-up read as broken (playtest 2026-10-13). - bool ready = true; - char const* why = nullptr; - if (Services::Config().behavior_ready_check_info()) - { - if (snapshot.hp_pct() < 35) - { ready = false; why = "low hp, eating first"; } - else if (snapshot.max_power(POWER_MANA) > 0 && snapshot.power_pct(POWER_MANA) < 35) - { ready = false; why = "low on mana, drinking first"; } - else if (snapshot.lowest_equipped_durability_pct() < 15) - { ready = false; why = "my gear is broken, need a repair"; } - } - emit.emit(GroupReadyResponseIntent{ready}); - if (why) - emit.say(why); - else if (ready) - { - // Now and then a plain "ready" in chat, like a person (Playerbot.Behavior.PartyBanter). - std::string line = BotChatter::BanterLine(BotChatter::Banter::Ready, ai, snapshot); - if (!line.empty()) - emit.say(std::move(line)); - } - ai.set_ready_check_acked(true); - ai.set_last_rule_fired("ingroup:ready_check_ack"); - } - } - else if (ai.ready_check_acked()) - { - ai.set_ready_check_acked(false); - } - // Owner's fallback order: the rally anchor and the target choice belong to States::FallbackTick // (idle:fallback / the top of DispatchInCombat); the follow / assist below would pull the bot // back out to the owner or the fight it just left. @@ -490,6 +505,50 @@ void DispatchInGroup(BotAI& ai, } } + // Leash break (a bot in a group with a player, Passive or Aggressive; open world and instance trash, never a boss or a run the dungeon + // autopilot drives): a bot whose target is not on anyone in the group + // and has drifted beyond the leash from the leader drops it and goes back to follow, so no bot runs off after a mob the group never + // pulled (a kited or fleeing mob, a pack past the aggressive radius). A mob on the bot or on a member is never dropped. + // Not while the leader has just ordered it (attack / pull window, an engage order, pull back, fallback): his call has no leash. + if (snapshot.is_led_by_player() && !snapshot.in_battleground() && !snapshot.victim().IsEmpty() && + (!snapshot.is_in_instance() || (!ai.dungeon_active() && snapshot.victim_info() && !Classic::IsBossUnit(*snapshot.victim_info()))) && + !ai.owner_order_window_open() && !ai.pull_back_active() && !ai.fallback_active() && + !(ai.is_manual_mode(snapshot.published_at_ms()) && ai.owner_command() == BotAI::OwnerCommand::Engage)) + { + auto const stance = ai.owner_stance(); + bool const aggressive = stance == BotAI::OwnerStance::Aggressive; + bool const leashed = aggressive || stance == BotAI::OwnerStance::Passive || stance == BotAI::OwnerStance::Auto; + float const reach = aggressive ? Services::Config().behavior_aggressive_radius_yd() : Services::Config().behavior_passive_leash_yd(); + auto const* grp_members = group.members(); + NearbyUnit const* tgt = snapshot.victim_info(); + ObjectGuid const ctl = snapshot.controller_guid(); + if (leashed && reach > 0.f && grp_members && tgt && !ctl.IsEmpty()) + { + bool on_group = tgt->victim == snapshot.raw().guid; + GroupMemberSummary const* ctl_member = nullptr; + for (auto const& m : *grp_members) + { + if (m.guid == tgt->victim || (m.guid != snapshot.raw().guid && m.victim == tgt->guid)) on_group = true; // on a member, or a member (the leader) is fighting it + if (m.guid == ctl && m.online && m.map_id == snapshot.map_id()) ctl_member = &m; + } + if (!on_group && ctl_member && + std::hypot(tgt->x - ctl_member->x, tgt->y - ctl_member->y) > reach + 10.0f) + { + emit.stop_attack(); + if (snapshot.has_pet()) + emit.pet_set_command_state(1); // COMMAND_FOLLOW: the pet comes back with it + ai.set_last_rule_fired("ingroup:leash_break"); + static std::atomic s_leash_log_ms{ 0 }; + uint32 const now_lb = snapshot.published_at_ms(); + uint32 last_lb = s_leash_log_ms.load(std::memory_order_relaxed); + if (now_lb - last_lb >= 500u && s_leash_log_ms.compare_exchange_strong(last_lb, now_lb)) + TC_LOG_INFO("playerbot.v2", "[leash] {} drops entry {}: {:.0f} y from {}, not on the group (reach {:.0f} y)", + snapshot.name(), tgt->entry, std::hypot(tgt->x - ctl_member->x, tgt->y - ctl_member->y), ctl_member->name, reach); + return; + } + } + } + // Don't override combat-state actions — the primary InCombat dispatch is // already running the APL. if (ai.state() == BotState::InCombat) return; @@ -686,14 +745,16 @@ void DispatchInGroup(BotAI& ai, // Owner "passive": no assist on the owner's, the skull's or a member's target; only a mob already on a group member is engaged // (the defend-member step below). Stance Passive, or Auto in an instance a human leads (BotAI::passive_now); an attack / pull // order opens a 15 s window in which it fights. - const bool owner_passive = ai.passive_now(snapshot.is_in_instance() && !group.leader_is_bot()); + // Led by a player (his companion, or a world bot he invited) and no stance picked: Passive, in the open world too. + const bool auto_passive = (snapshot.is_in_instance() && !group.leader_is_bot()) || snapshot.is_led_by_player(); + const bool owner_passive = ai.passive_now(auto_passive); // A Passive bot inside an order window (every Attack / Pull / assist order opens 15 s of it) joins the owner's own target and // nothing wider: no skull, no kill focus, no other member's victim, no creature outside its scan or far from the owner (the owner, // Deadmines 2026-10-15: "the bots were attacking willy-nilly, hitting things that weren't close to me"; with Attack pressed every few // seconds the window never closed and the whole assist chain ran, the tank opening on mobs 32-43 y away). const bool window_limited = !owner_passive && (ai.owner_stance() == BotAI::OwnerStance::Passive || - (ai.owner_stance() == BotAI::OwnerStance::Auto && snapshot.is_in_instance() && !group.leader_is_bot())); + (ai.owner_stance() == BotAI::OwnerStance::Auto && auto_passive)); // A pet never starts a pull. PetAttack (the bot's own assist) leaves the pet Aggressive for good, and an aggressive pet // pulls every mob around it while the group stands still (Deadmines, 2026-10-13). Between fights the pet goes back to // Defensive (it fights what attacks its owner or itself), and to Passive when the group is told to stay or is passive. @@ -876,6 +937,19 @@ void DispatchInGroup(BotAI& ai, for (auto const& m : *members) if (m.guid == u.victim) { attacks_member = true; victim_member = &m; break; } if (!attacks_member) continue; + // Leash (open world and instance trash, never a boss): a Passive bot defends a mob on someone else only while it is within PassiveLeashYd of the leader + // or of the member it is on (a healer 30 y back is still defended), and that member is itself near the leader. It + // never runs off to a pack the group has not pulled. A mob on the bot itself is always fought. + if ((owner_passive || window_limited) && snapshot.is_led_by_player() && + (!snapshot.is_in_instance() || (!ai.dungeon_active() && !Classic::IsBossUnit(u)))) + { + float const leash = Services::Config().behavior_passive_leash_yd(); + float near_d = std::hypot(u.x - leader_member->x, u.y - leader_member->y); + if (victim_member && victim_member->map_id == snapshot.map_id() && + std::hypot(victim_member->x - leader_member->x, victim_member->y - leader_member->y) <= 2.0f * leash) + near_d = std::min(near_d, std::hypot(u.x - victim_member->x, u.y - victim_member->y)); + if (!GroupControl::PassiveMayDefend(u.victim == snapshot.raw().guid, near_d, leash)) continue; + } // Passive, tank first (playtest 2026-10-14): a mob on another member is the tank's to pick up; a damage bot joins once the // tank has its opening lead, or at once when the member it is on is under 70 % (a healer waits for nothing here: it heals). if (owner_passive && victim_member && ai.effective_role(snapshot) == Role::Dps && !u.is_player) @@ -923,7 +997,9 @@ void DispatchInGroup(BotAI& ai, if (assist_target.IsEmpty() && ai.owner_stance() == BotAI::OwnerStance::Aggressive && !group.leader_is_bot()) { float best_dsq = std::numeric_limits::max(); - constexpr float kR2 = BotAI::kAggressiveRadiusYd * BotAI::kAggressiveRadiusYd; + // Measured from the leader (not the bot), so a bot never leaves the group to reach a mob. + const float kRadius = Services::Config().behavior_aggressive_radius_yd(); + const float kR2 = kRadius * kRadius; for (auto const& u : snapshot.raw().combat.nearby_enemies) { if (u.hp <= 0 || !u.in_los || u.no_xp_kill || u.is_pacified || u.untargetable) continue; @@ -1170,6 +1246,10 @@ void DispatchInGroup(BotAI& ai, (ai.pull_back_active() || (ai.is_manual_mode(snapshot.published_at_ms()) && ai.owner_command() == BotAI::OwnerCommand::Engage)) && dist < kDetourMaxRange; + // The one answer to "does another layer own this bot's movement right now": the follow, the slot move and the recall all stand + // down for it (a rooted bot cannot follow either). + bool const movement_owned_elsewhere = + in_active_bg || dungeon_run_owns_movement || detour_leased || holding_position || order_owns_movement || snapshot.is_rooted(); bool const refollow = ai.take_formation_refollow(); // Owner formation: the bot's goal is its SLOT, recomputed every tick from the owner's live position and facing, // not "within the recall slack of the owner" (a slot ring wider than the slack, or any spot inside the ring, @@ -1182,7 +1262,7 @@ void DispatchInGroup(BotAI& ai, auto& ft = ai.formation_track(); constexpr float kArriveYd = 1.5f, kStartYd = 2.5f, kRetargetYd = 2.0f; constexpr uint32 kMinReissueMs = 500, kStuckMs = 3000, kFallbackMs = 8000; - bool const gated = in_active_bg || dungeon_run_owns_movement || detour_leased || holding_position || order_owns_movement || snapshot.is_rooted(); + bool const gated = movement_owned_elsewhere; float const slot_dist = DistanceXY(bx, by, slot_x, slot_y); bool const moving = snapshot.raw().movement.is_moving; // 0 = none, 1 = move, 2 = hold, 3 = fallback @@ -1224,13 +1304,36 @@ void DispatchInGroup(BotAI& ai, } } } + // A bot that is told to move and does not, for more than 3 s: where it stands, what is around it, and whether its moves were refused. + // Cause of a standstill that no path_fail line explains (a bot standing on a gameobject model is higher than the ground under it). + if ((action == 1 || action == 3) && !moving && formation_now_ms - ft.last_progress_ms > kStuckMs && + formation_now_ms - ft.last_stuck_log_ms >= 5000) + { + ft.last_stuck_log_ms = formation_now_ms; + std::string near_objs; + for (auto const& o : snapshot.raw().world_objects.nearby_objects) + { + float const od = DistanceXY(bx, by, o.x, o.y); + if (od <= 4.0f) + near_objs += fmt::format("{}{}(type {}) d={:.1f} dz={:.1f}", near_objs.empty() ? "" : "; ", o.entry, o.go_type, od, o.z - bz); + } + float const gz = snapshot.raw().movement.ground_z; + TC_LOG_INFO("playerbot.v2", + "[formation_stuck] {} bot=({:.1f},{:.1f},{:.1f}) ground_z={} slot=({:.1f},{:.1f}) slot_dist={:.1f} action={} stuck_ms={} " + "path_blocked={} last_blocked_ms_ago={} rooted={} objects_within_4y=[{}]", + snapshot.name(), bx, by, bz, gz > -50000.0f ? fmt::format("{:.1f}", gz) : std::string("n/a"), slot_x, slot_y, slot_dist, + action == 1 ? "move" : "fallback", formation_now_ms - ft.last_progress_ms, snapshot.path_blocked_count(), + snapshot.last_path_blocked_ms() ? formation_now_ms - snapshot.last_path_blocked_ms() : 0u, int(snapshot.is_rooted()), near_objs); + } if (action != 0 && action != ft.last_action && formation_now_ms - ft.last_log_ms >= 5000) { TC_LOG_INFO("playerbot.v2", - "[formation] {} type={} slot={}/{} slot=({:.1f},{:.1f}) owner=({:.1f},{:.1f}) dist={:.1f} action={}", + "[formation] {} type={} slot={}/{} slot=({:.1f},{:.1f}) owner=({:.1f},{:.1f}) dist={:.1f} action={} " + "bot=({:.1f},{:.1f},{:.1f}) owner_z={:.1f} owner_dist={:.1f} moving={}", snapshot.name(), FormationTypeName(slot_type), slot_index, slot_count, slot_x, slot_y, leader_member->x, leader_member->y, slot_dist, - action == 1 ? "move" : action == 2 ? "hold" : "fallback"); + action == 1 ? "move" : action == 2 ? "hold" : "fallback", + bx, by, bz, leader_member->z, dist, moving ? 1 : 0); ft.last_log_ms = formation_now_ms; ft.last_action = action; } @@ -1238,9 +1341,8 @@ void DispatchInGroup(BotAI& ai, else if (!formation_fallback && ai.formation_track().dest_valid) ai.formation_track().dest_valid = false; - if (!formation_slot_active && - !in_active_bg && !dungeon_run_owns_movement && !detour_leased && !holding_position && !order_owns_movement && - (dist > kRecallSlack || (refollow && dist > 1.5f)) && !snapshot.is_rooted()) + if (!formation_slot_active && !movement_owned_elsewhere && + (dist > kRecallSlack || (refollow && dist > 1.5f))) { // Follow uses MotionMaster MoveFollow, which silently re-emits forever // when the leader is unreachable (across a gap / closed door) — and @@ -1323,7 +1425,8 @@ void DispatchInGroup(BotAI& ai, } } } - emit.move_to(tx, ty, tz, /*run*/ true); + // Toward the owner himself (not the escape node): a gap across his side, level with the bot, is leapt from its edge (API::move_to follow_drop). + emit.move_to(tx, ty, tz, /*run*/ true, false, false, /*follow_drop*/ stale < kFollowEscapeTicks); ai.set_last_rule_fired("ingroup:follow_recall_repath"); } else @@ -1336,7 +1439,11 @@ void DispatchInGroup(BotAI& ai, { // Within slack (or following suppressed) — not separated, clear the // stale-progress counter so a future real separation starts fresh. - ai.reset_follow_progress(); + // Not while an owner formation has the bot outside its slack: the slot walk and the plain-follow fallback alternate (3 s / 8 s), + // and clearing the counter at every switch kept the stale count under the repath threshold forever, so a bot that could not + // reach its slot never got the validated repath or the escape node (the Stormwind Trade District ramp). + if (!(formation_slot_active && dist > kRecallSlack)) + ai.reset_follow_progress(); } // Auto-mount when the leader is far ahead and we're outdoors — closes @@ -1450,4 +1557,54 @@ void DispatchInGroup(BotAI& ai, } } +// Follow an owner who dropped or jumped to a floor 4+ y below (he went 11 y down into the arena; his bots, which +// only followed the walking route, went round through the Blackhand packs and died. A warlock then started the ledge walk, a buff cast +// stopped it, and a combat escape took it along the rim the long way). Runs at the top of every tick, whatever the state. The follow +// itself is API::move_to follow_drop: when the walking route to him is missing or a long detour it walks to the nearest ledge and +// drops or leaps; when the route is fine it is the ordinary pathed move and the intent executor marks it fine (no attempt for 3 s). +// While the walk or the flight is on, the tick is consumed: no buff, no stand-up, no combat step can re-aim the bot. +bool HonorFollowDrop(BotSnapshotView const& s, BotAI& ai, GroupSnapshotView const& g, BotIntentEmitter& emit) +{ + uint32 const now = GameTime::GetGameTimeMS(); + if (!s.is_alive() || s.in_battleground() || ai.dungeon_active() || s.is_rooted() || s.raw().movement.is_mounted || !g.exists()) + { ai.clear_follow_drop(); return false; } + uint32 const pub = s.published_at_ms(); + if (ai.holding_position(pub) || ai.pull_back_active() || + (ai.is_manual_mode(pub) && ai.owner_command() == BotAI::OwnerCommand::Engage)) + { ai.clear_follow_drop(); return false; } + ObjectGuid const leader_guid = g.leader(); + auto const* members = g.members(); + if (leader_guid.IsEmpty() || leader_guid == s.guid() || !members) + { ai.clear_follow_drop(); return false; } + GroupMemberSummary const* leader = nullptr; + for (auto const& m : *members) + if (m.guid == leader_guid) { leader = &m; break; } + // Only a human owner is followed off a ledge; a bot leader is not. + if (!leader || !leader->online || !leader->is_alive || leader->is_bot || leader->map_id != s.map_id()) + { ai.clear_follow_drop(); return false; } + float bx, by, bz; s.position(bx, by, bz); + float const dist = DistanceXY(bx, by, leader->x, leader->y); + if (dist < 6.0f || dist > 50.0f || bz - leader->z < 4.0f) + { ai.clear_follow_drop(); return false; } + + bool const committed = ai.follow_drop_committed(now); + if (!committed && (ai.follow_drop_fine(now) || ai.follow_drop_blocked(now))) + return false; + if (committed && now - ai.follow_drop_since_ms() > BotAI::kFollowDropMaxMs) + { + TC_LOG_INFO("playerbot.v2", "[follow_drop] {} gives up the walk to the ledge after {} s", s.name(), BotAI::kFollowDropMaxMs / 1000u); + ai.block_follow_drop(now); + return false; + } + bool const pushed = emit.move_to(leader->x, leader->y, leader->z, /*run=*/true, false, false, /*follow_drop=*/true); + // A refused move (casting, no path) ends the attempt; the rules and the plain follow carry on. + if (!pushed && ai.move_refused_recently(leader->x, leader->y, leader->z, pub)) + { ai.clear_follow_drop(); return false; } + ai.set_last_rule_fired(committed ? "follow_drop:commit" : "follow_drop:try"); + // A first attempt consumes its tick so the plain follow cannot override the ledge walk it starts; a deduped re-attempt of one in + // progress consumes it too (the walk is running); a deduped attempt with nothing in progress lets the rules run. + return committed || pushed; +} + + } // namespace Playerbot::States diff --git a/src/modules/PlayerbotV2/Bot/ThreatDiscipline.h b/src/modules/PlayerbotV2/Bot/ThreatDiscipline.h index 48b6279491..5001c933b7 100644 --- a/src/modules/PlayerbotV2/Bot/ThreatDiscipline.h +++ b/src/modules/PlayerbotV2/Bot/ThreatDiscipline.h @@ -164,11 +164,13 @@ inline AoeHazard FindAoeHazard(BotSnapshotView const& s, float cx, float cy, flo { hit = { &u, AoeHazardKind::CrowdControlled }; return true; } if (school_avoided(u)) { hit = { &u, AoeHazardKind::SchoolAvoided }; return true; } - if (hit.unit || !tanked || !u.has_threat_list) return false; // keep the first soft hazard + // A bot told to start nothing (Passive, or led by a player with no stance picked) never tags a pack with an AoE either: a mob + // nobody has engaged is a hazard whether or not the group has a tank. + if (hit.unit || !(tanked || s.no_tag_stance()) || !u.has_threat_list) return false; // keep the first soft hazard if (!u.unit_in_combat) { hit = { &u, AoeHazardKind::Unpulled }; return false; } // Raid only: a party's AoE is not held for the tank's lead (the Unpulled and CC guards above still apply). - if (s.is_in_raid() && !me_tank && ThreatVictim(u.victim_kind) == ThreatVictim::Tank && TankNotSecured(s, u)) + if (tanked && s.is_in_raid() && !me_tank && ThreatVictim(u.victim_kind) == ThreatVictim::Tank && TankNotSecured(s, u)) { hit = { &u, AoeHazardKind::NotTanked }; return false; } return false; }; diff --git a/src/modules/PlayerbotV2/Bot/ThreatLimits.h b/src/modules/PlayerbotV2/Bot/ThreatLimits.h index 3d54562b55..f04b5fbdc4 100644 --- a/src/modules/PlayerbotV2/Bot/ThreatLimits.h +++ b/src/modules/PlayerbotV2/Bot/ThreatLimits.h @@ -47,4 +47,48 @@ constexpr float ThreatEarlyHoldRatio(float base, bool melee, float tank_threat, return lowered > floor ? lowered : floor; } +// The class threat drops (Fade, Feign Death, Feint, Cower): spell, the aura it needs, and whether it is cast on the mob. The rotations +// cast them when a bot holds kThreatDropPct of the tank's threat on a mob; the generic hold casts them once at the hard limit. +struct ThreatDrop { unsigned char cls; unsigned spell; unsigned needs_aura; bool on_target; }; +constexpr ThreatDrop kThreatDrops[] = { + { 5, 586, 0, false }, // Priest: Fade + { 3, 5384, 0, false }, // Hunter: Feign Death + { 4, 1966, 0, true }, // Rogue: Feint + { 11, 8998, 768, true }, // Druid: Cower (Cat Form) +}; +constexpr int kThreatDropPct = 60; // percent of the tank's threat from which a rotation sheds threat +constexpr int kThreatHighPct = 80; // percent of the tank's threat from which a rotation uses its big threat drop + +// How long a raid's DPS wait after the tank's first hit on a boss before they open by themselves (the owner's Attack still releases them at +// once). The tank runs in from the room's edge and builds its lead in that time; the dungeons' parties keep their own, shorter wait. The one +// number for the generic boss opening and for every boss fight script (Raid::Script::Fight::startWaitMs). +constexpr unsigned kRaidBossOpenWaitMs = 8000; + +// The "a forgotten Attack must not wipe the raid" release (Playerbot.Raid.DpsWaitTimeoutMs): after the tanks have fought this long without the +// owner's Attack the DPS go anyway. A raid's, limited to the same eight seconds and defaulting to it; a party keeps its six. +constexpr unsigned kRaidDpsWaitTimeoutMaxMs = kRaidBossOpenWaitMs; +constexpr unsigned kPartyDpsWaitTimeoutMs = 6000; + +// Past the hard limit the over-threat hold waits for the tank's threat to rise. A tank that is stunned, feared, dead, in an Inferno +// or out of reach never raises it, and every DPS and healer at the limit stood idle for as long as that lasted. +// After kStalledTankHoldMs on a tank whose threat has not moved the hold releases: the class threat drop (Fade, Feign Death, Feint, +// Cower) has had its chance during the hold, and plain fighting takes over. The same clock bounds the healer's near-tank hold. +constexpr unsigned kStalledTankHoldMs = 6000; + +struct StalledTankClock { unsigned since_ms = 0; unsigned last_ms = 0; float tank_threat = 0.0f; }; + +// One poll of a hold past the hard limit: true once the hold has lasted kStalledTankHoldMs with the tank's threat at a standstill. +// The clock restarts when the tank's threat rises (the tank is building, the hold is doing its job) and after gap_ms without a +// poll (a new hold). +constexpr bool StalledTankHoldExpired(StalledTankClock& c, unsigned now, float tank_threat, unsigned gap_ms) +{ + if (!c.since_ms || now - c.last_ms > gap_ms || tank_threat > c.tank_threat) + { + c.since_ms = now; + c.tank_threat = tank_threat; + } + c.last_ms = now; + return now - c.since_ms >= kStalledTankHoldMs; +} + } // namespace Playerbot diff --git a/src/modules/PlayerbotV2/Bot/TownLife.h b/src/modules/PlayerbotV2/Bot/TownLife.h index 4ef31d0167..68d8685d0e 100644 --- a/src/modules/PlayerbotV2/Bot/TownLife.h +++ b/src/modules/PlayerbotV2/Bot/TownLife.h @@ -21,7 +21,7 @@ namespace Playerbot::V2::TownLife // strikes (a bot stood still too long), split by capital and elsewhere, which is how a frozen bot shows up in the log. struct Stats { - std::atomic inn_ticks{0}, mailbox_ticks{0}, duels{0}, campfires{0}, lfg_calls{0}, idle_town{0}, idle_field{0}; + std::atomic inn_ticks{0}, inn_walk{0}, inn_none{0}, inn_stuck{0}, mailbox_ticks{0}, duels{0}, campfires{0}, lfg_calls{0}, idle_town{0}, idle_field{0}; }; inline Stats& Counters() { diff --git a/src/modules/PlayerbotV2/CMakeLists.txt b/src/modules/PlayerbotV2/CMakeLists.txt index 6dae1ad5b5..753809bebf 100644 --- a/src/modules/PlayerbotV2/CMakeLists.txt +++ b/src/modules/PlayerbotV2/CMakeLists.txt @@ -53,10 +53,15 @@ function(playerbot_v2_configure_sublib target_name) CXX_EXTENSIONS OFF FOLDER "src/modules/PlayerbotV2" ) + # A function that calls itself on every path never returns and the compiler turns it into a bare jump to itself (a static wrapper + # named like the function it forwards to did this, and froze the world thread): that warning is an error here. if(MSVC) - target_compile_options(${target_name} PRIVATE /W4) + target_compile_options(${target_name} PRIVATE /W4 /we4717) else() target_compile_options(${target_name} PRIVATE -Wall -Wextra -Wpedantic) + if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") + target_compile_options(${target_name} PRIVATE -Werror=infinite-recursion) + endif() endif() if(USE_COREPCH) target_precompile_headers(${target_name} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/PCH.h) diff --git a/src/modules/PlayerbotV2/Combat/ApRegistry.cpp b/src/modules/PlayerbotV2/Combat/ApRegistry.cpp index 2dce307104..648d813bd6 100644 --- a/src/modules/PlayerbotV2/Combat/ApRegistry.cpp +++ b/src/modules/PlayerbotV2/Combat/ApRegistry.cpp @@ -78,39 +78,11 @@ std::vector ListRotations() // Forward declarations of per-spec registration functions. Each Apl_*.cpp // defines `void RegisterApl__()` and we call them from // RegisterAllRotations. -extern void RegisterApl_Hunter_BeastMastery(); -extern void RegisterApl_Hunter_Marksmanship(); -extern void RegisterApl_Hunter_Survival(); -extern void RegisterApl_Paladin_Holy(); -extern void RegisterApl_Paladin_Retribution(); -extern void RegisterApl_Paladin_Protection(); -extern void RegisterApl_Mage_Frost(); -extern void RegisterApl_Mage_Fire(); -extern void RegisterApl_Mage_Arcane(); -extern void RegisterApl_Warrior_Arms(); -extern void RegisterApl_Warrior_Fury(); -extern void RegisterApl_Warrior_Protection(); -extern void RegisterApl_Priest_Shadow(); -extern void RegisterApl_Priest_Holy(); -extern void RegisterApl_Priest_Discipline(); -extern void RegisterApl_Druid_Restoration(); -extern void RegisterApl_Druid_Guardian(); -extern void RegisterApl_Druid_Balance(); -extern void RegisterApl_Druid_Feral(); extern void RegisterApl_DeathKnight_Frost(); extern void RegisterApl_DeathKnight_Unholy(); -extern void RegisterApl_Warlock_Affliction(); -extern void RegisterApl_Warlock_Demonology(); -extern void RegisterApl_Warlock_Destruction(); extern void RegisterApl_DemonHunter_Havoc(); extern void RegisterApl_DemonHunter_Vengeance(); extern void RegisterApl_DemonHunter_Devourer(); -extern void RegisterApl_Rogue_Subtlety(); -extern void RegisterApl_Rogue_Outlaw(); -extern void RegisterApl_Rogue_Assassination(); -extern void RegisterApl_Shaman_Elemental(); -extern void RegisterApl_Shaman_Restoration(); -extern void RegisterApl_Shaman_Enhancement(); extern void RegisterApl_Evoker_Devastation(); extern void RegisterApl_Evoker_Preservation(); extern void RegisterApl_Evoker_Augmentation(); @@ -136,39 +108,11 @@ void RegisterAllRotations() // skipped. GetRotation prefers exact spec match anyway, so order // is functional rather than semantic. RegisterApl_Baseline(); - RegisterApl_Hunter_BeastMastery(); - RegisterApl_Hunter_Marksmanship(); - RegisterApl_Hunter_Survival(); - RegisterApl_Paladin_Holy(); - RegisterApl_Paladin_Retribution(); - RegisterApl_Paladin_Protection(); - RegisterApl_Mage_Frost(); - RegisterApl_Mage_Fire(); - RegisterApl_Mage_Arcane(); - RegisterApl_Warrior_Arms(); - RegisterApl_Warrior_Fury(); - RegisterApl_Warrior_Protection(); - RegisterApl_Priest_Shadow(); - RegisterApl_Priest_Holy(); - RegisterApl_Priest_Discipline(); - RegisterApl_Druid_Restoration(); - RegisterApl_Druid_Guardian(); - RegisterApl_Druid_Balance(); - RegisterApl_Druid_Feral(); RegisterApl_DeathKnight_Frost(); RegisterApl_DeathKnight_Unholy(); - RegisterApl_Warlock_Affliction(); - RegisterApl_Warlock_Demonology(); - RegisterApl_Warlock_Destruction(); RegisterApl_DemonHunter_Havoc(); RegisterApl_DemonHunter_Vengeance(); RegisterApl_DemonHunter_Devourer(); - RegisterApl_Rogue_Subtlety(); - RegisterApl_Rogue_Outlaw(); - RegisterApl_Rogue_Assassination(); - RegisterApl_Shaman_Elemental(); - RegisterApl_Shaman_Restoration(); - RegisterApl_Shaman_Enhancement(); RegisterApl_Evoker_Devastation(); RegisterApl_Evoker_Preservation(); RegisterApl_Evoker_Augmentation(); diff --git a/src/modules/PlayerbotV2/Combat/Apl/ApClassicHeal.h b/src/modules/PlayerbotV2/Combat/Apl/ApClassicHeal.h index 3c5b0adb17..2bf3b32db3 100644 --- a/src/modules/PlayerbotV2/Combat/Apl/ApClassicHeal.h +++ b/src/modules/PlayerbotV2/Combat/Apl/ApClassicHeal.h @@ -63,6 +63,7 @@ #include "Bot/RezClaims.h" // IsRezSpell, rez cast refusals #include "Bot/RezRule.h" // RezRank, RezFightLive #include "Bot/ThreatDiscipline.h" +#include "Bot/ThreatLimits.h" // StalledTankClock: the near-tank hold's bound #include "Bot/Raid/RaidEncounters.h" // Raid::ThreatShareAfterDrop #include "Bot/Raid/RaidHealStats.h" #include "Bot/Raid/RaidManaLedger.h" @@ -512,6 +513,11 @@ inline bool TankOpeningOnBoss(BotSnapshotView const& s) // Away cut the tank by a quarter and she turned on it). Healing threat is the effective health done, so the healer leaves members above // kHealOpeningHoldPct alone until the tank is clear of it again. Emergencies are never held, and a tank is never held off. constexpr float kHealerThreatHoldRatio = 0.85f; +// The hold waits for the tank to build threat again; a tank that is stunned, feared, dead or out of reach never does, so it is bounded by +// the tank standing still for kStalledTankHoldMs (Bot/ThreatLimits.h), one clock per healer and boss. The healer heals as usual after that. +constexpr uint32 kHealerThreatHoldGapMs = 4000; +inline std::mutex g_healer_threat_hold_mu; +inline std::unordered_map g_healer_threat_hold; inline bool HealerNearTankThreat(BotSnapshotView const& s) { if (!ThreatDisciplineApplies(s)) @@ -520,7 +526,15 @@ inline bool HealerNearTankThreat(BotSnapshotView const& s) if ((u.is_dungeon_boss || u.is_boss_rank) && !u.is_player && u.hp > 0 && u.has_threat_list && u.unit_in_combat && ThreatVictim(u.victim_kind) == ThreatVictim::Tank && u.tank_threat > 0.0f && u.my_threat >= u.tank_threat * kHealerThreatHoldRatio * Raid::ThreatShareAfterDrop(s.map_id(), u.entry)) - return true; + { + uint32 const now = s.published_at_ms(); + uint64 const key = (uint64(s.guid().GetCounter()) << 32) | uint64(uint32(u.guid.GetCounter())); + std::lock_guard lock(g_healer_threat_hold_mu); + if (g_healer_threat_hold.size() > 1024) + for (auto it = g_healer_threat_hold.begin(); it != g_healer_threat_hold.end();) + it = (now - it->second.last_ms > 60'000u) ? g_healer_threat_hold.erase(it) : std::next(it); + return !StalledTankHoldExpired(g_healer_threat_hold[key], now, u.tank_threat, kHealerThreatHoldGapMs); + } return false; } diff --git a/src/modules/PlayerbotV2/Combat/Apl/ApTankThreat.h b/src/modules/PlayerbotV2/Combat/Apl/ApTankThreat.h index 1f6d9e99cb..bcce32e78e 100644 --- a/src/modules/PlayerbotV2/Combat/Apl/ApTankThreat.h +++ b/src/modules/PlayerbotV2/Combat/Apl/ApTankThreat.h @@ -19,6 +19,7 @@ #include "Bot/BotSnapshotView.h" #include "Bot/ClassicUpkeep.h" // Classic::BossFight +#include "Bot/Raid/RaidEncounters.h" // Raid::OffTankMob #include "Bot/ThreatDiscipline.h" #include "Log.h" #include "SpellInfo.h" @@ -192,6 +193,10 @@ inline NearbyUnit const* CcLockedWithin(BotSnapshotView const& s, float range) // the loose mobs nobody else was given, and no crowd-controlled mob in reach. inline bool AreaTauntWorth(BotSnapshotView const& s, float range, char const* what) { + // Majordomo: every tank holds its own add, a shout would pull all eight onto one tank. + for (NearbyUnit const& u : s.nearby_enemies()) + if (Engaged(u) && Raid::OffTankMob(s.map_id(), u.entry)) + return false; if (UnclaimedLooseWithin(s, range) < 3) return false; if (NearbyUnit const* cc = CcLockedWithin(s, range)) { diff --git a/src/modules/PlayerbotV2/Combat/Apl/ApThreatDump.h b/src/modules/PlayerbotV2/Combat/Apl/ApThreatDump.h index 5f22a2150c..a6e8ca3f80 100644 --- a/src/modules/PlayerbotV2/Combat/Apl/ApThreatDump.h +++ b/src/modules/PlayerbotV2/Combat/Apl/ApThreatDump.h @@ -6,12 +6,13 @@ // tank_threat, filled by the snapshot builder). Used to time Fade and Feint. #include "Bot/BotSnapshotView.h" +#include "Bot/ThreatLimits.h" #include namespace Playerbot::Combat::ThreatDump { -constexpr int32 kMediumThreatPct = 60; // VM MediumThreatTrigger -constexpr int32 kHighThreatPct = 80; // VM HighThreatTrigger +constexpr int32 kMediumThreatPct = kThreatDropPct; // the numbers live in Bot/ThreatLimits.h +constexpr int32 kHighThreatPct = kThreatHighPct; // Highest share (percent) of the group tank's threat the bot holds on any mob that is fighting and whose victim is not the // bot already. 0 when no tank holds threat on a mob or nothing qualifies. diff --git a/src/modules/PlayerbotV2/Combat/Apl/AplPetThrottle.h b/src/modules/PlayerbotV2/Combat/Apl/AplPetThrottle.h index 3d63194800..3070b1704a 100644 --- a/src/modules/PlayerbotV2/Combat/Apl/AplPetThrottle.h +++ b/src/modules/PlayerbotV2/Combat/Apl/AplPetThrottle.h @@ -1,34 +1,36 @@ -// AplPetThrottle.h: pace for the pet_attack rotation rule of the pet classes (warlock, hunter). +// AplPetThrottle.h: pace for the one pet_attack order of a bot's combat tick (State_InCombat, all pet classes). // -// pet_attack sits ahead of every damage rule and fires whenever the pet's victim is not the bot's victim. A pet that cannot or will -// not take the order (it cannot reach the mob, is out of range, a boss immune to it, a stale snapshot) kept the predicate true on -// every tick, so the first-match rotation never got past it: live MC Gehennas 2026-10-08, two warlocks stuck up to 83 s on -// "classic_warlock:pet_attack / no rule acted" at 26-32 y with 96-99% mana, no spell cast. The order is given at most once per -// kPetAttackGapMs; in between the rule steps aside and the nukes run. +// The order goes out whenever the pet's victim is not the bot's victim. A pet that cannot or will not take it (it cannot reach the +// mob, is out of range, a boss immune to it, a stale snapshot) kept that true on every tick (live MC Gehennas 2026-10-08, two +// warlocks stuck up to 83 s). A new victim is ordered at once; the same victim again only after kPetAttackGapMs. #pragma once #include #include #include +#include "ObjectGuid.h" + namespace Playerbot::AplPet { constexpr uint32_t kPetAttackGapMs = 3000; -inline std::mutex& Mutex() { static std::mutex m; return m; } -inline std::unordered_map& LastOrderMs() { static std::unordered_map m; return m; } +struct LastOrder { ObjectGuid target; uint32_t ms = 0; }; -// True when no pet_attack order went out for this bot in the last kPetAttackGapMs. -inline bool PetAttackDue(uint64_t guid, uint32_t now_ms) +inline std::mutex& Mutex() { static std::mutex m; return m; } +inline std::unordered_map& LastOrders() { static std::unordered_map m; return m; } + +// True when this bot has not ordered its pet onto `target` in the last kPetAttackGapMs. +inline bool PetAttackDue(uint64_t guid, ObjectGuid target, uint32_t now_ms) { std::lock_guard lk(Mutex()); - auto const it = LastOrderMs().find(guid); - return it == LastOrderMs().end() || uint32_t(now_ms - it->second) >= kPetAttackGapMs; + auto const it = LastOrders().find(guid); + return it == LastOrders().end() || it->second.target != target || uint32_t(now_ms - it->second.ms) >= kPetAttackGapMs; } -inline void NotePetAttack(uint64_t guid, uint32_t now_ms) +inline void NotePetAttack(uint64_t guid, ObjectGuid target, uint32_t now_ms) { std::lock_guard lk(Mutex()); - LastOrderMs()[guid] = now_ms; + LastOrders()[guid] = LastOrder{target, now_ms}; } } // namespace Playerbot::AplPet diff --git a/src/modules/PlayerbotV2/Combat/Apl/Apl_Baseline.cpp b/src/modules/PlayerbotV2/Combat/Apl/Apl_Baseline.cpp index 492da25484..5a11b16759 100644 --- a/src/modules/PlayerbotV2/Combat/Apl/Apl_Baseline.cpp +++ b/src/modules/PlayerbotV2/Combat/Apl/Apl_Baseline.cpp @@ -2,7 +2,7 @@ // (spec=0) for L1-9 pre-spec characters and bots with corrupt / // missing ChrSpecialization. Per-class rule sets live in the // sibling Apl_Baseline_.cpp files; this file is now just -// the aggregator that wires the 13 per-class registration calls +// the aggregator that wires the 4 non-vanilla per-class registration calls // into a single entry point that ApRegistry::RegisterAllRotations // invokes at module init. // @@ -16,17 +16,8 @@ namespace Playerbot::Combat { void RegisterApl_Baseline() { - RegisterApl_Baseline_Warrior(); - RegisterApl_Baseline_Paladin(); - RegisterApl_Baseline_Hunter(); - RegisterApl_Baseline_Rogue(); - RegisterApl_Baseline_Priest(); RegisterApl_Baseline_DK(); - RegisterApl_Baseline_Shaman(); - RegisterApl_Baseline_Mage(); - RegisterApl_Baseline_Warlock(); RegisterApl_Baseline_Monk(); - RegisterApl_Baseline_Druid(); RegisterApl_Baseline_DH(); RegisterApl_Baseline_Evoker(); } diff --git a/src/modules/PlayerbotV2/Combat/Apl/Apl_Baseline_Common.h b/src/modules/PlayerbotV2/Combat/Apl/Apl_Baseline_Common.h index 015041860b..befa7afeb6 100644 --- a/src/modules/PlayerbotV2/Combat/Apl/Apl_Baseline_Common.h +++ b/src/modules/PlayerbotV2/Combat/Apl/Apl_Baseline_Common.h @@ -4,7 +4,7 @@ // // Each class baseline is registered separately via its own // RegisterApl_Baseline_() function. Apl_Baseline.cpp owns the -// top-level RegisterApl_Baseline() aggregator that fans out to all 13. +// top-level RegisterApl_Baseline() aggregator that fans out to the non-vanilla classes (the nine vanilla ones have only the Classic rotations). // // Why this split: the previous monolithic Apl_Baseline.cpp (~1180 lines // covering all 13 classes) made parallel coverage work impossible — @@ -190,17 +190,8 @@ inline void DoAutoAttack(ApPredicateContext const& ctx, BotIntentEmitter& e) // Per-class registration entry points — called by RegisterApl_Baseline() // in Apl_Baseline.cpp. Each per-class .cpp defines exactly one of these. -void RegisterApl_Baseline_Warrior(); -void RegisterApl_Baseline_Paladin(); -void RegisterApl_Baseline_Hunter(); -void RegisterApl_Baseline_Rogue(); -void RegisterApl_Baseline_Priest(); void RegisterApl_Baseline_DK(); -void RegisterApl_Baseline_Shaman(); -void RegisterApl_Baseline_Mage(); -void RegisterApl_Baseline_Warlock(); void RegisterApl_Baseline_Monk(); -void RegisterApl_Baseline_Druid(); void RegisterApl_Baseline_DH(); void RegisterApl_Baseline_Evoker(); diff --git a/src/modules/PlayerbotV2/Combat/Apl/Apl_Baseline_Druid.cpp b/src/modules/PlayerbotV2/Combat/Apl/Apl_Baseline_Druid.cpp deleted file mode 100644 index 5878103e7e..0000000000 --- a/src/modules/PlayerbotV2/Combat/Apl/Apl_Baseline_Druid.cpp +++ /dev/null @@ -1,347 +0,0 @@ -// Apl_Baseline_Druid.cpp — baseline rotation for class CLASS_DRUID (spec=0). -// Extracted from the monolithic Apl_Baseline.cpp on the split refactor; -// future edits go here exclusively. See Apl_Baseline_Common.h for the -// shared helpers + rule macros. -// -// Form-management strategy (THE point of this file) -// ------------------------------------------------ -// Unlike the other 12 baseline rotations, the druid baseline is a -// FORM-AWARE state machine. Cat Form is the optimal leveling form: it -// stacks armor, gives bleed CP builders, has a stealth opener, and lets -// every druid (Balance / Feral / Guardian / Resto, any level) contribute -// meaningful melee damage even before they pick a spec. Sitting in -// caster form auto-attacking with a staff is what the previous baseline -// did and it was wrong. The user explicitly called that out. -// -// WoW 12.1.0.69587 kit note: the baseline may only use class-baseline -// SkillLineAbility spells. Rake, Rip, Tiger's Fury, Swipe, Rejuvenation -// and Cenarion Ward are talents (or gone) in Midnight, so they belong to -// the spec files; the baseline cat kit is Cat Form / Prowl / Shred / -// Ferocious Bite / Thrash. -// -// Rules that work IN CAT FORM (form-independent or cat-only): -// * Barkskin - INSTANT, off-GCD, no shapeshift gate (L10). -// * Cat Form entry - the shapeshift cast itself; only fires -// when not yet in cat, not mounted, not -// flying, and we have a live target (or -// we're OOC and want to Prowl). -// * Prowl - cat-form stealth opener, OOC only. -// * Shred - cat-form CP builder. -// * Ferocious Bite - cat-form 4-5 CP finisher (the only baseline -// finisher in 12.1). -// * Thrash (cat) - cat-form AoE bleed (3+ enemies). -// * Auto attack - works in any form. -// -// Rules that DROP cat form when they fire (caster-form spells): -// * Regrowth (panic) — emergency hard-cast at <=50%; bot will be -// back in caster form afterwards, and the -// next tick's Cat Form rule will re-shift. -// * Mark of the Wild - only fires OOC, so the form drop is cheap -// (we'll re-enter cat on pull). -// * Wrath / Moonfire — caster-form fillers ONLY used if the bot -// somehow has no Cat Form known (very low -// level pre-L1 racial?, polymorphed, -// aura-stripped). Gated on "not in cat" so -// they don't pop us out of cat mid-pull. -// * Entangling Roots — caster-form CC, same "not in cat" gate. -// -// Avoidance design choices -// ------------------------ -// - **Do not shapeshift while mounted or flying.** Casting Cat Form on a -// mount dismounts and then shifts — fine in PvP burst but disastrous -// when crossing zones. We gate on `!is_mounted && !is_flying`. -// - **Do not refresh Mark of the Wild mid-combat.** It requires caster -// form, which would drop the cat-form bleeds + reset Prowl. Gated on -// `!in_combat`. -// - **No HoT upkeep**: Rejuvenation is a class talent in 12.1 (the spec -// files own it). Emergency healing is Regrowth's job at <=50% HP. -// - **Regrowth panic IS allowed to drop cat.** Dying in cat with full CP -// is worse than spending a GCD healing and re-shifting on the next -// tick. The Cat Form re-entry rule sits high in priority so the -// transition costs at most ~1.5s of caster-form exposure. -// - **Caster-form damage rules (Wrath / Moonfire / Roots) are gated on -// `!has_aura(CAT_FORM)`.** They only run when we genuinely can't get -// into cat (no spell known, sub-L1 race-gate, debuff stripping form). -// -// What we DON'T cover (intentionally): -// * Bear Form / Mangle / Growl / Maul — tank specialty. Guardian spec -// owns the bear stance + tank kit; the baseline is for any druid. -// * Predatory Swiftness instant Regrowth proc - requires aura tracking -// past baseline scope; Feral spec handles it. -// * Rake / Rip / Tiger's Fury / Swipe / Rejuvenation / Cenarion Ward - -// class or spec talents in 12.1 (Cenarion Ward is gone entirely); -// not in the class baseline list, so the spec rotations own them. -// * Combo-point-aware finishers below 4 CP - the baseline treats -// Ferocious Bite as "4-5 CP go", not "5 CP only". Feral is stricter. -// * Tank-form swap on heavy hits — Feral does that; baseline can't -// assume the bot has bear-form rotations to run after the swap. -// -// To audit coverage: -// python src/modules/PlayerbotV2/tools/baseline_coverage_audit.py - -#include "Apl_Baseline_Common.h" - -namespace Playerbot::Combat { - -namespace { - -using ::Playerbot::Combat::baseline_common::HasLiveTarget; -using ::Playerbot::Combat::baseline_common::AlwaysInCombat; -using ::Playerbot::Combat::baseline_common::DoAutoAttack; - -// ---- Spell IDs (WoW 12.1.0.69587, class baseline SkillLineAbility list) ---- -constexpr uint32 CAT_FORM = 768; // L5 shapeshift; aura id == spell id -constexpr uint32 PROWL = 5215; // L13 cat-form OOC stealth -constexpr uint32 SHRED = 5221; // L5 cat-form CP builder -constexpr uint32 FEROCIOUS_BITE = 22568; // L7 cat-form 4-5 CP finisher -constexpr uint32 THRASH_CAT = 106830; // cat-form AoE bleed (cast id) -constexpr uint32 THRASH_CAT_DOT = 405233; // cat Thrash bleed aura - -constexpr uint32 WRATH = 5176; // L1 caster-form filler nuke -constexpr uint32 MOONFIRE = 8921; // L2 caster-form DoT (cast id) -constexpr uint32 MOONFIRE_DOT = 164812; // Moonfire periodic aura -constexpr uint32 ENTANGLING_ROOTS = 339; // L4 caster-form root CC -constexpr uint32 REGROWTH = 8936; // L3 caster-form panic heal -constexpr uint32 MARK_OF_THE_WILD = 1126; // L9 caster-form buff -constexpr uint32 BARKSKIN = 22812; // L10 form-independent, off-GCD, 20% DR - -// Combo points / energy live in the snapshot power array. Indices match -// the WoW 12.0 power enum used by Apl_Druid_Feral.cpp. -constexpr uint8 POWER_COMBO_POINTS_IDX = 4; -constexpr uint8 POWER_ENERGY_IDX = 3; - -inline bool InCatForm(ApPredicateContext const& ctx) -{ - return ctx.bot.has_aura(CAT_FORM); -} - -inline bool CanShapeshiftNow(ApPredicateContext const& ctx) -{ - // No shifting while mounted or flying — would either dismount + shift - // (long zone crossings) or worse, kill flight and drop us. - auto const& mv = ctx.bot.raw().movement; - if (mv.is_mounted) return false; - if (mv.is_flying) return false; - return true; -} - -inline uint8 ComboPoints(ApPredicateContext const& ctx) -{ - return static_cast(ctx.bot.power(POWER_COMBO_POINTS_IDX)); -} - -// ---- Defensive (form-independent, off-GCD) ---- -// Barkskin: 20% damage reduction, off-GCD, fires from any form. Threshold -// 60% — slightly more eager than the generic 50% since the druid baseline -// has no other big DR cooldown. -BASELINE_DEFENSIVE_RULE(Barkskin, BARKSKIN, 60) - -// ---- Emergency hard-cast heal (Regrowth) ---- -// Regrowth is the only direct heal a druid has at low level. It REQUIRES -// caster form — casting it shifts us out of cat. That's an accepted cost -// at <=50% HP: dying with full CP is worse than spending a GCD healing -// and re-shifting next tick. The Cat Form rule sits high in priority so -// re-entry costs at most ~1.5s of caster-form exposure. -bool ShouldRegrowthSelfPanic(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(REGROWTH)) return false; - if (ctx.bot.hp_pct() > 50) return false; - return true; -} -void DoRegrowthSelfPanic(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(REGROWTH, ctx.bot.raw().guid); -} - -// ---- Buff (Mark of the Wild) ---- -// Mark requires caster form. Gate on `!in_combat` so we don't shift out -// of cat mid-pull just to refresh a buff. The aura is hours long; the -// "refresh OOC between pulls" cadence is fine. -bool ShouldMarkOfTheWild(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(MARK_OF_THE_WILD)) return false; - if (!ctx.bot.is_ready(MARK_OF_THE_WILD)) return false; - if (ctx.bot.in_combat()) return false; - return ctx.bot.find_aura(MARK_OF_THE_WILD, ObjectGuid::Empty) == nullptr; -} -void DoMarkOfTheWild(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(MARK_OF_THE_WILD, ctx.bot.raw().guid); -} - -// ---- Form entry: Cat Form ---- -// Fires when: -// * we know the spell, -// * we aren't already in cat, -// * we have a live target (combat ramp) OR we're OOC and could Prowl, -// * we can safely shapeshift (not mounted, not flying). -// We deliberately allow shifting OOC too — it lets Prowl come up before -// the bot engages, and keeps the bot in cat form between pulls so we -// don't pay the 1.5s shift-back tax on every engage. -bool ShouldCatForm(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(CAT_FORM)) return false; - if (InCatForm(ctx)) return false; - if (!CanShapeshiftNow(ctx)) return false; - return true; -} -void DoCatForm(ApPredicateContext const&, BotIntentEmitter& e) -{ - e.cast(CAT_FORM); -} - -// ---- Prowl (OOC stealth opener) ---- -// Only useful when: -// * in cat form, -// * out of combat (Prowl breaks on damage / combat), -// * not already prowling. -// Skipped while mounted (would have dropped cat already) — covered by -// the in-cat gate. -bool ShouldProwl(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(PROWL)) return false; - if (!ctx.bot.is_ready(PROWL)) return false; - if (!InCatForm(ctx)) return false; - if (ctx.bot.in_combat()) return false; - return !ctx.bot.has_aura(PROWL); -} -void DoProwl(ApPredicateContext const&, BotIntentEmitter& e) -{ - e.cast(PROWL); -} - -// ---- Ferocious Bite (cat-form 4-5 CP finisher) ---- -// The only finisher in the 12.1 baseline kit (Rip is a class talent that -// the Feral file owns). Baseline: 4+ CP. -bool ShouldFerociousBite(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(FEROCIOUS_BITE)) return false; - if (!ctx.bot.is_ready(FEROCIOUS_BITE)) return false; - if (!InCatForm(ctx)) return false; - if (ComboPoints(ctx) < 4) return false; - return true; -} -void DoFerociousBite(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(FEROCIOUS_BITE, ctx.bot.victim()); -} - -// ---- Thrash (cat-form AoE bleed, 3+ enemies) ---- -// Applies a bleed to all nearby enemies; refresh when missing or short. -bool ShouldThrashCat(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(THRASH_CAT)) return false; - if (!InCatForm(ctx)) return false; - if (ctx.bot.enemies_within(8.0f) < 3) return false; - AuraEntry const* a = ctx.bot.find_aura(THRASH_CAT_DOT, ctx.bot.victim()); - if (a && a->remaining.count() > 4500) return false; - return true; -} -void DoThrashCat(ApPredicateContext const&, BotIntentEmitter& e) -{ - e.cast(THRASH_CAT); -} - -// ---- Shred (cat-form CP filler) ---- -// Primary cat-form filler. Energy floor of 40 mirrors Feral; below that -// the auto-attack rule will tick energy back up. -bool ShouldShred(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(SHRED)) return false; - if (!InCatForm(ctx)) return false; - return ctx.bot.power(POWER_ENERGY_IDX) >= 40; -} -void DoShred(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(SHRED, ctx.bot.victim()); -} - -// ---- Caster-form fallbacks (only when NOT in cat) ---- -// These exist for the edge cases where the bot can't be in cat form: -// pre-Cat-Form level (very early class quests for non-druid starting -// races), polymorphed, aura-stripped, or just shapeshift-dispelled. They -// are gated on `!InCatForm` so they don't fire while we're in cat (which -// would either fail to cast or — worse — shift us out). - -bool ShouldWrathCaster(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(WRATH)) return false; - if (InCatForm(ctx)) return false; - return true; -} -void DoWrathCaster(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(WRATH, ctx.bot.victim()); -} - -bool ShouldMoonfireCaster(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(MOONFIRE)) return false; - if (!ctx.bot.is_ready(MOONFIRE)) return false; - if (InCatForm(ctx)) return false; - return ctx.bot.find_aura(MOONFIRE_DOT, ctx.bot.victim()) == nullptr; -} -void DoMoonfireCaster(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(MOONFIRE, ctx.bot.victim()); -} - -bool ShouldEntanglingRoots(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(ENTANGLING_ROOTS)) return false; - if (!ctx.bot.is_ready(ENTANGLING_ROOTS)) return false; - if (InCatForm(ctx)) return false; // caster-form only - if (ctx.bot.enemies_within(8.0f) == 0) return false; - return ctx.bot.find_aura(ENTANGLING_ROOTS, ctx.bot.victim()) == nullptr; -} -void DoEntanglingRoots(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(ENTANGLING_ROOTS, ctx.bot.victim()); -} - -// ---- Rule table ---- -// Order rationale (top = highest priority): -// 1. Barkskin - off-GCD panic DR, fires from any form. -// 2. RegrowthSelfPanic - emergency hard-cast heal at <=50%. -// DROPS cat form; accepted cost vs. dying. -// 3. MarkOfTheWild - OOC buff maintenance (caster form). -// 4. CatForm - re-enter cat ASAP after any caster-form -// spell or fresh login. High priority so the -// caster-form-exposure window is short. -// 5. Prowl - OOC stealth opener once in cat. -// 6. ThrashCat - AoE bleed at 3+ targets. -// 7. FerociousBite - 4-5 CP direct finisher. -// 8. Shred - CP builder / filler. -// 9. EntanglingRoots - caster-form CC fallback (only if not cat). -// 10. MoonfireCaster - caster-form DoT fallback. -// 11. WrathCaster - caster-form nuke fallback. -// 12. AutoAttack - no-mana floor (works in cat). -ApRule const baseline_druid_kRules[] = { - { ShouldBarkskin, DoBarkskin, "Barkskin (<60% panic DR)" }, - { ShouldRegrowthSelfPanic, DoRegrowthSelfPanic, "Regrowth (<=50% self panic)" }, - { ShouldMarkOfTheWild, DoMarkOfTheWild, "Mark of the Wild (OOC buff)" }, - { ShouldCatForm, DoCatForm, "Cat Form (form entry)" }, - { ShouldProwl, DoProwl, "Prowl (OOC stealth opener)" }, - { ShouldThrashCat, DoThrashCat, "Thrash cat (3+ AoE bleed)" }, - { ShouldFerociousBite, DoFerociousBite, "Ferocious Bite (4+ CP)" }, - { ShouldShred, DoShred, "Shred (CP filler)" }, - { ShouldEntanglingRoots, DoEntanglingRoots, "Entangling Roots (caster CC)" }, - { ShouldMoonfireCaster, DoMoonfireCaster, "Moonfire (caster DoT fallback)" }, - { ShouldWrathCaster, DoWrathCaster, "Wrath (caster nuke fallback)" }, - { AlwaysInCombat, DoAutoAttack, "Auto attack" }, -}; - -} // anonymous - -void RegisterApl_Baseline_Druid() -{ - RegisterRotation(CLASS_DRUID, 0, ApRotation{baseline_druid_kRules}); -} - -} // namespace Playerbot::Combat diff --git a/src/modules/PlayerbotV2/Combat/Apl/Apl_Baseline_Hunter.cpp b/src/modules/PlayerbotV2/Combat/Apl/Apl_Baseline_Hunter.cpp deleted file mode 100644 index 8bc8bf8fa3..0000000000 --- a/src/modules/PlayerbotV2/Combat/Apl/Apl_Baseline_Hunter.cpp +++ /dev/null @@ -1,290 +0,0 @@ -// Apl_Baseline_Hunter.cpp — baseline rotation for class CLASS_HUNTER (spec=0). Extracted from the monolithic Apl_Baseline.cpp on the split refactor; future edits go -// here exclusively. See Apl_Baseline_Common.h for the -// shared helpers + rule macros. -// -// To audit coverage: -// python src/modules/PlayerbotV2/tools/baseline_coverage_audit.py - -#include "Apl_Baseline_Common.h" - -namespace Playerbot::Combat { - -namespace { - -using ::Playerbot::Combat::baseline_common::HasLiveTarget; -using ::Playerbot::Combat::baseline_common::AlwaysInCombat; -using ::Playerbot::Combat::baseline_common::DoAutoAttack; - -// Target version: WoW 12.1.0.69587 (Midnight). Classic-era fallback IDs -// were removed 2026-05-21 per user directive ("we do not develop -// any legacy versions"). If a Midnight bot is observed without the -// retail ID in its spellbook, that's a data-layer issue (db2 / -// SkillLineAbility) to fix in the data, not by reintroducing -// classic fallbacks here. -// -// Validated spell IDs (WoW 12.1.0.69587, Hunter class baseline -// SkillLineAbility list - every id here is class-wide, learn level <= 9): -// 56641 Steady Shot (L1) | 185358 Arcane Shot (L2) | 195645 Wing Clip (L3) -// 781 Disengage (L4) | 136 Mend Pet (L5) | 883 Call Pet 1 (L5) -// 982 Revive Pet (L5) | 5384 Feign Death (L6) | 257284 Hunter's Mark (L7) -// 186265 Aspect of Turtle(L8)| 109304 Exhilaration (L9) -// -// Skipped (deliberate, 12.1): Aimed Shot (19434) is a Marksmanship spec -// talent, Kill Command (34026) a Beast Mastery spec talent, Serpent Sting -// (271788) no longer exists for any Hunter spec, Concussive Shot (5116) -// and Binding Shot (109248; the old 117526 was its stun aura) are class -// TALENTS - none of them is class baseline, so they live in the spec -// rotations only. Freezing Trap (187650) / Aspect of the Cheetah (186257) -// are L10 / movement utility outside the combat ladder. -constexpr uint32 ARCANE_SHOT_IDS[] = { 185358 }; -constexpr uint32 STEADY_SHOT_IDS[] = { 56641 }; -constexpr uint32 HUNTERS_MARK_IDS[] = { 257284 }; -constexpr uint32 WING_CLIP_IDS[] = { 195645 }; -constexpr uint32 DISENGAGE_IDS[] = { 781 }; -constexpr uint32 FEIGN_DEATH_IDS[] = { 5384 }; -constexpr uint32 MEND_PET_IDS[] = { 136 }; -constexpr uint32 CALL_PET_1_IDS[] = { 883 }; -constexpr uint32 REVIVE_PET_IDS[] = { 982 }; -// Pre-L10 baseline coverage. -// Aspect of the Turtle (L8, 186265): 8s damage/CC immunity, panic-tier -// CD - the strongest defensive a baseline hunter owns before specs -// unlock. Exhilaration (L9, 109304): self+pet heal CD (~30% HP/2min). -constexpr uint32 ASPECT_TURTLE_ID = 186265; -constexpr uint32 EXHILARATION_ID = 109304; - -// First candidate the bot knows + is ready to cast. 0 = none. -inline uint32 FirstReady(ApPredicateContext const& ctx, std::span ids) -{ - for (uint32 sid : ids) if (ctx.bot.is_ready(sid)) return sid; - return 0; -} -// First candidate the bot has in its spellbook (ignores cooldown / GCD). -// Used for predicates that need to check aura presence (Hunter's Mark) -// to decide whether to refresh before we care if it's ready. -inline uint32 FirstKnown(ApPredicateContext const& ctx, std::span ids) -{ - for (uint32 sid : ids) if (ctx.bot.knows_spell(sid)) return sid; - return 0; -} - -// ---- Pet maintenance ---- -// Revive Pet: only when the bot HAD a pet that's now dead. If pet_guid is -// empty the bot never tamed/summoned one, and casting Revive Pet does -// nothing — the rule then fires every tick (~5Hz) and starves every -// downstream rule of evaluation. See log audit 2026-05-21: spell 982 -// attempted 22,819 times across the fleet, vs 0 Arcane Shot. -bool ShouldRevivePet(ApPredicateContext const& ctx) -{ - if (ctx.bot.pet_guid().IsEmpty()) return false; // no pet at all - if (ctx.bot.has_pet()) return false; // pet alive - return FirstReady(ctx, REVIVE_PET_IDS) != 0; -} -void DoRevivePet(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (uint32 sid = FirstReady(ctx, REVIVE_PET_IDS)) e.cast(sid, ObjectGuid::Empty); -} -// Call Pet 1: out-of-combat summon when an empty pet slot points at a -// stabled beast. Only fires if there's actually a pet entry in the -// active stable slot (slot_kind==0 with a non-zero entry id). -// has_stabled_pets() returns true for ANY non-active slot too, which -// for low-level Hunters that never tamed a beast was firing Call Pet -// every OOC tick — server rejected with SPELL_FAILED_NO_PET (32), the -// rule re-fired, 367 wasted casts observed pre-fix. Per-bot cooldown -// on retry prevents log spam after the gate tightens. -bool ShouldCallPet(ApPredicateContext const& ctx) -{ - if (ctx.bot.in_combat()) return false; - if (!ctx.bot.pet_guid().IsEmpty()) return false; - if (!ctx.bot.knows_spell(CALL_PET_1_IDS[0])) return false; - // Require a stable_pets entry that *can* be summoned — slot_kind 0 - // (active slot) with a real creature entry. Anything else is a - // dead record from a prior pet that got dismissed/abandoned. - bool has_summonable = false; - for (auto const& sp : ctx.bot.stable_pets()) - { - if (sp.slot_kind == 0 && sp.creature_id != 0) - { has_summonable = true; break; } - } - if (!has_summonable) return false; - return ctx.bot.is_ready(CALL_PET_1_IDS[0]); -} -void DoCallPet(ApPredicateContext const&, BotIntentEmitter& e) -{ - e.cast(CALL_PET_1_IDS[0], ObjectGuid::Empty); -} -bool ShouldMendPet(ApPredicateContext const& ctx) -{ - if (!ctx.bot.has_pet()) return false; - if (ctx.bot.pet_hp_pct() >= 60) return false; - return FirstReady(ctx, MEND_PET_IDS) != 0; -} -void DoMendPet(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (uint32 sid = FirstReady(ctx, MEND_PET_IDS)) e.cast(sid, ObjectGuid::Empty); -} - -// ---- Survival ---- -// Aspect of the Turtle: 8s total damage + CC immunity, ~3min CD. This -// is the strongest panic button a hunter has — it stops everything -// (PvE crit spike, mob enrage, PvP burst) for 8 seconds. Fires at -// ≤20% HP. Placed FIRST in the rule list so it pre-empts every other -// decision (including Disengage / Feign Death which both leave the -// bot vulnerable mid-animation). Spell 186265 is granted at L8. -bool ShouldAspectTurtle(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (ctx.bot.hp_pct() > 20) return false; - if (!ctx.bot.knows_spell(ASPECT_TURTLE_ID)) return false; - return ctx.bot.is_ready(ASPECT_TURTLE_ID); -} -void DoAspectTurtle(ApPredicateContext const&, BotIntentEmitter& e) -{ - e.cast(ASPECT_TURTLE_ID, ObjectGuid::Empty); -} - -// Exhilaration: ~30% HP self+pet heal on a ~2min CD. Sits one tier -// below Aspect of the Turtle — fires at ≤50% HP so it lands before -// the bot enters the panic-CD bracket. Pet co-heal is a bonus (saves -// a Mend Pet GCD when both are wounded). Spell 109304 is granted at L9. -bool ShouldExhilaration(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (ctx.bot.hp_pct() > 50) return false; - if (!ctx.bot.knows_spell(EXHILARATION_ID)) return false; - return ctx.bot.is_ready(EXHILARATION_ID); -} -void DoExhilaration(ApPredicateContext const&, BotIntentEmitter& e) -{ - e.cast(EXHILARATION_ID, ObjectGuid::Empty); -} - -// Disengage: panic-kite. Fires when a melee-range enemy is adjacent AND -// bot is below 70% HP. Once per CD (~20s). Without this gate L1-9 -// hunters never used Disengage — the spec rotations only triggered on -// 2+ melee within 8y, almost never true in starter zones. -bool ShouldDisengage(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (ctx.bot.enemies_within(5.0f) == 0) return false; - if (ctx.bot.hp_pct() >= 70) return false; - return FirstReady(ctx, DISENGAGE_IDS) != 0; -} -void DoDisengage(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (uint32 sid = FirstReady(ctx, DISENGAGE_IDS)) e.cast(sid, ObjectGuid::Empty); -} - -// Feign Death: emergency aggro drop. Hunters' panic-bail when Disengage -// is on cooldown OR doesn't help (kited backwards into wall, multiple -// ranged attackers). Drops player from all PvE creature threat tables, -// making it the strongest survivability tool a low-level hunter has. -// Fires at 25% HP with at least one nearby enemy + Disengage NOT -// available (so the two CDs are alternated, not blown simultaneously). -bool ShouldFeignDeath(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (ctx.bot.hp_pct() >= 25) return false; - if (ctx.bot.enemies_within(40.0f) == 0) return false; - // Skip in PvP — Feign Death is broken by player damage so it just - // wastes the cooldown. Battlegrounds + duels gated here. - if (ctx.bot.is_pvp()) return false; - if (FirstReady(ctx, DISENGAGE_IDS) != 0) return false; // prefer Disengage if up - return FirstReady(ctx, FEIGN_DEATH_IDS) != 0; -} -void DoFeignDeath(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (uint32 sid = FirstReady(ctx, FEIGN_DEATH_IDS)) e.cast(sid, ObjectGuid::Empty); -} - -// ---- Slow / utility ---- -// Wing Clip (195645, L3, 20 focus, 5y): melee slow, still class baseline -// in 12.1. Fires when an enemy is sitting on top of the bot (<=5y) and -// the slow isn't already running, so the bot can back off to shot range. -bool ShouldWingClip(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (ctx.bot.enemies_within(5.0f) == 0) return false; - uint32 known = FirstKnown(ctx, WING_CLIP_IDS); - if (!known) return false; - if (ctx.bot.find_aura(known, ctx.bot.victim())) return false; // still slowed - constexpr uint8 POWER_FOCUS_IDX = 2; - if (ctx.bot.power(POWER_FOCUS_IDX) < 20) return false; - return FirstReady(ctx, WING_CLIP_IDS) != 0; -} -void DoWingClip(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (uint32 sid = FirstReady(ctx, WING_CLIP_IDS)) e.cast(sid, ctx.bot.victim()); -} - -// ---- Debuff opener ---- -bool ShouldHuntersMark(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - uint32 known = FirstKnown(ctx, HUNTERS_MARK_IDS); - if (!known) return false; - if (ctx.bot.find_aura(known, ctx.bot.victim())) return false; // already marked - return FirstReady(ctx, HUNTERS_MARK_IDS) != 0; -} -void DoHuntersMark(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (uint32 sid = FirstReady(ctx, HUNTERS_MARK_IDS)) e.cast(sid, ctx.bot.victim()); -} - -// ---- Damage rotation ---- -// Each one is "have-target + ready + (resource check)". Falls through -// to the next on cooldown so the turn is never wasted on a queued spell. -// Arcane Shot costs 40 focus. The bare is_ready check let this rule -// claim the tick at ANY focus level - the cast then bounced off -// SPELL_FAILED_NO_POWER server-side and (pre-B02) starved Steady Shot, -// the generator sitting one slot below. Gate on affordability. (Spec -// spenders such as Kill Command are spec talents, not class baseline, -// so the pre-L10 ladder has no reserve to keep.) -bool ShouldArcaneShot(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - constexpr uint8 POWER_FOCUS_IDX = 2; - constexpr int32 ARCANE_COST = 40; - if (ctx.bot.power(POWER_FOCUS_IDX) < ARCANE_COST) return false; - return FirstReady(ctx, ARCANE_SHOT_IDS) != 0; -} -void DoArcaneShot(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (uint32 sid = FirstReady(ctx, ARCANE_SHOT_IDS)) e.cast(sid, ctx.bot.victim()); -} -bool ShouldSteadyShot(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - return FirstReady(ctx, STEADY_SHOT_IDS) != 0; -} -void DoSteadyShot(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (uint32 sid = FirstReady(ctx, STEADY_SHOT_IDS)) e.cast(sid, ctx.bot.victim()); -} - -ApRule const baseline_hunter_kRules[] = { - // Top-priority panic: 8s full immunity pre-empts every other decision - // so the bot doesn't bleed through a CD animation at ≤20% HP. - { ShouldAspectTurtle, DoAspectTurtle, "Aspect of the Turtle (<=20%)"}, - { ShouldCallPet, DoCallPet, "Call Pet (stabled, OOC)" }, - { ShouldRevivePet, DoRevivePet, "Revive Pet (dead pet only)" }, - { ShouldMendPet, DoMendPet, "Mend Pet (<60%)" }, - { ShouldDisengage, DoDisengage, "Disengage (panic kite)" }, - // Exhilaration sits in the Disengage/Feign Death tier — fires at - // ≤50% HP so it lands before the bot enters the deeper panic CDs. - { ShouldExhilaration, DoExhilaration, "Exhilaration (<=50%)" }, - { ShouldFeignDeath, DoFeignDeath, "Feign Death (emergency)" }, - { ShouldWingClip, DoWingClip, "Wing Clip (melee slow)" }, - { ShouldHuntersMark, DoHuntersMark, "Hunter's Mark (debuff)" }, - { ShouldArcaneShot, DoArcaneShot, "Arcane Shot" }, - { ShouldSteadyShot, DoSteadyShot, "Steady Shot (filler)" }, - { AlwaysInCombat, DoAutoAttack, "Auto attack" }, -}; - -} // anonymous - -void RegisterApl_Baseline_Hunter() -{ - RegisterRotation(CLASS_HUNTER, 0, ApRotation{baseline_hunter_kRules}); -} - -} // namespace Playerbot::Combat diff --git a/src/modules/PlayerbotV2/Combat/Apl/Apl_Baseline_Mage.cpp b/src/modules/PlayerbotV2/Combat/Apl/Apl_Baseline_Mage.cpp deleted file mode 100644 index adaab8e26a..0000000000 --- a/src/modules/PlayerbotV2/Combat/Apl/Apl_Baseline_Mage.cpp +++ /dev/null @@ -1,205 +0,0 @@ -// Apl_Baseline_Mage.cpp — baseline rotation for class CLASS_MAGE (spec=0). Extracted from the monolithic Apl_Baseline.cpp on the split refactor; future edits go -// here exclusively. See Apl_Baseline_Common.h for the -// shared helpers + rule macros. -// -// To audit coverage: -// python src/modules/PlayerbotV2/tools/baseline_coverage_audit.py -// -// ---- Validated spell IDs (WoW 12.1.0.69587, Mage class baseline) ---- -// 116 Frostbolt (L1) 319836 Fire Blast (L2) -// 122 Frost Nova (L3) 1953 Blink (L4) -// 1449 Arcane Explosion (L6) 2139 Counterspell (L7) -// 1459 Arcane Intellect (L8) 120 Cone of Cold (L18) -// 61025 / 61780 / 126819 / 161353 / 161354 / 161355 Polymorph (L1) -// 118 Polymorph (L10) -// -// ---- Skipped spells (and why) ---- -// 133 Fireball - Fire SPEC spell (overrides Frostbolt at L10); -// not in the class baseline list. -// 45438 Ice Block - class-tree talent, not baseline. -// 55342 Mirror Image - class-tree talent, not baseline. -// 80353 Time Warp - L49 baseline; boss-gated group CD lives in the -// spec rotations, baseline stays lean. - -#include "Apl_Baseline_Common.h" -#include "ApCrowdControl.h" // PickOffTargetCC / CanBeCCd / ApInPvp - -#include - -namespace Playerbot::Combat { - -namespace { - -using ::Playerbot::Combat::baseline_common::HasLiveTarget; -using ::Playerbot::Combat::baseline_common::AlwaysInCombat; -using ::Playerbot::Combat::baseline_common::DoAutoAttack; - -constexpr uint32 FROSTBOLT = 116; // L1 -constexpr uint32 ARCANE_EXPLOSION = 1449; // L6 - PBAoE -constexpr uint32 FROST_NOVA = 122; // L3 - 8y root -constexpr uint32 COUNTERSPELL = 2139; // L7 -constexpr uint32 BLINK = 1953; // L4 -constexpr uint32 FIRE_BLAST = 319836; // L2 - core instant (baseline ID) -constexpr uint32 ARCANE_INTELLECT = 1459; // L8 - group/self intellect buff -constexpr uint32 CONE_OF_COLD = 120; // L18 - frontal cone + slow - -// Polymorph variants (12.1.0.69587 class baseline). Different spell IDs -// encode different visuals (serpent / turkey / porcupine / etc.) - all -// share the L1 unlock + functionally identical CC; 118 (sheep) is the L10 -// form. Pick the first ID the bot has trained; that's what their data -// layer (SkillLineAbility) granted. Pattern lifted from the hunter -// baseline *_IDS arrays. -constexpr uint32 POLYMORPH_IDS[] = { 118, 61025, 61780, 126819, 161353, 161354, 161355 }; - -// First candidate the bot knows + is ready to cast. 0 = none. -// Same helper shape as Apl_Baseline_Hunter.cpp's FirstReady. -inline uint32 FirstReadyPoly(ApPredicateContext const& ctx, std::span ids) -{ - for (uint32 sid : ids) - if (ctx.bot.knows_spell(sid) && ctx.bot.is_ready(sid)) - return sid; - return 0; -} - -BASELINE_SPELL_RULE(Frostbolt, FROSTBOLT) -BASELINE_INTERRUPT_RULE(Counterspell, COUNTERSPELL) - -BASELINE_SELF_RULE(FrostNova, FROST_NOVA) -BASELINE_SELF_RULE(Blink, BLINK) -BASELINE_SELF_RULE(ArcaneExplosion, ARCANE_EXPLOSION) -BASELINE_SELF_RULE(ConeOfCold, CONE_OF_COLD) - -// L8 group/self buff. Retail 1459 is a self-aura that auto-shares to -// party members via Magic-school intellect aura — casting on self -// satisfies group coverage. Refresh-aware via the macro's find_aura -// gate (re-fires only when the aura drops). -BASELINE_SELFBUFF_RULE(ArcaneIntellect, ARCANE_INTELLECT) - -bool ShouldBlinkLow(ApPredicateContext const& ctx) -{ - if (ctx.bot.hp_pct() >= 30) return false; - return ctx.bot.knows_spell(BLINK) && ctx.bot.is_ready(BLINK); -} - -// Frost Nova: defensive root. Original baseline rule fires on any -// melee-adjacent enemy when CD is ready. Override the SELF_RULE -// gate with a melee-range check so we don't burn a 30s CD with no -// enemies inside the 8y nova radius. -bool ShouldFrostNovaMelee(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(FROST_NOVA)) return false; - if (!ctx.bot.is_ready(FROST_NOVA)) return false; - return ctx.bot.enemies_within(8.0f) >= 1; -} - -// Arcane Explosion: 8y PBAoE. Fires at 2+ enemies in range. Override -// the SELF_RULE-generated predicate so we don't waste mana on a single -// target. (Spec rotations apply tighter thresholds; baseline 2 is -// permissive because low-level mages have no other AoE option.) -bool ShouldArcaneExplosionAoE(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(ARCANE_EXPLOSION)) return false; - if (!ctx.bot.is_ready(ARCANE_EXPLOSION)) return false; - return ctx.bot.enemies_within(8.0f) >= 2; -} - -// Cone of Cold (L18): frontal cone damage + slow, 25s CD. Fire on a 2+ -// melee cluster so the slow buys kiting room; Frost Nova's root already -// fired above when only one attacker is on us. -bool ShouldConeOfColdMelee(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(CONE_OF_COLD)) return false; - if (!ctx.bot.is_ready(CONE_OF_COLD)) return false; - return ctx.bot.enemies_within(8.0f) >= 2; -} - -// Fire Blast: instant ranged nuke. Core baseline filler whenever -// off-GCD/instant is needed (e.g. mid-move). Simple have-target + -// ready + knows-spell gate; the engine handles the actual GCD/CD. -bool ShouldFireBlast(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(FIRE_BLAST)) return false; - return ctx.bot.is_ready(FIRE_BLAST); -} -void DoFireBlast(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(FIRE_BLAST, ctx.bot.victim()); -} - -// Polymorph — baseline emergency CC. -// -// Trigger model (intentionally narrow for baseline): -// * 2+ enemies engaged AND -// * (a) a non-victim caster/dps enemy exists -> sheep that one off, OR -// * (b) bot HP ≤ 50% -> emergency sheep on the -// victim (last resort, -// bot kites + heals) -// -// Variant resolution: walks POLYMORPH_IDS and picks the first known + -// ready ID. Different morph visuals (sheep/turtle/penguin/etc.) all -// share the L1 unlock — whichever the data layer trained on this -// character is what we cast. -// -// Refresh-aware: skips an off-target candidate that's already sheeped -// (avoids re-applying a 60s CC and resetting its diminishing-returns -// counter on PvP targets). -// Emergency victim-sheep candidate: the unit we're fighting, when we're -// about to die, not already CC'd and CC-able by type. A last-resort reset -// for a low-level mage with no heal. Returns true when it should fire. -inline bool CanPanicSheepVictim(ApPredicateContext const& ctx, uint32 sid) -{ - if (ctx.bot.hp_pct() > 50) return false; - NearbyUnit const* vi = ctx.bot.victim_info(); - return vi && !vi->is_cc_locked && CanBeCCd(sid, vi->creature_type); -} -bool ShouldPolymorph(ApPredicateContext const& ctx) -{ - const uint32 sid = FirstReadyPoly(ctx, POLYMORPH_IDS); - if (sid == 0) return false; - // (a) Off-target sheep — only on a genuine 2+ ATTACKER pull, skipping - // already-CC'd mobs (shared gate; see ApCrowdControl.h). The old - // nearby_enemies.size()>=2 + has_aura path sheeped a 40y scan - // bystander every GCD and never let the damage rules run. - if (!PickOffTargetCC(ctx, sid, ApInPvp(ctx)).IsEmpty()) return true; - // (b) Emergency CC the victim itself when HP critical. - return CanPanicSheepVictim(ctx, sid); -} -void DoPolymorph(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - const uint32 sid = FirstReadyPoly(ctx, POLYMORPH_IDS); - if (sid == 0) return; - ObjectGuid t = PickOffTargetCC(ctx, sid, ApInPvp(ctx)); - if (t.IsEmpty() && CanPanicSheepVictim(ctx, sid)) t = ctx.bot.victim(); - if (!t.IsEmpty()) e.cast(sid, t); -} - -ApRule const baseline_mage_kRules[] = { - // Survival first. - { ShouldBlinkLow, DoBlink, "Blink (<30% escape)" }, - // Self-buff (refresh). - { ShouldArcaneIntellect, DoArcaneIntellect, "Arcane Intellect (self-buff)" }, - // Interrupt (caster-victim gated by macro). - { ShouldCounterspell, DoCounterspell, "Counterspell (interrupt)" }, - // Melee root / slow. - { ShouldFrostNovaMelee, DoFrostNova, "Frost Nova (root melee)" }, - { ShouldConeOfColdMelee, DoConeOfCold, "Cone of Cold (2+ melee)" }, - // Emergency CC. - { ShouldPolymorph, DoPolymorph, "Polymorph (CC off-target / panic)"}, - // AoE. - { ShouldArcaneExplosionAoE, DoArcaneExplosion, "Arcane Explosion (PBAoE)" }, - // Damage. - { ShouldFireBlast, DoFireBlast, "Fire Blast (instant)" }, - { ShouldFrostbolt, DoFrostbolt, "Frostbolt" }, - // Fallback. - { AlwaysInCombat, DoAutoAttack, "Auto attack" }, -}; - -} // anonymous - -void RegisterApl_Baseline_Mage() -{ - RegisterRotation(CLASS_MAGE, 0, ApRotation{baseline_mage_kRules}); -} - -} // namespace Playerbot::Combat diff --git a/src/modules/PlayerbotV2/Combat/Apl/Apl_Baseline_Paladin.cpp b/src/modules/PlayerbotV2/Combat/Apl/Apl_Baseline_Paladin.cpp deleted file mode 100644 index 564a12a123..0000000000 --- a/src/modules/PlayerbotV2/Combat/Apl/Apl_Baseline_Paladin.cpp +++ /dev/null @@ -1,188 +0,0 @@ -// Apl_Baseline_Paladin.cpp - baseline rotation for class CLASS_PALADIN (spec=0). Extracted from the monolithic Apl_Baseline.cpp on the split refactor; future edits go -// here exclusively. See Apl_Baseline_Common.h for the -// shared helpers + rule macros. -// -// To audit coverage: -// python src/modules/PlayerbotV2/tools/baseline_coverage_audit.py - -#include "Apl_Baseline_Common.h" - -namespace Playerbot::Combat { - -namespace { - -using ::Playerbot::Combat::baseline_common::HasLiveTarget; -using ::Playerbot::Combat::baseline_common::AlwaysInCombat; -using ::Playerbot::Combat::baseline_common::DoAutoAttack; - -// ---- Spell IDs (WoW 12.1.0.69587 class baseline, kit Apl_Baseline_Paladin.md) ---- -// Every id below is a Paladin SkillLineAbility spell in 12.1; the spec -// rotations take over at L10, so the ladder prefers the L1-9 kit. -constexpr uint32 CRUSADER_STRIKE = 35395; // L1 - Holy Power generator -// Judgment baseline 20271 (L3). The spec spells 275773 (Holy) / 275779 -// (Prot) override it once a spec is chosen; baseline keeps 20271 so -// unspecced + L1-9 bots fire the canonical instance. -constexpr uint32 JUDGMENT = 20271; -// Word of Glory 85673 (L7). The old second candidate 115675 is -// "Boundless Conviction" (a passive) in 12.1 and would hijack the pick. -constexpr uint32 WORD_OF_GLORY = 85673; -constexpr uint32 FLASH_OF_LIGHT = 19750; // L4 - 1.5s cast heal -constexpr uint32 HAMMER_OF_JUSTICE = 853; // L5 - 45s CD, 6s stun -constexpr uint32 SHIELD_OF_RIGHTEOUS = 53600; // L2 - 3 HP armor spender -constexpr uint32 HAND_OF_RECKONING = 62124; // L9 - single-target taunt -constexpr uint32 CONSECRATION = 26573; // L6 - AoE ground tick (signature) -constexpr uint32 DIVINE_SHIELD = 642; // L10 - 8s full immunity (Forbearance) -constexpr uint32 LAY_ON_HANDS = 633; // L14 - full HP heal, 10 min CD - -BASELINE_SPELL_RULE(CrusaderStrike, CRUSADER_STRIKE) -BASELINE_SPELL_RULE(Judgment, JUDGMENT) -BASELINE_SPELL_RULE(ShieldOfRighteous, SHIELD_OF_RIGHTEOUS) - -// Hand of Reckoning (L9): single-target taunt. Fire when there is an -// untaunted enemy threatening the bot or an ally - tanks pull aggro, -// DPS/healers no-op when no taunt target exists. Knows_spell gate keeps -// L1-8 bots silent. -bool ShouldHandOfReckoning(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(HAND_OF_RECKONING)) return false; - if (!ctx.bot.is_ready(HAND_OF_RECKONING)) return false; - return ctx.bot.untaunted_enemy() != nullptr; -} -void DoHandOfReckoning(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* c = ctx.bot.untaunted_enemy()) - e.cast(HAND_OF_RECKONING, c->guid); -} - -// Hammer of Justice (L5): 45s CD stun. Spend it on actual casters -// (interrupt via stun) or when the bot is taking a beating (<=50% HP) -// to peel pressure. Never burn it as a generic filler. -bool ShouldHammerOfJustice(ApPredicateContext const& ctx) -{ - if (!::Playerbot::Combat::baseline_common::HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(HAMMER_OF_JUSTICE)) return false; - if (!ctx.bot.is_ready(HAMMER_OF_JUSTICE)) return false; - NearbyUnit const* v = ctx.bot.victim_info(); - if (!v) return false; - // Victim is mid-cast on an interruptible spell - top-priority use. - if (v->is_casting && v->is_interruptible) return true; - // Defensive peel - bot is under pressure. - if (ctx.bot.hp_pct() <= 50 && ctx.bot.in_combat()) return true; - return false; -} -void DoHammerOfJustice(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(HAMMER_OF_JUSTICE, ctx.bot.victim()); -} - -// Consecration (L6): AoE ground tick, paladin signature. Fire on any -// in-combat tick when 2+ enemies are in range - lower threshold than -// the typical 3-target AoE rule because it's also a single-target -// threat tool for Prot and a passive damage source for Ret. Knows_spell -// gate keeps L1-5 bots silent. -bool ShouldConsecration(ApPredicateContext const& ctx) -{ - if (!::Playerbot::Combat::baseline_common::HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(CONSECRATION)) return false; - if (!ctx.bot.is_ready(CONSECRATION)) return false; - // 2+ enemies in melee/Consecration radius (8y). - return ctx.bot.enemies_within(8.0f) >= 2; -} -void DoConsecration(ApPredicateContext const&, BotIntentEmitter& e) -{ - // Ground-targeted at the bot's feet - empty guid lets the cast - // resolver place the AoE under the caster. - e.cast(CONSECRATION, ObjectGuid::Empty); -} - -// Word of Glory (L7): 3 Holy Power instant self heal. -bool ShouldWordOfGlory(ApPredicateContext const& ctx) -{ - if (ctx.bot.hp_pct() >= 60) return false; - return ctx.bot.knows_spell(WORD_OF_GLORY) && ctx.bot.is_ready(WORD_OF_GLORY); -} -void DoWordOfGlory(ApPredicateContext const&, BotIntentEmitter& e) -{ - e.cast(WORD_OF_GLORY, ObjectGuid::Empty); -} - -// Flash of Light: 1.5s cast self-heal; baseline panic when WoG is -// unavailable / on CD. Threshold pulled below WoG so the instant -// heal is preferred when both are ready. -bool ShouldFlashOfLight(ApPredicateContext const& ctx) -{ - if (ctx.bot.hp_pct() >= 50) return false; - if (ctx.bot.is_moving()) return false; // cast-time spell - return ctx.bot.knows_spell(FLASH_OF_LIGHT) && ctx.bot.is_ready(FLASH_OF_LIGHT); -} -void DoFlashOfLight(ApPredicateContext const&, BotIntentEmitter& e) -{ - e.cast(FLASH_OF_LIGHT, ObjectGuid::Empty); -} - -// Divine Shield (L10): 8s full immunity, drops aggro. Reserved for true -// emergencies (<25% HP) - applies Forbearance which locks Lay on Hands. -// To avoid blowing two CDs simultaneously, skip when WoG is ready AND -// HP > 15% (let the cheap heal handle moderate dips). -bool ShouldDivineShield(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (ctx.bot.hp_pct() >= 25) return false; - if (ctx.bot.enemies_within(40.0f) == 0) return false; - // Alternation: if WoG is still up and HP isn't critical, defer to it. - if (ctx.bot.hp_pct() > 15 && ctx.bot.is_ready(WORD_OF_GLORY)) return false; - return ctx.bot.knows_spell(DIVINE_SHIELD) && ctx.bot.is_ready(DIVINE_SHIELD); -} -void DoDivineShield(ApPredicateContext const&, BotIntentEmitter& e) -{ - e.cast(DIVINE_SHIELD, ObjectGuid::Empty); -} - -// Lay on Hands (L14): full-HP heal, 10 min CD. Last-resort below 15% HP -// when Divine Shield is also unavailable. knows_spell skips it for -// lower levels. -bool ShouldLayOnHands(ApPredicateContext const& ctx) -{ - if (ctx.bot.hp_pct() >= 15) return false; - return ctx.bot.knows_spell(LAY_ON_HANDS) && ctx.bot.is_ready(LAY_ON_HANDS); -} -void DoLayOnHands(ApPredicateContext const&, BotIntentEmitter& e) -{ - e.cast(LAY_ON_HANDS, ObjectGuid::Empty); -} - -// Rule order (defensive ladder first, then utility, then damage): -// 1. Lay on Hands - full HP heal, <=15% emergency -// 2. Divine Shield - 8s immunity, <=25% bail -// 3. Flash of Light - instant-when-stationary panic heal, <=50% self -// 4. Hammer of Justice- interrupt-via-stun OR peel when bot <=50% HP -// 5. Hand of Reckoning- single-target taunt (tanks; DPS no-op when no untaunted enemy) -// 6. Judgment - ranged opener / debuff -// 7. Crusader Strike - melee filler -// 8. Consecration - AoE ground tick (2+ enemies) -// 9. Shield of the Righteous - Prot active mitigation (knows_spell gate) -// 10. Word of Glory - Holy Power heal (<=60% self) -// 11. Auto attack - always-on melee swing -ApRule const baseline_paladin_kRules[] = { - { ShouldLayOnHands, DoLayOnHands, "Lay on Hands (<15% emergency)" }, - { ShouldDivineShield, DoDivineShield, "Divine Shield (<25% immunity)" }, - { ShouldFlashOfLight, DoFlashOfLight, "Flash of Light (<50% self)" }, - { ShouldHammerOfJustice, DoHammerOfJustice, "Hammer of Justice (stun/peel)" }, - { ShouldHandOfReckoning, DoHandOfReckoning, "Hand of Reckoning (taunt)" }, - { ShouldJudgment, DoJudgment, "Judgment" }, - { ShouldCrusaderStrike, DoCrusaderStrike, "Crusader Strike" }, - { ShouldConsecration, DoConsecration, "Consecration (AoE 2+)" }, - { ShouldShieldOfRighteous,DoShieldOfRighteous,"Shield of the Righteous (Prot)" }, - { ShouldWordOfGlory, DoWordOfGlory, "Word of Glory (<60% self heal)" }, - { AlwaysInCombat, DoAutoAttack, "Auto attack" }, -}; - -} // anonymous - -void RegisterApl_Baseline_Paladin() -{ - RegisterRotation(CLASS_PALADIN, 0, ApRotation{baseline_paladin_kRules}); -} - -} // namespace Playerbot::Combat diff --git a/src/modules/PlayerbotV2/Combat/Apl/Apl_Baseline_Priest.cpp b/src/modules/PlayerbotV2/Combat/Apl/Apl_Baseline_Priest.cpp deleted file mode 100644 index 0747d52d90..0000000000 --- a/src/modules/PlayerbotV2/Combat/Apl/Apl_Baseline_Priest.cpp +++ /dev/null @@ -1,76 +0,0 @@ -// Apl_Baseline_Priest.cpp — baseline rotation for class CLASS_PRIEST (spec=0). Extracted from the monolithic Apl_Baseline.cpp on the split refactor; future edits go -// here exclusively. See Apl_Baseline_Common.h for the -// shared helpers + rule macros. -// -// Coverage focus: L1-9 leveling + unspecced. WoW 12.1.0.69587: the Priest -// class baseline below L10 is Smite (L1), Shadow Word: Pain (L2), Flash -// Heal (L3), Power Word: Shield (L4) and Power Word: Fortitude (L6). Shadow -// Mend (now a Discipline talent passive), Renew (removed) and Fade (a class -// talent from L10) are no longer class baseline spells, so self-sustain is -// PW: Shield (7.5s category cooldown - Weakened Soul is gone) + Flash Heal. -// -// To audit coverage: -// python src/modules/PlayerbotV2/tools/baseline_coverage_audit.py - -#include "Apl_Baseline_Common.h" - -namespace Playerbot::Combat { - -namespace { - -using ::Playerbot::Combat::baseline_common::HasLiveTarget; -using ::Playerbot::Combat::baseline_common::AlwaysInCombat; -using ::Playerbot::Combat::baseline_common::DoAutoAttack; - -// ---- Spell IDs (WoW 12.1.0.69587 class baseline, SkillLineAbility) ---- -constexpr uint32 SMITE = 585; // L1 -constexpr uint32 SHADOW_WORD_PAIN = 589; // L2 -constexpr uint32 FLASH_HEAL = 2061; // L3 -constexpr uint32 POWER_WORD_SHIELD = 17; // L4 - 7.5s category CD (Weakened Soul 6788 no longer exists) -constexpr uint32 POWER_WORD_FORTITUDE = 21562; // L6 group stamina buff - -// ---- Damage ---- -BASELINE_SPELL_RULE(Smite, SMITE) -BASELINE_DEBUFF_RULE(ShadowWordPain, SHADOW_WORD_PAIN) - -// ---- Self-buff (refresh when not up) ---- -BASELINE_SELFBUFF_RULE(PowerWordFortitude, POWER_WORD_FORTITUDE) - -// ---- Survival ---- -// PW: Shield self - proactive absorb at <=70%. is_ready covers the 7.5s -// category cooldown; the aura gate avoids stacking a fresh shield over an -// existing one. Doubles as pre-pull when an enemy is nearby. -bool ShouldPowerWordShieldSelf(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(POWER_WORD_SHIELD)) return false; - if (!ctx.bot.is_ready(POWER_WORD_SHIELD)) return false; - if (ctx.bot.hp_pct() > 70) return false; - if (ctx.bot.find_aura(POWER_WORD_SHIELD, ObjectGuid::Empty)) return false; - return true; -} -void DoPowerWordShieldSelf(ApPredicateContext const&, BotIntentEmitter& e) -{ - e.cast(POWER_WORD_SHIELD, ObjectGuid::Empty); -} - -// Flash Heal - the only direct heal in the 12.1 class baseline (Shadow Mend -// and Renew are gone below L10). -BASELINE_DEFENSIVE_RULE(FlashHealSelf, FLASH_HEAL, 50) - -ApRule const baseline_priest_kRules[] = { - { ShouldPowerWordShieldSelf, DoPowerWordShieldSelf, "PW: Shield self (<=70%)" }, - { ShouldFlashHealSelf, DoFlashHealSelf, "Flash Heal self (<=50%)" }, - { ShouldPowerWordFortitude, DoPowerWordFortitude, "PW: Fortitude (self-buff)" }, - { ShouldShadowWordPain, DoShadowWordPain, "Shadow Word: Pain (debuff)" }, - { ShouldSmite, DoSmite, "Smite (filler)" }, - { AlwaysInCombat, DoAutoAttack, "Auto attack" }, -}; - -} // anonymous - -void RegisterApl_Baseline_Priest() -{ - RegisterRotation(CLASS_PRIEST, 0, ApRotation{baseline_priest_kRules}); -} - -} // namespace Playerbot::Combat diff --git a/src/modules/PlayerbotV2/Combat/Apl/Apl_Baseline_Rogue.cpp b/src/modules/PlayerbotV2/Combat/Apl/Apl_Baseline_Rogue.cpp deleted file mode 100644 index b2e1125fcf..0000000000 --- a/src/modules/PlayerbotV2/Combat/Apl/Apl_Baseline_Rogue.cpp +++ /dev/null @@ -1,228 +0,0 @@ -// Apl_Baseline_Rogue.cpp — baseline rotation for class CLASS_ROGUE (spec=0). Extracted from the monolithic Apl_Baseline.cpp on the split refactor; future edits go -// here exclusively. See Apl_Baseline_Common.h for the -// shared helpers + rule macros. -// -// To audit coverage: -// python src/modules/PlayerbotV2/tools/baseline_coverage_audit.py - -#include "Apl_Baseline_Common.h" - -namespace Playerbot::Combat { - -namespace { - -using ::Playerbot::Combat::baseline_common::HasLiveTarget; -using ::Playerbot::Combat::baseline_common::AlwaysInCombat; -using ::Playerbot::Combat::baseline_common::DoAutoAttack; - -// Class baseline ids, WoW 12.1.0.69587 (SkillLineAbility, all specs). -constexpr uint32 SINISTER_STRIKE = 1752; // L1 - builder (spec overrides keep it castable) -constexpr uint32 EVISCERATE = 196819; // L2 - CP finisher -constexpr uint32 SLICE_AND_DICE = 315496; // L9 - attack-speed finisher -constexpr uint32 KIDNEY_SHOT = 408; // L13 - CP stun -constexpr uint32 EVASION = 5277; // L21 - 100% dodge vs physical, 10s -constexpr uint32 VANISH = 1856; // L17 - drop combat, restealth -constexpr uint32 CLOAK_OF_SHADOWS = 31224; // L47 - magic immunity -constexpr uint32 STEALTH = 1784; // L3 - OOC stealth; aura id == spell id -constexpr uint32 CHEAP_SHOT = 1833; // L3 - stealth-only 4s stun opener (2 CP) -constexpr uint32 AMBUSH = 8676; // L7 - stealth-only opener (2 CP) -constexpr uint32 KICK = 1766; // L6 - interrupt -constexpr uint32 CRIMSON_VIAL = 185311; // L8 - self HoT - -constexpr uint8 POWER_COMBO_POINTS_IDX = 4; - -uint8 ComboPoints(ApPredicateContext const& ctx) -{ - return static_cast(ctx.bot.power(POWER_COMBO_POINTS_IDX)); -} - -BASELINE_INTERRUPT_RULE(Kick, KICK) -BASELINE_DEFENSIVE_RULE(CrimsonVial, CRIMSON_VIAL, 60) - -// Finishers need combo points: firing Eviscerate / Kidney Shot / Slice -// and Dice on 0 CP fails the cast and wastes the tick, so every finisher -// below is CP-gated instead of using the plain BASELINE_SPELL_RULE. -bool ShouldEviscerate(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.is_ready(EVISCERATE)) return false; - return ComboPoints(ctx) >= 3; -} -void DoEviscerate(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(EVISCERATE, ctx.bot.victim()); -} - -// Kidney Shot (L13): CP stun. Spend it on a casting mob (interrupt -// fallback when Kick is down) or when the bot is getting low. -bool ShouldKidneyShot(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(KIDNEY_SHOT) || !ctx.bot.is_ready(KIDNEY_SHOT)) return false; - if (ComboPoints(ctx) < 3) return false; - NearbyUnit const* v = ctx.bot.victim_info(); - const bool caster = v && v->is_casting && !ctx.bot.is_ready(KICK); - return caster || ctx.bot.hp_pct() <= 50; -} -void DoKidneyShot(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(KIDNEY_SHOT, ctx.bot.victim()); -} - -// Slice and Dice (L9): attack-speed buff. Put it up at 2+ CP when missing -// or about to fall off; Eviscerate takes the CP otherwise. -bool ShouldSliceAndDice(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(SLICE_AND_DICE) || !ctx.bot.is_ready(SLICE_AND_DICE)) return false; - if (ComboPoints(ctx) < 2) return false; - AuraEntry const* a = ctx.bot.find_aura(SLICE_AND_DICE, ObjectGuid::Empty); - return !a || a->remaining.count() <= 3000; -} -void DoSliceAndDice(ApPredicateContext const&, BotIntentEmitter& e) -{ - e.cast(SLICE_AND_DICE, ObjectGuid::Empty); -} - -// Evasion: 100% dodge vs physical, 10s. Panic for melee-range trouble. -// Useless vs caster damage so gated on a nearby melee threat. -bool ShouldEvasion(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (ctx.bot.hp_pct() >= 50) return false; - if (ctx.bot.enemies_within(5.0f) == 0) return false; - return ctx.bot.knows_spell(EVASION) && ctx.bot.is_ready(EVASION); -} -void DoEvasion(ApPredicateContext const&, BotIntentEmitter& e) -{ - e.cast(EVASION, ObjectGuid::Empty); -} - -// Vanish: drop combat. Last-resort below 20% HP when Evasion isn't up. -// Alternates with Evasion (different CDs) so the bot has TWO panic -// pulls per fight cluster. Doesn't fire in PvP arenas where it's -// tactical rather than emergency. -bool ShouldVanish(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (ctx.bot.hp_pct() >= 20) return false; - if (ctx.bot.is_ready(EVASION) && ctx.bot.knows_spell(EVASION)) return false; - return ctx.bot.knows_spell(VANISH) && ctx.bot.is_ready(VANISH); -} -void DoVanish(ApPredicateContext const&, BotIntentEmitter& e) -{ - e.cast(VANISH, ObjectGuid::Empty); -} - -// Cloak of Shadows: ~5s magic immunity, dispels existing harmful magic -// auras. Fires on low HP / silence (proxy for magic-debuff pressure). -bool ShouldCloakOfShadows(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (ctx.bot.hp_pct() < 40 || ctx.bot.is_silenced()) - return ctx.bot.knows_spell(CLOAK_OF_SHADOWS) && ctx.bot.is_ready(CLOAK_OF_SHADOWS); - return false; -} -void DoCloakOfShadows(ApPredicateContext const&, BotIntentEmitter& e) -{ - e.cast(CLOAK_OF_SHADOWS, ObjectGuid::Empty); -} - -// Stealth (L3): OOC opener prep. Aura ID matches spell ID. Don't restealth -// while mounted (the cast would auto-dismount and bots have no reason to -// blow a mount during travel). The two improved-stealth talent auras -// (115191 Subterfuge, 115192 post-break) only exist for talented specs -// and don't apply to baseline; checking STEALTH alone is sufficient at -// spec=0 since the bot can't pick those talents pre-L10. -bool ShouldStealth(ApPredicateContext const& ctx) -{ - if (ctx.bot.in_combat()) return false; - if (ctx.bot.is_mounted()) return false; - if (!ctx.bot.knows_spell(STEALTH)) return false; - if (!ctx.bot.is_ready(STEALTH)) return false; - return ctx.bot.find_aura(STEALTH, ObjectGuid::Empty) == nullptr; -} -void DoStealth(ApPredicateContext const&, BotIntentEmitter& e) -{ - e.cast(STEALTH, ObjectGuid::Empty); -} - -// Cheap Shot (L3): stealth-only 4s stun, 2 CP. Use when stealthed and -// in melee range — Ambush is the ranged-opener counterpart but Cheap -// Shot's stun is more valuable at melee distance because it locks the -// mob down while the bot stacks CPs. -bool ShouldCheapShot(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(CHEAP_SHOT) || !ctx.bot.is_ready(CHEAP_SHOT)) return false; - if (ctx.bot.find_aura(STEALTH, ObjectGuid::Empty) == nullptr) return false; - return ctx.bot.enemies_within(5.0f) >= 1; -} -void DoCheapShot(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(CHEAP_SHOT, ctx.bot.victim()); -} - -// Ambush (L7): stealth-only opener, 2 CP, big up-front damage. Fires -// when stealthed but not in Cheap Shot's melee window — i.e. as the -// ranged-opener form. Falling through to Ambush from any stealth state -// is fine since both spells break stealth and the rule ordering puts -// Cheap Shot first when adjacent. -bool ShouldAmbush(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(AMBUSH) || !ctx.bot.is_ready(AMBUSH)) return false; - return ctx.bot.find_aura(STEALTH, ObjectGuid::Empty) != nullptr; -} -void DoAmbush(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(AMBUSH, ctx.bot.victim()); -} - -// Sinister Strike (L1): the only baseline builder. Spec overrides -// (193315 Outlaw / 1329 Mutilate / 53 Backstab) replace it on the action -// bar but the base id stays in the spellbook and castable. -bool ShouldSinisterStrike(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (ComboPoints(ctx) >= 5) return false; - return ctx.bot.knows_spell(SINISTER_STRIKE) && ctx.bot.is_ready(SINISTER_STRIKE); -} -void DoSinisterStrike(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(SINISTER_STRIKE, ctx.bot.victim()); -} - -// NOTE on omitted baseline spells (WoW 12.1.0.69587): -// 1776 Gouge - no longer a class baseline spell (class talent in 12.1); -// removed from the baseline ladder. -// 2983 Sprint (L5) - pure movement CD; idle-rule territory, not a -// combat rotation rule. -// 1966 Feint (L12) / 3408 Crippling Poison / 315584 Instant Poison (L10) -// - above the L<10 window this rotation targets; spec rotations own them. -// 6770 Sap (L11) / 1725 Distract - hidden OOC utility, not a combat rule. - -ApRule const baseline_rogue_kRules[] = { - { ShouldCloakOfShadows, DoCloakOfShadows,"Cloak of Shadows (magic emergency <=40%)"}, - { ShouldVanish, DoVanish, "Vanish (<20% last resort)" }, - { ShouldEvasion, DoEvasion, "Evasion (<50% panic dodge)" }, - { ShouldCrimsonVial, DoCrimsonVial, "Crimson Vial (<=60% self HoT)" }, - { ShouldKick, DoKick, "Kick (interrupt)" }, - { ShouldStealth, DoStealth, "Stealth (OOC opener prep)" }, - { ShouldCheapShot, DoCheapShot, "Cheap Shot (stealth melee 4s stun)"}, - { ShouldAmbush, DoAmbush, "Ambush (stealth opener)" }, - { ShouldKidneyShot, DoKidneyShot, "Kidney Shot (CP stun)" }, - { ShouldSliceAndDice, DoSliceAndDice, "Slice and Dice (2+ CP)" }, - { ShouldEviscerate, DoEviscerate, "Eviscerate (3+ CP finisher)" }, - { ShouldSinisterStrike, DoSinisterStrike,"Sinister Strike (builder)" }, - { AlwaysInCombat, DoAutoAttack, "Auto attack" }, -}; - -} // anonymous - -void RegisterApl_Baseline_Rogue() -{ - RegisterRotation(CLASS_ROGUE, 0, ApRotation{baseline_rogue_kRules}); -} - -} // namespace Playerbot::Combat diff --git a/src/modules/PlayerbotV2/Combat/Apl/Apl_Baseline_Shaman.cpp b/src/modules/PlayerbotV2/Combat/Apl/Apl_Baseline_Shaman.cpp deleted file mode 100644 index cea7fa95fe..0000000000 --- a/src/modules/PlayerbotV2/Combat/Apl/Apl_Baseline_Shaman.cpp +++ /dev/null @@ -1,138 +0,0 @@ -// Apl_Baseline_Shaman.cpp - baseline rotation for class CLASS_SHAMAN (spec=0). Extracted from the monolithic Apl_Baseline.cpp on the split refactor; future edits go -// here exclusively. See Apl_Baseline_Common.h for the -// shared helpers + rule macros. -// -// To audit coverage: -// python src/modules/PlayerbotV2/tools/baseline_coverage_audit.py - -#include "Apl_Baseline_Common.h" - -namespace Playerbot::Combat { - -namespace { - -using ::Playerbot::Combat::baseline_common::HasLiveTarget; -using ::Playerbot::Combat::baseline_common::AlwaysInCombat; -using ::Playerbot::Combat::baseline_common::DoAutoAttack; - -// Spell IDs - WoW 12.1.0.69587 class baseline (SkillLineAbility) unless -// noted. Everything is knows_spell-gated so the fallback (spec 0 at any -// level) stays correct for a shaman that has the class-tree talents. -constexpr uint32 LIGHTNING_BOLT = 188196; // L1 - core caster filler -constexpr uint32 PRIMAL_STRIKE = 73899; // L2 - single-target melee opener -constexpr uint32 FLAME_SHOCK = 470411; // Midnight id (12.1); 188389 is the legacy DoT row -constexpr uint32 FLAME_SHOCK_DOT_LEGACY = 188389; // aura-only - debuff may still land under it -constexpr uint32 EARTH_SHOCK = 8042; // Elemental spec choice node - fallback only -constexpr uint32 WIND_SHEAR = 57994; // class talent L12 - interrupt (fallback only) -constexpr uint32 EARTHBIND_TOTEM = 2484; // L5 - AoE slow (avoid in dungeons - totems pull adds) -constexpr uint32 LIGHTNING_SHIELD = 192106; // L9 - self-reactive damage buff -constexpr uint32 HEALING_SURGE = 8004; // L4 - self-heal -constexpr uint32 ASTRAL_SHIFT = 108271; // class talent L42 - 12s DR, 120s CD (fallback only) - -// ---- Survival: Astral Shift (defensive CD, soak heavy hits) ---- -// 40% damage reduction for 8s on a 90s CD. Healing Surge is a heal - -// this is a true mitigation. Hold Astral Shift if a Healing Surge cast -// would still top the bot off (mana available, HP not catastrophic). -bool ShouldAstralShift(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (ctx.bot.hp_pct() >= 40) return false; - if (ctx.bot.enemies_within(40.0f) == 0) return false; - if (ctx.bot.is_ready(HEALING_SURGE) && ctx.bot.knows_spell(HEALING_SURGE) - && ctx.bot.power_pct(0) > 30 && ctx.bot.hp_pct() > 20) - return false; - return ctx.bot.knows_spell(ASTRAL_SHIFT) && ctx.bot.is_ready(ASTRAL_SHIFT); -} -void DoAstralShift(ApPredicateContext const&, BotIntentEmitter& e) -{ - e.cast(ASTRAL_SHIFT, ObjectGuid::Empty); -} - -// ---- Self-heal: Healing Surge on self when <=50% HP ---- -bool ShouldHealingSurgeSelf(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(HEALING_SURGE)) return false; - if (!ctx.bot.is_ready(HEALING_SURGE)) return false; - return ctx.bot.hp_pct() <= 50; -} -void DoHealingSurgeSelf(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(HEALING_SURGE, ctx.bot.raw().guid); -} - -// ---- Self-buff: Lightning Shield (reactive damage buff) ---- -BASELINE_SELFBUFF_RULE(LightningShield, LIGHTNING_SHIELD) - -// ---- Interrupt: Wind Shear ---- -BASELINE_INTERRUPT_RULE(WindShear, WIND_SHEAR) - -// ---- Debuff: Flame Shock (470411; DoT may be tracked under legacy 188389) ---- -bool ShouldFlameShock(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(FLAME_SHOCK)) return false; - if (!ctx.bot.is_ready(FLAME_SHOCK)) return false; - if (ctx.bot.find_aura(FLAME_SHOCK, ctx.bot.victim()) != nullptr) return false; - return ctx.bot.find_aura(FLAME_SHOCK_DOT_LEGACY, ctx.bot.victim()) == nullptr; -} -void DoFlameShock(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(FLAME_SHOCK, ctx.bot.victim()); -} - -// ---- AoE control: Earthbind Totem (slow) ---- -// Only in open world - totems aggro adds in dungeons, which is a net -// loss for the group. Gate on >=2 enemies within the totem's 10y pulse -// radius. -bool ShouldEarthbindTotem(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(EARTHBIND_TOTEM)) return false; - if (!ctx.bot.is_ready(EARTHBIND_TOTEM)) return false; - if (ctx.bot.is_in_dungeon()) return false; - return ctx.bot.enemies_within(10.0f) >= 2; -} -void DoEarthbindTotem(ApPredicateContext const&, BotIntentEmitter& e) -{ - e.cast(EARTHBIND_TOTEM, ObjectGuid::Empty); -} - -// ---- Damage: Primal Strike (Enhance melee opener) ---- -BASELINE_SPELL_RULE(PrimalStrike, PRIMAL_STRIKE) - -// ---- Damage: Earth Shock (Elemental spender - level 10) ---- -BASELINE_SPELL_RULE(EarthShock, EARTH_SHOCK) - -// ---- Damage: Lightning Bolt (caster filler) ---- -// 12.1 has a single learnable Lightning Bolt (188196, L1); the old 318044 -// rank-2 row is a passive and no longer a cast candidate. -bool ShouldLightningBolt(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - return ctx.bot.knows_spell(LIGHTNING_BOLT); -} -void DoLightningBolt(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(LIGHTNING_BOLT, ctx.bot.victim()); -} - -ApRule const baseline_shaman_kRules[] = { - { ShouldAstralShift, DoAstralShift, "Astral Shift (<40% dmg red)" }, - { ShouldHealingSurgeSelf, DoHealingSurgeSelf, "Healing Surge (<=50% self)" }, - { ShouldLightningShield, DoLightningShield, "Lightning Shield (self buff)" }, - { ShouldWindShear, DoWindShear, "Wind Shear (interrupt)" }, - { ShouldFlameShock, DoFlameShock, "Flame Shock (DoT)" }, - { ShouldEarthbindTotem, DoEarthbindTotem, "Earthbind Totem (2+ AoE, open) "}, - { ShouldPrimalStrike, DoPrimalStrike, "Primal Strike (melee opener)" }, - { ShouldEarthShock, DoEarthShock, "Earth Shock" }, - { ShouldLightningBolt, DoLightningBolt, "Lightning Bolt (filler)" }, - { AlwaysInCombat, DoAutoAttack, "Auto attack" }, -}; - -} // anonymous - -void RegisterApl_Baseline_Shaman() -{ - RegisterRotation(CLASS_SHAMAN, 0, ApRotation{baseline_shaman_kRules}); -} - -} // namespace Playerbot::Combat diff --git a/src/modules/PlayerbotV2/Combat/Apl/Apl_Baseline_Warlock.cpp b/src/modules/PlayerbotV2/Combat/Apl/Apl_Baseline_Warlock.cpp deleted file mode 100644 index a4b4b6dff6..0000000000 --- a/src/modules/PlayerbotV2/Combat/Apl/Apl_Baseline_Warlock.cpp +++ /dev/null @@ -1,150 +0,0 @@ -// Apl_Baseline_Warlock.cpp - baseline rotation for class CLASS_WARLOCK -// (spec=0), used below level 10 and as the fallback when no spec rotation -// is registered. Extracted from the monolithic Apl_Baseline.cpp on the -// split refactor; future edits go here exclusively. See -// Apl_Baseline_Common.h for the shared helpers + rule macros. -// -// ---- Validated IDs (SkillLineAbility class baseline, WoW 12.1.0.69587) -- -// 686 Shadow Bolt L1 filler -// 172 Corruption L2 DoT (cast id) -// 146739 Corruption periodic aura applied by 172 -// 688 Summon Imp L3 pet -// 104773 Unending Resolve L4 defensive, 40% DR -// 5782 Fear L5 CC -// 702 Curse of Weakness L6 debuff -// 234153 Drain Life L9 emergency self-heal channel -// -// ---- Skipped spells (and why) ------------------------------------------- -// - Immolate (348) and Agony (980): Destruction spec spell / Affliction -// talent in 12.1, not class baseline - the spec rotations own them. -// - Create Healthstone (6201, L7): out-of-combat item creation, not a -// rotation slot. -// - Summon Voidwalker (697, L10+) and later pets: pet choice lives in -// State_Idle's ooc pet-summon rule; the baseline only backstops the Imp. -// -// To audit coverage: -// python src/modules/PlayerbotV2/tools/baseline_coverage_audit.py - -#include "Apl_Baseline_Common.h" - -namespace Playerbot::Combat { - -namespace { - -using ::Playerbot::Combat::baseline_common::HasLiveTarget; -using ::Playerbot::Combat::baseline_common::AlwaysInCombat; -using ::Playerbot::Combat::baseline_common::DoAutoAttack; - -constexpr uint32 SHADOW_BOLT = 686; // L1 filler -constexpr uint32 CORRUPTION = 172; // L2 DoT (cast id) -constexpr uint32 CORRUPTION_DOT = 146739; // periodic aura applied by 172 -constexpr uint32 FEAR = 5782; // L5 CC -constexpr uint32 SUMMON_IMP = 688; // L3 pet -constexpr uint32 CURSE_OF_WEAKNESS = 702; // L6 debuff -constexpr uint32 DRAIN_LIFE = 234153; // L9 emergency self-heal channel -constexpr uint32 UNENDING_RESOLVE = 104773; // L4 defensive - -BASELINE_SPELL_RULE(ShadowBolt, SHADOW_BOLT) - -// Corruption: BASELINE_DEBUFF_RULE semantics, but the cast (172) applies a -// separately-numbered periodic aura (146739), so check that aura on the -// victim (and the cast id as a fallback) rather than re-rolling the DoT -// every GCD. -bool ShouldCorruption(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(CORRUPTION)) return false; - if (!ctx.bot.is_ready(CORRUPTION)) return false; - if (ctx.bot.find_aura(CORRUPTION_DOT, ctx.bot.victim())) return false; - return ctx.bot.find_aura(CORRUPTION, ctx.bot.victim()) == nullptr; -} -void DoCorruption(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(CORRUPTION, ctx.bot.victim()); -} - -BASELINE_DEBUFF_RULE(CurseOfWeakness, CURSE_OF_WEAKNESS) - -// Fear as emergency CC: 2+ enemies AND we're at <=50% HP. The baseline -// version is intentionally conservative - Fear breaks on damage and the -// baseline bot has no follow-up CC, so we only burn it when it actually -// buys breathing room. -bool ShouldFearEmergency(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(FEAR)) return false; - if (!ctx.bot.is_ready(FEAR)) return false; - if (ctx.bot.hp_pct() > 50) return false; - return ctx.bot.enemies_within(15.0f) >= 2; -} -void DoFearEmergency(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(FEAR, ctx.bot.victim()); -} - -// Drain Life as emergency heal channel (L9). Channels for ~5s, locks the -// bot in place - only fire when we're genuinely in trouble AND no other -// defensive is ready (Unending Resolve burned or not yet learned). -// Threshold is <=50% HP per spec. -bool ShouldDrainLifeEmergency(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(DRAIN_LIFE)) return false; - if (!ctx.bot.is_ready(DRAIN_LIFE)) return false; - if (ctx.bot.hp_pct() > 50) return false; - // Prefer Unending Resolve if it's available - it's instant, off-GCD, - // and doesn't pin the bot in a channel. Only channel Drain Life when - // UR is unavailable (not learned yet, or on cooldown). - if (ctx.bot.knows_spell(UNENDING_RESOLVE) && ctx.bot.is_ready(UNENDING_RESOLVE)) - return false; - return true; -} -void DoDrainLifeEmergency(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(DRAIN_LIFE, ctx.bot.victim()); -} - -// Summon Imp: skip when bot already has a live pet. Without this -// the rule fires every tick at OOC walking-around, server processes -// a dismiss+resummon cycle and the pet ends up perpetually getting -// re-summoned (also burns 60% of the bot's mana repeatedly). -bool ShouldSummonImp(ApPredicateContext const& ctx) -{ - if (ctx.bot.has_pet()) return false; - return ctx.bot.knows_spell(SUMMON_IMP) && ctx.bot.is_ready(SUMMON_IMP); -} -void DoSummonImp(ApPredicateContext const&, BotIntentEmitter& e) -{ - e.cast(SUMMON_IMP, ObjectGuid::Empty); -} - -BASELINE_DEFENSIVE_RULE(UnendingResolve, UNENDING_RESOLVE, 30) - -// Rule order (per spec): -// 1. Unending Resolve - panic CD <=30% -// 2. Drain Life - emergency self-heal <=50% when UR unavailable -// 3. Summon Imp - pet maintenance (no live pet) -// 4. Corruption (172) - DoT (aura 146739) -// 5. Curse of Weakness - debuff -// 6. Fear (emergency) - >=2 enemies AND <=50% HP -// 7. Shadow Bolt - filler -// 8. Auto attack -ApRule const baseline_warlock_kRules[] = { - { ShouldUnendingResolve, DoUnendingResolve, "Unending Resolve (<30%)" }, - { ShouldDrainLifeEmergency, DoDrainLifeEmergency, "Drain Life (emergency heal)" }, - { ShouldSummonImp, DoSummonImp, "Summon Imp (no pet)" }, - { ShouldCorruption, DoCorruption, "Corruption (DoT)" }, - { ShouldCurseOfWeakness, DoCurseOfWeakness, "Curse of Weakness (debuff)" }, - { ShouldFearEmergency, DoFearEmergency, "Fear (emergency CC)" }, - { ShouldShadowBolt, DoShadowBolt, "Shadow Bolt" }, - { AlwaysInCombat, DoAutoAttack, "Auto attack" }, -}; - -} // anonymous - -void RegisterApl_Baseline_Warlock() -{ - RegisterRotation(CLASS_WARLOCK, 0, ApRotation{baseline_warlock_kRules}); -} - -} // namespace Playerbot::Combat diff --git a/src/modules/PlayerbotV2/Combat/Apl/Apl_Baseline_Warrior.cpp b/src/modules/PlayerbotV2/Combat/Apl/Apl_Baseline_Warrior.cpp deleted file mode 100644 index 32f8566b10..0000000000 --- a/src/modules/PlayerbotV2/Combat/Apl/Apl_Baseline_Warrior.cpp +++ /dev/null @@ -1,164 +0,0 @@ -// Apl_Baseline_Warrior.cpp - baseline rotation for class CLASS_WARRIOR (spec=0). Extracted from the monolithic Apl_Baseline.cpp on the split refactor; future edits go -// here exclusively. See Apl_Baseline_Common.h for the -// shared helpers + rule macros. -// -// To audit coverage: -// python src/modules/PlayerbotV2/tools/baseline_coverage_audit.py - -#include "Apl_Baseline_Common.h" - -namespace Playerbot::Combat { - -namespace { - -using ::Playerbot::Combat::baseline_common::HasLiveTarget; -using ::Playerbot::Combat::baseline_common::AlwaysInCombat; -using ::Playerbot::Combat::baseline_common::DoAutoAttack; - -constexpr uint32 CHARGE = 100; -constexpr uint32 SLAM = 1464; -constexpr uint32 BATTLE_SHOUT = 6673; // DB2 SpellLevel=10 - gated on knows_spell, harmless when unknown -constexpr uint32 PUMMEL = 6552; -constexpr uint32 VICTORY_RUSH = 34428; -constexpr uint32 HAMSTRING = 1715; -constexpr uint32 EXECUTE = 163201; // WoW 12.1.0.69587 class baseline Execute (L10); 5308 is the Fury spec override. Gated on knows_spell -constexpr uint32 SHIELD_SLAM = 23922; // L5 Protection in spellbook audit -constexpr uint32 BERSERKER_RAGE = 18499; // L1 panic - immunity to fear/sap/incap (DB2 SpellLevel=12 - gated) -constexpr uint32 SHIELD_BLOCK = 2565; // L6 - active block mitigation, requires shield equipped -constexpr uint32 TAUNT = 355; // L8 - taunt; included even on non-tank baseline since it's cheap and useful when a mob targets a healer/caster -constexpr uint32 WHIRLWIND = 1680; // L9 - AoE melee swing (>=2 enemies in 8y) - -BASELINE_SPELL_RULE(Charge, CHARGE) -BASELINE_INTERRUPT_RULE(Pummel, PUMMEL) -BASELINE_SPELL_RULE(Execute, EXECUTE) -BASELINE_SPELL_RULE(Slam, SLAM) -BASELINE_SPELL_RULE(ShieldSlam, SHIELD_SLAM) -// Battle Shout is a self-buff aura - must use SELFBUFF (find_aura gate) so we -// re-cast only after it falls off, not every tick. Using BASELINE_SELF_RULE -// here was a bug that burned a GCD every tick the bot was idle. -BASELINE_SELFBUFF_RULE(BattleShout, BATTLE_SHOUT) -BASELINE_SPELL_RULE(VictoryRush, VICTORY_RUSH) -// Whirlwind: baseline AoE. 8y radius, hits all nearby enemies. Gate on -// >=2 targets (not 3) since baseline warriors don't have Cleave/Sweeping -// Strikes and Whirlwind is their only AoE option pre-spec. -BASELINE_AOE_RULE(Whirlwind, WHIRLWIND, 8.0f, 2) - -// Berserker Rage: panic CD. Grants immunity to fear/sap/incapacitate -// and a brief damage buff. L1 baseline so always available to fresh -// warriors. Fires below 35% HP with a nearby enemy - no alternation -// because Victory Rush requires a recent kill (not a true panic CD). -bool ShouldBerserkerRage(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (ctx.bot.hp_pct() >= 35) return false; - if (ctx.bot.enemies_within(40.0f) == 0) return false; - return ctx.bot.knows_spell(BERSERKER_RAGE) && ctx.bot.is_ready(BERSERKER_RAGE); -} -void DoBerserkerRage(ApPredicateContext const&, BotIntentEmitter& e) -{ - e.cast(BERSERKER_RAGE, ObjectGuid::Empty); -} - -// Shield Block: active mitigation CD (L6 baseline). Requires a shield -// equipped - we can't reliably probe slot contents from the snapshot, -// but the cast will silently fail if no shield is on and is_ready gates -// the CD. Fire at <=70% HP so it overlaps real incoming damage instead -// of being wasted on the first trash mob. No aura check needed: the -// CD itself (~16s) is longer than the buff (~6s), so is_ready prevents -// double-emit anyway. -bool ShouldShieldBlock(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (ctx.bot.hp_pct() > 70) return false; - if (!ctx.bot.knows_spell(SHIELD_BLOCK)) return false; - if (!ctx.bot.is_ready(SHIELD_BLOCK)) return false; - if (ctx.bot.has_aura(SHIELD_BLOCK)) return false; - return true; -} -void DoShieldBlock(ApPredicateContext const&, BotIntentEmitter& e) -{ - e.cast(SHIELD_BLOCK, ObjectGuid::Empty); -} - -// Taunt: a tank tool, but kept in the baseline because pre-L10 dungeon -// runs frequently feature undirected warriors who CAN peel a caster off -// the healer. Cheap (no GCD, short CD), gated on an enemy not currently -// targeting us. The Prot spec rotation has the same idiom (untaunted_enemy). -bool ShouldTaunt(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(TAUNT)) return false; - if (!ctx.bot.is_ready(TAUNT)) return false; - return ctx.bot.untaunted_enemy(8.0f) != nullptr; -} -void DoTaunt(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* t = ctx.bot.untaunted_enemy(8.0f)) - e.cast(TAUNT, t->guid); -} - -// Hamstring: melee 50% slow. Fires whenever a target's adjacent and -// the bot has rage to spend; cheap reapply since the debuff stacks -// a fresh duration. is_ready gates GCD; the cast-emit dedup prevents -// re-emitting within ~1.5s, so we just lean on those for cadence. -bool ShouldHamstring(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(HAMSTRING)) return false; - if (!ctx.bot.is_ready(HAMSTRING)) return false; - // Don't bother refreshing if the bot's already in melee with a - // slowed target - track aura presence and skip while up. - if (ctx.bot.find_aura(HAMSTRING, ctx.bot.victim())) return false; - return ctx.bot.enemies_within(5.0f) > 0; -} -void DoHamstring(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(HAMSTRING, ctx.bot.victim()); -} - -// Execute only when victim HP <= 20% (the rule's "below" trigger). -bool ShouldExecuteLow(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(EXECUTE)) return false; - if (auto const* t = ctx.bot.victim_info()) - return t->max_hp > 0 && (t->hp * 100 / t->max_hp) <= 20; - return false; -} - -ApRule const baseline_warrior_kRules[] = { - // 1) Panic / immunity - { ShouldBerserkerRage,DoBerserkerRage,"Berserker Rage (<35% panic)"}, - // 2) Active defensive - { ShouldShieldBlock, DoShieldBlock, "Shield Block (<=70% mit)" }, - // 3) Self-buff maintenance (refreshes via SELFBUFF aura check) - { ShouldBattleShout, DoBattleShout, "Battle Shout (self buff)" }, - // 4) Gap closer - { ShouldCharge, DoCharge, "Charge (gap close)" }, - // 5) Interrupt (gated on victim casting interruptible) - { ShouldPummel, DoPummel, "Pummel (interrupt)" }, - // 6) Threat / peel - useful when a mob breaks off to a squishy - { ShouldTaunt, DoTaunt, "Taunt (peel caster)" }, - // 7) Slow - { ShouldHamstring, DoHamstring, "Hamstring (melee slow)" }, - // 8) Execute window - { ShouldExecuteLow, DoExecute, "Execute (<=20% target)" }, - // 9) Post-kill heal - { ShouldVictoryRush, DoVictoryRush, "Victory Rush (post-kill)" }, - // 10) AoE (>=2 enemies in 8y) - { ShouldWhirlwind, DoWhirlwind, "Whirlwind (>=2 AoE)" }, - // 11) Single-target damage - { ShouldShieldSlam, DoShieldSlam, "Shield Slam" }, - { ShouldSlam, DoSlam, "Slam (rage spender)" }, - // 12) Auto-attack fallback - { AlwaysInCombat, DoAutoAttack, "Auto attack" }, -}; - -} // anonymous - -void RegisterApl_Baseline_Warrior() -{ - RegisterRotation(CLASS_WARRIOR, 0, ApRotation{baseline_warrior_kRules}); -} - -} // namespace Playerbot::Combat diff --git a/src/modules/PlayerbotV2/Combat/Apl/Apl_Classic_Hunter.cpp b/src/modules/PlayerbotV2/Combat/Apl/Apl_Classic_Hunter.cpp index 94107345af..4c71d9acf6 100644 --- a/src/modules/PlayerbotV2/Combat/Apl/Apl_Classic_Hunter.cpp +++ b/src/modules/PlayerbotV2/Combat/Apl/Apl_Classic_Hunter.cpp @@ -19,7 +19,6 @@ // raid10-revamp, playerbot/strategy/hunter/*Strategy.cpp, MANGOSBOT_ZERO). #include "Bot/SpellFamily.h" -#include "AplPetThrottle.h" #include "../ApRegistry.h" #include "../ApRotation.h" #include "Apl_Baseline_Common.h" @@ -140,17 +139,6 @@ bool ShouldMendPet(ApPredicateContext const& ctx) } void DoMendPet(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(MEND_PET); } -bool ShouldPetAttack(ApPredicateContext const& ctx) -{ - return ctx.bot.has_pet() && HasLiveTarget(ctx) && ctx.bot.pet_victim() != ctx.bot.victim() - && Playerbot::AplPet::PetAttackDue(ctx.bot.guid().GetCounter(), ctx.bot.published_at_ms()); -} -void DoPetAttack(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - Playerbot::AplPet::NotePetAttack(ctx.bot.guid().GetCounter(), ctx.bot.published_at_ms()); - e.pet_attack(ctx.bot.victim()); -} - // ======================= Defensive ======================= bool ShouldDeterrence(ApPredicateContext const& ctx) @@ -380,7 +368,6 @@ ApRule const kRules[] = { { ShouldAspectHawk, DoAspectHawk, "classic_hunter:aspect_of_the_hawk" }, { ShouldTrueshotAura, DoTrueshotAura, "classic_hunter:trueshot_aura" }, { ShouldPrePullTrap, DoPrePullTrap, "classic_hunter:freezing_trap" }, - { ShouldPetAttack, DoPetAttack, "classic_hunter:pet_attack" }, { ShouldBestialWrath, DoBestialWrath, "classic_hunter:bestial_wrath" }, { ShouldRapidFire, DoRapidFire, "classic_hunter:rapid_fire" }, { ShouldHuntersMark, DoHuntersMark, "classic_hunter:hunters_mark" }, diff --git a/src/modules/PlayerbotV2/Combat/Apl/Apl_Classic_Warlock.cpp b/src/modules/PlayerbotV2/Combat/Apl/Apl_Classic_Warlock.cpp index ee1bb71a16..0171fc5b53 100644 --- a/src/modules/PlayerbotV2/Combat/Apl/Apl_Classic_Warlock.cpp +++ b/src/modules/PlayerbotV2/Combat/Apl/Apl_Classic_Warlock.cpp @@ -26,7 +26,6 @@ // Skipped: Fear, Fel Domination (Soulstone / Healthstone live in // the upkeep rules). -#include "AplPetThrottle.h" #include "Bot/SpellFamily.h" #include "../ApRegistry.h" #include "../ApRotation.h" @@ -189,17 +188,6 @@ bool ShouldSummonPet(ApPredicateContext const& ctx) } void DoSummonPet(ApPredicateContext const& ctx, BotIntentEmitter& e) { e.cast(PetSpell(ctx)); } -bool ShouldPetAttack(ApPredicateContext const& ctx) -{ - return HasLiveTarget(ctx) && ctx.bot.in_combat() && ctx.bot.has_pet() && ctx.bot.pet_victim() != ctx.bot.victim() - && Playerbot::AplPet::PetAttackDue(ctx.bot.guid().GetCounter(), ctx.bot.published_at_ms()); -} -void DoPetAttack(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - Playerbot::AplPet::NotePetAttack(ctx.bot.guid().GetCounter(), ctx.bot.published_at_ms()); - e.pet_attack(ctx.bot.victim()); -} - // A raid group: the curse comes from the raid plan and the dots are capped. bool InRaid(ApPredicateContext const& ctx) { @@ -373,7 +361,6 @@ ApRule const kWarlockRules[] = { { ShouldLifeTap, DoLifeTap, "classic_warlock:life_tap" }, { ShouldArmor, DoArmor, "classic_warlock:armor" }, { ShouldSummonPet, DoSummonPet, "classic_warlock:summon_pet" }, - { ShouldPetAttack, DoPetAttack, "classic_warlock:pet_attack" }, { ShouldRaidCurse, DoRaidCurse, "classic_warlock:raid_curse" }, { ShouldShadowTrance, DoShadowBolt, "classic_warlock:shadow_trance" }, { ShouldSchoolNuke, DoSchoolNuke, "classic_warlock:school_nuke" }, diff --git a/src/modules/PlayerbotV2/Combat/Apl/Apl_Druid_Balance.cpp b/src/modules/PlayerbotV2/Combat/Apl/Apl_Druid_Balance.cpp deleted file mode 100644 index 7e22c1749b..0000000000 --- a/src/modules/PlayerbotV2/Combat/Apl/Apl_Druid_Balance.cpp +++ /dev/null @@ -1,640 +0,0 @@ -// Balance Druid (Boomkin) - WoW 12.1.0.69587 (Midnight) spec rotation (specId 102). -// -// Stance / form -// ------------- -// Balance is a CASTER-form spec. The bot lives in Moonkin Form for the -// damage / haste auras and never voluntarily drops it. The baseline druid -// file is cat-form-centric (any-druid leveling default); the moment a -// druid is in the Balance spec we override that by parking in Moonkin -// Form. We do NOT cast Cat Form / Bear Form here — those are emergency -// drops the user can trigger manually or via other rules elsewhere. -// -// Astral Power loop (12.1) -// ------------------------ -// Eclipse is an ACTIVE button in Midnight (talent 1239669 teaches -// 1233346): pressing it enters Solar Eclipse (Wrath empowered) or Lunar -// Eclipse (Starfire empowered); the mode follows the last filler cast and -// both modes share the button + cooldown. Wrath / Starfire are the AP -// builders (Wrath single-target, Starfire cleave / Lunar). Starsurge is -// the instant 40-AP single-target spender; Starfall is the 50-AP ground -// AoE spender. Moonfire + Sunfire are instant DoTs blanketed across every -// reachable enemy via the BotSnapshotBuilder outbound enemy scan. -// -// Cooldowns -// --------- -// Celestial Alignment (talent 395022 -> castable 194223) and Incarnation: -// Chosen of Elune (talent 394013 -> castable 102560, replaces CA) are the -// burst windows - fire on boss-like targets or 3+ enemy AoE. Fury of -// Elune [R] is the 1min AoE beam; Heart of the Wild [R] in Moonkin Form -// is a burst of empowered falling stars; Force of Nature is a talent the -// curated build does not take (rule kept, knows_spell-gated). -// -// Survival ladder -// --------------- -// Barkskin (off-GCD 20% DR), Regrowth (hard-cast, drops Moonkin Form, -// deep panic only), Typhoon (knockback peel). Renewal no longer exists in -// 12.1. No bear-form bail in Balance - we trust the CDs + raid healer. -// -// Group utility -// ------------- -// Rebirth (battle rez), Innervate (ally mana), Mark of the Wild (group -// buff, OOC only), Soothe (enrage dispel), Remove Corruption (Curse + -// Poison dispel, class talent [R]). CC: Solar Beam (interrupt + silence) -// is the primary kick; Mighty Bash + Typhoon are emergency tools; -// Hibernate / Cyclone / Entangling Roots are situational CC options we -// leave for the baseline / non-rotational logic. -// -// Validated spell IDs (SpellName.csv, WoW 12.1.0.69587) -// ---------------------------------------------------- -// 24858 Moonkin Form (class talent [R]) -// 194153 Starfire (class talent [R]) -// 190984 Wrath (Balance spec override of baseline 5176) -// 78674 Starsurge (class talent [R], 40 AP) -// 191034 Starfall (spec spell L15, 50 AP) -// 8921 Moonfire (cast id; DoT aura is 164812) -// 93402 Sunfire (class talent [R]; DoT aura is 164815) -// 274281 New Moon (spec talent, not in build; the button -// morphs into Half / Full Moon - 274282 / -// 274283 are no longer learnable ids) -// 205636 Force of Nature (spec talent, not in build) -// 202770 Fury of Elune (spec talent [R]) -// 1233346 Solar Eclipse (Eclipse button, taught by talent 1239669; -// 1233272 Lunar Eclipse is the flipped face) -// 48517 Eclipse (Solar) (aura while Wrath is empowered) -// 48518 Eclipse (Lunar) (aura while Starfire is empowered) -// 194223 Celestial Alignment (castable; talent id 395022 teaches it) -// 102560 Incarnation: Chosen of Elune (castable; talent id 394013 teaches it) -// 1261867 Heart of the Wild (class talent [R]; Moonkin = empowered Starfall) -// 78675 Solar Beam (spec talent [R]; interrupt + silence) -// 5211 Mighty Bash (class talent, not in build) -// 132469 Typhoon (class talent [R]) -// 20484 Rebirth (battle rez) -// 22812 Barkskin (off-GCD 20% DR) -// 29166 Innervate (class talent [R]) -// 2908 Soothe (class talent [R]) -// 2782 Remove Corruption (class talent [R]; Curse + Poison) -// 8936 Regrowth (hard-cast self-heal) -// 1126 Mark of the Wild (group buff) -// -// Skipped spells (and why) -// ------------------------ -// * 202347 Stellar Flare, 202425 Warrior of Elune, 124974 Nature's -// Vigil, 108238 Renewal - not learnable by any druid in 12.1 (removed -// or reworked into passives); rules deleted. -// * 274282 / 274283 Half Moon / Full Moon - no longer separate learnable -// spells; New Moon's button morphs. Only 274281 is cast. -// * 391528 Convoke the Spirits, 88747 Wild Mushroom - spec talents the -// curated Balance builds do not take. -// * 22842 Frenzied Regeneration, 106898 Stampeding Roar, 102401 Wild -// Charge, 102793 Ursol's Vortex - [R] class talents that need Bear Form -// or ground/ally positioning the caster rotation does not do. -// * 1229376 Single-Button Assistant - client convenience macro. -// * 197911 Astral Power - power resource, read via power(POWER_LUNAR_POWER_IDX). - -#include "../ApRegistry.h" -#include "../ApRotation.h" -#include "Bot/BotIntentEmitter.h" -#include "Bot/BotSnapshotView.h" -#include "Group/GroupSnapshot.h" -#include "SharedDefines.h" - -namespace Playerbot::Combat { - -namespace { - -// ---- Spell IDs (WoW 12.1.0.69587, validated against SpellName.csv) ---- -constexpr uint32 MOONKIN_FORM = 24858; // class talent [R] -constexpr uint32 STARFIRE = 194153; // class talent [R] -constexpr uint32 WRATH = 190984; // Balance spec override of 5176 -constexpr uint32 STARSURGE = 78674; // class talent [R] - 40 AP spender -constexpr uint32 STARFALL = 191034; // spec spell L15 - 50 AP AoE spender -constexpr uint32 MOONFIRE = 8921; // cast id -constexpr uint32 MOONFIRE_DOT = 164812; // periodic aura applied by 8921 -constexpr uint32 SUNFIRE = 93402; // class talent [R]; cast id -constexpr uint32 SUNFIRE_DOT = 164815; // periodic aura applied by 93402 -constexpr uint32 NEW_MOON = 274281; // spec talent (not in build); button morphs to Half/Full Moon -constexpr uint32 FORCE_OF_NATURE = 205636; // spec talent (not in build) - treant adds -constexpr uint32 FURY_OF_ELUNE = 202770; // spec talent [R] - ground AoE beam -constexpr uint32 ECLIPSE = 1233346; // Solar Eclipse button (taught by talent 1239669) -constexpr uint32 ECLIPSE_TALENT = 1239669; // Eclipse talent [R] (teaches 1233346) -constexpr uint32 ECLIPSE_LUNAR = 48518; // Lunar Eclipse aura (Starfire empowered) -constexpr uint32 ECLIPSE_SOLAR = 48517; // Solar Eclipse aura (Wrath empowered) -constexpr uint32 CELESTIAL_ALIGN = 194223; // castable CA (taught by talent 395022) -constexpr uint32 CELESTIAL_ALIGN_TALENT = 395022; // Celestial Alignment talent [R] -constexpr uint32 INCARNATION_CHOSEN_OF_ELUNE = 102560; // castable (taught by talent 394013) -constexpr uint32 INCARNATION_TALENT = 394013; // Incarnation: Chosen of Elune talent [R] -constexpr uint32 HEART_OF_THE_WILD = 1261867; // class talent [R] - Moonkin: empowered Starfall -constexpr uint32 SOLAR_BEAM = 78675; // spec talent [R] - interrupt + silence -constexpr uint32 MIGHTY_BASH = 5211; // class talent (not in build) - stun -constexpr uint32 TYPHOON = 132469; // class talent [R] - knockback -constexpr uint32 REBIRTH = 20484; // battle resurrection -constexpr uint32 BARKSKIN = 22812; // 20% DR, 8s, 1min CD -constexpr uint32 INNERVATE = 29166; // class talent [R] - ally mana -constexpr uint32 SOOTHE = 2908; // class talent [R] - enrage dispel -constexpr uint32 REMOVE_CORRUPTION = 2782; // class talent [R] - Curse + Poison dispel -constexpr uint32 REGROWTH = 8936; // self heal (drops Moonkin Form) -constexpr uint32 MARK_OF_THE_WILD = 1126; // group buff - -// Astral Power lives at POWER_LUNAR_POWER (8) in the WoW 12.0 power array. -constexpr uint8 POWER_LUNAR_POWER_IDX = 8; - -// ---- Helpers ---- -bool HasLiveTarget(ApPredicateContext const& ctx) -{ - return !ctx.bot.victim().IsEmpty(); -} - -bool BossLikeTargetEngaged(ApPredicateContext const& ctx) -{ - constexpr int32 kBossHpThreshold = 5'000'000; - NearbyUnit const* t = ctx.bot.victim_info(); - if (t && t->max_hp >= kBossHpThreshold) return true; - for (auto const& a : ctx.bot.raw().combat.attackers) - if (a.max_hp >= kBossHpThreshold) return true; - return false; -} - -uint8 NearbyEnemiesInRange(ApPredicateContext const& ctx, float range) -{ - return static_cast(ctx.bot.enemies_within(range)); -} - -bool CanShapeshiftNow(ApPredicateContext const& ctx) -{ - auto const& mv = ctx.bot.raw().movement; - return !mv.is_mounted && !mv.is_flying; -} - -// Several 12.1 talents are exposed as a talent spell that teaches the -// classic castable (kit: "teaches"). Depending on how the talent build was -// applied the bot may know either id, so pick whichever is in the spellbook -// - classic castable first, talent id as fallback - and gate is_ready() on -// that id (is_ready folds knows_spell). Returns 0 when neither is known. -uint32 KnownId(ApPredicateContext const& ctx, uint32 castable, uint32 talent) -{ - if (ctx.bot.knows_spell(castable)) return castable; - if (ctx.bot.knows_spell(talent)) return talent; - return 0; -} - -// ---- Stance / buffs ---- -// Moonkin Form is the spec's home stance — we enter it any time the aura -// is missing and we're not mounted/flying. The baseline druid file would -// otherwise drop us into Cat Form; this rule sits high enough that on a -// Balance bot the Moonkin re-entry beats the baseline's Cat Form rule -// (different rule tables, but the spec table runs first by design). -bool ShouldMoonkinForm(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(MOONKIN_FORM)) return false; - if (ctx.bot.has_aura(MOONKIN_FORM)) return false; - if (!CanShapeshiftNow(ctx)) return false; - return true; -} -void DoMoonkinForm(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(MOONKIN_FORM); } - -bool ShouldMarkOfTheWild(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(MARK_OF_THE_WILD)) return false; - if (ctx.bot.in_combat()) return false; - return !ctx.bot.has_aura(MARK_OF_THE_WILD); -} -void DoMarkOfTheWild(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(MARK_OF_THE_WILD, ctx.bot.raw().guid); -} - -// ---- Survival ---- -bool ShouldBarkskin(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(BARKSKIN)) return false; - if (!ctx.bot.is_ready(BARKSKIN)) return false; - return ctx.bot.hp_pct() <= 50; -} -void DoBarkskin(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(BARKSKIN); } - -// Regrowth is a 1.5s hard-cast that DROPS Moonkin Form. Only fire at the -// deep-panic threshold (<=30%) and only when Barkskin is on CD - -// otherwise the lost Moonkin aura window costs more damage than the heal -// saves. Barkskin (above) runs first. -bool ShouldRegrowth(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(REGROWTH)) return false; - if (ctx.bot.hp_pct() > 30) return false; - // If the instant DR is up, prefer it. - if (ctx.bot.knows_spell(BARKSKIN) && ctx.bot.is_ready(BARKSKIN)) return false; - if (ctx.bot.is_moving() && !ctx.bot.can_cast_while_moving(REGROWTH)) return false; - return true; -} -void DoRegrowth(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(REGROWTH, ctx.bot.raw().guid); -} - -// ---- Group utility ---- -bool ShouldRebirth(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(REBIRTH)) return false; - if (!ctx.bot.is_ready(REBIRTH)) return false; - return ctx.group.dead_member_priority(ctx.bot.map_id()) != nullptr; -} -void DoRebirth(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* m = ctx.group.dead_member_priority(ctx.bot.map_id())) - e.cast(REBIRTH, m->guid); -} - -bool ShouldInnervate(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(INNERVATE)) return false; - if (!ctx.bot.is_ready(INNERVATE)) return false; - auto const* m = ctx.group.lowest_mana_caster(); - if (!m || !m->online || m->hp <= 0) return false; - if (m->guid == ctx.bot.raw().guid) return false; - return m->max_mana > 0 && (m->mana * 100) / m->max_mana <= 30; -} -void DoInnervate(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* m = ctx.group.lowest_mana_caster()) - e.cast(INNERVATE, m->guid); -} - -bool ShouldSoothe(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(SOOTHE)) return false; - if (!ctx.bot.is_ready(SOOTHE)) return false; - return ctx.bot.target_dispellable(Playerbot::DispelType::Enrage); -} -void DoSoothe(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(SOOTHE, ctx.bot.victim()); -} - -// Remove Corruption: Curse + Poison dispel (class talent [R]). Castable in -// Moonkin Form. Group member first, self as fallback. -bool ShouldRemoveCorruption(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(REMOVE_CORRUPTION)) return false; - if (!ctx.bot.is_ready(REMOVE_CORRUPTION)) return false; - if (ctx.group.dispel_candidate(Playerbot::DispelType::Curse) != nullptr) return true; - if (ctx.group.dispel_candidate(Playerbot::DispelType::Poison) != nullptr) return true; - return ctx.bot.self_dispellable(Playerbot::DispelType::Curse) - || ctx.bot.self_dispellable(Playerbot::DispelType::Poison); -} -void DoRemoveCorruption(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* m = ctx.group.dispel_candidate(Playerbot::DispelType::Curse)) - { e.cast(REMOVE_CORRUPTION, m->guid); return; } - if (auto const* m = ctx.group.dispel_candidate(Playerbot::DispelType::Poison)) - { e.cast(REMOVE_CORRUPTION, m->guid); return; } - e.cast(REMOVE_CORRUPTION, ctx.bot.raw().guid); -} - -// ---- Interrupt / CC ---- -// Interrupt-aware gates: every Druid interrupt should check that the -// victim is actually casting an interruptible spell (saves CD for caster -// mobs instead of burning on melee trash). `kick_target()` already -// returns nullptr unless the candidate is mid-cast on an interruptible. -bool ShouldSolarBeam(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(SOLAR_BEAM)) return false; - if (!ctx.bot.is_ready(SOLAR_BEAM)) return false; - const bool pvp = ctx.pvp.in_battleground || ctx.pvp.in_arena; - auto const* c = ctx.bot.kick_target(pvp, 40.0f); - return c && !c->guid.IsEmpty(); -} -void DoSolarBeam(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - const bool pvp = ctx.pvp.in_battleground || ctx.pvp.in_arena; - if (auto const* c = ctx.bot.kick_target(pvp, 40.0f)) - e.cast_at(SOLAR_BEAM, c->x, c->y, c->z); -} - -bool ShouldMightyBash(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(MIGHTY_BASH)) return false; - if (!ctx.bot.is_ready(MIGHTY_BASH)) return false; - // Only fire when Solar Beam isn't a better option (Solar Beam is the - // primary kick) AND a caster is actually interruptible nearby. - if (ctx.bot.is_ready(SOLAR_BEAM) && ctx.bot.knows_spell(SOLAR_BEAM)) return false; - return ctx.bot.interruptible_caster() != nullptr - || ctx.bot.enemies_within(8.0f) >= 1; -} -void DoMightyBash(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* c = ctx.bot.interruptible_caster()) - { e.cast(MIGHTY_BASH, c->guid); return; } - e.cast(MIGHTY_BASH, ctx.bot.victim()); -} - -bool ShouldTyphoon(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(TYPHOON)) return false; - if (!ctx.bot.is_ready(TYPHOON)) return false; - // Knockback to peel melee — at least 2 attackers in our face and we're - // taking pressure. - return ctx.bot.enemies_within(15.0f) >= 2 && ctx.bot.hp_pct() <= 50; -} -void DoTyphoon(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(TYPHOON); } - -// ---- Major offensive cooldowns ---- -// Incarnation: Chosen of Elune replaces Celestial Alignment when talented; -// both are exposed as talent-teaches-castable pairs (see KnownId). -bool ShouldIncarnation(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - const uint32 id = KnownId(ctx, INCARNATION_CHOSEN_OF_ELUNE, INCARNATION_TALENT); - if (!id || !ctx.bot.is_ready(id)) return false; - return BossLikeTargetEngaged(ctx) || NearbyEnemiesInRange(ctx, 40.0f) >= 3; -} -void DoIncarnation(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (const uint32 id = KnownId(ctx, INCARNATION_CHOSEN_OF_ELUNE, INCARNATION_TALENT)) - e.cast(id); -} - -bool ShouldCelestialAlign(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - // Incarnation owns the burst slot when it is talented. - if (KnownId(ctx, INCARNATION_CHOSEN_OF_ELUNE, INCARNATION_TALENT)) return false; - const uint32 id = KnownId(ctx, CELESTIAL_ALIGN, CELESTIAL_ALIGN_TALENT); - if (!id || !ctx.bot.is_ready(id)) return false; - return BossLikeTargetEngaged(ctx) || NearbyEnemiesInRange(ctx, 40.0f) >= 3; -} -void DoCelestialAlign(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (const uint32 id = KnownId(ctx, CELESTIAL_ALIGN, CELESTIAL_ALIGN_TALENT)) - e.cast(id); -} - -// ---- Eclipse (12.1: an active button) ---- -// The Eclipse talent turns Eclipse into a cast: the button enters Solar -// Eclipse (empowers Wrath) or Lunar Eclipse (empowers Starfire); the mode -// follows the last filler cast (Wrath -> Solar, Starfire -> Lunar) and both -// modes share the button and its cooldown. Press it whenever no Eclipse -// (or CA / Incarnation, which grant both) is active, after letting one -// filler arm the mode that fits the fight shape: Lunar on 2+ targets, -// Solar single-target. -bool ShouldEclipse(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - const uint32 id = KnownId(ctx, ECLIPSE, ECLIPSE_TALENT); - if (!id || !ctx.bot.is_ready(id)) return false; - if (ctx.bot.has_aura(ECLIPSE_SOLAR) || ctx.bot.has_aura(ECLIPSE_LUNAR)) return false; - if (ctx.bot.has_aura(CELESTIAL_ALIGN) || ctx.bot.has_aura(INCARNATION_CHOSEN_OF_ELUNE)) return false; - const bool aoe = ctx.aoe_preference || NearbyEnemiesInRange(ctx, 40.0f) >= 2; - const uint32 last = ctx.bot.last_cast_spell_id(); - // Wrong mode armed for the fight shape - let one filler flip it first. - if (aoe && last == WRATH) return false; - if (!aoe && last == STARFIRE) return false; - return true; -} -void DoEclipse(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (const uint32 id = KnownId(ctx, ECLIPSE, ECLIPSE_TALENT)) - e.cast(id); -} - -// Heart of the Wild in Moonkin Form = a burst of empowered falling stars -// around the bot (2min CD). Treat it as an AoE / boss cooldown next to -// Fury of Elune; self-targeted since the Moonkin variant is caster-centred. -bool ShouldHeartOfTheWild(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(HEART_OF_THE_WILD)) return false; - if (!ctx.bot.is_ready(HEART_OF_THE_WILD)) return false; - if (!ctx.bot.has_aura(MOONKIN_FORM)) return false; - return BossLikeTargetEngaged(ctx) || NearbyEnemiesInRange(ctx, 40.0f) >= 2; -} -void DoHeartOfTheWild(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(HEART_OF_THE_WILD, ctx.bot.raw().guid); -} - -bool ShouldForceOfNature(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(FORCE_OF_NATURE)) return false; - if (!ctx.bot.is_ready(FORCE_OF_NATURE)) return false; - return true; -} -void DoForceOfNature(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* v = ctx.bot.victim_info()) - e.cast_at(FORCE_OF_NATURE, v->x, v->y, v->z); - else - e.cast(FORCE_OF_NATURE, ctx.bot.victim()); -} - -bool ShouldFuryOfElune(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(FURY_OF_ELUNE)) return false; - if (!ctx.bot.is_ready(FURY_OF_ELUNE)) return false; - return true; -} -void DoFuryOfElune(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* v = ctx.bot.victim_info()) - e.cast_at(FURY_OF_ELUNE, v->x, v->y, v->z); - else - e.cast(FURY_OF_ELUNE, ctx.bot.victim()); -} - -// ---- AoE ---- -bool ShouldStarfall(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(STARFALL)) return false; - if (!ctx.bot.is_ready(STARFALL)) return false; - if (ctx.bot.power(POWER_LUNAR_POWER_IDX) < 50) return false; - // 2+ targets makes it more total damage than Starsurge. - return ctx.aoe_preference || NearbyEnemiesInRange(ctx, 40.0f) >= 2; -} -void DoStarfall(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(STARFALL); } - -// ---- DoTs ---- -// Moonfire / Sunfire casts apply separate periodic auras (164812 / 164815), -// so refresh and multi-dot checks look for the DoT ids, not the cast ids. -bool ShouldMoonfirePrimary(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(MOONFIRE)) return false; - AuraEntry const* a = ctx.bot.find_aura(MOONFIRE_DOT, ctx.bot.victim()); - return !a || a->remaining.count() <= 4000; -} -void DoMoonfirePrimary(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(MOONFIRE, ctx.bot.victim()); -} - -bool ShouldSunfirePrimary(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(SUNFIRE)) return false; - AuraEntry const* a = ctx.bot.find_aura(SUNFIRE_DOT, ctx.bot.victim()); - return !a || a->remaining.count() <= 4000; -} -void DoSunfirePrimary(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(SUNFIRE, ctx.bot.victim()); -} - -bool ShouldMoonfireExpand(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(MOONFIRE)) return false; - return ctx.bot.enemy_without_my_aura(MOONFIRE_DOT, 40.0f) != nullptr; -} -void DoMoonfireExpand(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* off = ctx.bot.enemy_without_my_aura(MOONFIRE_DOT, 40.0f)) - e.cast(MOONFIRE, off->guid); -} - -bool ShouldSunfireExpand(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(SUNFIRE)) return false; - return ctx.bot.enemy_without_my_aura(SUNFIRE_DOT, 40.0f) != nullptr; -} -void DoSunfireExpand(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* off = ctx.bot.enemy_without_my_aura(SUNFIRE_DOT, 40.0f)) - e.cast(SUNFIRE, off->guid); -} - -// ---- New Moon (the button morphs into Half / Full Moon in 12.1) ---- -bool ShouldNewMoon(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(NEW_MOON)) return false; - return ctx.bot.is_ready(NEW_MOON); -} -void DoNewMoon(ApPredicateContext const& ctx, BotIntentEmitter& e) { e.cast(NEW_MOON, ctx.bot.victim()); } - -// ---- AP spender ---- -bool ShouldStarsurge(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(STARSURGE)) return false; - if (!ctx.bot.is_ready(STARSURGE)) return false; - if (ctx.bot.power(POWER_LUNAR_POWER_IDX) < 40) return false; - // Instant in 12.1; the moving guard stays harmless if build data differs. - if (ctx.bot.is_moving() && !ctx.bot.can_cast_while_moving(STARSURGE)) return false; - // Single-target spender — defer to Starfall when 2+ enemies. - return NearbyEnemiesInRange(ctx, 40.0f) <= 1 || BossLikeTargetEngaged(ctx); -} -void DoStarsurge(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(STARSURGE, ctx.bot.victim()); -} - -// ---- Eclipse fillers ---- -// Starfire is the heavier filler - preferred in Lunar Eclipse (cleave -// bonus on secondary targets) and on 2+ enemy AoE. Wrath is the lighter -// filler - preferred in Solar Eclipse and on single-target sustained -// damage. In 12.1 the last filler cast also arms which mode the Eclipse -// button enters (see ShouldEclipse), so this split doubles as the mode -// selector. -bool ShouldStarfire(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(STARFIRE)) return false; - if (!ctx.bot.is_ready(STARFIRE)) return false; - if (ctx.bot.is_moving() && !ctx.bot.can_cast_while_moving(STARFIRE)) return false; - if (ctx.bot.has_aura(ECLIPSE_LUNAR)) return true; - if (NearbyEnemiesInRange(ctx, 40.0f) >= 2) return true; - // Otherwise, build toward Solar Eclipse via Wrath. Only fall through - // to Starfire if Wrath isn't known (very low level / no spec). - return !ctx.bot.knows_spell(WRATH); -} -void DoStarfire(ApPredicateContext const& ctx, BotIntentEmitter& e) { e.cast(STARFIRE, ctx.bot.victim()); } - -bool ShouldWrath(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(WRATH)) return false; - if (ctx.bot.is_moving() && !ctx.bot.can_cast_while_moving(WRATH)) return false; - return true; -} -void DoWrath(ApPredicateContext const& ctx, BotIntentEmitter& e) { e.cast(WRATH, ctx.bot.victim()); } - -bool AlwaysAlive(ApPredicateContext const& ctx) { return ctx.bot.is_alive(); } -void DoNothing(ApPredicateContext const&, BotIntentEmitter&) {} - -// ---- Rule table (priority order top-down) ---- -// Order rationale: -// 1. Rebirth - battle-rez has highest impact in group. -// 2. Barkskin - off-GCD survival, fire on damage spikes. -// 3. Regrowth - hard-cast panic only (DROPS Moonkin -// briefly) when Barkskin is down. -// 4. Typhoon - peel knockback when surrounded. -// 5. Moonkin Form - spec stance entry, sits above DPS rules -// so a stripped/dispelled form re-applies -// before any nuke fires. -// 6. Mark of the Wild - OOC group buff maintenance. -// 7. Solar Beam - primary interrupt (AoE silence too). -// 8. Mighty Bash - interrupt fallback when Solar Beam down. -// 9. Soothe - enrage dispel on target. -// 10. Remove Corruption - Curse / Poison dispel on group or self. -// 11. Innervate - ally caster mana cooldown. -// 12. Incarnation - major CD (replaces CA when talented). -// 13. Celestial Alignment - major CD when Incarnation not talented. -// 14. Eclipse - active Eclipse button (12.1) whenever no -// Eclipse / CA / Incarnation is up. -// 15. Heart of the Wild - empowered Starfall burst (2+ / boss). -// 16. Force of Nature - treant adds (talent, not in build). -// 17. Fury of Elune - ground AoE beam (talent). -// 18. Starfall - 50-AP AoE spender (2+ targets). -// 19. Sunfire primary - instant DoT on victim. -// 20. Moonfire primary - instant DoT on victim. -// 21. Sunfire expand - blanket DoT on off-target enemies. -// 22. Moonfire expand - blanket DoT on off-target enemies. -// 23. New Moon - talent nuke (button morphs Half / Full). -// 24. Starsurge - 40-AP ST spender. -// 25. Starfire - heavier filler (Lunar / AoE). -// 26. Wrath - lighter filler (Solar build). -// 27. Idle - alive fallthrough. -ApRule const kRules[] = { - { ShouldRebirth, DoRebirth, "Rebirth (battle rez)" }, - { ShouldBarkskin, DoBarkskin, "Barkskin (<=50%)" }, - { ShouldRegrowth, DoRegrowth, "Regrowth (<=30% deep panic)"}, - { ShouldTyphoon, DoTyphoon, "Typhoon (peel)" }, - { ShouldMoonkinForm, DoMoonkinForm, "Moonkin Form" }, - { ShouldMarkOfTheWild, DoMarkOfTheWild, "Mark of the Wild" }, - { ShouldSolarBeam, DoSolarBeam, "Solar Beam (interrupt)" }, - { ShouldMightyBash, DoMightyBash, "Mighty Bash (interrupt fb)" }, - { ShouldSoothe, DoSoothe, "Soothe (enrage)" }, - { ShouldRemoveCorruption, DoRemoveCorruption, "Remove Corruption (dispel)" }, - { ShouldInnervate, DoInnervate, "Innervate (healer mana)" }, - { ShouldIncarnation, DoIncarnation, "Incarnation" }, - { ShouldCelestialAlign, DoCelestialAlign, "Celestial Alignment" }, - { ShouldEclipse, DoEclipse, "Eclipse (enter)" }, - { ShouldHeartOfTheWild, DoHeartOfTheWild, "Heart of the Wild (stars)" }, - { ShouldForceOfNature, DoForceOfNature, "Force of Nature (treants)" }, - { ShouldFuryOfElune, DoFuryOfElune, "Fury of Elune" }, - { ShouldStarfall, DoStarfall, "Starfall (2+ AoE)" }, - { ShouldSunfirePrimary, DoSunfirePrimary, "Sunfire (primary)" }, - { ShouldMoonfirePrimary, DoMoonfirePrimary, "Moonfire (primary)" }, - { ShouldSunfireExpand, DoSunfireExpand, "Sunfire (expand off-tgt)" }, - { ShouldMoonfireExpand, DoMoonfireExpand, "Moonfire (expand off-tgt)" }, - { ShouldNewMoon, DoNewMoon, "New Moon" }, - { ShouldStarsurge, DoStarsurge, "Starsurge (spend)" }, - { ShouldStarfire, DoStarfire, "Starfire (lunar/cleave)" }, - { ShouldWrath, DoWrath, "Wrath (solar build)" }, - { AlwaysAlive, DoNothing, "Idle" }, -}; - -} // anonymous - -void RegisterApl_Druid_Balance() -{ - constexpr uint32 SPEC_DRUID_BALANCE = 102; - RegisterRotation(CLASS_DRUID, SPEC_DRUID_BALANCE, ApRotation{kRules}); -} - -} // namespace Playerbot::Combat diff --git a/src/modules/PlayerbotV2/Combat/Apl/Apl_Druid_Feral.cpp b/src/modules/PlayerbotV2/Combat/Apl/Apl_Druid_Feral.cpp deleted file mode 100644 index fa5250bc84..0000000000 --- a/src/modules/PlayerbotV2/Combat/Apl/Apl_Druid_Feral.cpp +++ /dev/null @@ -1,742 +0,0 @@ -// Feral Druid - WoW 12.1.0.69587 (Midnight) spec rotation (specId 103). -// -// Stance / form -// ------------- -// Feral lives in CAT FORM. The baseline druid file already runs a cat- -// form-centric kit (Rake / Rip / Shred / FB at 4+ CP); Feral SPEC tightens -// that to: -// -// * 5-CP-only finishers (Rip / Ferocious Bite / Primal Wrath) - better -// damage per CP than baseline's 4+ CP threshold. -// * Predatory Swiftness proc tracking (buff 69369) - instant-Regrowth -// window after a finisher, used for self-top-up without losing GCDs -// to a hard cast or dropping Cat Form. -// * Feral Frenzy [R] (or its Frantic Frenzy override) - 5-CP instant -// builder + bleed; Heart of the Wild [R] in Cat Form is an empowered -// Feral Frenzy and is used the same way. -// * Tiger's Fury / Berserk [R] (talent 343223 teaches 106951) / -// Incarnation: Avatar of Ashamane CD set; Convoke the Spirits [R] -// inside the burst window (or on a boss when no window is coming). -// * Bear Form bail at <=25% as a last-ditch when both Survival -// Instincts and Barkskin are on CD - armor + reduced damage gives -// the healer a window; Frenzied Regeneration [R] is used from bear. -// -// We do NOT cast Moonkin Form here. The baseline rotation handles cat- -// form re-entry too; this spec rotation just runs FIRST, so our stricter -// form-management gate fires before the baseline can take over. -// -// Validated spell IDs (SpellName.csv, WoW 12.1.0.69587) -// ---------------------------------------------------- -// 768 Cat Form -// 5487 Bear Form (emergency bail) -// 5221 Shred -// 1822 Rake (class talent [R]; bleed aura 155722) -// 1079 Rip (class talent [R]; aura id == cast id) -// 106830 Thrash (Cat) (cast id; bleed aura 405233) -// 22568 Ferocious Bite -// 5217 Tiger's Fury (spec talent [R]) -// 106951 Berserk (castable; talent id 343223 teaches it) -// 102543 Incarnation: Avatar of Ashamane (spec talent, not in build) -// 391528 Convoke the Spirits (spec talent [R]) -// 274837 Feral Frenzy (spec talent [R]; 1243807 Frantic Frenzy -// is its override when talented) -// 1261867 Heart of the Wild (class talent [R]; Cat = empowered Feral Frenzy) -// 155580 Lunar Inspiration (spec passive [R]; teaches 155627; makes -// Moonfire 8921 usable in Cat Form) -// 8921 Moonfire (cast id; DoT aura 164812) -// 106839 Skull Bash (class talent [R]) -// 213764 Swipe (class talent [R]; single id for cat + bear) -// 285381 Primal Wrath (spec talent, not in build) -// 22570 Maim (class talent, not in build) -// 5211 Mighty Bash (class talent, not in build) -// 2908 Soothe (class talent [R]) -// 20484 Rebirth -// 29166 Innervate (class talent [R]) -// 8936 Regrowth -// 61336 Survival Instincts (spec talent [R]) -// 22842 Frenzied Regeneration (class talent [R]; bear-only) -// 22812 Barkskin -// 5215 Prowl -// 1126 Mark of the Wild -// 16974 Predatory Swiftness (passive); 69369 is the proc buff aura -// -// Skipped spells (and why) -// ------------------------ -// * 202028 Brutal Slash, 108238 Renewal, 155625 Moonfire (cat variant) -// - not learnable in 12.1; rules deleted (Swipe / Moonfire 8921 cover -// the roles). -// * 1244258 Chomp - spec talent the curated build does not take. -// * 2782 Remove Corruption, 106898 Stampeding Roar, 102401 Wild Charge, -// 102793 Ursol's Vortex - [R] class talents that need caster form or -// ally / ground positioning the cat rotation does not do. -// * 1229376 Single-Button Assistant - client convenience macro. -// * Mark of the Wild during combat - would drop cat form. Gated on -// `!in_combat` in the ShouldMarkOfTheWild predicate. - -#include "../ApRegistry.h" -#include "../ApRotation.h" -#include "Bot/BotIntentEmitter.h" -#include "Bot/BotSnapshotView.h" -#include "Group/GroupSnapshot.h" -#include "SharedDefines.h" - -namespace Playerbot::Combat { - -namespace { - -// ---- Spell IDs (WoW 12.1.0.69587, validated against SpellName.csv) ---- -constexpr uint32 CAT_FORM = 768; -constexpr uint32 BEAR_FORM = 5487; // emergency bail -constexpr uint32 SHRED = 5221; -constexpr uint32 RAKE = 1822; // class talent [R] -constexpr uint32 RAKE_DEBUFF = 155722; // Rake bleed aura -constexpr uint32 RIP = 1079; // class talent [R]; aura id == cast id -constexpr uint32 THRASH_CAT = 106830; // cast id -constexpr uint32 THRASH_DEBUFF = 405233; // cat Thrash bleed aura -constexpr uint32 FEROCIOUS_BITE = 22568; -constexpr uint32 TIGERS_FURY = 5217; // spec talent [R] -constexpr uint32 BERSERK = 106951; // castable (talent 343223 teaches it) -constexpr uint32 BERSERK_TALENT = 343223; // Berserk talent [R] -constexpr uint32 INCARNATION_KING_OF_THE_JUNGLE = 102543; // Incarnation: Avatar of Ashamane (not in build) -constexpr uint32 CONVOKE_SPIRITS = 391528; // spec talent [R] burst -constexpr uint32 FERAL_FRENZY = 274837; // spec talent [R] - 5cp instant builder -constexpr uint32 FRANTIC_FRENZY = 1243807; // talent override of Feral Frenzy (not in build) -constexpr uint32 HEART_OF_THE_WILD = 1261867; // class talent [R] - Cat: empowered Feral Frenzy -constexpr uint32 LUNAR_INSPIRATION = 155580; // spec passive [R] - Moonfire usable in Cat Form -constexpr uint32 LUNAR_INSPIRATION_ALT = 155627; // spell taught by 155580 -constexpr uint32 MOONFIRE = 8921; // cast id (155625 cat variant is gone) -constexpr uint32 MOONFIRE_DOT = 164812; // Moonfire periodic aura -constexpr uint32 SKULL_BASH = 106839; // class talent [R] -constexpr uint32 SWIPE = 213764; // class talent [R] - single Swipe id in 12.1 -constexpr uint32 PRIMAL_WRATH = 285381; // spec talent (not in build) -constexpr uint32 MAIM = 22570; // class talent (not in build) - CP stun -constexpr uint32 MIGHTY_BASH = 5211; // class talent (not in build) -constexpr uint32 SOOTHE = 2908; // class talent [R] -constexpr uint32 REBIRTH = 20484; -constexpr uint32 INNERVATE = 29166; // class talent [R] -constexpr uint32 REGROWTH = 8936; -constexpr uint32 SURVIVAL_INSTINCTS = 61336; // spec talent [R] -constexpr uint32 FRENZIED_REGEN = 22842; // class talent [R] - bear-form self heal -constexpr uint32 BARKSKIN_FERAL = 22812; -constexpr uint32 PROWL = 5215; // OOC stealth -constexpr uint32 MARK_OF_THE_WILD = 1126; -constexpr uint32 PREDATORY_SWIFTNESS = 16974; // passive (always present as an aura) -constexpr uint32 PREDATORY_SWIFTNESS_BUFF = 69369; // proc buff - next Regrowth instant, all forms - -// Combo points live in POWER_COMBO_POINTS (4) in the power array. -constexpr uint8 POWER_COMBO_POINTS_IDX = 4; -// Energy in POWER_ENERGY (3), Rage in POWER_RAGE (1). -constexpr uint8 POWER_ENERGY_IDX = 3; -constexpr uint8 POWER_RAGE_IDX = 1; - -bool HasLiveTarget(ApPredicateContext const& ctx) -{ - return !ctx.bot.victim().IsEmpty(); -} - -bool BossLikeTargetEngaged(ApPredicateContext const& ctx) -{ - constexpr int32 kBossHpThreshold = 5'000'000; - NearbyUnit const* t = ctx.bot.victim_info(); - if (t && t->max_hp >= kBossHpThreshold) return true; - for (auto const& a : ctx.bot.raw().combat.attackers) - if (a.max_hp >= kBossHpThreshold) return true; - return false; -} - -uint8 ComboPoints(ApPredicateContext const& ctx) -{ - return static_cast(ctx.bot.power(POWER_COMBO_POINTS_IDX)); -} - -bool CanShapeshiftNow(ApPredicateContext const& ctx) -{ - auto const& mv = ctx.bot.raw().movement; - return !mv.is_mounted && !mv.is_flying; -} - -// Pick the first of two ids the bot actually knows. Used for 12.1 pairs -// where a talent spell teaches the classic castable (Berserk 343223 -> -// 106951) and for talent overrides (Frantic Frenzy over Feral Frenzy). -// Gate is_ready() on the returned id - is_ready folds knows_spell. -uint32 KnownId(ApPredicateContext const& ctx, uint32 primary, uint32 fallback) -{ - if (ctx.bot.knows_spell(primary)) return primary; - if (ctx.bot.knows_spell(fallback)) return fallback; - return 0; -} - -// ---- Stealth opener (mirrors Assassination Rogue's Stealth → Garrote) ---- -// Prowl out of combat so we open from stealth: the stealth Rake hits for -// bonus damage (Improved Prowl) and is the spec's strongest opener. Requires -// an enemy to be present/nearby — no point stealthing in an empty field. -bool ShouldProwl(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(PROWL)) return false; - if (ctx.bot.in_combat()) return false; - if (ctx.bot.has_aura(PROWL)) return false; - if (!CanShapeshiftNow(ctx)) return false; - // Only stealth when there's something to open on — a live victim or a - // hostile within engage range. - return HasLiveTarget(ctx) || ctx.bot.enemies_within(30.0f) >= 1; -} -void DoProwl(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(PROWL); } - -// Stealth-opener Rake: from Prowl, Rake applies its bonus opener damage + -// stun. Fire BEFORE the standard builders so the stealth window isn't -// wasted on a plain Shred. Requires Cat Form (Prowl coexists with Cat Form -// for Feral). -bool ShouldRakeOpener(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(RAKE)) return false; - if (!ctx.bot.has_aura(PROWL)) return false; - return true; -} -void DoRakeOpener(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(RAKE, ctx.bot.victim()); -} - -// ---- Stance / buffs ---- -// Cat Form is the spec's home stance. We enter it whenever the aura is -// missing AND we're not currently bailing in Bear Form for survival — -// the bear-form bail rule below has higher priority, so this rule only -// fires when the bail isn't active (or HP recovered above the bail -// threshold). -bool ShouldCatForm(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(CAT_FORM)) return false; - if (ctx.bot.has_aura(CAT_FORM)) return false; - if (!CanShapeshiftNow(ctx)) return false; - // Don't pop Cat Form while we're bailing in Bear — the bail rule - // wants us to stay in bear armor until HP recovers above 40%. - if (ctx.bot.has_aura(BEAR_FORM) && ctx.bot.hp_pct() <= 40) return false; - return true; -} -void DoCatForm(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(CAT_FORM); } - -bool ShouldMarkOfTheWild(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(MARK_OF_THE_WILD)) return false; - if (ctx.bot.in_combat()) return false; - return !ctx.bot.has_aura(MARK_OF_THE_WILD); -} -void DoMarkOfTheWild(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(MARK_OF_THE_WILD, ctx.bot.raw().guid); -} - -// ---- Survival ---- -// Last-ditch bail to Bear Form: both major DRs on CD, sub-25% HP. Bear -// armor + reduced damage buys the healer one or two GCDs. -bool ShouldBearFormBail(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(BEAR_FORM)) return false; - if (ctx.bot.has_aura(BEAR_FORM)) return false; - if (!CanShapeshiftNow(ctx)) return false; - if (ctx.bot.hp_pct() > 25) return false; - if (ctx.bot.knows_spell(SURVIVAL_INSTINCTS) && ctx.bot.is_ready(SURVIVAL_INSTINCTS)) return false; - if (ctx.bot.knows_spell(BARKSKIN_FERAL) && ctx.bot.is_ready(BARKSKIN_FERAL)) return false; - return true; -} -void DoBearForm(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(BEAR_FORM); } - -// Frenzied Regeneration (class talent [R]) is bear-only. It is reachable -// only while we sit in the Bear Form bail, where the shift itself grants -// enough Rage for one cast. -bool ShouldFrenziedRegen(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.has_aura(BEAR_FORM)) return false; - if (!ctx.bot.knows_spell(FRENZIED_REGEN)) return false; - if (!ctx.bot.is_ready(FRENZIED_REGEN)) return false; - if (ctx.bot.power(POWER_RAGE_IDX) < 10) return false; - return ctx.bot.hp_pct() <= 50; -} -void DoFrenziedRegen(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(FRENZIED_REGEN); } - -bool ShouldSurvivalInstincts(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(SURVIVAL_INSTINCTS)) return false; - if (!ctx.bot.is_ready(SURVIVAL_INSTINCTS)) return false; - return ctx.bot.hp_pct() <= 30; -} -void DoSurvivalInstincts(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(SURVIVAL_INSTINCTS); } - -bool ShouldBarkskin(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(BARKSKIN_FERAL)) return false; - if (!ctx.bot.is_ready(BARKSKIN_FERAL)) return false; - return ctx.bot.hp_pct() <= 60; -} -void DoBarkskin(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(BARKSKIN_FERAL); } - -// Predatory Swiftness - instant Regrowth window. Finishers proc the 69369 -// buff ("next Regrowth instant, free, castable in all forms"); we use it -// whenever it is up and we're below 80% HP because the instant cast does -// NOT drop Cat Form. Note: 16974 is the passive and is always present - -// checking it would fire a form-dropping hard cast every tick. -bool ShouldPredatorySwiftnessRegrowth(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(REGROWTH)) return false; - if (!ctx.bot.knows_spell(PREDATORY_SWIFTNESS)) return false; - if (!ctx.bot.has_aura(PREDATORY_SWIFTNESS_BUFF)) return false; - return ctx.bot.hp_pct() <= 80; -} -void DoPredatorySwiftnessRegrowth(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(REGROWTH, ctx.bot.raw().guid); -} - -// Hard-cast Regrowth fallback: OOC only (in cat, it would drop us; we -// only run it between pulls when the cost is a few seconds of caster -// form before re-shifting). In combat use Predatory Swiftness above. -bool ShouldRegrowth(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(REGROWTH)) return false; - return ctx.bot.hp_pct() <= 35 && !ctx.bot.in_combat(); -} -void DoRegrowth(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(REGROWTH, ctx.bot.raw().guid); -} - -// ---- Group utility ---- -bool ShouldRebirth(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(REBIRTH)) return false; - if (!ctx.bot.is_ready(REBIRTH)) return false; - return ctx.group.dead_member_priority(ctx.bot.map_id()) != nullptr; -} -void DoRebirth(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* m = ctx.group.dead_member_priority(ctx.bot.map_id())) - e.cast(REBIRTH, m->guid); -} - -bool ShouldInnervate(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(INNERVATE)) return false; - if (!ctx.bot.is_ready(INNERVATE)) return false; - auto const* m = ctx.group.lowest_mana_caster(); - if (!m || !m->online || m->hp <= 0) return false; - if (m->guid == ctx.bot.raw().guid) return false; - return m->max_mana > 0 && (m->mana * 100) / m->max_mana <= 30; -} -void DoInnervate(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* m = ctx.group.lowest_mana_caster()) - e.cast(INNERVATE, m->guid); -} - -bool ShouldSoothe(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(SOOTHE)) return false; - if (!ctx.bot.is_ready(SOOTHE)) return false; - return ctx.bot.target_dispellable(Playerbot::DispelType::Enrage); -} -void DoSoothe(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(SOOTHE, ctx.bot.victim()); -} - -// ---- Interrupt / CC ---- -// Skull Bash: primary 13y kick. kick_target() already verifies the -// victim is mid-cast on an interruptible spell — no false fires on melee -// trash that just happens to be close. -bool ShouldSkullBash(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(SKULL_BASH)) return false; - if (!ctx.bot.is_ready(SKULL_BASH)) return false; - const bool pvp = ctx.pvp.in_battleground || ctx.pvp.in_arena; - return ctx.bot.kick_target(pvp, 13.0f) != nullptr; -} -void DoSkullBash(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - const bool pvp = ctx.pvp.in_battleground || ctx.pvp.in_arena; - if (auto const* c = ctx.bot.kick_target(pvp, 13.0f)) - e.cast(SKULL_BASH, c->guid); -} - -// Maim is a CP-spending stun — fallback interrupt when Skull Bash is on -// CD. Needs at least 1 CP and a kick target in melee range. -bool ShouldMaim(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(MAIM)) return false; - if (!ctx.bot.is_ready(MAIM)) return false; - if (ComboPoints(ctx) < 1) return false; - if (ctx.bot.is_ready(SKULL_BASH) && ctx.bot.knows_spell(SKULL_BASH)) return false; - const bool pvp = ctx.pvp.in_battleground || ctx.pvp.in_arena; - return ctx.bot.kick_target(pvp, 5.0f) != nullptr; -} -void DoMaim(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - const bool pvp = ctx.pvp.in_battleground || ctx.pvp.in_arena; - if (auto const* c = ctx.bot.kick_target(pvp, 5.0f)) - e.cast(MAIM, c->guid); -} - -bool ShouldMightyBash(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(MIGHTY_BASH)) return false; - if (!ctx.bot.is_ready(MIGHTY_BASH)) return false; - if (ctx.bot.is_ready(SKULL_BASH) && ctx.bot.knows_spell(SKULL_BASH)) return false; - return ctx.bot.interruptible_caster() != nullptr - || ctx.bot.enemies_within(8.0f) >= 1; -} -void DoMightyBash(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* c = ctx.bot.interruptible_caster()) - { e.cast(MIGHTY_BASH, c->guid); return; } - e.cast(MIGHTY_BASH, ctx.bot.victim()); -} - -// ---- Major offensive cooldowns ---- -bool ShouldTigersFury(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(TIGERS_FURY)) return false; - if (!ctx.bot.is_ready(TIGERS_FURY)) return false; - if (!ctx.bot.has_aura(CAT_FORM)) return false; // useless outside cat - // Energy floor — only worthwhile when we have room for the +60 refund. - return ctx.bot.power(POWER_ENERGY_IDX) <= 50; -} -void DoTigersFury(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(TIGERS_FURY); } - -// Berserk is a talent-teaches-castable pair in 12.1 (343223 -> 106951); -// Incarnation: Avatar of Ashamane replaces it when talented. -bool ShouldBerserk(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (ctx.bot.knows_spell(INCARNATION_KING_OF_THE_JUNGLE)) return false; - const uint32 id = KnownId(ctx, BERSERK, BERSERK_TALENT); - if (!id || !ctx.bot.is_ready(id)) return false; - if (!ctx.bot.has_aura(CAT_FORM)) return false; - return BossLikeTargetEngaged(ctx) || ctx.bot.enemies_within(10.0f) >= 3; -} -void DoBerserk(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (const uint32 id = KnownId(ctx, BERSERK, BERSERK_TALENT)) - e.cast(id); -} - -bool ShouldIncarnation(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(INCARNATION_KING_OF_THE_JUNGLE)) return false; - if (!ctx.bot.is_ready(INCARNATION_KING_OF_THE_JUNGLE)) return false; - if (!ctx.bot.has_aura(CAT_FORM)) return false; - return BossLikeTargetEngaged(ctx) || ctx.bot.enemies_within(10.0f) >= 3; -} -void DoIncarnation(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(INCARNATION_KING_OF_THE_JUNGLE); } - -bool InBurstWindow(ApPredicateContext const& ctx) -{ - return ctx.bot.has_aura(BERSERK) || ctx.bot.has_aura(INCARNATION_KING_OF_THE_JUNGLE); -} - -bool ShouldConvoke(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(CONVOKE_SPIRITS)) return false; - if (!ctx.bot.is_ready(CONVOKE_SPIRITS)) return false; - if (!ctx.bot.has_aura(CAT_FORM)) return false; - // Best paired with Berserk / Incarnation. Failing that, don't sit on a - // 2min CD against a boss when no burst window is coming soon. - if (InBurstWindow(ctx)) return true; - if (!BossLikeTargetEngaged(ctx)) return false; - if (ctx.bot.knows_spell(INCARNATION_KING_OF_THE_JUNGLE)) - return ctx.bot.cd_remaining(INCARNATION_KING_OF_THE_JUNGLE).count() > 45000; - const uint32 b = KnownId(ctx, BERSERK, BERSERK_TALENT); - return !b || ctx.bot.cd_remaining(b).count() > 45000; -} -void DoConvoke(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(CONVOKE_SPIRITS, ctx.bot.victim()); -} - -// Feral Frenzy: 5-CP instant builder with its own bleed (Frantic Frenzy is -// the talented override - same role, hits everything in front of us). Best -// when our combo bar is low so we don't overcap. -bool ShouldFeralFrenzy(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - const uint32 id = KnownId(ctx, FRANTIC_FRENZY, FERAL_FRENZY); - if (!id || !ctx.bot.is_ready(id)) return false; - if (!ctx.bot.has_aura(CAT_FORM)) return false; - return ComboPoints(ctx) <= 1; -} -void DoFeralFrenzy(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (const uint32 id = KnownId(ctx, FRANTIC_FRENZY, FERAL_FRENZY)) - e.cast(id, ctx.bot.victim()); -} - -// Heart of the Wild in Cat Form = an empowered Feral Frenzy that awards 5 -// combo points (2min CD). Same low-CP gate as Feral Frenzy. -bool ShouldHeartOfTheWild(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(HEART_OF_THE_WILD)) return false; - if (!ctx.bot.is_ready(HEART_OF_THE_WILD)) return false; - if (!ctx.bot.has_aura(CAT_FORM)) return false; - return ComboPoints(ctx) <= 1; -} -void DoHeartOfTheWild(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(HEART_OF_THE_WILD, ctx.bot.victim()); -} - -// ---- AoE ---- -bool ShouldThrash(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(THRASH_CAT)) return false; - if (!ctx.bot.has_aura(CAT_FORM)) return false; - if (!ctx.aoe_preference && ctx.bot.enemies_within(8.0f) < 2) return false; - AuraEntry const* a = ctx.bot.find_aura(THRASH_DEBUFF, ctx.bot.victim()); - return !a || a->remaining.count() <= 4500; -} -void DoThrash(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(THRASH_CAT); } - -// Swipe is a single spell id in 12.1 (213764, damage varies by form) and -// the class-talent AoE builder now that Brutal Slash is gone. -bool ShouldSwipe(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(SWIPE)) return false; - if (!ctx.bot.has_aura(CAT_FORM)) return false; - return ctx.aoe_preference || ctx.bot.enemies_within(8.0f) >= 3; -} -void DoSwipe(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(SWIPE); } - -// ---- Bleeds (primary + multi-target expand) ---- -bool ShouldRakePrimary(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(RAKE)) return false; - if (!ctx.bot.has_aura(CAT_FORM)) return false; - AuraEntry const* a = ctx.bot.find_aura(RAKE_DEBUFF, ctx.bot.victim()); - return !a || a->remaining.count() <= 4500; -} -void DoRakePrimary(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(RAKE, ctx.bot.victim()); -} - -bool ShouldRakeExpand(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(RAKE)) return false; - if (!ctx.bot.has_aura(CAT_FORM)) return false; - return ctx.bot.enemy_without_my_aura(RAKE_DEBUFF, 8.0f) != nullptr; -} -void DoRakeExpand(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* off = ctx.bot.enemy_without_my_aura(RAKE_DEBUFF, 8.0f)) - e.cast(RAKE, off->guid); -} - -// Moonfire in Cat Form needs the Lunar Inspiration passive [R] (155580, -// teaches 155627). The cat variant 155625 is gone in 12.1 - the regular -// 8921 cast is used and its DoT aura is 164812. -bool CatMoonfireAvailable(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(MOONFIRE)) return false; - return ctx.bot.knows_spell(LUNAR_INSPIRATION) || ctx.bot.knows_spell(LUNAR_INSPIRATION_ALT); -} - -bool ShouldMoonfirePrimary(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!CatMoonfireAvailable(ctx)) return false; - if (!ctx.bot.has_aura(CAT_FORM)) return false; - AuraEntry const* a = ctx.bot.find_aura(MOONFIRE_DOT, ctx.bot.victim()); - return !a || a->remaining.count() <= 4500; -} -void DoMoonfirePrimary(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(MOONFIRE, ctx.bot.victim()); -} - -bool ShouldMoonfireExpand(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!CatMoonfireAvailable(ctx)) return false; - if (!ctx.bot.has_aura(CAT_FORM)) return false; - return ctx.bot.enemy_without_my_aura(MOONFIRE_DOT, 30.0f) != nullptr; -} -void DoMoonfireExpand(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* off = ctx.bot.enemy_without_my_aura(MOONFIRE_DOT, 30.0f)) - e.cast(MOONFIRE, off->guid); -} - -// Strict 5-CP Rip — Feral wants the maximum-duration bleed, not the 4-CP -// shortcut the baseline accepts. -bool ShouldRip(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(RIP)) return false; - if (!ctx.bot.has_aura(CAT_FORM)) return false; - if (ComboPoints(ctx) < 5) return false; - AuraEntry const* a = ctx.bot.find_aura(RIP, ctx.bot.victim()); - return !a || a->remaining.count() <= 7500; -} -void DoRip(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(RIP, ctx.bot.victim()); -} - -// ---- Spenders ---- -bool ShouldPrimalWrath(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(PRIMAL_WRATH)) return false; - if (!ctx.bot.is_ready(PRIMAL_WRATH)) return false; - if (!ctx.bot.has_aura(CAT_FORM)) return false; - if (ComboPoints(ctx) < 5) return false; - return ctx.aoe_preference || - ctx.bot.attackers_count() >= 2 || ctx.bot.enemies_within(8.0f) >= 2; -} -void DoPrimalWrath(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(PRIMAL_WRATH, ctx.bot.victim()); -} - -bool ShouldFerociousBite(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(FEROCIOUS_BITE)) return false; - if (!ctx.bot.is_ready(FEROCIOUS_BITE)) return false; - if (!ctx.bot.has_aura(CAT_FORM)) return false; - if (ComboPoints(ctx) < 5) return false; - // Don't bite over Rip if Rip is missing/short — we want Rip up first. - AuraEntry const* rip = ctx.bot.find_aura(RIP, ctx.bot.victim()); - if (!rip || rip->remaining.count() <= 4500) return false; - return true; -} -void DoFerociousBite(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(FEROCIOUS_BITE, ctx.bot.victim()); -} - -// ---- Filler ---- -bool ShouldShred(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(SHRED)) return false; - if (!ctx.bot.has_aura(CAT_FORM)) return false; - return ctx.bot.power(POWER_ENERGY_IDX) >= 40; -} -void DoShred(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(SHRED, ctx.bot.victim()); -} - -bool AlwaysInCombat(ApPredicateContext const& ctx) { return ctx.bot.in_combat(); } -void DoAutoAttack(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - ObjectGuid t = ctx.bot.victim(); - if (t.IsEmpty()) t = ctx.bot.current_target(); - // Retaliate fallback (2026-06-17): in combat with no victim/target the bot - // looped "Engage auto attack" as a no-op while taking damage (the CombatLoop - // wedge cluster). Engage whatever is meleeing us (attackers are adjacent and - // reachable), else the nearest visible enemy, so combat actually resolves. - // Strictly additive: only runs when no target was already selected. - if (t.IsEmpty()) - for (auto const& u : ctx.bot.attackers()) - if (u.hp > 0) { t = u.guid; break; } - if (t.IsEmpty()) - for (auto const& u : ctx.bot.nearby_enemies()) - if (u.hp > 0 && u.in_los) { t = u.guid; break; } - if (!t.IsEmpty()) e.start_attack(t); -} - -// ---- Rule table (priority order top-down) ---- -// Order rationale: -// 1. Rebirth - battle-rez in group. -// 2. Survival Instincts - 50% DR on <=30%, fires before bail. -// 3. Barkskin - 20% DR on <=60%. -// 4. Bear Form bail - last-ditch <=25% with both DRs on CD. -// 5. Frenzied Regen - bear-only heal while bailed (<=50%). -// 6. PS Regrowth - instant Regrowth via Predatory Swiftness -// proc (69369); does NOT drop cat. -// 7. Regrowth OOC - hard-cast top-up between pulls only. -// 8. Cat Form - spec stance entry (re-enter post-bail). -// 9. Mark of the Wild - OOC group buff. -// 9b. Prowl - OOC stealth before the pull (enemy present). -// 9c. Rake opener - bonus-damage stealth opener while in Prowl. -// 10. Skull Bash - primary 13y interrupt. -// 11. Maim - CP-spend interrupt fallback. -// 12. Mighty Bash - interrupt last-resort (talent). -// 13. Soothe - enrage dispel. -// 14. Innervate - ally caster mana. -// 15. Tiger's Fury - energy CD when low. -// 16. Berserk - burst CD on boss/AoE (343223 -> 106951). -// 17. Incarnation - burst CD (talent replacement of Berserk). -// 18. Convoke the Spirits - inside the burst window / boss fallback. -// 19. Feral Frenzy - 5-CP builder (low CP); Frantic Frenzy override. -// 20. Heart of the Wild - empowered Feral Frenzy (low CP). -// 21. Thrash cat - AoE bleed. -// 22. Swipe - AoE damage (3+). -// 23. Primal Wrath - 5-CP AoE spender. -// 24. Rip - 5-CP single-target bleed. -// 25. Rake primary - single-target bleed refresh. -// 26. Rake expand - multi-dot Rake on off-targets. -// 27. Moonfire primary - cat Moonfire (Lunar Inspiration). -// 28. Moonfire expand - multi-dot Moonfire. -// 29. Ferocious Bite - 5-CP single-target spender (after Rip). -// 30. Shred - CP filler. -// 31. Auto attack - engage fallthrough. -ApRule const kRules[] = { - { ShouldRebirth, DoRebirth, "Rebirth (battle rez)" }, - { ShouldSurvivalInstincts, DoSurvivalInstincts, "Survival Instincts (<=30%)" }, - { ShouldBarkskin, DoBarkskin, "Barkskin (<=60%)" }, - { ShouldBearFormBail, DoBearForm, "Bear Form (panic bail)" }, - { ShouldFrenziedRegen, DoFrenziedRegen, "Frenzied Regen (bear bail)" }, - { ShouldPredatorySwiftnessRegrowth, DoPredatorySwiftnessRegrowth, "PS Regrowth (instant)" }, - { ShouldRegrowth, DoRegrowth, "Regrowth (OOC <=35%)" }, - { ShouldCatForm, DoCatForm, "Cat Form" }, - { ShouldMarkOfTheWild, DoMarkOfTheWild, "Mark of the Wild" }, - { ShouldProwl, DoProwl, "Prowl (OOC stealth opener)" }, - { ShouldRakeOpener, DoRakeOpener, "Rake (stealth opener)" }, - { ShouldSkullBash, DoSkullBash, "Skull Bash (interrupt)" }, - { ShouldMaim, DoMaim, "Maim (interrupt fallback)" }, - { ShouldMightyBash, DoMightyBash, "Mighty Bash" }, - { ShouldSoothe, DoSoothe, "Soothe (enrage)" }, - { ShouldInnervate, DoInnervate, "Innervate (healer mana)" }, - { ShouldTigersFury, DoTigersFury, "Tiger's Fury" }, - { ShouldBerserk, DoBerserk, "Berserk" }, - { ShouldIncarnation, DoIncarnation, "Incarnation (Avatar)" }, - { ShouldConvoke, DoConvoke, "Convoke the Spirits" }, - { ShouldFeralFrenzy, DoFeralFrenzy, "Feral Frenzy (5 CP gen)" }, - { ShouldHeartOfTheWild, DoHeartOfTheWild, "Heart of the Wild (5 CP)" }, - { ShouldThrash, DoThrash, "Thrash (2+ AoE bleed)" }, - { ShouldSwipe, DoSwipe, "Swipe (3+ targets)" }, - { ShouldPrimalWrath, DoPrimalWrath, "Primal Wrath (2+ AoE spend)" }, - { ShouldRip, DoRip, "Rip (5 CP refresh)" }, - { ShouldRakePrimary, DoRakePrimary, "Rake (primary)" }, - { ShouldRakeExpand, DoRakeExpand, "Rake (expand off-target)" }, - { ShouldMoonfirePrimary, DoMoonfirePrimary, "Moonfire (primary)" }, - { ShouldMoonfireExpand, DoMoonfireExpand, "Moonfire (expand off-target)" }, - { ShouldFerociousBite, DoFerociousBite, "Ferocious Bite (5 CP spend)" }, - { ShouldShred, DoShred, "Shred (filler)" }, - { AlwaysInCombat, DoAutoAttack, "Engage auto attack" }, -}; - -} // anonymous - -void RegisterApl_Druid_Feral() -{ - constexpr uint32 SPEC_DRUID_FERAL = 103; - RegisterRotation(CLASS_DRUID, SPEC_DRUID_FERAL, ApRotation{kRules}); -} - -} // namespace Playerbot::Combat diff --git a/src/modules/PlayerbotV2/Combat/Apl/Apl_Druid_Guardian.cpp b/src/modules/PlayerbotV2/Combat/Apl/Apl_Druid_Guardian.cpp deleted file mode 100644 index ef9b4b8c05..0000000000 --- a/src/modules/PlayerbotV2/Combat/Apl/Apl_Druid_Guardian.cpp +++ /dev/null @@ -1,550 +0,0 @@ -// Guardian Druid - WoW 12.1.0.69587 (Midnight) spec rotation (specId 104). -// -// Stance / form -// ------------- -// Guardian lives in BEAR FORM. The baseline druid file would otherwise -// park us in Cat Form (any-druid leveling default); this spec table runs -// first, so the Bear Form rule near the top of the cascade re-shifts us -// out of cat as soon as the spec is active. -// -// We do NOT cast Cat Form here. The bear-form rotation owns the bot: -// Mangle (rage + bleed-stack helper), Thrash (rage + AoE bleed), Moonfire -// (off-GCD-feeling refresh), Maul (rage spender), plus the mitigation -// triad Ironfur / Frenzied Regeneration / Survival Instincts. -// -// Tank duties -// ----------- -// * Growl — single-target taunt on the closest enemy not already attacking -// the tank. Critical for picking up adds when the tank already has aggro. -// * Skull Bash + Mighty Bash — interrupt ladder. Skull Bash leads; Mighty -// Bash is a fallback that targets an interruptible caster. -// * Stampeding Roar — group sprint, fired as a panic reposition tool. -// -// Mitigation ladder (12.1) -// ------------------------ -// * Ironfur - physical DR active mitigation. Burn rage continuously; the -// buff stacks so we re-cast every time the cooldown allows and rage -// permits, re-stacking up to 4s of remaining duration (pandemic). -// * Frenzied Regeneration - self-heal HoT. Fires <=70%. -// * Survival Instincts - 50% DR panic; <=35%. -// * Heart of the Wild [R] - Bear Form: +max health for a while; <=50%. -// * Lunar Beam [R] - ground beam that also heals us and raises mastery; -// used on cooldown in real fights. -// Pulverize, Rage of the Sleeper and Renewal no longer exist in 12.1. -// -// Bear Form variant (270100) -// -------------------------- -// Modern Guardian receives an extra Bear Form definition (270100) that -// piggy-backs additional passive auras (armor / Stamina / etc.). The -// LEARNED spell that actually triggers shapeshift on the player is still -// 5487 in this build — 270100 is an aura-only variant applied implicitly -// by the spec passive. We cast 5487 and let the spec passive layer on -// 270100. Don't add a separate cast rule for 270100. -// -// Validated spell IDs (SpellName.csv, WoW 12.1.0.69587) -// ---------------------------------------------------- -// 5487 Bear Form (cast id - produces both 5487 + 270100 -// aura on Guardian via spec passive) -// 33917 Mangle -// 77758 Thrash (Bear) (cast id; bleed aura 192090) -// 213764 Swipe (class talent [R]; single id for cat + bear) -// 8921 Moonfire (cast id; DoT aura 164812) -// 1252871 Red Moon (spec talent [R]; replaces Moonfire; 8s -// DoT on the target, Mangle extends it) -// 213708 Galactic Guardian (proc buff: next Moonfire free + Rage) -// 6807 Maul (spec talent [R]) -// 400254 Raze (spec talent, not in build; replaces Maul) -// 192081 Ironfur (class talent [R]; cast & aura same id) -// 22842 Frenzied Regeneration (class talent [R]) -// 102558 Incarnation: Guardian of Ursoc (spec talent [R]) -// 50334 Berserk (Guardian) (spec talent [R]; replaced by Incarnation) -// 204066 Lunar Beam (spec talent [R]) -// 1261867 Heart of the Wild (class talent [R]; Bear = +max health) -// 22812 Barkskin -// 61336 Survival Instincts (spec talent [R]) -// 106898 Stampeding Roar (class talent [R]; Bear-form cast) -// 106839 Skull Bash (class talent [R]) -// 5211 Mighty Bash (class talent, not in build) -// 6795 Growl -// 20484 Rebirth -// 2908 Soothe (class talent [R]) -// 1126 Mark of the Wild -// 29166 Innervate (class talent [R]) -// -// Skipped spells (and why) -// ------------------------ -// * 80313 Pulverize, 200851 Rage of the Sleeper, 108238 Renewal - not -// learnable in 12.1; rules and the 192090 Thrash-stack check deleted. -// * 1253799 Sundering Roar, 155835 Bristling Fur, 391528 Convoke the -// Spirits - spec talents the curated Guardian builds do not take. -// * 2782 Remove Corruption - [R] class talent but not castable in Bear -// Form; leaving the stance mid-pull is worse than the dispel. -// * 99 Incapacitating Roar, 132469 Typhoon - [M]-only class talents. -// * 102401 Wild Charge, 102793 Ursol's Vortex - [R] but need ally / -// ground positioning the tank rotation does not do. -// * 8936 Regrowth - hard cast that leaves Bear Form; the healer covers it. -// * 270100 Bear Form variant - passive aura, not a separate cast. -// * 1229376 Single-Button Assistant - client convenience macro. -// * Cat Form cast - would break the bear-form rotation. -// Spec rotation overrides the baseline cat-form re-entry by running -// first and casting Bear Form ASAP. - -#include "../ApRegistry.h" -#include "../ApRotation.h" -#include "Bot/BotIntentEmitter.h" -#include "Bot/BotSnapshotView.h" -#include "Group/GroupSnapshot.h" -#include "SharedDefines.h" - -namespace Playerbot::Combat { - -namespace { - -// ---- Spell IDs (WoW 12.1.0.69587, validated against SpellName.csv) ---- -constexpr uint32 BEAR_FORM = 5487; -constexpr uint32 CAT_FORM = 768; // for "drop cat into bear" guard -constexpr uint32 MANGLE = 33917; -constexpr uint32 THRASH_BEAR = 77758; -constexpr uint32 SWIPE = 213764; // class talent [R] - single Swipe id in 12.1 -constexpr uint32 MOONFIRE = 8921; // cast id -constexpr uint32 MOONFIRE_DOT = 164812; // Moonfire periodic aura -constexpr uint32 RED_MOON = 1252871; // spec talent [R] - replaces Moonfire; aura id == cast id -constexpr uint32 GALACTIC_GUARDIAN_BUFF = 213708; // proc: next Moonfire free + extra Rage -constexpr uint32 MAUL = 6807; // spec talent [R] -constexpr uint32 RAZE = 400254; // spec talent (not in build) - replaces Maul, cleaves -constexpr uint32 IRONFUR = 192081; // class talent [R] -constexpr uint32 FRENZIED_REGEN = 22842; // class talent [R] -constexpr uint32 INCARNATION_GUARDIAN = 102558; // spec talent [R] - replaces Berserk -constexpr uint32 BERSERK_GUARDIAN = 50334; // spec talent [R] -constexpr uint32 LUNAR_BEAM = 204066; // spec talent [R] - AoE beam + self heal + mastery -constexpr uint32 HEART_OF_THE_WILD = 1261867; // class talent [R] - Bear: +max health -constexpr uint32 BARKSKIN = 22812; -constexpr uint32 SURVIVAL_INSTINCTS = 61336; // spec talent [R] -constexpr uint32 STAMPEDING_ROAR_BEAR = 106898; // class talent [R] -constexpr uint32 SKULL_BASH = 106839; // class talent [R] -constexpr uint32 MIGHTY_BASH = 5211; // class talent (not in build) -constexpr uint32 GROWL = 6795; -constexpr uint32 REBIRTH = 20484; -constexpr uint32 SOOTHE = 2908; // class talent [R] -constexpr uint32 MARK_OF_THE_WILD = 1126; -constexpr uint32 INNERVATE = 29166; // class talent [R] - -constexpr uint8 POWER_RAGE_IDX = 1; - -bool HasLiveTarget(ApPredicateContext const& ctx) -{ - return !ctx.bot.victim().IsEmpty(); -} - -bool BossLikeTargetEngaged(ApPredicateContext const& ctx) -{ - constexpr int32 kBossHpThreshold = 5'000'000; - NearbyUnit const* t = ctx.bot.victim_info(); - if (t && t->max_hp >= kBossHpThreshold) return true; - for (auto const& a : ctx.bot.raw().combat.attackers) - if (a.max_hp >= kBossHpThreshold) return true; - return false; -} - -bool CanShapeshiftNow(ApPredicateContext const& ctx) -{ - auto const& mv = ctx.bot.raw().movement; - return !mv.is_mounted && !mv.is_flying; -} - -// ---- Stance / buffs ---- -// Bear Form: the spec stance. We cast it whenever the aura is missing AND -// we're not mounted/flying. The "drop cat into bear" case is handled by -// the same rule (Cat Form aura present => Bear Form aura missing => we -// re-shift to bear). -bool ShouldBearForm(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(BEAR_FORM)) return false; - if (ctx.bot.has_aura(BEAR_FORM)) return false; - if (!CanShapeshiftNow(ctx)) return false; - return true; -} -void DoBearForm(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(BEAR_FORM); } - -bool ShouldMarkOfTheWild(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(MARK_OF_THE_WILD)) return false; - if (ctx.bot.in_combat()) return false; - return !ctx.bot.has_aura(MARK_OF_THE_WILD); -} -void DoMarkOfTheWild(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(MARK_OF_THE_WILD, ctx.bot.raw().guid); -} - -// ---- Tank utility ---- -bool ShouldGrowl(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(GROWL)) return false; - if (!ctx.bot.is_ready(GROWL)) return false; - return ctx.bot.untaunted_enemy() != nullptr; -} -void DoGrowl(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* t = ctx.bot.untaunted_enemy()) - e.cast(GROWL, t->guid); -} - -bool ShouldSkullBash(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(SKULL_BASH)) return false; - if (!ctx.bot.is_ready(SKULL_BASH)) return false; - const bool pvp = ctx.pvp.in_battleground || ctx.pvp.in_arena; - return ctx.bot.kick_target(pvp, 13.0f) != nullptr; -} -void DoSkullBash(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - const bool pvp = ctx.pvp.in_battleground || ctx.pvp.in_arena; - if (auto const* c = ctx.bot.kick_target(pvp, 13.0f)) - e.cast(SKULL_BASH, c->guid); -} - -bool ShouldMightyBash(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(MIGHTY_BASH)) return false; - if (!ctx.bot.is_ready(MIGHTY_BASH)) return false; - // Only fire when Skull Bash isn't a better option. - if (ctx.bot.is_ready(SKULL_BASH) && ctx.bot.knows_spell(SKULL_BASH)) return false; - return ctx.bot.interruptible_caster() != nullptr; -} -void DoMightyBash(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* c = ctx.bot.interruptible_caster()) - e.cast(MIGHTY_BASH, c->guid); -} - -bool ShouldStampedingRoar(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(STAMPEDING_ROAR_BEAR)) return false; - if (!ctx.bot.is_ready(STAMPEDING_ROAR_BEAR)) return false; - // Group sprint — panic reposition for the bot/party. - return ctx.bot.hp_pct() <= 35; -} -void DoStampedingRoar(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(STAMPEDING_ROAR_BEAR); } - -// ---- Survival ladder ---- -bool ShouldSurvivalInstincts(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(SURVIVAL_INSTINCTS)) return false; - if (!ctx.bot.is_ready(SURVIVAL_INSTINCTS)) return false; - return ctx.bot.hp_pct() <= 35; -} -void DoSurvivalInstincts(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(SURVIVAL_INSTINCTS); } - -bool ShouldBarkskin(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(BARKSKIN)) return false; - if (!ctx.bot.is_ready(BARKSKIN)) return false; - return ctx.bot.hp_pct() <= 60; -} -void DoBarkskin(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(BARKSKIN); } - -// Heart of the Wild in Bear Form raises maximum health for its duration -// (2min CD) - a defensive in the Guardian kit, so it lives on the HP ladder. -bool ShouldHeartOfTheWild(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(HEART_OF_THE_WILD)) return false; - if (!ctx.bot.is_ready(HEART_OF_THE_WILD)) return false; - if (!ctx.bot.has_aura(BEAR_FORM)) return false; - return ctx.bot.hp_pct() <= 50; -} -void DoHeartOfTheWild(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(HEART_OF_THE_WILD, ctx.bot.raw().guid); -} - -// Lunar Beam: ground beam at the target's feet that damages nearby -// enemies, heals us and raises mastery for its duration (1min CD). Used on -// cooldown whenever the fight is real (pressure, boss or a pack). -bool ShouldLunarBeam(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(LUNAR_BEAM)) return false; - if (!ctx.bot.is_ready(LUNAR_BEAM)) return false; - return ctx.bot.hp_pct() <= 80 || BossLikeTargetEngaged(ctx) - || ctx.bot.enemies_within(8.0f) >= 2; -} -void DoLunarBeam(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* v = ctx.bot.victim_info()) - e.cast_at(LUNAR_BEAM, v->x, v->y, v->z); - else - e.cast(LUNAR_BEAM, ctx.bot.victim()); -} - -bool ShouldFrenziedRegen(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(FRENZIED_REGEN)) return false; - if (!ctx.bot.is_ready(FRENZIED_REGEN)) return false; - if (ctx.bot.power(POWER_RAGE_IDX) < 10) return false; - return ctx.bot.hp_pct() <= 70; -} -void DoFrenziedRegen(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(FRENZIED_REGEN); } - -// Ironfur: physical DR active mitigation. The buff STACKS in WoW 12.0; -// previous predicate suppressed re-casts whenever any Ironfur aura was -// up, which is wrong. We allow re-stack up to ~4s remaining (pandemic -// window) so the stacks build during heavy melee pressure. -bool ShouldIronfur(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(IRONFUR)) return false; - if (!ctx.bot.is_ready(IRONFUR)) return false; - if (ctx.bot.power(POWER_RAGE_IDX) < 40) return false; - if (ctx.bot.attackers_count() < 1) return false; - AuraEntry const* a = ctx.bot.find_aura(IRONFUR); - return !a || a->remaining.count() <= 4000; -} -void DoIronfur(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(IRONFUR); } - -// ---- Group utility ---- -bool ShouldRebirth(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(REBIRTH)) return false; - if (!ctx.bot.is_ready(REBIRTH)) return false; - return ctx.group.dead_member_priority(ctx.bot.map_id()) != nullptr; -} -void DoRebirth(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* m = ctx.group.dead_member_priority(ctx.bot.map_id())) - e.cast(REBIRTH, m->guid); -} - -bool ShouldInnervate(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(INNERVATE)) return false; - if (!ctx.bot.is_ready(INNERVATE)) return false; - auto const* m = ctx.group.lowest_mana_caster(); - if (!m || !m->online || m->hp <= 0) return false; - if (m->guid == ctx.bot.raw().guid) return false; - return m->max_mana > 0 && (m->mana * 100) / m->max_mana <= 30; -} -void DoInnervate(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* m = ctx.group.lowest_mana_caster()) - e.cast(INNERVATE, m->guid); -} - -bool ShouldSoothe(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(SOOTHE)) return false; - if (!ctx.bot.is_ready(SOOTHE)) return false; - return ctx.bot.target_dispellable(Playerbot::DispelType::Enrage); -} -void DoSoothe(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(SOOTHE, ctx.bot.victim()); -} - -// ---- Major offensive cooldowns ---- -bool ShouldIncarnation(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(INCARNATION_GUARDIAN)) return false; - if (!ctx.bot.is_ready(INCARNATION_GUARDIAN)) return false; - return BossLikeTargetEngaged(ctx); -} -void DoIncarnation(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(INCARNATION_GUARDIAN); } - -bool ShouldBerserkGuardian(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - // Incarnation replaces Berserk when talented (choice node). - if (ctx.bot.knows_spell(INCARNATION_GUARDIAN)) return false; - if (!ctx.bot.knows_spell(BERSERK_GUARDIAN)) return false; - if (!ctx.bot.is_ready(BERSERK_GUARDIAN)) return false; - return BossLikeTargetEngaged(ctx); -} -void DoBerserkGuardian(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(BERSERK_GUARDIAN); } - -// ---- Damage / threat ---- -// Red Moon replaces Moonfire when talented [R]: an 8s DoT on the target -// that Mangle extends and that generates Rage. Keep it on the victim. -bool ShouldRedMoon(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(RED_MOON)) return false; - if (!ctx.bot.is_ready(RED_MOON)) return false; - AuraEntry const* a = ctx.bot.find_aura(RED_MOON, ctx.bot.victim()); - return !a || a->remaining.count() <= 1500; -} -void DoRedMoon(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(RED_MOON, ctx.bot.victim()); -} - -// Moonfire: refresh the 164812 DoT on the victim, or spend a Galactic -// Guardian proc (free instant + Rage) immediately. Skipped when Red Moon -// has replaced Moonfire. -bool ShouldMoonfire(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(MOONFIRE)) return false; - if (ctx.bot.knows_spell(RED_MOON)) return false; - if (ctx.bot.has_aura(GALACTIC_GUARDIAN_BUFF)) return true; - AuraEntry const* a = ctx.bot.find_aura(MOONFIRE_DOT, ctx.bot.victim()); - return !a || a->remaining.count() <= 4000; -} -void DoMoonfire(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(MOONFIRE, ctx.bot.victim()); -} - -bool ShouldThrash(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(THRASH_BEAR)) return false; - return ctx.bot.is_ready(THRASH_BEAR); -} -void DoThrash(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(THRASH_BEAR); } - -bool ShouldMangle(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(MANGLE)) return false; - return ctx.bot.is_ready(MANGLE); -} -void DoMangle(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(MANGLE, ctx.bot.victim()); -} - -// Maul / Raze: rage spenders (Raze is the cleaving talent override of -// Maul). Only spend when Ironfur and Frenzied Regen are satisfied - never -// starve those of resources. -bool RageSpendAllowed(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (ctx.bot.power(POWER_RAGE_IDX) < 60) return false; - if (ctx.bot.hp_pct() <= 60) return false; - return true; -} - -bool ShouldRaze(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(RAZE)) return false; - if (!ctx.bot.is_ready(RAZE)) return false; - return RageSpendAllowed(ctx); -} -void DoRaze(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(RAZE, ctx.bot.victim()); -} - -bool ShouldMaul(ApPredicateContext const& ctx) -{ - if (ctx.bot.knows_spell(RAZE)) return false; // Raze replaces Maul - if (!ctx.bot.knows_spell(MAUL)) return false; - if (!ctx.bot.is_ready(MAUL)) return false; - return RageSpendAllowed(ctx); -} -void DoMaul(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(MAUL, ctx.bot.victim()); -} - -// Swipe is a single spell id in 12.1 (213764, damage varies by form). -bool ShouldSwipe(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(SWIPE)) return false; - return true; -} -void DoSwipe(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(SWIPE); } - -bool AlwaysInCombat(ApPredicateContext const& ctx) { return ctx.bot.in_combat(); } -void DoAutoAttack(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - ObjectGuid t = ctx.bot.victim(); - if (t.IsEmpty()) t = ctx.bot.current_target(); - // Retaliate fallback (2026-06-17): in combat with no victim/target the bot - // looped "Engage auto attack" as a no-op while taking damage (the CombatLoop - // wedge cluster). Engage whatever is meleeing us (attackers are adjacent and - // reachable), else the nearest visible enemy, so combat actually resolves. - // Strictly additive: only runs when no target was already selected. - if (t.IsEmpty()) - for (auto const& u : ctx.bot.attackers()) - if (u.hp > 0) { t = u.guid; break; } - if (t.IsEmpty()) - for (auto const& u : ctx.bot.nearby_enemies()) - if (u.hp > 0 && u.in_los) { t = u.guid; break; } - if (!t.IsEmpty()) e.start_attack(t); -} - -// ---- Rule table (priority order top-down) ---- -// Order rationale (tank lens): -// 1. Rebirth - battle-rez in group. -// 2. Bear Form - spec stance, MUST be active before -// anything else fires. Sits above survival -// CDs because most of them are bear-only. -// 3. Mark of the Wild - OOC group buff (rare maintenance). -// 4. Growl - taunt off-target enemies. -// 5. Skull Bash - primary interrupt. -// 6. Mighty Bash - interrupt fallback. -// 7. Soothe - enrage dispel. -// 8. Stampeding Roar - group sprint panic. -// 9. Survival Instincts - 50% DR panic. -// 10. Heart of the Wild - +max health (<=50%). -// 11. Barkskin - 20% DR. -// 12. Frenzied Regen - self-heal HoT (<=70%). -// 13. Ironfur - physical DR mit stack maintenance. -// 14. Innervate - ally caster mana. -// 15. Incarnation: Guardian - burst CD on boss. -// 16. Berserk (Guardian) - burst CD on boss (when not talented away). -// 17. Lunar Beam - AoE beam + self heal + mastery. -// 18. Red Moon - Moonfire replacement DoT (talent). -// 19. Moonfire - DoT refresh / Galactic Guardian proc. -// 20. Thrash - rage gen + AoE bleed stacks. -// 21. Mangle - rage generator + filler. -// 22. Raze / Maul - rage spender at >60% (Raze overrides Maul). -// 23. Swipe - AoE filler. -// 24. Auto attack - engage fallthrough. -ApRule const kRules[] = { - { ShouldRebirth, DoRebirth, "Rebirth (battle rez)" }, - { ShouldBearForm, DoBearForm, "Bear Form" }, - { ShouldMarkOfTheWild, DoMarkOfTheWild, "Mark of the Wild" }, - { ShouldGrowl, DoGrowl, "Growl (taunt)" }, - { ShouldSkullBash, DoSkullBash, "Skull Bash (interrupt)" }, - { ShouldMightyBash, DoMightyBash, "Mighty Bash (interrupt fb)" }, - { ShouldSoothe, DoSoothe, "Soothe (enrage)" }, - { ShouldStampedingRoar, DoStampedingRoar, "Stampeding Roar (panic)" }, - { ShouldSurvivalInstincts, DoSurvivalInstincts, "Survival Instincts (<=35%)" }, - { ShouldHeartOfTheWild, DoHeartOfTheWild, "Heart of the Wild (<=50%)" }, - { ShouldBarkskin, DoBarkskin, "Barkskin (<=60%)" }, - { ShouldFrenziedRegen, DoFrenziedRegen, "Frenzied Regen (<=70%)" }, - { ShouldIronfur, DoIronfur, "Ironfur (active mit)" }, - { ShouldInnervate, DoInnervate, "Innervate (healer mana)" }, - { ShouldIncarnation, DoIncarnation, "Incarnation: Guardian (boss)" }, - { ShouldBerserkGuardian, DoBerserkGuardian, "Berserk (boss)" }, - { ShouldLunarBeam, DoLunarBeam, "Lunar Beam" }, - { ShouldRedMoon, DoRedMoon, "Red Moon (refresh)" }, - { ShouldMoonfire, DoMoonfire, "Moonfire (refresh)" }, - { ShouldThrash, DoThrash, "Thrash (rage gen + AoE bleed)" }, - { ShouldMangle, DoMangle, "Mangle" }, - { ShouldRaze, DoRaze, "Raze (rage spend, cleave)" }, - { ShouldMaul, DoMaul, "Maul (rage spend)" }, - { ShouldSwipe, DoSwipe, "Swipe (filler)" }, - { AlwaysInCombat, DoAutoAttack, "Engage auto attack" }, -}; - -} // anonymous - -void RegisterApl_Druid_Guardian() -{ - constexpr uint32 SPEC_DRUID_GUARDIAN = 104; - RegisterRotation(CLASS_DRUID, SPEC_DRUID_GUARDIAN, ApRotation{kRules}); -} - -} // namespace Playerbot::Combat diff --git a/src/modules/PlayerbotV2/Combat/Apl/Apl_Druid_Restoration.cpp b/src/modules/PlayerbotV2/Combat/Apl/Apl_Druid_Restoration.cpp deleted file mode 100644 index cf95e29344..0000000000 --- a/src/modules/PlayerbotV2/Combat/Apl/Apl_Druid_Restoration.cpp +++ /dev/null @@ -1,600 +0,0 @@ -// Restoration Druid - WoW 12.1.0.69587 (Midnight) spec rotation (specId 105). -// -// Stance / form -// ------------- -// Resto lives in CASTER FORM. The baseline druid file would otherwise -// park us in Cat Form (any-druid leveling default); for Resto we run the -// spec table first and there are no form-shift rules here. Healers don't -// benefit from any druid stance and Tree of Life (Incarnation: Tree of -// Life) is the one optional form burst — talented + temporary. Outside -// of that we stay in our human/elf form casting heals. -// -// Decision tree (12.1) -// -------------------- -// 1) Cast-swap shim - cancel current heal if a more urgent target appeared -// 2) Emergency layer - Rebirth, MotW, Symbiotic Relationship (OOC bond -// with the tank), Barkskin, Ironbark, Innervate -// 3) Dispel - Nature's Cure (Magic+Curse+Poison) + Remove -// Corruption fallback (Curse+Poison; pre-spec -// cleanse) + Soothe (enrage) -// 4) Tranquility - raid CD when 3+ at <=50% (Flourish is now a -// passive rider on it) -// 5) Big CDs - Heart of the Wild (empowered Wild Growth), -// Convoke, Incarnation: Tree of Life -// 6) AoE heal - Wild Growth threshold, Efflorescence placement -// (skipped with Lifetreading: it follows Lifebloom) -// 7) Spike heal - Swiftmend (needs a HoT), Nature's Swiftness -> -// instant Regrowth, Regrowth -// 8) HoT maintenance - Lifebloom on tank, Rejuvenation on lowest -// 9) Offensive filler - Sunfire / Moonfire / Wrath when group is full -// -// Validated spell IDs (SpellName.csv, WoW 12.1.0.69587) -// ---------------------------------------------------- -// 774 Rejuvenation (class talent [R]) -// 8936 Regrowth -// 33763 Lifebloom (spec talent [R]; aura id == cast id) -// 18562 Swiftmend (spec talent [R]) -// 48438 Wild Growth (class talent [R]) -// 740 Tranquility (spec talent [R]; 197721 Flourish is a -// passive that extends HoTs during it) -// 145205 Efflorescence (spec talent [R]; 1217941 Lifetreading -// passive [R] makes it auto-follow Lifebloom) -// 132158 Nature's Swiftness (spec talent [R]; next Regrowth instant) -// 1261867 Heart of the Wild (class talent [R]; caster = empowered Wild Growth) -// 391528 Convoke the Spirits (spec talent [R]) -// 88423 Nature's Cure (spec spell; Magic + Curse + Poison) -// 440015 Remove Corruption (spec spell; Curse + Poison fallback) -// 2908 Soothe (class talent [R]) -// 29166 Innervate (class talent [R]) -// 20484 Rebirth -// 22812 Barkskin -// 102342 Ironbark (spec talent [R]) -// 474750 Symbiotic Relationship (class talent [R]; 474754 is the bond aura -// on the ally) -// 1126 Mark of the Wild -// 93402 Sunfire (class talent, not in Resto build; DoT 164815) -// 8921 Moonfire (filler DoT; DoT aura 164812) -// 5176 Wrath (baseline Wrath; Balance learns 190984) -// 33891 Incarnation: Tree of Life (spec talent, not in build) -// -// Skipped spells (and why) -// ------------------------ -// * 102351 Cenarion Ward - the talent is gone from the 12.1 class tree -// (102352 that remains is the ward's HoT sub-spell, not a cast). -// * 391888 Adaptive Swarm, 108238 Renewal - not learnable in 12.1. -// * 1226140 Grove Guardians - a passive in 12.1 (Swiftmend / Wild Growth -// summon the treant automatically); no cast rule. -// * 197721 Flourish - passive in 12.1 (rides on Tranquility). -// * 212040 Revitalize - out-of-combat mass resurrection; not a rotation -// ability. -// * 22842 Frenzied Regeneration, 106898 Stampeding Roar, 102401 Wild -// Charge, 102793 Ursol's Vortex, 132469 Typhoon - [R] class talents that -// need Bear Form or positioning the healer rotation does not do. -// * 1229376 Single-Button Assistant - client convenience macro. - -#include "../ApRegistry.h" -#include "../ApRotation.h" -#include "ApDispelHelpers.h" -#include "ApHealHelpers.h" -#include "Bot/BotIntentEmitter.h" -#include "Bot/BotSnapshotView.h" -#include "Group/GroupSnapshot.h" -#include "SharedDefines.h" - -namespace Playerbot::Combat { - -namespace { - -// ---- Spell IDs (WoW 12.1.0.69587, validated against SpellName.csv) ---- -constexpr uint32 REJUVENATION = 774; // class talent [R] -constexpr uint32 REGROWTH = 8936; -constexpr uint32 LIFEBLOOM = 33763; // spec talent [R] -constexpr uint32 SWIFTMEND = 18562; // spec talent [R] -constexpr uint32 WILD_GROWTH = 48438; // class talent [R] -constexpr uint32 TRANQUILITY = 740; // spec talent [R] -constexpr uint32 EFFLORESCENCE = 145205; // spec talent [R] -constexpr uint32 LIFETREADING = 1217941; // spec passive [R] - Efflorescence follows Lifebloom target -constexpr uint32 NATURES_SWIFTNESS = 132158; // spec talent [R] - next Regrowth instant + free -constexpr uint32 HEART_OF_THE_WILD = 1261867; // class talent [R] - caster: empowered Wild Growth -constexpr uint32 CONVOKE_SPIRITS = 391528; // spec talent [R] burst -constexpr uint32 NATURES_CURE = 88423; // spec spell: Magic+Curse+Poison (overrides 440015) -constexpr uint32 REMOVE_CORRUPTION = 440015; // spec spell: Curse+Poison fallback -constexpr uint32 SOOTHE = 2908; // class talent [R] -constexpr uint32 INNERVATE = 29166; // class talent [R] -constexpr uint32 REBIRTH = 20484; -constexpr uint32 BARKSKIN = 22812; -constexpr uint32 IRONBARK = 102342; // spec talent [R] -constexpr uint32 SYMBIOTIC_RELATIONSHIP = 474750; // class talent [R] - OOC bond with the tank -constexpr uint32 SYMBIOTIC_BOND_AURA = 474754; // aura on the bonded ally -constexpr uint32 MARK_OF_THE_WILD = 1126; -constexpr uint32 SUNFIRE = 93402; // class talent (not in Resto build) - filler DoT -constexpr uint32 SUNFIRE_DOT = 164815; // Sunfire periodic aura -constexpr uint32 MOONFIRE = 8921; // filler DoT (cast id) -constexpr uint32 MOONFIRE_DOT = 164812; // Moonfire periodic aura -constexpr uint32 WRATH = 5176; // Resto's baseline Wrath learn -constexpr uint32 INCARN_TREE = 33891; // spec talent (not in build) - Incarnation: Tree of Life - -// ---- Helpers ---- -struct HealTarget -{ - ObjectGuid guid; - int32 hp_pct; -}; - -HealTarget LowestFriendOrSelf(ApPredicateContext const& ctx) -{ - HealTarget t{ ctx.bot.raw().guid, ctx.bot.hp_pct() }; - if (auto const* low = ctx.group.heal_assignment(ctx.bot.raw().guid, ctx.bot.map_id(), ctx.bot.raw().position.x, ctx.bot.raw().position.y, ctx.bot.raw().position.z, 45.0f)) - { - if (low->online && low->max_hp > 0) - { - const int32 pct = (low->hp * 100) / low->max_hp; - if (pct < t.hp_pct) { t.guid = low->guid; t.hp_pct = pct; } - } - } - return t; -} - -int WoundedFriendCount(ApPredicateContext const& ctx, int below_pct) -{ - int n = 0; - auto const* members = ctx.group.members(); - // SOLO (audit B22): ungrouped, "wounded friend" used to collapse to - // "my own HP <= below_pct" — the 92% GroupTopped gates then froze ALL - // damage the moment a questing healer took two melee hits, degenerating - // solo healer-spec leveling into heal-regen-nuke loops (3-10x kill - // time). Cap the solo threshold at a 45% survival floor: topped-style - // gates (92) stay open while merely scratched, true emergency heals - // (<=45) keep their thresholds. - if (!members) return ctx.bot.hp_pct() <= std::min(below_pct, 45) ? 1 : 0; - for (auto const& m : *members) - { - if (!m.online || m.max_hp <= 0 || m.hp <= 0) continue; - if ((m.hp * 100) / m.max_hp <= below_pct) ++n; - } - return n; -} - -// True when the group is "topped" — every reachable member at >=92% HP. Used -// to gate offensive filler so we don't drift into combat-DPS mode mid-spike. -bool GroupTopped(ApPredicateContext const& ctx) -{ - return WoundedFriendCount(ctx, 92) == 0; -} - -GroupMemberSummary const* DispelTarget(ApPredicateContext const& ctx) -{ - return DispelTargetWithPriority(ctx, [](GroupSnapshotView const& g) - -> GroupMemberSummary const* - { - if (auto const* m = g.dispel_candidate(DispelType::Magic)) return m; - if (auto const* m = g.dispel_candidate(DispelType::Curse)) return m; - if (auto const* m = g.dispel_candidate(DispelType::Poison)) return m; - return nullptr; - }); -} - -// Remove Corruption fallback: handles Curse+Poison only (no Magic). Used -// when Nature's Cure isn't known yet — typically very low-level Resto -// before the spec passive grants the upgrade. Same priority ordering but -// without the Magic check. -GroupMemberSummary const* DispelTargetCursePoison(ApPredicateContext const& ctx) -{ - return DispelTargetWithPriority(ctx, [](GroupSnapshotView const& g) - -> GroupMemberSummary const* - { - if (auto const* m = g.dispel_candidate(DispelType::Curse)) return m; - if (auto const* m = g.dispel_candidate(DispelType::Poison)) return m; - return nullptr; - }); -} - -bool SelfNeedsDispel(ApPredicateContext const& ctx) -{ - return ctx.bot.self_dispellable(DispelType::Magic) - || ctx.bot.self_dispellable(DispelType::Curse) - || ctx.bot.self_dispellable(DispelType::Poison); -} - -bool SelfNeedsDispelCursePoison(ApPredicateContext const& ctx) -{ - return ctx.bot.self_dispellable(DispelType::Curse) - || ctx.bot.self_dispellable(DispelType::Poison); -} - -// ---- Emergency layer ---- -bool ShouldBarkskin(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(BARKSKIN)) return false; - if (!ctx.bot.is_ready(BARKSKIN)) return false; - return ctx.bot.hp_pct() <= 50; -} -void DoBarkskin(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(BARKSKIN); } - -// Symbiotic Relationship: hour-long bond with the tank - our heals on the -// tank heal us and our self-heals heal the tank. OOC maintenance only -// (1.5s cast); the bond aura 474754 sits on the ally. -bool ShouldSymbioticRelationship(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(SYMBIOTIC_RELATIONSHIP)) return false; - if (!ctx.bot.is_ready(SYMBIOTIC_RELATIONSHIP)) return false; - if (ctx.bot.in_combat()) return false; - GroupMemberSummary const* tank = ctx.group.tank(); - if (!tank || !tank->online || tank->hp <= 0) return false; - if (tank->guid == ctx.bot.raw().guid) return false; - return !ctx.bot.has_aura(SYMBIOTIC_BOND_AURA, tank->guid); -} -void DoSymbioticRelationship(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* tank = ctx.group.tank()) - e.cast(SYMBIOTIC_RELATIONSHIP, tank->guid); -} - -bool ShouldIronbark(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(IRONBARK)) return false; - if (!ctx.bot.is_ready(IRONBARK)) return false; - GroupMemberSummary const* tank = ctx.group.tank(); - if (!tank || !tank->online || tank->max_hp <= 0 || tank->hp <= 0) return false; - return (tank->hp * 100) / tank->max_hp <= 50; -} -void DoIronbark(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* tank = ctx.group.tank()) - e.cast(IRONBARK, tank->guid); -} - -bool ShouldInnervate(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(INNERVATE)) return false; - if (!ctx.bot.is_ready(INNERVATE)) return false; - if (auto const* m = ctx.group.lowest_mana_caster()) - if (m->max_mana > 0 && (m->mana * 100) / m->max_mana <= 30) - return true; - return ctx.bot.max_power(0) > 0 && ctx.bot.power_pct(0) <= 30; -} -void DoInnervate(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* m = ctx.group.lowest_mana_caster()) - if (m->max_mana > 0 && (m->mana * 100) / m->max_mana <= 30) - { e.cast(INNERVATE, m->guid); return; } - e.cast(INNERVATE, ctx.bot.raw().guid); -} - -// ---- Dispel ---- -// Nature's Cure: the full Resto cleanse (Magic + Curse + Poison). Primary -// dispel; sits ahead of Remove Corruption in the rule table. -bool ShouldNaturesCure(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(NATURES_CURE)) return false; - if (!ctx.bot.is_ready(NATURES_CURE)) return false; - return DispelTarget(ctx) != nullptr || SelfNeedsDispel(ctx); -} -void DoNaturesCure(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* t = DispelTarget(ctx)) - { - e.cast(NATURES_CURE, t->guid); - return; - } - if (SelfNeedsDispel(ctx)) - e.cast(NATURES_CURE, ctx.bot.raw().guid); -} - -// Remove Corruption: Curse + Poison only. Fallback for pre-Nature's-Cure -// brackets and a redundant safety net if Nature's Cure isn't known. -bool ShouldRemoveCorruption(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(REMOVE_CORRUPTION)) return false; - if (!ctx.bot.is_ready(REMOVE_CORRUPTION)) return false; - // If Nature's Cure is up, prefer it — that path covers Magic too. - if (ctx.bot.knows_spell(NATURES_CURE) && ctx.bot.is_ready(NATURES_CURE)) return false; - return DispelTargetCursePoison(ctx) != nullptr || SelfNeedsDispelCursePoison(ctx); -} -void DoRemoveCorruption(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* t = DispelTargetCursePoison(ctx)) - { - e.cast(REMOVE_CORRUPTION, t->guid); - return; - } - if (SelfNeedsDispelCursePoison(ctx)) - e.cast(REMOVE_CORRUPTION, ctx.bot.raw().guid); -} - -bool ShouldSoothe(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(SOOTHE)) return false; - if (!ctx.bot.is_ready(SOOTHE)) return false; - if (ctx.bot.victim().IsEmpty()) return false; - return ctx.bot.target_dispellable(Playerbot::DispelType::Enrage); -} -void DoSoothe(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(SOOTHE, ctx.bot.victim()); -} - -// ---- Battle rez / buff ---- -bool ShouldRebirth(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(REBIRTH)) return false; - if (!ctx.bot.is_ready(REBIRTH)) return false; - return ctx.group.dead_member_priority(ctx.bot.map_id()) != nullptr; -} -void DoRebirth(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* m = ctx.group.dead_member_priority(ctx.bot.map_id())) - e.cast(REBIRTH, m->guid); -} - -bool ShouldMarkOfTheWild(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(MARK_OF_THE_WILD)) return false; - if (ctx.bot.in_combat()) return false; - return !ctx.bot.has_aura(MARK_OF_THE_WILD); -} -void DoMarkOfTheWild(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(MARK_OF_THE_WILD, ctx.bot.raw().guid); -} - -// ---- Major CDs ---- -bool ShouldTranquility(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(TRANQUILITY)) return false; - if (!ctx.bot.is_ready(TRANQUILITY)) return false; - return WoundedFriendCount(ctx, 50) >= 3; -} -void DoTranquility(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(TRANQUILITY); } - -// Heart of the Wild in caster form = an empowered Wild Growth (more -// targets, bigger heal) on a 2min CD. Fire it on real group-wide damage. -bool ShouldHeartOfTheWild(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(HEART_OF_THE_WILD)) return false; - if (!ctx.bot.is_ready(HEART_OF_THE_WILD)) return false; - return WoundedFriendCount(ctx, 75) >= 3; -} -void DoHeartOfTheWild(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(HEART_OF_THE_WILD, LowestFriendOrSelf(ctx).guid); -} - -bool ShouldConvoke(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(CONVOKE_SPIRITS)) return false; - if (!ctx.bot.is_ready(CONVOKE_SPIRITS)) return false; - return WoundedFriendCount(ctx, 70) >= 2; -} -void DoConvoke(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(CONVOKE_SPIRITS, LowestFriendOrSelf(ctx).guid); -} - -// Incarnation: Tree of Life — 30s burst form. Empowers Wild Growth (extra -// target), Regrowth (instant), Rejuvenation (cheaper). Pop on raid-wide -// damage events. -bool ShouldIncarnTree(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(INCARN_TREE)) return false; - if (!ctx.bot.is_ready(INCARN_TREE)) return false; - return WoundedFriendCount(ctx, 75) >= 3; -} -void DoIncarnTree(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(INCARN_TREE); } - -// ---- Instant-Regrowth setup ---- -// Nature's Swiftness makes the next Regrowth instant + free. Arm it when -// the lowest ally is in spike range so the Regrowth rule below lands -// instantly instead of as a 1.5s hard cast. -bool ShouldNaturesSwiftness(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(NATURES_SWIFTNESS)) return false; - if (!ctx.bot.is_ready(NATURES_SWIFTNESS)) return false; - if (ctx.bot.has_aura(NATURES_SWIFTNESS)) return false; - if (!ctx.bot.knows_spell(REGROWTH)) return false; - return LowestFriendOrSelf(ctx).hp_pct <= 40; -} -void DoNaturesSwiftness(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(NATURES_SWIFTNESS); } - -// ---- AoE heal ---- -bool ShouldWildGrowth(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(WILD_GROWTH)) return false; - if (!ctx.bot.is_ready(WILD_GROWTH)) return false; - return WoundedFriendCount(ctx, 80) >= 3; -} -void DoWildGrowth(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(WILD_GROWTH, LowestFriendOrSelf(ctx).guid); -} - -// Efflorescence: with the Lifetreading passive [R] the blossom grows under -// the Lifebloom target automatically, so only place it by hand without it. -bool ShouldEfflorescence(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(EFFLORESCENCE)) return false; - if (ctx.bot.knows_spell(LIFETREADING)) return false; - if (!ctx.bot.is_ready(EFFLORESCENCE)) return false; - return !ctx.bot.has_aura(EFFLORESCENCE); -} -void DoEfflorescence(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - float bx, by, bz; - ctx.bot.position(bx, by, bz); - e.cast_at(EFFLORESCENCE, bx, by, bz); -} - -// ---- Spike heal ---- -// Swiftmend consumes (or, with Verdant Infusion, utilizes) one of our -// Rejuvenation / Regrowth / Wild Growth effects - it cannot be cast on a -// target without one, so require a HoT before spending the GCD. -bool ShouldSwiftmend(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(SWIFTMEND)) return false; - if (!ctx.bot.is_ready(SWIFTMEND)) return false; - HealTarget t = LowestFriendOrSelf(ctx); - if (t.hp_pct > 50) return false; - return ctx.bot.has_aura(REJUVENATION, t.guid) - || ctx.bot.has_aura(REGROWTH, t.guid) - || ctx.bot.has_aura(WILD_GROWTH, t.guid); -} -void DoSwiftmend(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(SWIFTMEND, LowestFriendOrSelf(ctx).guid); -} - -bool ShouldRegrowth(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(REGROWTH)) return false; - return LowestFriendOrSelf(ctx).hp_pct <= 65; -} -void DoRegrowth(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(REGROWTH, LowestFriendOrSelf(ctx).guid); -} - -// ---- HoT maintenance ---- -bool ShouldLifebloom(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(LIFEBLOOM)) return false; - GroupMemberSummary const* tank = ctx.group.tank(); - ObjectGuid target = tank && tank->online ? tank->guid : ctx.bot.raw().guid; - AuraEntry const* a = ctx.bot.find_aura(LIFEBLOOM, target); - return !a || a->remaining.count() <= 4500; -} -void DoLifebloom(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - GroupMemberSummary const* tank = ctx.group.tank(); - ObjectGuid target = tank && tank->online ? tank->guid : ctx.bot.raw().guid; - e.cast(LIFEBLOOM, target); -} - -bool ShouldRejuvenation(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(REJUVENATION)) return false; - HealTarget t = LowestFriendOrSelf(ctx); - if (t.hp_pct >= 95) return false; - AuraEntry const* a = ctx.bot.find_aura(REJUVENATION, t.guid); - return !a || a->remaining.count() <= 3000; -} -void DoRejuvenation(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(REJUVENATION, LowestFriendOrSelf(ctx).guid); -} - -// ---- Offensive filler (group is topped) ---- -bool ShouldSunfire(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!GroupTopped(ctx)) return false; - if (!ctx.bot.knows_spell(SUNFIRE)) return false; - if (ctx.bot.victim().IsEmpty()) return false; - AuraEntry const* a = ctx.bot.find_aura(SUNFIRE_DOT, ctx.bot.victim()); - return !a || a->remaining.count() <= 4000; -} -void DoSunfire(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(SUNFIRE, ctx.bot.victim()); -} - -bool ShouldMoonfire(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!GroupTopped(ctx)) return false; - if (!ctx.bot.knows_spell(MOONFIRE)) return false; - if (ctx.bot.victim().IsEmpty()) return false; - AuraEntry const* a = ctx.bot.find_aura(MOONFIRE_DOT, ctx.bot.victim()); - return !a || a->remaining.count() <= 4000; -} -void DoMoonfire(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(MOONFIRE, ctx.bot.victim()); -} - -bool ShouldWrath(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!GroupTopped(ctx)) return false; - if (!ctx.bot.knows_spell(WRATH)) return false; - return !ctx.bot.victim().IsEmpty(); -} -void DoWrath(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(WRATH, ctx.bot.victim()); -} - -bool AlwaysAlive(ApPredicateContext const& ctx) { return ctx.bot.is_alive(); } -void DoNothing(ApPredicateContext const&, BotIntentEmitter&) {} - -// Cast-swap shim — Resto Druid kit is HoT-heavy (Rejuvenation / -// Lifebloom / Swiftmend = instant). REGROWTH 1.5s is the main slow -// direct heal worth cancelling. See ApHealHelpers.h. -bool ShouldCancelHealForSwap(ApPredicateContext const& ctx) -{ - return ShouldCancelHealForSwapImpl(ctx, { REGROWTH }); -} - -// ---- Rule table (priority order top-down) ---- -// Order rationale: -// 1. Cancel heal swap - drop slow cast when a more urgent target appears. -// 2. Rebirth - battle rez has highest party impact. -// 3. Mark of the Wild - OOC group buff maintenance. -// 4. Symbiotic Relationship - OOC bond with the tank (hour-long). -// 5. Barkskin - off-GCD survival. -// 6. Ironbark - tank DR + heal amp at <=50%. -// 7. Nature's Cure - full dispel (Magic + Curse + Poison). -// 8. Remove Corruption - Curse+Poison fallback when NC unknown. -// 9. Soothe - enrage dispel on target. -// 10. Innervate - own / ally caster mana. -// 11. Tranquility - raid CD at 3+ heavily wounded. -// 12. Heart of the Wild - empowered Wild Growth at 3+ wounded. -// 13. Convoke - burst heal/damage on 2+ wounded. -// 14. Incarnation: Tree of Life - 30s heal-burst window (talent). -// 15. Wild Growth - group AoE HoT (3+ at <=80%). -// 16. Efflorescence - ground AoE HoT placement (no Lifetreading). -// 17. Swiftmend - instant spike heal (<=50%, needs a HoT). -// 18. Nature's Swiftness - arm instant Regrowth (<=40%). -// 19. Regrowth - direct heal + HoT (<=65%). -// 20. Lifebloom - tank HoT maintenance. -// 21. Rejuvenation - lowest-friend HoT refresh. -// 22. Sunfire / Moonfire / Wrath - offensive filler ONLY when group is topped. -// 23. Idle - alive fallthrough. -ApRule const kRules[] = { - { ShouldCancelHealForSwap, DoCancelHealForSwap, "Cancel heal — swap to lower target" }, - { ShouldRebirth, DoRebirth, "Rebirth (battle rez)" }, - { ShouldMarkOfTheWild, DoMarkOfTheWild, "Mark of the Wild" }, - { ShouldSymbioticRelationship, DoSymbioticRelationship, "Symbiotic Relationship" }, - { ShouldBarkskin, DoBarkskin, "Barkskin (<=50% self)" }, - { ShouldIronbark, DoIronbark, "Ironbark (tank <=50%)" }, - { ShouldNaturesCure, DoNaturesCure, "Nature's Cure (dispel)" }, - { ShouldRemoveCorruption, DoRemoveCorruption, "Remove Corruption (fb)" }, - { ShouldSoothe, DoSoothe, "Soothe (enrage)" }, - { ShouldInnervate, DoInnervate, "Innervate" }, - { ShouldTranquility, DoTranquility, "Tranquility (3+ at <=50%)" }, - { ShouldHeartOfTheWild, DoHeartOfTheWild, "Heart of the Wild (WG)" }, - { ShouldConvoke, DoConvoke, "Convoke the Spirits" }, - { ShouldIncarnTree, DoIncarnTree, "Incarnation: Tree of Life" }, - { ShouldWildGrowth, DoWildGrowth, "Wild Growth (3+ at <=80%)" }, - { ShouldEfflorescence, DoEfflorescence, "Efflorescence (maintain)" }, - { ShouldSwiftmend, DoSwiftmend, "Swiftmend (<=50%)" }, - { ShouldNaturesSwiftness, DoNaturesSwiftness, "Nature's Swiftness (<=40%)" }, - { ShouldRegrowth, DoRegrowth, "Regrowth (<=65%)" }, - { ShouldLifebloom, DoLifebloom, "Lifebloom on tank" }, - { ShouldRejuvenation, DoRejuvenation, "Rejuvenation (refresh)" }, - { ShouldSunfire, DoSunfire, "Sunfire (filler, group full)" }, - { ShouldMoonfire, DoMoonfire, "Moonfire (filler)" }, - { ShouldWrath, DoWrath, "Wrath (filler)" }, - { AlwaysAlive, DoNothing, "Idle" }, -}; - -} // anonymous - -void RegisterApl_Druid_Restoration() -{ - constexpr uint32 SPEC_DRUID_RESTORATION = 105; - RegisterRotation(CLASS_DRUID, SPEC_DRUID_RESTORATION, ApRotation{kRules}); -} - -} // namespace Playerbot::Combat diff --git a/src/modules/PlayerbotV2/Combat/Apl/Apl_Hunter_BeastMastery.cpp b/src/modules/PlayerbotV2/Combat/Apl/Apl_Hunter_BeastMastery.cpp deleted file mode 100644 index 9616078af5..0000000000 --- a/src/modules/PlayerbotV2/Combat/Apl/Apl_Hunter_BeastMastery.cpp +++ /dev/null @@ -1,562 +0,0 @@ -// Hunter Beast Mastery - WoW 12.1.0.69587 (Midnight) enterprise rotation. -// Pet-driven ranged DPS with Frenzy uptime via Barbed Shot, Bestial Wrath -// burst, Kill Command focus economy and Black Arrow (Dark Ranger hero -// talent) as the execute / opener shot. Multi-target via Wild Thrash -// (turns on Beast Cleave) + Stomp / Kill Cleave passives. -// -// Leveling-bracket aware (rework 2026-06-10, live-verified on Uraimus L13): -// before this rework a low-level BM bot cast ONLY Steady Shot between Kill -// Commands - no focus spender existed in the rule list for the pre-Cobra -// bracket (Arcane Shot was missing entirely), so focus sat capped while -// Steady kept over-generating. Every rule gates on knows_spell, so one -// rule list serves L10 through max level (90 in Midnight): -// * Arcane Shot is the focus dump until Cobra Shot is learned, then -// Cobra takes over (Arcane rule self-disables once Cobra is known). -// * Spenders fire only with >=30 focus headroom left AFTER the cast so -// Kill Command - the highest damage-per-focus BM button - is never -// starved by a filler. -// * Wild Thrash is cast to ACTIVATE/refresh Beast Cleave (pet aura -// 118455), not spammed every AoE GCD. -// * Bestial Wrath is a leveling workhorse (90s CD vs 15s kills): fires -// on meaty single targets and 2+ pulls, not just raid bosses. -// Ranged white damage (Auto Shot 75) is armed by API::start_attack, not -// by an APL rule - see PlayerbotAPI.cpp ensureAutoShot. -// -// Layered survival: Aspect of the Turtle -> Exhilaration -> Survival of the -// Fittest -> Disengage / Feign Death. Group utility: Misdirection (tank -// threat), Primal Rage (pet-cast Bloodlust, Ferocity pets). Pet upkeep: -// Mend Pet, Revive Pet. CC: Counter Shot, Intimidation (pet stun), Binding -// Shot, Tar Trap. Major CD: Bestial Wrath (Bloodshed and Dire Beast are -// PASSIVES in 12.1 - they ride on Bestial Wrath / bleed ticks). -// -// Validated spell IDs (WoW 12.1.0.69587, kit + SpellName.csv): -// 217200 Barbed Shot | 34026 Kill Command | 193455 Cobra Shot -// 185358 Arcane Shot | 56641 Steady Shot | 19574 Bestial Wrath -// 466930 Black Arrow | 1264359 Wild Thrash | 147362 Counter Shot -// 19577 Intimidation | 109248 Binding Shot | 187698 Tar Trap -// 34477 Misdirection | 264735 Survival o.t.Fit.| 186265 Aspect of the Turtle -// 109304 Exhilaration | 781 Disengage | 5384 Feign Death -// 136 Mend Pet | 982 Revive Pet | 257284 Hunter's Mark -// 264667 Primal Rage (PET ability, pet_cast) | 272790 Frenzy (pet aura) -// 118455 Beast Cleave (pet aura) -// -// Skipped (deliberate, 12.1): -// * Kill Shot ( 53351) - Marksmanship-only talent in 12.1; BM's -// execute is Black Arrow (466930). -// * Bloodshed (1272099) - passive in 12.1 (Bestial Wrath applies it). -// * Dire Beast ( 120679) - passive in 12.1 (bleed-proc summon). -// * Aspect of the Wild / Call of the Wild / Stampede / Multi-Shot - no -// 12.1 learn path for BM (Wild Thrash is the AoE button). -// * Freezing Trap ( 187650) / Aspect of the Cheetah (186257) - out of -// combat / positional utility, not driven by the combat APL. -// * Tranquilizing Shot (19801) - [M]-only class talent, dispel logic -// lives outside the DPS ladder. -// * Track Pets / Exotic Beasts / Eyes of the Beast - minimap utility, -// passive, pet-vision toy (breaks bot bot logic control). - -#include "../ApRegistry.h" -#include "../ApRotation.h" -#include "Bot/BotIntentEmitter.h" -#include "Bot/BotSnapshotView.h" -#include "Group/GroupSnapshot.h" -#include "SharedDefines.h" - -namespace Playerbot::Combat { - -namespace { - -// ---- Spell IDs (WoW 12.1.0.69587, validated against the 12.1 kit and -// SpellName.csv; see the header table) ---- -constexpr uint32 BARBED_SHOT = 217200; // BM spec talent [R][M] (L12); OVERRIDES Steady Shot on the bar -constexpr uint32 KILL_COMMAND = 34026; // BM spec talent [R][M], 1st starter-build pick -> effectively L10 -constexpr uint32 COBRA_SHOT = 193455; // BM spec talent [R][M] (L14); OVERRIDES Arcane Shot on the bar -constexpr uint32 ARCANE_SHOT = 185358; // baseline L2 spender; BM's focus dump until Cobra Shot is talented -constexpr uint32 STEADY_SHOT = 56641; // baseline L1 filler/generator until Barbed Shot overrides it -constexpr uint32 BESTIAL_WRATH = 19574; // BM spec talent [R][M] (L20) -constexpr uint32 BLACK_ARROW = 466930; // Dark Ranger hero talent [R][M] - execute (<20%) / opener (>80%) shot -constexpr uint32 COUNTER_SHOT = 147362; // class talent [R][M] (L18), BM/MM only -constexpr uint32 WILD_THRASH = 1264359; // BM AoE button [M] - replaces Multi-Shot and triggers Beast Cleave -constexpr uint32 MISDIRECTION = 34477; -constexpr uint32 ASPECT_TURTLE = 186265; -constexpr uint32 EXHILARATION = 109304; -constexpr uint32 SURVIVAL_FITTEST = 264735; -constexpr uint32 DISENGAGE = 781; -constexpr uint32 MEND_PET = 136; -constexpr uint32 REVIVE_PET = 982; -constexpr uint32 FEIGN_DEATH = 5384; -constexpr uint32 INTIMIDATION = 19577; -constexpr uint32 TAR_TRAP = 187698; -constexpr uint32 FREEZING_TRAP = 187650; -constexpr uint32 BINDING_SHOT = 109248; -constexpr uint32 PRIMAL_RAGE = 264667; // PET ability (Ferocity, via Command Pet 272651) - pet_cast only -constexpr uint32 FRENZY_AURA = 272790; // pet buff stacked by Barbed Shot (talent passive is 1264934) -constexpr uint32 BEAST_CLEAVE_PET = 118455; // pet aura applied by Wild Thrash; pet melee cleaves while up -constexpr uint32 ASPECT_CHEETAH = 186257; -constexpr uint32 HUNTERS_MARK = 257284; - -constexpr uint8 POWER_FOCUS_IDX = 2; - -// Focus costs (display units, stable since Legion). Spenders only fire -// when the cast leaves >= KILL_COMMAND_COST in the tank so KC - BM's -// best damage-per-focus button - is never delayed by a filler. -constexpr int32 KILL_COMMAND_COST = 30; -constexpr int32 COBRA_SHOT_COST = 35; -constexpr int32 ARCANE_SHOT_COST = 40; -constexpr int32 BLACK_ARROW_COST = 10; - -bool HasLiveTarget(ApPredicateContext const& ctx) -{ - return !ctx.bot.victim().IsEmpty(); -} - -bool BossLikeTargetEngaged(ApPredicateContext const& ctx) -{ - constexpr int32 kBossHpThreshold = 5'000'000; - NearbyUnit const* t = ctx.bot.victim_info(); - if (t && t->max_hp >= kBossHpThreshold) return true; - for (auto const& a : ctx.bot.raw().combat.attackers) - if (a.max_hp >= kBossHpThreshold) return true; - return false; -} - -bool BotHasSatedDebuff(ApPredicateContext const& ctx) -{ - constexpr uint32 SATED_DEBUFF = 57724; - constexpr uint32 TEMPORAL_DISPL_DEBUFF = 80354; - constexpr uint32 INSANITY_HUNTER_DEBUFF = 95809; - constexpr uint32 FATIGUED_DEBUFF = 264689; - return ctx.bot.has_aura(SATED_DEBUFF) - || ctx.bot.has_aura(TEMPORAL_DISPL_DEBUFF) - || ctx.bot.has_aura(INSANITY_HUNTER_DEBUFF) - || ctx.bot.has_aura(FATIGUED_DEBUFF); -} - -int32 FocusVal(ApPredicateContext const& ctx) { return ctx.bot.power(POWER_FOCUS_IDX); } - -// Black Arrow window: "Only usable on enemies above 80% health or below -// 20% health" (466930). Mirrors the classic Kill Shot execute band plus -// the opener band. -bool TargetBlackArrowWindow(ApPredicateContext const& ctx) -{ - NearbyUnit const* t = ctx.bot.victim_info(); - if (!t || t->max_hp <= 0 || t->hp <= 0) return false; - const int64 pct = (int64_t(t->hp) * 100) / t->max_hp; - return pct <= 20 || pct >= 80; -} - -// ---- Pet maintenance ---- -bool ShouldRevivePet(ApPredicateContext const& ctx) -{ - // Revive Pet brings a *dead* pet back. If pet_guid is empty the bot - // never had a pet (or it was dismissed) — Revive Pet would silently - // fail and starve the rest of the rotation by re-firing every tick. - // Use Call Pet via the BM-specific summon flow for that case instead. - if (ctx.bot.pet_guid().IsEmpty()) return false; - if (ctx.bot.has_pet()) return false; - if (!ctx.bot.knows_spell(REVIVE_PET)) return false; - return ctx.bot.is_ready(REVIVE_PET); -} -void DoRevivePet(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(REVIVE_PET); } - -bool ShouldMendPet(ApPredicateContext const& ctx) -{ - if (!ctx.bot.has_pet()) return false; - if (!ctx.bot.knows_spell(MEND_PET)) return false; - if (!ctx.bot.is_ready(MEND_PET)) return false; - // Mend Pet is a ~10s HoT, not a direct heal. Without this gate the rule - // (which sits ABOVE the damage tier) re-cast every GCD while the pet stayed - // <50%, starving the whole shot rotation — the bot "kept healing the pet and - // never attacked" (observed L11 Uraimus). Once the HoT is ticking, yield to - // damage; only re-apply after it falls off and the pet is still hurt. - if (ctx.bot.find_pet_aura(MEND_PET) != nullptr) return false; - return ctx.bot.pet_hp_pct() <= 50; -} -void DoMendPet(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(MEND_PET); } - -// ---- Survival ---- -bool ShouldAspectTurtle(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(ASPECT_TURTLE)) return false; - if (!ctx.bot.is_ready(ASPECT_TURTLE)) return false; - // PvP: player-spike windows kill faster than PvE; pop earlier so the - // immunity catches the burst rather than chasing it. - const int32 threshold = ctx.pvp.under_player_attack ? 40 : 20; - return ctx.bot.hp_pct() <= threshold; -} -void DoAspectTurtle(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(ASPECT_TURTLE); } - -bool ShouldExhilaration(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(EXHILARATION)) return false; - if (!ctx.bot.is_ready(EXHILARATION)) return false; - return ctx.bot.hp_pct() <= 50; -} -void DoExhilaration(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(EXHILARATION); } - -bool ShouldSurvivalFittest(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(SURVIVAL_FITTEST)) return false; - if (!ctx.bot.is_ready(SURVIVAL_FITTEST)) return false; - return ctx.bot.hp_pct() <= 60; -} -void DoSurvivalFittest(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(SURVIVAL_FITTEST); } - -bool ShouldDisengage(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(DISENGAGE)) return false; - if (!ctx.bot.is_ready(DISENGAGE)) return false; - // "Kite 2+ melee": leap back only when 2+ enemies are actually ATTACKING - // the bot in melee range — not merely near it. The old enemies_within(8) - // gate also counted the PET's targets, so a full-HP BM hunter whose boar - // pulled a camp leapt away from the pet's fight every cooldown, never - // engaging — a 60-minute in-combat / 0-XP stall (Zekani, L10, Barrens). - return ctx.bot.melee_attackers_within(8.0f) >= 2; -} -void DoDisengage(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(DISENGAGE); } - -bool ShouldFeignDeath(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(FEIGN_DEATH)) return false; - if (!ctx.bot.is_ready(FEIGN_DEATH)) return false; - return ctx.bot.hp_pct() <= 30 && ctx.bot.attackers_count() >= 1; -} -void DoFeignDeath(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(FEIGN_DEATH); } - -// ---- Group utility ---- -bool ShouldMisdirection(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(MISDIRECTION)) return false; - if (!ctx.bot.is_ready(MISDIRECTION)) return false; - auto const* tank = ctx.group.tank(); - return tank && tank->online && tank->guid != ctx.bot.raw().guid; -} -void DoMisdirection(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* tank = ctx.group.tank()) - e.cast(MISDIRECTION, tank->guid); -} - -// Primal Rage is a PET ability (Ferocity family, surfaced to the hunter via -// Command Pet 272651), not a hunter spell - knows_spell()/is_ready() query -// the BOT's spellbook and always failed, and even if they passed, e.cast() -// would cast from the player and bounce off NOT_KNOWN. Route through -// pet_cast; API::pet_cast validates the pet knows it (Ferocity) and checks -// the pet's own SpellHistory, so no bot-side spellbook gates apply. 264667 -// still exists in 12.1 SpellName ("Ferocity Ability"). -bool ShouldPrimalRage(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.has_pet()) return false; - if (!ctx.bot.pet_can_bloodlust()) return false; // Ferocity pets only - if (BotHasSatedDebuff(ctx)) return false; - return BossLikeTargetEngaged(ctx); -} -void DoPrimalRage(ApPredicateContext const&, BotIntentEmitter& e) { e.pet_cast(PRIMAL_RAGE); } - -// ---- Interrupt / CC ---- -bool ShouldCounterShot(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(COUNTER_SHOT)) return false; - if (!ctx.bot.is_ready(COUNTER_SHOT)) return false; - const bool pvp = ctx.pvp.in_battleground || ctx.pvp.in_arena; - return ctx.bot.kick_target(pvp, 40.0f) != nullptr; -} -void DoCounterShot(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - const bool pvp = ctx.pvp.in_battleground || ctx.pvp.in_arena; - if (auto const* c = ctx.bot.kick_target(pvp, 40.0f)) - e.cast(COUNTER_SHOT, c->guid); -} - -bool ShouldIntimidation(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(INTIMIDATION)) return false; - if (!ctx.bot.is_ready(INTIMIDATION)) return false; - if (ctx.bot.is_ready(COUNTER_SHOT)) return false; - const bool pvp = ctx.pvp.in_battleground || ctx.pvp.in_arena; - return ctx.bot.kick_target(pvp, 40.0f) != nullptr; -} -void DoIntimidation(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - const bool pvp = ctx.pvp.in_battleground || ctx.pvp.in_arena; - if (auto const* c = ctx.bot.kick_target(pvp, 40.0f)) - e.cast(INTIMIDATION, c->guid); -} - -bool ShouldBindingShot(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(BINDING_SHOT)) return false; - if (!ctx.bot.is_ready(BINDING_SHOT)) return false; - return ctx.bot.enemies_within(15.0f) >= 3; -} -void DoBindingShot(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* v = ctx.bot.victim_info()) - e.cast_at(BINDING_SHOT, v->x, v->y, v->z); - else - e.cast(BINDING_SHOT); -} - -// Tar Trap [R] (187698): ground slow. Defensive use only - drop it under -// a pack when the bot is taking real pressure, same gate as the MM file. -bool ShouldTarTrap(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(TAR_TRAP)) return false; - if (!ctx.bot.is_ready(TAR_TRAP)) return false; - return ctx.bot.enemies_within(15.0f) >= 2 && ctx.bot.hp_pct() <= 50; -} -void DoTarTrap(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* v = ctx.bot.victim_info()) - e.cast_at(TAR_TRAP, v->x, v->y, v->z); - else - e.cast(TAR_TRAP); -} - -// ---- Major offensive cooldowns ---- -// 12.1: Aspect of the Wild, Call of the Wild and Stampede have no BM learn -// path; Bloodshed (1272099) and Dire Beast (120679) are PASSIVES (Bestial -// Wrath applies the Bloodshed bleed, Dire Beasts proc from bleed ticks). -// BM burst is therefore a single button: Bestial Wrath. -bool ShouldBestialWrath(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(BESTIAL_WRATH)) return false; - if (!ctx.bot.is_ready(BESTIAL_WRATH)) return false; - // Leveling workhorse, not a boss-only button: at a 90s CD vs ~15s - // overworld kills, holding it for "boss-like" (5M HP) targets meant - // leveling bots NEVER pressed it. Fire on any fight that can absorb - // the CD: a meaty single target (more HP than the bot), a multi-pull, - // or the classic boss/burst windows. - if (BossLikeTargetEngaged(ctx)) return true; - if (ctx.bot.attackers_count() >= 2 || ctx.bot.enemies_within(10.0f) >= 2) return true; - NearbyUnit const* t = ctx.bot.victim_info(); - return t && t->max_hp >= ctx.bot.max_hp(); -} -void DoBestialWrath(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(BESTIAL_WRATH); } - -// Hunter's Mark - baseline ranged-damage-taken debuff (5%). Auto-granted -// around L7 and persists across all three specs. Apply once per target -// (the aura is permanent on the victim until they die or the bot dies). -bool ShouldHuntersMark(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(HUNTERS_MARK)) return false; - if (!ctx.bot.is_ready(HUNTERS_MARK)) return false; - return ctx.bot.find_aura(HUNTERS_MARK, ctx.bot.victim()) == nullptr; -} -void DoHuntersMark(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(HUNTERS_MARK, ctx.bot.victim()); -} - -// ---- Execute / opener ---- -// Black Arrow (466930, Dark Ranger [R][M]) is BM's Kill Shot replacement in -// 12.1: 10 focus, usable only when the target is above 80% or below 20% -// health. Fires ahead of Barbed Shot / Kill Command inside its window - it -// is the highest damage-per-GCD shot BM owns. No focus reserve needed at -// 10 focus. -bool ShouldBlackArrow(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(BLACK_ARROW)) return false; - if (!ctx.bot.is_ready(BLACK_ARROW)) return false; - if (FocusVal(ctx) < BLACK_ARROW_COST) return false; - return TargetBlackArrowWindow(ctx); -} -void DoBlackArrow(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(BLACK_ARROW, ctx.bot.victim()); -} - -// ---- Frenzy + AoE + filler ---- -bool ShouldBarbedShot(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(BARBED_SHOT)) return false; - if (!ctx.bot.is_ready(BARBED_SHOT)) return false; - if (!ctx.bot.has_pet()) return true; - AuraEntry const* frenzy = ctx.bot.find_pet_aura(FRENZY_AURA); - if (!frenzy) return true; - // 2.5s refresh window: snapshot cadence (~250ms) + per-bot reaction - // delay (200-450ms) + the GCD ate too far into the old 2.0s margin — - // Frenzy (8s) dropped between ticks. 2.5s still avoids early clipping. - if (frenzy->remaining.count() <= 2500) return true; - // Anti-cap: with Frenzy healthy, still spend a charge when BOTH are - // banked — sitting at 2/2 wastes recharge time (12s per charge). - return ctx.bot.charges(BARBED_SHOT) >= 2; -} -void DoBarbedShot(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(BARBED_SHOT, ctx.bot.victim()); -} - -// Wild Thrash (1264359, [M]) - BM's AoE button, replacing the unobtainable -// Multi-Shot: it triggers Beast Cleave (115939) so the pet's melee + Kill -// Command strike everything nearby for ~8s. Cast it to TURN CLEAVE ON -// and keep it up through a pack, not every AoE GCD: re-cast only when -// the pet's cleave aura is missing or about to fall off. AoE detection -// uses attackers_count (mobs actually fighting us) — a bot leveling -// through a populated camp should not cleave on proximity alone. -bool ShouldWildThrash(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(WILD_THRASH)) return false; - if (!ctx.bot.is_ready(WILD_THRASH)) return false; - const bool aoe = ctx.aoe_preference || ctx.bot.attackers_count() >= 2; - if (!aoe) return false; - if (!ctx.bot.has_pet()) return false; // cleave is pet damage; pointless petless - AuraEntry const* cleave = ctx.bot.find_pet_aura(BEAST_CLEAVE_PET); - return !cleave || cleave->remaining.count() <= 1500; -} -void DoWildThrash(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(WILD_THRASH, ctx.bot.victim()); -} - -bool ShouldKillCommand(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.has_pet()) return false; - if (!ctx.bot.knows_spell(KILL_COMMAND)) return false; - if (!ctx.bot.is_ready(KILL_COMMAND)) return false; - return FocusVal(ctx) >= KILL_COMMAND_COST; -} -void DoKillCommand(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(KILL_COMMAND, ctx.bot.victim()); -} - -// ---- Focus spenders ---- -// Shared gate: spend only when the cast leaves >= KILL_COMMAND_COST -// banked, so Kill Command comes off cooldown fully funded. Without the -// reserve the old Cobra rule (bare 35-focus check) drained the pool and -// delayed KC by 1-2 GCDs every cycle. -bool CanAffordSpender(ApPredicateContext const& ctx, int32 cost) -{ - return FocusVal(ctx) >= cost + KILL_COMMAND_COST; -} - -bool ShouldCobraShot(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(COBRA_SHOT)) return false; - if (!ctx.bot.is_ready(COBRA_SHOT)) return false; - return CanAffordSpender(ctx, COBRA_SHOT_COST); -} -void DoCobraShot(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(COBRA_SHOT, ctx.bot.victim()); -} - -// Arcane Shot: the focus dump for the pre-Cobra leveling bracket. This -// was MISSING from the BM list entirely — live-verified 2026-06-10 -// (Uraimus, L13): rule history showed Hunter's Mark -> Kill Command -> -// Steady, Steady, Steady... with focus pinned at cap, because the only -// listed spender (Cobra Shot) isn't learned yet at that level. Once -// Cobra Shot is known this rule self-disables (Cobra is strictly better -// for BM and sits one slot above). -bool ShouldArcaneShot(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (ctx.bot.knows_spell(COBRA_SHOT)) return false; - if (!ctx.bot.knows_spell(ARCANE_SHOT)) return false; - if (!ctx.bot.is_ready(ARCANE_SHOT)) return false; - return CanAffordSpender(ctx, ARCANE_SHOT_COST); -} -void DoArcaneShot(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(ARCANE_SHOT, ctx.bot.victim()); -} - -// Steady Shot: L1 baseline filler for unspecced and Beast Mastery hunters. -// Verified 2026-05-20 — fleet hunters at L1-9 default-route to the BM -// rotation (ApRegistry::DefaultSpecForClass returns 253), but BM's only -// filler is Cobra Shot which is learned at higher level + requires -// 35 focus. Without Steady Shot, L1 hunters fall through to AutoAttack -// which is melee — and L1 hunters typically aren't carrying a melee -// weapon, so auto-attack does nothing. Steady Shot has no minimum -// range, no focus cost, and is the baseline shot all hunters keep -// across levels. -// -// is_ready gate (2026-06-10): without it the rule re-emitted mid-cast -// once the 1.5s emit lockout lapsed inside Steady's ~2s cast — the -// executor then burned a world-thread cast that bounced off -// SPELL_FAILED_SPELL_IN_PROGRESS (observed as CastSpell|NotReady pairs -// in Uraimus's intent history). is_ready folds in is_casting + GCD. -// Barbed-Shot gate (12.0): the Barbed Shot talent OVERRIDES Steady Shot on -// the bar (TraitDefinition OverridesSpellID) — TC redirects casts of the -// base spell to the override, so a Steady emit from a Barbed-talented bot -// would silently burn a Barbed CHARGE as an unintended filler. Once Barbed -// is known, BM's filler is auto shot + focus regen (matches retail play). -bool ShouldSteadyShot(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (ctx.bot.knows_spell(BARBED_SHOT)) return false; - if (!ctx.bot.knows_spell(STEADY_SHOT)) return false; - return ctx.bot.is_ready(STEADY_SHOT); -} -void DoSteadyShot(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(STEADY_SHOT, ctx.bot.victim()); -} - -bool AlwaysInCombat(ApPredicateContext const& ctx) { return ctx.bot.in_combat(); } -void DoAutoAttack(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - ObjectGuid t = ctx.bot.victim(); - if (t.IsEmpty()) t = ctx.bot.current_target(); - // Retaliate fallback (2026-06-17): in combat with no victim/target the bot - // looped "Engage auto attack" as a no-op while taking damage (the CombatLoop - // wedge cluster). Engage whatever is meleeing us (attackers are adjacent and - // reachable), else the nearest visible enemy, so combat actually resolves. - // Strictly additive: only runs when no target was already selected. - if (t.IsEmpty()) - for (auto const& u : ctx.bot.attackers()) - if (u.hp > 0) { t = u.guid; break; } - if (t.IsEmpty()) - for (auto const& u : ctx.bot.nearby_enemies()) - if (u.hp > 0 && u.in_los) { t = u.guid; break; } - if (!t.IsEmpty()) e.start_attack(t); -} - -ApRule const kRules[] = { - { ShouldRevivePet, DoRevivePet, "Revive Pet" }, - { ShouldMendPet, DoMendPet, "Mend Pet (<=50%)" }, - { ShouldAspectTurtle, DoAspectTurtle, "Aspect of the Turtle (<=20%)"}, - { ShouldSurvivalFittest, DoSurvivalFittest, "Survival of the Fittest" }, - { ShouldExhilaration, DoExhilaration, "Exhilaration (<=50%)" }, - { ShouldDisengage, DoDisengage, "Disengage (kite 2+ melee)" }, - { ShouldFeignDeath, DoFeignDeath, "Feign Death (drop aggro)" }, - { ShouldMisdirection, DoMisdirection, "Misdirection (tank threat)" }, - { ShouldCounterShot, DoCounterShot, "Counter Shot (interrupt)" }, - { ShouldIntimidation, DoIntimidation, "Intimidation (interrupt fb)" }, - { ShouldBindingShot, DoBindingShot, "Binding Shot (3+ AoE)" }, - { ShouldTarTrap, DoTarTrap, "Tar Trap (slow)" }, - { ShouldPrimalRage, DoPrimalRage, "Primal Rage (Bloodlust)" }, - { ShouldBestialWrath, DoBestialWrath, "Bestial Wrath" }, - { ShouldHuntersMark, DoHuntersMark, "Hunter's Mark (debuff)" }, - { ShouldBlackArrow, DoBlackArrow, "Black Arrow (<20% / >80%)" }, - { ShouldBarbedShot, DoBarbedShot, "Barbed Shot (Frenzy)" }, - { ShouldWildThrash, DoWildThrash, "Wild Thrash (Beast Cleave)" }, - { ShouldKillCommand, DoKillCommand, "Kill Command" }, - { ShouldCobraShot, DoCobraShot, "Cobra Shot (spender)" }, - { ShouldArcaneShot, DoArcaneShot, "Arcane Shot (pre-Cobra)" }, - { ShouldSteadyShot, DoSteadyShot, "Steady Shot (filler)" }, - { AlwaysInCombat, DoAutoAttack, "Engage auto attack" }, -}; - -} // anonymous - -void RegisterApl_Hunter_BeastMastery() -{ - constexpr uint8 SPEC_HUNTER_BEAST_MASTERY = 253; - RegisterRotation(CLASS_HUNTER, SPEC_HUNTER_BEAST_MASTERY, ApRotation{kRules}); -} - -} // namespace Playerbot::Combat diff --git a/src/modules/PlayerbotV2/Combat/Apl/Apl_Hunter_Marksmanship.cpp b/src/modules/PlayerbotV2/Combat/Apl/Apl_Hunter_Marksmanship.cpp deleted file mode 100644 index e6cdf6f50b..0000000000 --- a/src/modules/PlayerbotV2/Combat/Apl/Apl_Hunter_Marksmanship.cpp +++ /dev/null @@ -1,517 +0,0 @@ -// Marksmanship Hunter - WoW 12.1.0.69587 (Midnight) enterprise rotation. -// Pure ranged, PETLESS DPS (MM hunts with a Spotting Eagle since 11.1 - no -// beast companion) with Aimed Shot as the heavy hitter, Rapid Fire as a -// focus generator + spike, Explosive Shot on cooldown (Precision Detonation), -// Trueshot burst window, Precise Shots procs spent on Arcane Shot, and -// Kill Shot (or Black Arrow when the Dark Ranger hero talent replaces it) -// as the execute. Steady Shot is the cast-while-moving filler. -// -// Layered survival: Aspect of the Turtle -> Exhilaration -> Survival of the -// Fittest -> Disengage -> Feign Death. Group utility: Misdirection (tank -// threat redirect), Harrier's Cry (L48 spec spell: raid haste / Bloodlust -// equivalent, Sated-gated). CC: Counter Shot, Intimidation (eagle stun, -// interrupt fallback), Tar Trap, Binding Shot. Major CDs: Trueshot, Volley -// (ground AoE, also grants Trick Shots). -// -// Validated spell IDs (WoW 12.1.0.69587, kit + SpellName.csv): -// 19434 Aimed Shot | 185358 Arcane Shot | 257044 Rapid Fire -// 56641 Steady Shot | 53351 Kill Shot | 466930 Black Arrow -// 288613 Trueshot | 260243 Volley | 212431 Explosive Shot -// 257620 Multi-Shot | 466904 Harrier's Cry | 257284 Hunter's Mark -// 147362 Counter Shot | 474421 Intimidation(MM) | 109248 Binding Shot -// 187698 Tar Trap | 34477 Misdirection | 264735 Survival o.t.Fit. -// 186265 Aspect of Turtle | 109304 Exhilaration | 781 Disengage -// 5384 Feign Death | 136 Mend Pet | 982 Revive Pet -// 260242 Precise Shots (buff aura; talent passive is 260240) -// -// Skipped (deliberate, 12.1): -// * Salvo ( 400456) - PASSIVE in 12.1 (Volley applies Explosive -// Shot); was wrongly cast as a spell. -// * Wailing Arrow ( 392060/355589) - no 12.1 learn path for MM (355589 is -// the Shadowlands legendary-bow leftover). -// * Death Chakram ( 375891/325028) - covenant leftover, not learnable. -// * Serpent Sting ( 271788) - removed from MM. -// * Aspect of the Wild (193530) - removed from the game. -// * Primal Rage ( 264667) - Ferocity PET ability; MM has no pet in 12.1. -// * Lone Wolf ( 155228) - not in the 12.1 MM kit (petless is baseline). -// * Steady Focus ( 193533) - passive, never cast. -// * Tranquilizing Shot (19801) - class talent not in either curated build. -// * Eagle Eye ( 6197) - scout-vision spell, removes bot control. -// * Fetch: Eagle (1232995) / Air Superiority (470937) - loot / passive DR -// granted by passives, no combat cast. - -#include "../ApRegistry.h" -#include "../ApRotation.h" -#include "Bot/BotIntentEmitter.h" -#include "Bot/BotSnapshotView.h" -#include "Group/GroupSnapshot.h" -#include "SharedDefines.h" - -namespace Playerbot::Combat { - -namespace { - -// ---- Spell IDs (WoW 12.1.0.69587, validated against the 12.1 kit and -// SpellName.csv; see the header table) ---- -constexpr uint32 AIMED_SHOT = 19434; // spec talent [R][M] (L10), 2.5s cast, 35 focus -constexpr uint32 ARCANE_SHOT = 185358; // baseline L2 - Precise Shots spender -constexpr uint32 RAPID_FIRE = 257044; // spec talent [R][M], 16s cd, focus generator -constexpr uint32 STEADY_SHOT = 56641; // baseline L1 filler, usable while moving -constexpr uint32 KILL_SHOT_MM = 53351; // spec talent [R] (L42), <20% execute -constexpr uint32 BLACK_ARROW = 466930; // Dark Ranger active; 466932 [R] REPLACES Kill Shot with it -constexpr uint32 TRUESHOT = 288613; // spec talent [R][M], 120s cd burst -constexpr uint32 PRECISE_SHOTS = 260242; // buff aura after Aimed Shot (talent passive 260240) -constexpr uint32 VOLLEY = 260243; // spec talent [R][M] - ground AoE, 45s cd -constexpr uint32 EXPLOSIVE_SHOT = 212431; // spec talent [R][M] - 30s cd, 20 focus, ST + AoE -constexpr uint32 MULTI_SHOT_MM = 257620; // spec spell L10, 30 focus -constexpr uint32 HUNTERS_MARK = 257284; -constexpr uint32 COUNTER_SHOT = 147362; // class talent [R][M] (L18) -constexpr uint32 INTIMIDATION_MM = 474421; // class talent [R][M] - MM variant (Spotting Eagle stun, 40y) -constexpr uint32 MISDIRECTION = 34477; -constexpr uint32 ASPECT_TURTLE = 186265; -constexpr uint32 EXHILARATION = 109304; -constexpr uint32 SURVIVAL_FITTEST = 264735; -constexpr uint32 DISENGAGE = 781; -constexpr uint32 MEND_PET = 136; // class baseline; inert for a petless MM (has_pet gate) -constexpr uint32 REVIVE_PET = 982; // class baseline; inert for a petless MM (pet_guid gate) -constexpr uint32 FEIGN_DEATH = 5384; -constexpr uint32 TAR_TRAP = 187698; // class talent [R] -constexpr uint32 BINDING_SHOT = 109248; // class talent [R][M] -constexpr uint32 HARRIERS_CRY = 466904; // spec spell L48 - raid haste (Bloodlust-class, applies Sated) - -constexpr uint8 POWER_FOCUS_IDX = 2; - -constexpr int32 AIMED_SHOT_COST = 35; -constexpr int32 MULTI_SHOT_COST = 30; -constexpr int32 EXPLOSIVE_SHOT_COST = 20; -constexpr int32 BLACK_ARROW_COST = 10; - -bool HasLiveTarget(ApPredicateContext const& ctx) -{ - return !ctx.bot.victim().IsEmpty(); -} - -bool BossLikeTargetEngaged(ApPredicateContext const& ctx) -{ - constexpr int32 kBossHpThreshold = 5'000'000; - NearbyUnit const* t = ctx.bot.victim_info(); - if (t && t->max_hp >= kBossHpThreshold) return true; - for (auto const& a : ctx.bot.raw().combat.attackers) - if (a.max_hp >= kBossHpThreshold) return true; - return false; -} - -bool BotHasSatedDebuff(ApPredicateContext const& ctx) -{ - constexpr uint32 SATED_DEBUFF = 57724; - constexpr uint32 TEMPORAL_DISPL_DEBUFF = 80354; - constexpr uint32 INSANITY_HUNTER_DEBUFF = 95809; - constexpr uint32 FATIGUED_DEBUFF = 264689; - return ctx.bot.has_aura(SATED_DEBUFF) - || ctx.bot.has_aura(TEMPORAL_DISPL_DEBUFF) - || ctx.bot.has_aura(INSANITY_HUNTER_DEBUFF) - || ctx.bot.has_aura(FATIGUED_DEBUFF); -} - -int64 TargetHpPct(ApPredicateContext const& ctx) -{ - NearbyUnit const* t = ctx.bot.victim_info(); - if (!t || t->max_hp <= 0 || t->hp <= 0) return -1; - return (int64_t(t->hp) * 100) / t->max_hp; -} - -bool TargetExecuteRange(ApPredicateContext const& ctx) -{ - const int64 pct = TargetHpPct(ctx); - return pct >= 0 && pct <= 20; -} - -// Black Arrow window (466930): "Only usable on enemies above 80% health or -// below 20% health". -bool TargetBlackArrowWindow(ApPredicateContext const& ctx) -{ - const int64 pct = TargetHpPct(ctx); - return pct >= 0 && (pct <= 20 || pct >= 80); -} - -int32 FocusVal(ApPredicateContext const& ctx) { return ctx.bot.power(POWER_FOCUS_IDX); } - -// ---- Pet maintenance ---- -// MM is petless in 12.1 (Spotting Eagle). Both rules stay for the class -// baseline spells but self-gate on pet_guid()/has_pet(), so they are inert -// unless a pet somehow exists (e.g. spec swap mid-session). -bool ShouldRevivePet(ApPredicateContext const& ctx) -{ - // See note on the BM version: only resurrect when there's actually a - // dead pet to bring back. pet_guid().IsEmpty() means the bot never - // tamed/summoned one, so Revive Pet is a no-op that would otherwise - // starve the entire rotation by re-firing every tick. - if (ctx.bot.pet_guid().IsEmpty()) return false; - if (ctx.bot.has_pet()) return false; - if (!ctx.bot.knows_spell(REVIVE_PET)) return false; - return ctx.bot.is_ready(REVIVE_PET); -} -void DoRevivePet(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(REVIVE_PET); } - -bool ShouldMendPet(ApPredicateContext const& ctx) -{ - if (!ctx.bot.has_pet()) return false; - if (!ctx.bot.knows_spell(MEND_PET)) return false; - if (!ctx.bot.is_ready(MEND_PET)) return false; - return ctx.bot.pet_hp_pct() <= 50; -} -void DoMendPet(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(MEND_PET); } - -// ---- Survival ---- -bool ShouldAspectTurtle(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(ASPECT_TURTLE)) return false; - if (!ctx.bot.is_ready(ASPECT_TURTLE)) return false; - // PvP: bump panic threshold so the immunity catches the burst window. - const int32 threshold = ctx.pvp.under_player_attack ? 40 : 20; - return ctx.bot.hp_pct() <= threshold; -} -void DoAspectTurtle(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(ASPECT_TURTLE); } - -bool ShouldSurvivalFittest(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(SURVIVAL_FITTEST)) return false; - if (!ctx.bot.is_ready(SURVIVAL_FITTEST)) return false; - return ctx.bot.hp_pct() <= 60; -} -void DoSurvivalFittest(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(SURVIVAL_FITTEST); } - -bool ShouldExhilaration(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(EXHILARATION)) return false; - if (!ctx.bot.is_ready(EXHILARATION)) return false; - return ctx.bot.hp_pct() <= 50; -} -void DoExhilaration(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(EXHILARATION); } - -bool ShouldDisengage(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(DISENGAGE)) return false; - if (!ctx.bot.is_ready(DISENGAGE)) return false; - // "Kite 2+ melee": leap back only when 2+ enemies are actually ATTACKING - // the bot in melee range — not merely near it. enemies_within(8) also - // counted the PET's targets, making a full-HP hunter leap away from its - // pet's fight every cooldown without ever engaging (see BeastMastery). - return ctx.bot.melee_attackers_within(8.0f) >= 2; -} -void DoDisengage(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(DISENGAGE); } - -bool ShouldFeignDeath(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(FEIGN_DEATH)) return false; - if (!ctx.bot.is_ready(FEIGN_DEATH)) return false; - return ctx.bot.hp_pct() <= 30 && ctx.bot.attackers_count() >= 1; -} -void DoFeignDeath(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(FEIGN_DEATH); } - -// ---- Group utility ---- -bool ShouldMisdirection(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(MISDIRECTION)) return false; - if (!ctx.bot.is_ready(MISDIRECTION)) return false; - auto const* tank = ctx.group.tank(); - return tank && tank->online && tank->guid != ctx.bot.raw().guid; -} -void DoMisdirection(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* tank = ctx.group.tank()) - e.cast(MISDIRECTION, tank->guid); -} - -// ---- Interrupt / CC ---- -bool ShouldCounterShot(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(COUNTER_SHOT)) return false; - if (!ctx.bot.is_ready(COUNTER_SHOT)) return false; - const bool pvp = ctx.pvp.in_battleground || ctx.pvp.in_arena; - return ctx.bot.kick_target(pvp, 40.0f) != nullptr; -} -void DoCounterShot(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - const bool pvp = ctx.pvp.in_battleground || ctx.pvp.in_arena; - if (auto const* c = ctx.bot.kick_target(pvp, 40.0f)) - e.cast(COUNTER_SHOT, c->guid); -} - -// Intimidation, MM variant (474421, [R][M]): the Spotting Eagle stuns the -// target for 5s at 40y - no pet required. Used as the interrupt fallback -// when Counter Shot is on cooldown (same slot Intimidation holds in BM). -bool ShouldIntimidation(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(INTIMIDATION_MM)) return false; - if (!ctx.bot.is_ready(INTIMIDATION_MM)) return false; - if (ctx.bot.is_ready(COUNTER_SHOT)) return false; - const bool pvp = ctx.pvp.in_battleground || ctx.pvp.in_arena; - return ctx.bot.kick_target(pvp, 40.0f) != nullptr; -} -void DoIntimidation(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - const bool pvp = ctx.pvp.in_battleground || ctx.pvp.in_arena; - if (auto const* c = ctx.bot.kick_target(pvp, 40.0f)) - e.cast(INTIMIDATION_MM, c->guid); -} - -bool ShouldBindingShot(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(BINDING_SHOT)) return false; - if (!ctx.bot.is_ready(BINDING_SHOT)) return false; - return ctx.bot.enemies_within(15.0f) >= 3; -} -void DoBindingShot(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* v = ctx.bot.victim_info()) - e.cast_at(BINDING_SHOT, v->x, v->y, v->z); - else - e.cast(BINDING_SHOT); -} - -bool ShouldTarTrap(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(TAR_TRAP)) return false; - if (!ctx.bot.is_ready(TAR_TRAP)) return false; - return ctx.bot.enemies_within(15.0f) >= 2 && ctx.bot.hp_pct() <= 50; -} -void DoTarTrap(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* v = ctx.bot.victim_info()) - e.cast_at(TAR_TRAP, v->x, v->y, v->z); - else - e.cast(TAR_TRAP); -} - -// ---- Major offensive cooldowns ---- -bool ShouldTrueshot(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(TRUESHOT)) return false; - if (!ctx.bot.is_ready(TRUESHOT)) return false; - return BossLikeTargetEngaged(ctx); -} -void DoTrueshot(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(TRUESHOT); } - -// Harrier's Cry (466904, L48 spec spell): "Increases haste by $s1% for all -// party and raid members for 40s ... Allies receiving this effect will -// become Sated". It is MM's Bloodlust, so it takes the Bloodlust gates: -// boss-like target only and never while the bot itself is Sated / Temporal -// Displacement / Fatigued (the cast would be wasted). -bool ShouldHarriersCry(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(HARRIERS_CRY)) return false; - if (!ctx.bot.is_ready(HARRIERS_CRY)) return false; - if (BotHasSatedDebuff(ctx)) return false; - return BossLikeTargetEngaged(ctx); -} -void DoHarriersCry(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(HARRIERS_CRY); } - -// Volley (260243, [R][M], 45s cd): 12.1 MM presses it on cooldown in single -// target too (it grants Trick Shots + Salvo's Explosive Shot spread and is -// a large chunk of damage on its own), so the only gate is readiness. -bool ShouldVolley(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(VOLLEY)) return false; - return ctx.bot.is_ready(VOLLEY); -} -void DoVolley(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* v = ctx.bot.victim_info()) - e.cast_at(VOLLEY, v->x, v->y, v->z); - else - e.cast(VOLLEY); -} - -// Explosive Shot (212431, [R][M], 30s cd, 20 focus): single-target AND AoE -// button in 12.1 (Precision Detonation / Unstable Trigger build around it), -// so it fires whenever ready and affordable. -bool ShouldExplosiveShot(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(EXPLOSIVE_SHOT)) return false; - if (!ctx.bot.is_ready(EXPLOSIVE_SHOT)) return false; - return FocusVal(ctx) >= EXPLOSIVE_SHOT_COST; -} -void DoExplosiveShot(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(EXPLOSIVE_SHOT, ctx.bot.victim()); -} - -// ---- Execute ---- -// Two-branch pattern (see Victory Rush / Impending Victory in Arms): the -// Dark Ranger passive 466932 [R] REPLACES Kill Shot with Black Arrow -// (466930). When the bot knows Black Arrow, fire it in its <20% / >80% -// window and keep Kill Shot silent; non-hero bots keep the plain execute. -bool ShouldBlackArrow(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(BLACK_ARROW)) return false; - if (!ctx.bot.is_ready(BLACK_ARROW)) return false; - if (FocusVal(ctx) < BLACK_ARROW_COST) return false; - return TargetBlackArrowWindow(ctx); -} -void DoBlackArrow(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(BLACK_ARROW, ctx.bot.victim()); -} - -bool ShouldKillShot(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (ctx.bot.knows_spell(BLACK_ARROW)) return false; // replaced by Black Arrow - if (!ctx.bot.knows_spell(KILL_SHOT_MM)) return false; - if (!ctx.bot.is_ready(KILL_SHOT_MM)) return false; - if (FocusVal(ctx) < BLACK_ARROW_COST) return false; // Kill Shot also costs 10 - return TargetExecuteRange(ctx); -} -void DoKillShot(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(KILL_SHOT_MM, ctx.bot.victim()); -} - -// ---- Damage rotation ---- -bool ShouldRapidFire(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(RAPID_FIRE)) return false; - return ctx.bot.is_ready(RAPID_FIRE); -} -void DoRapidFire(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(RAPID_FIRE, ctx.bot.victim()); -} - -bool ShouldArcaneShotProc(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(ARCANE_SHOT)) return false; - return ctx.bot.has_aura(PRECISE_SHOTS); -} -void DoArcaneShot(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(ARCANE_SHOT, ctx.bot.victim()); -} - -bool ShouldMultiShot(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(MULTI_SHOT_MM)) return false; - if (FocusVal(ctx) < MULTI_SHOT_COST) return false; // 30 focus in 12.1 (kit); under-costing let it claim ticks it couldn't pay for - // attackers_count (mobs actually fighting us), not "2 enemies anywhere - // within 40y" — the old gate made MM bots Multi-Shot single targets - // all through any populated camp. - return ctx.aoe_preference || ctx.bot.attackers_count() >= 2; -} -void DoMultiShot(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(MULTI_SHOT_MM, ctx.bot.victim()); -} - -bool ShouldAimedShot(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(AIMED_SHOT)) return false; - if (!ctx.bot.is_ready(AIMED_SHOT)) return false; - if (FocusVal(ctx) < AIMED_SHOT_COST) return false; - // Don't cast Aimed Shot while moving — it's a 2.5s channel that gets - // interrupted. Steady Shot fills the gap. - if (ctx.bot.is_moving()) return false; - return true; -} -void DoAimedShot(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(AIMED_SHOT, ctx.bot.victim()); -} - -bool ShouldSteadyShot(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(STEADY_SHOT)) return false; - // is_ready folds in is_casting + GCD — without it the rule re-emitted - // mid-cast and bounced off SPELL_FAILED_SPELL_IN_PROGRESS. - return ctx.bot.is_ready(STEADY_SHOT); -} -void DoSteadyShot(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(STEADY_SHOT, ctx.bot.victim()); -} - -// Hunter's Mark — baseline ranged-damage-taken debuff (5%). Granted -// around L7 and persists across all three specs. One cast per target. -bool ShouldHuntersMark(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(HUNTERS_MARK)) return false; - if (!ctx.bot.is_ready(HUNTERS_MARK)) return false; - return ctx.bot.find_aura(HUNTERS_MARK, ctx.bot.victim()) == nullptr; -} -void DoHuntersMark(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(HUNTERS_MARK, ctx.bot.victim()); -} - -bool AlwaysInCombat(ApPredicateContext const& ctx) { return ctx.bot.in_combat(); } -void DoAutoAttack(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - ObjectGuid t = ctx.bot.victim(); - if (t.IsEmpty()) t = ctx.bot.current_target(); - // Retaliate fallback (2026-06-17): in combat with no victim/target the bot - // looped "Engage auto attack" as a no-op while taking damage (the CombatLoop - // wedge cluster). Engage whatever is meleeing us (attackers are adjacent and - // reachable), else the nearest visible enemy, so combat actually resolves. - // Strictly additive: only runs when no target was already selected. - if (t.IsEmpty()) - for (auto const& u : ctx.bot.attackers()) - if (u.hp > 0) { t = u.guid; break; } - if (t.IsEmpty()) - for (auto const& u : ctx.bot.nearby_enemies()) - if (u.hp > 0 && u.in_los) { t = u.guid; break; } - if (!t.IsEmpty()) e.start_attack(t); -} - -ApRule const kRules[] = { - { ShouldRevivePet, DoRevivePet, "Revive Pet" }, - { ShouldMendPet, DoMendPet, "Mend Pet (<=50%)" }, - { ShouldAspectTurtle, DoAspectTurtle, "Aspect of the Turtle (<=20%)"}, - { ShouldSurvivalFittest,DoSurvivalFittest,"Survival of the Fittest" }, - { ShouldExhilaration, DoExhilaration, "Exhilaration (<=50%)" }, - { ShouldDisengage, DoDisengage, "Disengage (kite 2+ melee)" }, - { ShouldFeignDeath, DoFeignDeath, "Feign Death (drop aggro)" }, - { ShouldMisdirection, DoMisdirection, "Misdirection (tank threat)" }, - { ShouldCounterShot, DoCounterShot, "Counter Shot (interrupt)" }, - { ShouldIntimidation, DoIntimidation, "Intimidation (interrupt fb)" }, - { ShouldBindingShot, DoBindingShot, "Binding Shot (3+ AoE)" }, - { ShouldTarTrap, DoTarTrap, "Tar Trap (slow)" }, - { ShouldHarriersCry, DoHarriersCry, "Harrier's Cry (raid haste)" }, - { ShouldTrueshot, DoTrueshot, "Trueshot (boss)" }, - { ShouldVolley, DoVolley, "Volley (on cd)" }, - { ShouldExplosiveShot, DoExplosiveShot, "Explosive Shot (on cd)" }, - { ShouldHuntersMark, DoHuntersMark, "Hunter's Mark (debuff)" }, - { ShouldBlackArrow, DoBlackArrow, "Black Arrow (<20% / >80%)" }, - { ShouldKillShot, DoKillShot, "Kill Shot (<=20%)" }, - { ShouldRapidFire, DoRapidFire, "Rapid Fire" }, - { ShouldArcaneShotProc, DoArcaneShot, "Arcane Shot (Precise Shots)" }, - { ShouldMultiShot, DoMultiShot, "Multi-Shot (2+ AoE)" }, - { ShouldAimedShot, DoAimedShot, "Aimed Shot" }, - { ShouldSteadyShot, DoSteadyShot, "Steady Shot (filler)" }, - { AlwaysInCombat, DoAutoAttack, "Engage auto attack" }, -}; - -} // anonymous - -void RegisterApl_Hunter_Marksmanship() -{ - constexpr uint32 SPEC_HUNTER_MARKSMANSHIP = 254; - RegisterRotation(CLASS_HUNTER, SPEC_HUNTER_MARKSMANSHIP, ApRotation{kRules}); -} - -} // namespace Playerbot::Combat diff --git a/src/modules/PlayerbotV2/Combat/Apl/Apl_Hunter_Survival.cpp b/src/modules/PlayerbotV2/Combat/Apl/Apl_Hunter_Survival.cpp deleted file mode 100644 index b6e774762c..0000000000 --- a/src/modules/PlayerbotV2/Combat/Apl/Apl_Hunter_Survival.cpp +++ /dev/null @@ -1,507 +0,0 @@ -// Survival Hunter - WoW 12.1.0.69587 (Midnight) enterprise rotation. Melee -// Hunter built around Kill Command (focus generator, Tip of the Spear), -// Raptor Strike (spender, Mongoose Fury stacks / Raptor Swipe cleave are -// PASSIVE upgrades in 12.1), Wildfire Bomb (charges, cone + DoT) and two -// new 12.1 buttons: Takedown (90s cd leap-and-strike burst, replaces -// Coordinated Assault / Spearhead) and Boomstick (60s cd shotgun cone, -// 50 focus, replaces Butchery / Carve as the AoE spender). -// -// Layered survival: Aspect of the Turtle (immunity) -> Exhilaration -> -// Survival of the Fittest -> Feign Death threat dump. Group utility: -// Misdirection (tank threat redirect), Primal Rage (pet-cast Bloodlust, -// Ferocity pets). Pet maintenance: Mend Pet, Revive Pet. CC: Muzzle -// (melee interrupt), Intimidation (pet stun, interrupt fallback), Binding -// Shot (root cluster), Tar Trap (slow). Engage: Harpoon (gap close, L14) / -// Hatchet Toss (ranged opener, L12; overrides Arcane Shot). Aspect of the -// Eagle extends Raptor Strike to 40y as a boss burst window. -// -// Validated spell IDs (WoW 12.1.0.69587, kit + SpellName.csv): -// 186270 Raptor Strike | 259489 Kill Command (SV) | 259495 Wildfire Bomb -// 1250646 Takedown | 1261193 Boomstick | 193265 Hatchet Toss -// 190925 Harpoon | 186289 Aspect of the Eagle| 187707 Muzzle -// 19577 Intimidation | 109248 Binding Shot | 187698 Tar Trap -// 34477 Misdirection | 264735 Survival o.t.Fit. | 186265 Aspect of the Turtle -// 109304 Exhilaration | 5384 Feign Death | 136 Mend Pet -// 982 Revive Pet | 257284 Hunter's Mark -// 264667 Primal Rage (PET ability, pet_cast) -// -// Skipped (deliberate, 12.1): -// * Mongoose Bite ( 259387) - gone; Mongoose Fury (1252708) is a passive -// Raptor Strike self-buff now. -// * Carve / Butchery (187708 / 212436) - gone; Boomstick + Raptor Swipe -// passive (1259003) cover melee AoE. -// * Serpent Sting ( 259491) - removed from SV (no outbound DoT to cycle). -// * Coordinated Assault / Spearhead (360952 / 360966) - gone; Takedown is -// the 12.1 burst CD. -// * Kill Shot ( 53351) - Marksmanship-only talent in 12.1. -// * Counter Shot ( 147362) - BM/MM only; SV interrupts with Muzzle. -// * Bestial Wrath ( 19574) - BM-only talent. -// * Aspect of the Wild (193530) / Death Chakram (375891) / Steel Trap -// ( 162488) - removed from the game / no SV learn path. -// * Freezing Trap ( 187650) / Aspect of the Cheetah (186257) / Wing -// Clip (195645) - out-of-combat or positional utility. -// * Tranquilizing Shot (19801) / Camouflage (199483) - [M]-only class -// talents, dispel / stealth logic lives outside the DPS ladder. -// * Eyes of the Beast ( 321297) - pet-vision toy, breaks bot bot logic control. - -#include "../ApRegistry.h" -#include "../ApRotation.h" -#include "Bot/BotIntentEmitter.h" -#include "Bot/BotSnapshotView.h" -#include "Group/GroupSnapshot.h" -#include "SharedDefines.h" - -namespace Playerbot::Combat { - -namespace { - -// ---- Spell IDs (WoW 12.1.0.69587, validated against the 12.1 kit and -// SpellName.csv; see the header table) ---- -constexpr uint32 RAPTOR_STRIKE = 186270; // spec talent [R][M] (L10), 30 focus, 5y -constexpr uint32 KILL_COMMAND_SV = 259489; // spec talent [R][M] (L11), 50y, GENERATES focus -constexpr uint32 WILDFIRE_BOMB = 259495; // spec talent [R][M] (L20), 10 focus, cone + DoT -constexpr uint32 TAKEDOWN = 1250646; // spec talent [R][M] - 90s cd, 15y leap-and-strike burst -constexpr uint32 BOOMSTICK = 1261193; // spec talent [R][M] - 60s cd, 50 focus, 20y shotgun cone -constexpr uint32 HATCHET_TOSS = 193265; // spec spell L12 ranged opener (40y), 30 focus; overrides Arcane Shot -constexpr uint32 HARPOON = 190925; // spec spell L14 gap closer (30y) -constexpr uint32 ASPECT_EAGLE = 186289; // spec spell L24 burst CD - Raptor Strike at 40y for 15s -constexpr uint32 INTIMIDATION = 19577; // class talent [R][M] - 5s stun via pet -constexpr uint32 BINDING_SHOT = 109248; // class talent [R] root cluster -constexpr uint32 MUZZLE = 187707; // class talent [R][M] melee interrupt -constexpr uint32 MISDIRECTION = 34477; -constexpr uint32 ASPECT_TURTLE = 186265; -constexpr uint32 EXHILARATION = 109304; -constexpr uint32 SURVIVAL_FITTEST = 264735; // class talent [R][M] - DR self + pet -constexpr uint32 FEIGN_DEATH = 5384; -constexpr uint32 MEND_PET = 136; -constexpr uint32 REVIVE_PET = 982; // OOC + combat rez of pet -constexpr uint32 TAR_TRAP = 187698; // class talent [R][M] -constexpr uint32 HUNTERS_MARK = 257284; -constexpr uint32 PRIMAL_RAGE = 264667; // PET ability (Ferocity, via Command Pet 272651) - pet_cast only - -constexpr uint8 POWER_FOCUS_IDX = 2; - -constexpr int32 RAPTOR_STRIKE_COST = 30; -constexpr int32 HATCHET_TOSS_COST = 30; -constexpr int32 WILDFIRE_BOMB_COST = 10; -constexpr int32 BOOMSTICK_COST = 50; - -bool HasLiveTarget(ApPredicateContext const& ctx) -{ - return !ctx.bot.victim().IsEmpty(); -} - -int32 FocusVal(ApPredicateContext const& ctx) { return ctx.bot.power(POWER_FOCUS_IDX); } - -bool BossLikeTargetEngaged(ApPredicateContext const& ctx) -{ - constexpr int32 kBossHpThreshold = 5'000'000; - NearbyUnit const* t = ctx.bot.victim_info(); - if (t && t->max_hp >= kBossHpThreshold) return true; - for (auto const& a : ctx.bot.raw().combat.attackers) - if (a.max_hp >= kBossHpThreshold) return true; - return false; -} - -bool BotHasSatedDebuff(ApPredicateContext const& ctx) -{ - constexpr uint32 SATED_DEBUFF = 57724; - constexpr uint32 TEMPORAL_DISPL_DEBUFF = 80354; - constexpr uint32 INSANITY_HUNTER_DEBUFF = 95809; - constexpr uint32 FATIGUED_DEBUFF = 264689; - return ctx.bot.has_aura(SATED_DEBUFF) - || ctx.bot.has_aura(TEMPORAL_DISPL_DEBUFF) - || ctx.bot.has_aura(INSANITY_HUNTER_DEBUFF) - || ctx.bot.has_aura(FATIGUED_DEBUFF); -} - -// ---- Pet maintenance ---- -bool ShouldRevivePet(ApPredicateContext const& ctx) -{ - // Only resurrect when there's actually a dead pet to bring back. - // pet_guid().IsEmpty() means the bot never tamed/summoned one; Revive - // Pet would silently no-op and re-fire every tick, starving the rest - // of the rotation. See log audit 2026-05-21 (22.8k spell-982 emits). - if (ctx.bot.pet_guid().IsEmpty()) return false; - if (ctx.bot.has_pet()) return false; - if (!ctx.bot.knows_spell(REVIVE_PET)) return false; - return ctx.bot.is_ready(REVIVE_PET); -} -void DoRevivePet(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(REVIVE_PET); } - -bool ShouldMendPet(ApPredicateContext const& ctx) -{ - if (!ctx.bot.has_pet()) return false; - if (!ctx.bot.knows_spell(MEND_PET)) return false; - if (!ctx.bot.is_ready(MEND_PET)) return false; - return ctx.bot.pet_hp_pct() <= 50; -} -void DoMendPet(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(MEND_PET); } - -// ---- Survival ---- -bool ShouldAspectTurtle(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(ASPECT_TURTLE)) return false; - if (!ctx.bot.is_ready(ASPECT_TURTLE)) return false; - return ctx.bot.hp_pct() <= 20; -} -void DoAspectTurtle(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(ASPECT_TURTLE); } - -bool ShouldExhilaration(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(EXHILARATION)) return false; - if (!ctx.bot.is_ready(EXHILARATION)) return false; - return ctx.bot.hp_pct() <= 50; -} -void DoExhilaration(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(EXHILARATION); } - -bool ShouldSurvivalFittest(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(SURVIVAL_FITTEST)) return false; - if (!ctx.bot.is_ready(SURVIVAL_FITTEST)) return false; - return ctx.bot.hp_pct() <= 60; -} -void DoSurvivalFittest(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(SURVIVAL_FITTEST); } - -bool ShouldFeignDeath(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(FEIGN_DEATH)) return false; - if (!ctx.bot.is_ready(FEIGN_DEATH)) return false; - return ctx.bot.hp_pct() <= 30 && ctx.bot.attackers_count() >= 1; -} -void DoFeignDeath(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(FEIGN_DEATH); } - -// ---- Group utility ---- -bool ShouldMisdirection(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(MISDIRECTION)) return false; - if (!ctx.bot.is_ready(MISDIRECTION)) return false; - auto const* tank = ctx.group.tank(); - return tank && tank->online && tank->guid != ctx.bot.raw().guid; -} -void DoMisdirection(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* tank = ctx.group.tank()) - e.cast(MISDIRECTION, tank->guid); -} - -// Primal Rage is a PET ability (Ferocity family, surfaced to the hunter via -// Command Pet 272651), not a hunter spell - knows_spell()/is_ready() query -// the BOT's spellbook and always fail, and e.cast() would bounce off -// NOT_KNOWN. Route through pet_cast (API::pet_cast validates the pet knows -// it and checks the pet's own SpellHistory). Same pattern as the BM file. -bool ShouldPrimalRage(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.has_pet()) return false; - if (!ctx.bot.pet_can_bloodlust()) return false; // Ferocity pets only - if (BotHasSatedDebuff(ctx)) return false; - return BossLikeTargetEngaged(ctx); -} -void DoPrimalRage(ApPredicateContext const&, BotIntentEmitter& e) { e.pet_cast(PRIMAL_RAGE); } - -// ---- Interrupt / CC ---- -bool ShouldMuzzle(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(MUZZLE)) return false; - if (!ctx.bot.is_ready(MUZZLE)) return false; - const bool pvp = ctx.pvp.in_battleground || ctx.pvp.in_arena; - return ctx.bot.kick_target(pvp, 5.0f) != nullptr; -} -void DoMuzzle(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - const bool pvp = ctx.pvp.in_battleground || ctx.pvp.in_arena; - if (auto const* c = ctx.bot.kick_target(pvp, 5.0f)) - e.cast(MUZZLE, c->guid); -} - -// Intimidation (pet stun, 100y) doubles as the ranged interrupt fallback: -// Muzzle is melee-only (5y), so a caster that is out of reach - or casting -// while Muzzle is on cooldown - gets the pet stun instead. -bool ShouldIntimidation(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(INTIMIDATION)) return false; - if (!ctx.bot.is_ready(INTIMIDATION)) return false; - if (!ctx.bot.has_pet()) return false; - const bool pvp = ctx.pvp.in_battleground || ctx.pvp.in_arena; - if (ctx.bot.is_ready(MUZZLE) && ctx.bot.kick_target(pvp, 5.0f) != nullptr) return false; - return ctx.bot.kick_target(pvp, 40.0f) != nullptr; -} -void DoIntimidation(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - const bool pvp = ctx.pvp.in_battleground || ctx.pvp.in_arena; - if (auto const* c = ctx.bot.kick_target(pvp, 40.0f)) - e.cast(INTIMIDATION, c->guid); -} - -bool ShouldBindingShot(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(BINDING_SHOT)) return false; - if (!ctx.bot.is_ready(BINDING_SHOT)) return false; - return ctx.bot.enemies_within(15.0f) >= 3; -} -void DoBindingShot(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* v = ctx.bot.victim_info()) - e.cast_at(BINDING_SHOT, v->x, v->y, v->z); - else - e.cast(BINDING_SHOT); -} - -bool ShouldTarTrap(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(TAR_TRAP)) return false; - if (!ctx.bot.is_ready(TAR_TRAP)) return false; - return ctx.bot.enemies_within(20.0f) >= 2 && ctx.bot.hp_pct() <= 50; -} -void DoTarTrap(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* v = ctx.bot.victim_info()) - e.cast_at(TAR_TRAP, v->x, v->y, v->z); - else - e.cast(TAR_TRAP); -} - -// Compute squared-distance between bot and a NearbyUnit. NearbyUnit -// itself doesn't carry a pre-computed distance - match the cheap inline -// idiom used by enemies_within() in BotSnapshotView.cpp. -inline float TargetDistSq(ApPredicateContext const& ctx, NearbyUnit const& t) -{ - float bx, by, bz; ctx.bot.position(bx, by, bz); - const float dx = t.x - bx, dy = t.y - by, dz = t.z - bz; - return dx*dx + dy*dy + dz*dz; -} - -// ---- Major offensive CDs ---- -// Takedown (1250646, [R][M], 90s cd, 15y): "You and your pet leap to your -// target and strike as one ... For the next 8s the damage dealt by you -// [and your pet is increased]". It is SV's single burst CD in 12.1 -// (Coordinated Assault / Spearhead are gone). Same leveling-aware gate as -// BM's Bestial Wrath: any fight that can absorb a 90s CD - boss-like, -// multi-pull, or a target meatier than the bot - not raid bosses only. -// The leap also closes a 15y gap, so it doubles as a mini gap-closer. -bool ShouldTakedown(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(TAKEDOWN)) return false; - if (!ctx.bot.is_ready(TAKEDOWN)) return false; - NearbyUnit const* t = ctx.bot.victim_info(); - if (!t) return false; - if (TargetDistSq(ctx, *t) > 15.0f * 15.0f) return false; // out of leap range - if (BossLikeTargetEngaged(ctx)) return true; - if (ctx.bot.attackers_count() >= 2 || ctx.bot.enemies_within(10.0f) >= 2) return true; - return t->max_hp >= ctx.bot.max_hp(); -} -void DoTakedown(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(TAKEDOWN, ctx.bot.victim()); -} - -// Aspect of the Eagle (186289, L24, 90s CD). Extends Raptor Strike (and -// Mastery: Spirit Bond) to 40y for 15s. Use as a burst window - fires on -// boss-like targets so the CD isn't blown on a 3-second trash pull. -// Self-cast (no target). -bool ShouldAspectEagle(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(ASPECT_EAGLE)) return false; - if (!ctx.bot.is_ready(ASPECT_EAGLE)) return false; - return BossLikeTargetEngaged(ctx); -} -void DoAspectEagle(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(ASPECT_EAGLE); } - -// Harpoon (190925, L14, 30s CD). 8-30y leap that roots the target for 3s. -// SV is a melee spec, so Harpoon is the primary gap-closer when the bot -// is OOC-starting a pull or has been kited out. Gate on: -// * an enemy that's actually FURTHER than melee (>8y) but within the -// leap window (≤30y), -// * no enemies already adjacent (otherwise we'd waste it pulling toward -// someone next to us — leaping to a far target while glued in melee -// pulls aggro on a new mob). -bool ShouldHarpoon(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(HARPOON)) return false; - if (!ctx.bot.is_ready(HARPOON)) return false; - NearbyUnit const* t = ctx.bot.victim_info(); - if (!t) return false; - const float d2 = TargetDistSq(ctx, *t); - if (d2 <= 8.0f * 8.0f) return false; // already in melee - if (d2 > 30.0f * 30.0f) return false; // out of leap range - if (ctx.bot.enemies_within(5.0f) >= 1) return false; // someone on top of us - return true; -} -void DoHarpoon(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(HARPOON, ctx.bot.victim()); -} - -// Hatchet Toss (193265, L12, 30 focus, 40y; overrides Arcane Shot on the -// bar). The only damage cast SV has at range outside Aspect of the Eagle. -// Use when the bot is outside melee + Harpoon is on CD, or the target is -// too close for Harpoon (<=8y) but the bot has been pushed back. It costs -// the same 30 focus as Raptor Strike, so it slots in any time the bot is -// too far to swing and can afford a spender. -bool ShouldHatchetToss(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(HATCHET_TOSS)) return false; - if (!ctx.bot.is_ready(HATCHET_TOSS)) return false; - if (FocusVal(ctx) < HATCHET_TOSS_COST) return false; - NearbyUnit const* t = ctx.bot.victim_info(); - if (!t) return false; - const float d2 = TargetDistSq(ctx, *t); - return d2 > 8.0f * 8.0f && d2 <= 40.0f * 40.0f; -} -void DoHatchetToss(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(HATCHET_TOSS, ctx.bot.victim()); -} - -// ---- Bombs ---- -// Wildfire Bomb (259495, [R][M], 10 focus, charges via Quick Reload / -// Guerrilla Tactics). Cone + DoT on everything at the impact point, 12.1's -// top SV priority whenever a charge is up. is_ready() folds in charges. -bool ShouldWildfireBomb(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(WILDFIRE_BOMB)) return false; - if (!ctx.bot.is_ready(WILDFIRE_BOMB)) return false; - return FocusVal(ctx) >= WILDFIRE_BOMB_COST; -} -void DoWildfireBomb(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* v = ctx.bot.victim_info()) - e.cast_at(WILDFIRE_BOMB, v->x, v->y, v->z); - else - e.cast(WILDFIRE_BOMB, ctx.bot.victim()); -} - -// ---- Generators / spenders / AoE ---- -// Kill Command (259489): SV's version GENERATES focus and drives Tip of the -// Spear, so it is pressed on cooldown ahead of every focus spender. -bool ShouldKillCommand(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.has_pet()) return false; - if (!ctx.bot.knows_spell(KILL_COMMAND_SV)) return false; - return ctx.bot.is_ready(KILL_COMMAND_SV); -} -void DoKillCommand(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(KILL_COMMAND_SV, ctx.bot.victim()); -} - -// Boomstick (1261193, [R][M], 60s cd, 50 focus, 20y cone): "Unload a -// series of shotgun blasts in front of you ... reduced damage beyond N -// targets". The AoE spender that replaced Butchery / Carve; a cone, so it -// needs the target roughly in front (the bot faces its victim while -// attacking) and inside 20y. Fires on 2+ attackers or owner /aoe pin, and -// on boss-like targets as a plain big hit so the CD is not wasted in ST. -bool ShouldBoomstick(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(BOOMSTICK)) return false; - if (!ctx.bot.is_ready(BOOMSTICK)) return false; - if (FocusVal(ctx) < BOOMSTICK_COST) return false; - NearbyUnit const* t = ctx.bot.victim_info(); - if (!t || TargetDistSq(ctx, *t) > 20.0f * 20.0f) return false; - return ctx.aoe_preference || ctx.bot.attackers_count() >= 2 || BossLikeTargetEngaged(ctx); -} -void DoBoomstick(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(BOOMSTICK, ctx.bot.victim()); -} - -// Raptor Strike (186270, 30 focus, 5y): the focus spender / filler. In -// 12.1 Mongoose Bite is gone - Mongoose Fury (1252708) and Raptor Swipe -// (1259003) are passive upgrades to Raptor Strike itself, so this is the -// only melee spender and needs no talent branch. -bool ShouldRaptorStrike(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(RAPTOR_STRIKE)) return false; - if (!ctx.bot.is_ready(RAPTOR_STRIKE)) return false; - return FocusVal(ctx) >= RAPTOR_STRIKE_COST; -} -void DoRaptorStrike(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(RAPTOR_STRIKE, ctx.bot.victim()); -} - -// Hunter's Mark - baseline ranged-damage-taken debuff (5%). Granted -// around L7 and persists across all three specs. One cast per target. -bool ShouldHuntersMark(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(HUNTERS_MARK)) return false; - if (!ctx.bot.is_ready(HUNTERS_MARK)) return false; - return ctx.bot.find_aura(HUNTERS_MARK, ctx.bot.victim()) == nullptr; -} -void DoHuntersMark(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(HUNTERS_MARK, ctx.bot.victim()); -} - -bool AlwaysInCombat(ApPredicateContext const& ctx) { return ctx.bot.in_combat(); } -void DoAutoAttack(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - ObjectGuid t = ctx.bot.victim(); - if (t.IsEmpty()) t = ctx.bot.current_target(); - // Retaliate fallback (2026-06-17): in combat with no victim/target the bot - // looped "Engage auto attack" as a no-op while taking damage (the CombatLoop - // wedge cluster). Engage whatever is meleeing us (attackers are adjacent and - // reachable), else the nearest visible enemy, so combat actually resolves. - // Strictly additive: only runs when no target was already selected. - if (t.IsEmpty()) - for (auto const& u : ctx.bot.attackers()) - if (u.hp > 0) { t = u.guid; break; } - if (t.IsEmpty()) - for (auto const& u : ctx.bot.nearby_enemies()) - if (u.hp > 0 && u.in_los) { t = u.guid; break; } - if (!t.IsEmpty()) e.start_attack(t); -} - -ApRule const kRules[] = { - { ShouldRevivePet, DoRevivePet, "Revive Pet" }, - { ShouldMendPet, DoMendPet, "Mend Pet (<=50%)" }, - { ShouldAspectTurtle, DoAspectTurtle, "Aspect of the Turtle (<=20%)"}, - { ShouldSurvivalFittest, DoSurvivalFittest, "Survival of the Fittest" }, - { ShouldExhilaration, DoExhilaration, "Exhilaration (<=50%)" }, - { ShouldFeignDeath, DoFeignDeath, "Feign Death (drop aggro)" }, - { ShouldMisdirection, DoMisdirection, "Misdirection (tank threat)" }, - { ShouldMuzzle, DoMuzzle, "Muzzle (interrupt)" }, - { ShouldIntimidation, DoIntimidation, "Intimidation (interrupt fb)" }, - { ShouldBindingShot, DoBindingShot, "Binding Shot (3+ AoE)" }, - { ShouldTarTrap, DoTarTrap, "Tar Trap (slow)" }, - { ShouldPrimalRage, DoPrimalRage, "Primal Rage (Bloodlust)" }, - { ShouldTakedown, DoTakedown, "Takedown (burst)" }, - { ShouldAspectEagle, DoAspectEagle, "Aspect of the Eagle (range)" }, - { ShouldHuntersMark, DoHuntersMark, "Hunter's Mark (debuff)" }, - // Harpoon BEFORE the spenders: if the bot is too far away to melee, we - // need to close the gap before any GCD spender. - { ShouldHarpoon, DoHarpoon, "Harpoon (gap close 8-30y)" }, - { ShouldWildfireBomb, DoWildfireBomb, "Wildfire Bomb" }, - { ShouldKillCommand, DoKillCommand, "Kill Command (focus gen)" }, - { ShouldBoomstick, DoBoomstick, "Boomstick (cone AoE)" }, - // Hatchet Toss sits just above the melee filler so an out-of-range - // bot keeps damaging while Harpoon is on CD instead of falling all - // the way to AutoAttack (which won't reach). - { ShouldHatchetToss, DoHatchetToss, "Hatchet Toss (ranged 8-40y)" }, - { ShouldRaptorStrike, DoRaptorStrike, "Raptor Strike (spender)" }, - { AlwaysInCombat, DoAutoAttack, "Engage auto attack" }, -}; - -} // anonymous - -void RegisterApl_Hunter_Survival() -{ - constexpr uint32 SPEC_HUNTER_SURVIVAL = 255; - RegisterRotation(CLASS_HUNTER, SPEC_HUNTER_SURVIVAL, ApRotation{kRules}); -} - -} // namespace Playerbot::Combat diff --git a/src/modules/PlayerbotV2/Combat/Apl/Apl_Mage_Arcane.cpp b/src/modules/PlayerbotV2/Combat/Apl/Apl_Mage_Arcane.cpp deleted file mode 100644 index be86026ad5..0000000000 --- a/src/modules/PlayerbotV2/Combat/Apl/Apl_Mage_Arcane.cpp +++ /dev/null @@ -1,508 +0,0 @@ -// Arcane Mage - WoW 12.1.0.69587 (Midnight) enterprise rotation. Charge-driven -// mana caster: build Arcane Charges with Arcane Blast / Arcane Missiles / -// Arcane Orb, dump with Arcane Barrage at 4 stacks. Touch of the Magi window -// centers burst, Arcane Surge (spends all mana for one nuke + regen buff) and -// Presence of Mind layer on top, Evocation refills mana when Clearcasting goes -// long. Spellsteal pulls offensive enemy buffs, Polymorph keeps an off-target -// sapped while we focus the kill target. -// -// Charge state lives on the bot as the ARCANE_CHARGE aura with stack count. -// We use BotSnapshotView::aura_stacks() so the spender ticks at 4 charges -// every tick - no relying on next-tick heuristics. -// -// ---- Validated spell IDs (WoW 12.1.0.69587) ---- -// 30451 Arcane Blast 321507 Touch of the Magi (talent) -// 44425 Arcane Barrage 365350 Arcane Surge (talent, 90s) -// 5143 Arcane Missiles 365362 Arcane Surge buff (aura) -// 153626 Arcane Orb (talent) 1449 Arcane Explosion -// 12051 Evocation (talent) 1241462 Arcane Pulse (talent, overrides AE) -// 205025 Presence of Mind 30449 Spellsteal (talent) -// 263725 Clearcasting (proc) 55342 Mirror Image (talent) -// 36032 Arcane Charge (stack) 342245 Alter Time (talent) -// 235450 Prismatic Barrier 2139 Counterspell -// 110959 Greater Invisibility 110960 Greater Invisibility (aura) -// 45438 Ice Block (talent) 122 Frost Nova -// 1953 Blink 212653 Shimmer (talent, overrides Blink) -// 118 Polymorph 80353 Time Warp -// -// ---- Skipped spells (and why) ---- -// 12042 Arcane Power - removed in Midnight; Arcane Surge -// (365350) is the burst cooldown. -// 114923 Nether Tempest - no longer in the Arcane tree. -// 31589 Slow - no longer in the Mage class tree. -// 108839 Ice Floes - no longer in the Mage class tree. -// 314791 Shifting Power - no longer in the Mage class tree. -// 79684 Clearcasting passive - proc driver; we read the active -// aura (263725) via has_aura(). -// 190427 Arcane Charge (alt id) - empty helper; 36032 is the stacked -// aura the client shows. -// 157980 Supernova / 383121 Mass Polymorph / 157997 Ice Nova - not in -// the curated raid build; Supernova is -// [M]-only and a knockback we cannot -// aim safely in a group. -// 475 Remove Curse - not selected in the Arcane builds. - -#include "../ApRegistry.h" -#include "../ApRotation.h" -#include "ApCrowdControl.h" -#include "Bot/BotIntentEmitter.h" -#include "Bot/BotSnapshotView.h" -#include "SharedDefines.h" - -namespace Playerbot::Combat { - -namespace { - -// ---- Spell IDs (WoW 12.1.0.69587, validated) ---- -constexpr uint32 ARCANE_BLAST = 30451; -constexpr uint32 ARCANE_BARRAGE = 44425; -constexpr uint32 ARCANE_MISSILES = 5143; -constexpr uint32 ARCANE_ORB = 153626; // talent - single target builder + AoE -constexpr uint32 ARCANE_SURGE = 365350; // talent - 90s CD, spends all mana -constexpr uint32 ARCANE_SURGE_BUFF = 365362; // aura - damage + mana regen window -constexpr uint32 EVOCATION = 12051; // talent - 3s mana regen burst -constexpr uint32 PRESENCE_OF_MIND = 205025; // next 2 Arcane Blasts instant -constexpr uint32 CLEARCASTING = 263725; // proc - free Arcane Missiles -constexpr uint32 ARCANE_CHARGE = 36032; // tracked aura with stacks -constexpr uint32 TOUCH_OF_THE_MAGI = 321507; // damage accumulate / explode -constexpr uint32 ARCANE_EXPLOSION = 1449; // PBAoE charge builder -constexpr uint32 ARCANE_PULSE = 1241462; // talent - targeted AoE, overrides AE -constexpr uint32 SPELLSTEAL = 30449; // grab a buff off enemy -constexpr uint32 MIRROR_IMAGE = 55342; // threat dump + DPS cooldown -constexpr uint32 ALTER_TIME = 342245; // HP/position snapshot + return -constexpr uint32 PRISMATIC_BARRIER = 235450; // absorb + magic DR shield -constexpr uint32 GREATER_INVIS = 110959; // threat wipe, 2min CD -constexpr uint32 GREATER_INVIS_AURA = 110960; // active invisibility aura -constexpr uint32 COUNTERSPELL = 2139; -constexpr uint32 POLYMORPH = 118; // CC - sheep -constexpr uint32 ICE_BLOCK = 45438; // 10s immunity, 4min CD -constexpr uint32 FROST_NOVA = 122; // 8yd PBAoE root -constexpr uint32 BLINK = 1953; // 20yd reposition -constexpr uint32 SHIMMER = 212653; // talent - replaces Blink, off-GCD -constexpr uint32 TIME_WARP = 80353; -constexpr uint32 SATED_DEBUFF = 57724; -constexpr uint32 TEMPORAL_DISPL_DEBUFF = 80354; -constexpr uint32 INSANITY_HUNTER_DEBUFF = 95809; -constexpr uint32 FATIGUED_DEBUFF = 264689; - -// ---- Helpers ---- -bool HasLiveTarget(ApPredicateContext const& ctx) -{ - return !ctx.bot.victim().IsEmpty(); -} - -bool BotHasSatedDebuff(ApPredicateContext const& ctx) -{ - return ctx.bot.has_aura(SATED_DEBUFF) - || ctx.bot.has_aura(TEMPORAL_DISPL_DEBUFF) - || ctx.bot.has_aura(INSANITY_HUNTER_DEBUFF) - || ctx.bot.has_aura(FATIGUED_DEBUFF); -} - -bool BossLikeTargetEngaged(ApPredicateContext const& ctx) -{ - constexpr int32 kBossHpThreshold = 5'000'000; - NearbyUnit const* t = ctx.bot.victim_info(); - if (t && t->max_hp >= kBossHpThreshold) return true; - for (auto const& a : ctx.bot.raw().combat.attackers) - if (a.max_hp >= kBossHpThreshold) return true; - return false; -} - -uint8 ArcaneCharges(ApPredicateContext const& ctx) -{ - return ctx.bot.aura_stacks(ARCANE_CHARGE); -} - -// ---- Survival ---- -bool ShouldIceBlock(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(ICE_BLOCK)) return false; - if (!ctx.bot.is_ready(ICE_BLOCK)) return false; - // PvP burst kills cloth from 40% in <2s; the 20% threshold trips - // after the killshot has already landed. Bump under_player_attack - // for parity with Fire / Frost specs. - const int32 threshold = ctx.pvp.under_player_attack ? 40 : 20; - return ctx.bot.hp_pct() <= threshold; -} -void DoIceBlock(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(ICE_BLOCK); } - -// Greater Invisibility - instant threat wipe. The invisibility itself breaks -// on our next action, but the threat reset already happened on cast, so it -// is a usable "get the pack off me" button when Ice Block is gone. -bool ShouldGreaterInvis(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(GREATER_INVIS)) return false; - if (!ctx.bot.is_ready(GREATER_INVIS)) return false; - if (ctx.bot.has_aura(GREATER_INVIS_AURA)) return false; - if (ctx.bot.attackers_count() < 1) return false; - return ctx.bot.hp_pct() <= 35; -} -void DoGreaterInvis(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(GREATER_INVIS); } - -bool ShouldPrismaticBarrier(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(PRISMATIC_BARRIER)) return false; - if (!ctx.bot.is_ready(PRISMATIC_BARRIER)) return false; - if (ctx.bot.has_aura(PRISMATIC_BARRIER)) return false; // already up - return ctx.bot.hp_pct() <= 90; -} -void DoPrismaticBarrier(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(PRISMATIC_BARRIER); } - -bool ShouldAlterTime(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(ALTER_TIME)) return false; - if (!ctx.bot.is_ready(ALTER_TIME)) return false; - // Snapshot at high HP / safe position so the return jump rescues us - // when the inevitable damage spike comes during the burst window. - return ctx.bot.hp_pct() >= 80 && !ctx.bot.has_aura(ALTER_TIME); -} -void DoAlterTime(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(ALTER_TIME); } - -bool ShouldMirrorImage(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(MIRROR_IMAGE)) return false; - if (!ctx.bot.is_ready(MIRROR_IMAGE)) return false; - // Threat-dump trigger when something locked onto us, or proactively - // before a boss burst. Either condition fires the cooldown. - return ctx.bot.hp_pct() <= 70 || BossLikeTargetEngaged(ctx); -} -void DoMirrorImage(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(MIRROR_IMAGE); } - -bool ShouldFrostNova(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(FROST_NOVA)) return false; - if (!ctx.bot.is_ready(FROST_NOVA)) return false; - // Personal defensive — fire only with an attacker in melee range. - return ctx.bot.enemies_within(8.0f) >= 1; -} -void DoFrostNova(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(FROST_NOVA); } - -// Emergency reposition when low HP and a melee is on us - Blink / Shimmer -// gets us 20yd of breathing room before the Frost Nova / Ice Block decision -// tree fires next tick. Shimmer (talent) replaces Blink; two-branch so both -// talented and untalented bots keep the escape. -bool ShouldShimmerAway(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(SHIMMER)) return false; - if (!ctx.bot.is_ready(SHIMMER)) return false; - return ctx.bot.hp_pct() <= 35 && ctx.bot.enemies_within(8.0f) >= 1; -} -void DoShimmer(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(SHIMMER); } - -bool ShouldBlinkAway(ApPredicateContext const& ctx) -{ - if (ctx.bot.knows_spell(SHIMMER)) return false; - if (!ctx.bot.knows_spell(BLINK)) return false; - if (!ctx.bot.is_ready(BLINK)) return false; - return ctx.bot.hp_pct() <= 35 && ctx.bot.enemies_within(8.0f) >= 1; -} -void DoBlink(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(BLINK); } - -// ---- Interrupt / CC ---- -bool ShouldCounterspell(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(COUNTERSPELL)) return false; - if (!ctx.bot.is_ready(COUNTERSPELL)) return false; - const bool pvp = ctx.pvp.in_battleground || ctx.pvp.in_arena; - return ctx.bot.kick_target(pvp, 40.0f) != nullptr; -} -void DoCounterspell(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - const bool pvp = ctx.pvp.in_battleground || ctx.pvp.in_arena; - if (auto const* c = ctx.bot.kick_target(pvp, 40.0f)) - e.cast(COUNTERSPELL, c->guid); -} - -// Polymorph an off-target add via the shared PickOffTargetCC gate. PvE only -// fires on a genuine 2+ ATTACKER pull (never a 40y scan bystander while -// solo-questing) and skips already-sheeped mobs via NearbyUnit::is_cc_locked; -// PvP escalates to enemy Healer > caster. See ApCrowdControl.h for why the -// old nearby_enemies.size()>=2 + has_aura gate CC-spammed every GCD. -bool ShouldPolymorph(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(POLYMORPH)) return false; - if (!ctx.bot.is_ready(POLYMORPH)) return false; - return !PickOffTargetCC(ctx, POLYMORPH, ApInPvp(ctx)).IsEmpty(); -} -void DoPolymorph(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - ObjectGuid const t = PickOffTargetCC(ctx, POLYMORPH, ApInPvp(ctx)); - if (!t.IsEmpty()) e.cast(POLYMORPH, t); -} - -// Spellsteal — pull a useful buff off the enemy. We approximate "useful" -// by checking that an aura is dispellable as Magic. The snapshot view's -// target_dispellable() inspects the current target's aura list. -bool ShouldSpellsteal(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(SPELLSTEAL)) return false; - if (!ctx.bot.is_ready(SPELLSTEAL)) return false; - // Mana cost is significant (~21%); only spend when we have headroom. - if (ctx.bot.power_pct(0) < 35) return false; - return ctx.bot.target_dispellable(Playerbot::DispelType::Magic); -} -void DoSpellsteal(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(SPELLSTEAL, ctx.bot.victim()); -} - -// ---- Major offensive cooldowns ---- -bool ShouldTimeWarp(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(TIME_WARP)) return false; - if (!ctx.bot.is_ready(TIME_WARP)) return false; - if (BotHasSatedDebuff(ctx)) return false; - return BossLikeTargetEngaged(ctx); -} -void DoTimeWarp(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(TIME_WARP); } - -// Touch of the Magi - applied to the victim, accumulates damage, then explodes -// for the stored amount. We want to land it ASAP (window centers Arcane Surge) -// and only re-apply when the previous instance has expired. -bool ShouldTouchOfTheMagi(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(TOUCH_OF_THE_MAGI)) return false; - if (!ctx.bot.is_ready(TOUCH_OF_THE_MAGI)) return false; - // No point applying to a corpse; victim_info()->hp guards that. - NearbyUnit const* v = ctx.bot.victim_info(); - if (!v || v->hp <= 0) return false; - // Don't re-apply if our debuff is still ticking on this target. - return !ctx.bot.has_aura(TOUCH_OF_THE_MAGI, v->guid); -} -void DoTouchOfTheMagi(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(TOUCH_OF_THE_MAGI, ctx.bot.victim()); -} - -// Arcane Surge - 2.5s hard cast that spends ALL current mana for one big -// nuke (damage scales with mana spent) and then grants a damage + mana regen -// window (365362). Cast it with a full tank and only while standing still; -// the follow-up rotation runs on the regen buff plus Barrage refunds. -bool ShouldArcaneSurge(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(ARCANE_SURGE)) return false; - if (!ctx.bot.is_ready(ARCANE_SURGE)) return false; - if (ctx.bot.is_moving() && !ctx.bot.can_cast_while_moving(ARCANE_SURGE)) return false; - // Damage is proportional to mana spent - never fire it half empty. - return ctx.bot.power_pct(0) >= 60; -} -void DoArcaneSurge(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(ARCANE_SURGE, ctx.bot.victim()); -} - -bool ShouldPresenceOfMind(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(PRESENCE_OF_MIND)) return false; - if (!ctx.bot.is_ready(PRESENCE_OF_MIND)) return false; - // Stack with the Arcane Surge window, or use to clip movement. Either - // condition fires it - the buff lingers until 2 Arcane Blasts are used. - return ctx.bot.has_aura(ARCANE_SURGE_BUFF) || ctx.bot.is_moving(); -} -void DoPresenceOfMind(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(PRESENCE_OF_MIND); } - -// Evocation (12.1) is an instant 3s mana-regen burst, not a channel. Fire -// it when the tank is low - including right after Arcane Surge emptied it. -bool ShouldEvocation(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(EVOCATION)) return false; - if (!ctx.bot.is_ready(EVOCATION)) return false; - return ctx.bot.power_pct(0) <= 30; -} -void DoEvocation(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(EVOCATION); } - -// ---- AoE ---- -bool ShouldArcaneOrb(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(ARCANE_ORB)) return false; - if (!ctx.bot.is_ready(ARCANE_ORB)) return false; - // Free charge generator and decent damage — fire on cooldown when we - // are not yet at max charges (no overflow). - return ArcaneCharges(ctx) < 4; -} -void DoArcaneOrb(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(ARCANE_ORB, ctx.bot.victim()); -} - -// AoE cluster gate shared by Arcane Pulse / Arcane Explosion. aoe_preference -// is a soft owner hint; still require >= 2 enemies so a stale `.aoe on` -// doesn't fire on a single boss pull. -bool AoeClusterNear(ApPredicateContext const& ctx, float range) -{ - const int near = static_cast(ctx.bot.enemies_within(range)); - return near >= 3 || (ctx.aoe_preference && near >= 2); -} - -// Arcane Pulse (talent) replaces Arcane Explosion: 2s cast, 15s CD, AoE -// around the TARGET that generates a charge per enemy hit. Two-branch with -// Arcane Explosion below so untalented bots keep their PBAoE builder. -bool ShouldArcanePulse(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(ARCANE_PULSE)) return false; - if (!ctx.bot.is_ready(ARCANE_PULSE)) return false; - if (ctx.bot.is_moving() && !ctx.bot.can_cast_while_moving(ARCANE_PULSE)) return false; - return AoeClusterNear(ctx, 10.0f); -} -void DoArcanePulse(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(ARCANE_PULSE, ctx.bot.victim()); -} - -bool ShouldArcaneExplosion(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (ctx.bot.knows_spell(ARCANE_PULSE)) return false; // overridden by Pulse - if (!ctx.bot.knows_spell(ARCANE_EXPLOSION)) return false; - // PBAoE charge builder - only when 3+ enemies are in its 10yd hit box, - // so we don't waste mana on single-target. - return AoeClusterNear(ctx, 10.0f); -} -void DoArcaneExplosion(ApPredicateContext const&, BotIntentEmitter& e) -{ - e.cast(ARCANE_EXPLOSION); -} - -// ---- Charge spender ---- -bool ShouldArcaneBarrage(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(ARCANE_BARRAGE)) return false; - if (!ctx.bot.is_ready(ARCANE_BARRAGE)) return false; - // Spend at 4 charges, OR when low mana (Barrage costs much less than - // Blast and refunds mana on hit), OR when we need to dump charges - // before they overflow at the cap. - if (ArcaneCharges(ctx) >= 4) return true; - if (ctx.bot.power_pct(0) <= 35 && ArcaneCharges(ctx) >= 1) return true; - return false; -} -void DoArcaneBarrage(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(ARCANE_BARRAGE, ctx.bot.victim()); -} - -// ---- Proc spender ---- -bool ShouldArcaneMissiles(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(ARCANE_MISSILES)) return false; - // Free missiles (no mana cost while Clearcasting), so spend immediately. - return ctx.bot.has_aura(CLEARCASTING); -} -void DoArcaneMissiles(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(ARCANE_MISSILES, ctx.bot.victim()); -} - -// ---- Charge builder / filler ---- -bool ShouldArcaneBlast(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(ARCANE_BLAST)) return false; - // Mana floor — Arcane Blast cost scales with charges; refuse when too - // low so the next tick falls through to Barrage / Evocation instead. - if (ctx.bot.power_pct(0) <= 20) return false; - // Hard-cast — defer to instant Arcane Barrage when moving. - if (ctx.bot.is_moving() && !ctx.bot.can_cast_while_moving(ARCANE_BLAST)) return false; - return true; -} -void DoArcaneBlast(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(ARCANE_BLAST, ctx.bot.victim()); -} - -bool AlwaysInCombat(ApPredicateContext const& ctx) { return ctx.bot.in_combat(); } -void DoAutoAttack(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - ObjectGuid t = ctx.bot.victim(); - if (t.IsEmpty()) t = ctx.bot.current_target(); - // Retaliate fallback (2026-06-17): in combat with no victim/target the bot - // looped "Engage auto attack" as a no-op while taking damage (the CombatLoop - // wedge cluster). Engage whatever is meleeing us (attackers are adjacent and - // reachable), else the nearest visible enemy, so combat actually resolves. - // Strictly additive: only runs when no target was already selected. - if (t.IsEmpty()) - for (auto const& u : ctx.bot.attackers()) - if (u.hp > 0) { t = u.guid; break; } - if (t.IsEmpty()) - for (auto const& u : ctx.bot.nearby_enemies()) - if (u.hp > 0 && u.in_los) { t = u.guid; break; } - if (!t.IsEmpty()) e.start_attack(t); -} - -// ---- Rule table ---- -// -// Ordering matches the documented Mage spec ordering (most-urgent first): -// 1. Survival panic (Ice Block / Greater Invisibility) -// 2. Defensives (Prismatic Barrier / Mirror Image / Alter Time / -// Shimmer or Blink) -// 3. Interrupt (Counterspell) -// 4. Kite (Frost Nova) -// 5. CC (Polymorph) / utility (Spellsteal) -// 6. Major offensive CDs (Time Warp / Touch of the Magi / Arcane Surge -// / Presence of Mind / Evocation) -// 7. Procs (Arcane Missiles via Clearcasting) -// 8. AoE (Arcane Pulse or Arcane Explosion) -// 9. Charge spender (Arcane Barrage) -// 10. ST builder (Arcane Orb / Arcane Blast) -// 11. Filler (Auto Attack) -ApRule const kRules[] = { - // 1. Survival panic - { ShouldIceBlock, DoIceBlock, "Ice Block (panic <=20% / <=40% PvP)" }, - { ShouldGreaterInvis, DoGreaterInvis, "Greater Invis (threat wipe)" }, - // 2. Defensives - { ShouldPrismaticBarrier,DoPrismaticBarrier,"Prismatic Barrier (shield)" }, - { ShouldMirrorImage, DoMirrorImage, "Mirror Image (threat / boss)" }, - { ShouldAlterTime, DoAlterTime, "Alter Time (snapshot HP)" }, - { ShouldShimmerAway, DoShimmer, "Shimmer (escape melee)" }, - { ShouldBlinkAway, DoBlink, "Blink (escape melee)" }, - // 3. Interrupt - { ShouldCounterspell, DoCounterspell, "Counterspell (interrupt)" }, - // 4. Kite - { ShouldFrostNova, DoFrostNova, "Frost Nova (kite melee)" }, - // 5. CC / utility - { ShouldPolymorph, DoPolymorph, "Polymorph (off-target CC)" }, - { ShouldSpellsteal, DoSpellsteal, "Spellsteal (Magic buff)" }, - // 6. Major offensive CDs - { ShouldTimeWarp, DoTimeWarp, "Time Warp (boss)" }, - { ShouldTouchOfTheMagi, DoTouchOfTheMagi, "Touch of the Magi (window)" }, - { ShouldArcaneSurge, DoArcaneSurge, "Arcane Surge (burst)" }, - { ShouldPresenceOfMind, DoPresenceOfMind, "Presence of Mind (instant)" }, - { ShouldEvocation, DoEvocation, "Evocation (<=30% mana)" }, - // 7. Procs (free spender - fire ASAP before it expires) - { ShouldArcaneMissiles, DoArcaneMissiles, "Arcane Missiles (Clearcast)" }, - // 8. AoE (Arcane Pulse overrides Arcane Explosion when talented) - { ShouldArcanePulse, DoArcanePulse, "Arcane Pulse (3+ AoE)" }, - { ShouldArcaneExplosion, DoArcaneExplosion, "Arcane Explosion (3+ AoE)" }, - // 9. Charge spender (4-stack dump / mana-low refund) - { ShouldArcaneBarrage, DoArcaneBarrage, "Arcane Barrage (spend 4)" }, - // 10. ST builders / filler - { ShouldArcaneOrb, DoArcaneOrb, "Arcane Orb (charge gen)" }, - { ShouldArcaneBlast, DoArcaneBlast, "Arcane Blast (build)" }, - // 11. Auto attack fallback - { AlwaysInCombat, DoAutoAttack, "Engage auto attack" }, -}; - -} // anonymous - -void RegisterApl_Mage_Arcane() -{ - constexpr uint32 SPEC_MAGE_ARCANE = 62; - RegisterRotation(CLASS_MAGE, SPEC_MAGE_ARCANE, ApRotation{kRules}); -} - -} // namespace Playerbot::Combat diff --git a/src/modules/PlayerbotV2/Combat/Apl/Apl_Mage_Fire.cpp b/src/modules/PlayerbotV2/Combat/Apl/Apl_Mage_Fire.cpp deleted file mode 100644 index 2651ae0103..0000000000 --- a/src/modules/PlayerbotV2/Combat/Apl/Apl_Mage_Fire.cpp +++ /dev/null @@ -1,463 +0,0 @@ -// Fire Mage - WoW 12.1.0.69587 (Midnight) rotation. Hot Streak proc-driven -// Pyroblast / Flamestrike, Fire Blast converts Heating Up into Hot Streak, -// Combustion burst window, Meteor on cooldown for bosses / clusters, Scorch -// as the moving + execute filler (instant under Heat Shimmer). -// -// ---- Validated spell IDs (WoW 12.1.0.69587) ---- -// 133 Fireball 431044 Frostfire Bolt (hero, overrides Fireball) -// 11366 Pyroblast (talent) 431177 Frostfire Empowerment (proc aura) -// 108853 Fire Blast (talent) 48108 Hot Streak! (proc aura) -// 2948 Scorch (talent) 48107 Heating Up (half-proc aura) -// 190319 Combustion (talent) 458964 Heat Shimmer (instant Scorch aura) -// 2120 Flamestrike (talent) 153561 Meteor (talent) -// 31661 Dragon's Breath 235313 Blazing Barrier -// 45438 Ice Block 110959 Greater Invisibility -// 122 Frost Nova 110960 Greater Invisibility (aura) -// 55342 Mirror Image 342245 Alter Time -// 2139 Counterspell 475 Remove Curse -// 1953 Blink 212653 Shimmer (talent, overrides Blink) -// 118 Polymorph 80353 Time Warp -// -// ---- Skipped spells (and why) ---- -// 257541 Phoenix Flames - removed from the Fire tree in Midnight. -// 44457 Living Bomb - removed from the Fire tree in Midnight. -// 157981 Blast Wave - removed from the Mage class tree. -// 108839 Ice Floes - removed from the Mage class tree. -// 194466 Phoenix's Flames - Legion artifact spell (no learn level); -// never granted to a Midnight character. -// 1254851 Flamestrike (target) - alt Flamestrike variant that lands on -// the target; not in the curated build, -// we cast_at the victim with 2120. -// 195283 Hot Streak (passive) - proc driver; the runtime aura is 48108. -// 319836 Fire Blast (baseline) - Fire uses the spec talent id 108853. -// 157980 Supernova / 383121 Mass Polymorph / 157997 Ice Nova - not in -// the curated raid build. - -#include "../ApRegistry.h" -#include "../ApRotation.h" -#include "ApCrowdControl.h" -#include "Bot/BotIntentEmitter.h" -#include "Bot/BotSnapshotView.h" -#include "Group/GroupSnapshot.h" -#include "SharedDefines.h" - -namespace Playerbot::Combat { - -namespace { - -// ---- Spell IDs (WoW 12.1.0.69587, validated) ---- -constexpr uint32 FIREBALL = 133; -constexpr uint32 FROSTFIRE_BOLT = 431044; // hero talent - replaces Fireball -constexpr uint32 FROSTFIRE_EMPOWER = 431177; // proc aura - next Frostfire Bolt instant -constexpr uint32 PYROBLAST = 11366; -constexpr uint32 FIRE_BLAST = 108853; // charge-based, castable while casting -constexpr uint32 SCORCH = 2948; // cast-while-moving filler, guaranteed crit sub-30 -constexpr uint32 HEAT_SHIMMER = 458964; // proc aura - next Scorch instant + execute -constexpr uint32 COMBUSTION = 190319; // burst window - crit chance + damage -constexpr uint32 METEOR = 153561; // talent - delayed AoE, big single-hit -constexpr uint32 HOT_STREAK = 48108; // proc - instant Pyroblast / Flamestrike -constexpr uint32 HEATING_UP = 48107; // half-proc - next crit becomes Hot Streak -constexpr uint32 COUNTERSPELL = 2139; -constexpr uint32 FLAMESTRIKE = 2120; // ground AoE -constexpr uint32 DRAGONS_BREATH = 31661; // frontal cone disorient -constexpr uint32 ICE_BLOCK = 45438; // 10s immunity, 4min CD -constexpr uint32 FROST_NOVA = 122; // 8yd root -constexpr uint32 BLINK = 1953; // 20yd reposition -constexpr uint32 SHIMMER = 212653; // talent - replaces Blink, off-GCD -constexpr uint32 BLAZING_BARRIER = 235313; // absorb shield, burns melee attackers -constexpr uint32 GREATER_INVIS = 110959; // threat wipe, 2min CD -constexpr uint32 GREATER_INVIS_AURA= 110960; // active invisibility aura -constexpr uint32 REMOVE_CURSE = 475; // friendly curse dispel, 8s CD -constexpr uint32 MIRROR_IMAGE = 55342; // threat dump + DPS -constexpr uint32 ALTER_TIME = 342245; -constexpr uint32 POLYMORPH = 118; // CC -constexpr uint32 TIME_WARP = 80353; -constexpr uint32 SATED_DEBUFF = 57724; -constexpr uint32 TEMPORAL_DISPL_DEBUFF = 80354; -constexpr uint32 INSANITY_HUNTER_DEBUFF = 95809; -constexpr uint32 FATIGUED_DEBUFF = 264689; - -// ---- Helpers ---- -bool HasLiveTarget(ApPredicateContext const& ctx) -{ - return !ctx.bot.victim().IsEmpty(); -} - -bool TargetExecuteRange(ApPredicateContext const& ctx) -{ - NearbyUnit const* t = ctx.bot.victim_info(); - if (!t || t->max_hp <= 0 || t->hp <= 0) return false; - return (t->hp * 100) / t->max_hp <= 30; -} - -bool BotHasSatedDebuff(ApPredicateContext const& ctx) -{ - return ctx.bot.has_aura(SATED_DEBUFF) - || ctx.bot.has_aura(TEMPORAL_DISPL_DEBUFF) - || ctx.bot.has_aura(INSANITY_HUNTER_DEBUFF) - || ctx.bot.has_aura(FATIGUED_DEBUFF); -} - -bool BossLikeTargetEngaged(ApPredicateContext const& ctx) -{ - constexpr int32 kBossHpThreshold = 5'000'000; - NearbyUnit const* t = ctx.bot.victim_info(); - if (t && t->max_hp >= kBossHpThreshold) return true; - for (auto const& a : ctx.bot.raw().combat.attackers) - if (a.max_hp >= kBossHpThreshold) return true; - return false; -} - -// ---- CC (PvP-aware Polymorph) ---- -// Off-target sheep via the shared PickOffTargetCC gate (PvE: only on a 2+ -// ATTACKER pull, skipping already-sheeped mobs; PvP: enemy Healer > caster). -// See ApCrowdControl.h — this replaced the old nearby_enemies.size()>=2 + -// has_aura gate that CC-spammed every GCD during open-world questing. -bool ShouldPolymorph(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(POLYMORPH)) return false; - if (!ctx.bot.is_ready(POLYMORPH)) return false; - return !PickOffTargetCC(ctx, POLYMORPH, ApInPvp(ctx)).IsEmpty(); -} -void DoPolymorph(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - ObjectGuid const t = PickOffTargetCC(ctx, POLYMORPH, ApInPvp(ctx)); - if (!t.IsEmpty()) e.cast(POLYMORPH, t); -} - -// ---- Survival ---- -bool ShouldIceBlock(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(ICE_BLOCK)) return false; - if (!ctx.bot.is_ready(ICE_BLOCK)) return false; - // PvP burst kills clothies from 40% in <2s. See Apl_Mage_Frost for - // rationale; bumped under_player_attack. - const int32 threshold = ctx.pvp.under_player_attack ? 40 : 20; - return ctx.bot.hp_pct() <= threshold; -} -void DoIceBlock(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(ICE_BLOCK); } - -// Greater Invisibility - instant threat wipe. The invisibility breaks on our -// next action, but the threat reset already happened on cast, so it is the -// "get the pack off me" button once Ice Block is gone. -bool ShouldGreaterInvis(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(GREATER_INVIS)) return false; - if (!ctx.bot.is_ready(GREATER_INVIS)) return false; - if (ctx.bot.has_aura(GREATER_INVIS_AURA)) return false; - if (ctx.bot.attackers_count() < 1) return false; - return ctx.bot.hp_pct() <= 35; -} -void DoGreaterInvis(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(GREATER_INVIS); } - -bool ShouldBlazingBarrier(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(BLAZING_BARRIER)) return false; - if (!ctx.bot.is_ready(BLAZING_BARRIER)) return false; - if (ctx.bot.has_aura(BLAZING_BARRIER)) return false; // already up - return ctx.bot.hp_pct() <= 90; -} -void DoBlazingBarrier(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(BLAZING_BARRIER); } - -bool ShouldAlterTime(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(ALTER_TIME)) return false; - if (!ctx.bot.is_ready(ALTER_TIME)) return false; - return ctx.bot.hp_pct() >= 80 && !ctx.bot.has_aura(ALTER_TIME); -} -void DoAlterTime(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(ALTER_TIME); } - -bool ShouldMirrorImage(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(MIRROR_IMAGE)) return false; - if (!ctx.bot.is_ready(MIRROR_IMAGE)) return false; - return ctx.bot.hp_pct() <= 70 || BossLikeTargetEngaged(ctx); -} -void DoMirrorImage(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(MIRROR_IMAGE); } - -// Emergency reposition when low HP and a melee is on us. Shimmer (talent) -// replaces Blink; two-branch so both talented and untalented bots escape. -bool ShouldShimmerAway(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(SHIMMER)) return false; - if (!ctx.bot.is_ready(SHIMMER)) return false; - return ctx.bot.hp_pct() <= 35 && ctx.bot.enemies_within(8.0f) >= 1; -} -void DoShimmer(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(SHIMMER); } - -bool ShouldBlinkAway(ApPredicateContext const& ctx) -{ - if (ctx.bot.knows_spell(SHIMMER)) return false; - if (!ctx.bot.knows_spell(BLINK)) return false; - if (!ctx.bot.is_ready(BLINK)) return false; - return ctx.bot.hp_pct() <= 35 && ctx.bot.enemies_within(8.0f) >= 1; -} -void DoBlink(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(BLINK); } - -bool ShouldFrostNova(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(FROST_NOVA)) return false; - if (!ctx.bot.is_ready(FROST_NOVA)) return false; - // Personal defensive — only fire if attackers are in melee range. - return ctx.bot.enemies_within(8.0f) >= 1; -} -void DoFrostNova(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(FROST_NOVA); } - -// ---- Interrupt / CC ---- -bool ShouldCounterspell(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(COUNTERSPELL)) return false; - if (!ctx.bot.is_ready(COUNTERSPELL)) return false; - const bool pvp = ctx.pvp.in_battleground || ctx.pvp.in_arena; - return ctx.bot.kick_target(pvp, 40.0f) != nullptr; -} -void DoCounterspell(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - const bool pvp = ctx.pvp.in_battleground || ctx.pvp.in_arena; - if (auto const* c = ctx.bot.kick_target(pvp, 40.0f)) - e.cast(COUNTERSPELL, c->guid); -} - -bool ShouldDragonsBreath(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(DRAGONS_BREATH)) return false; - if (!ctx.bot.is_ready(DRAGONS_BREATH)) return false; - return ctx.bot.enemies_within(12.0f) >= 2; -} -void DoDragonsBreath(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(DRAGONS_BREATH); } - -// Remove Curse - group utility. Prefer a cursed group member, else self. -bool ShouldRemoveCurse(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(REMOVE_CURSE)) return false; - if (!ctx.bot.is_ready(REMOVE_CURSE)) return false; - if (ctx.group.dispel_candidate(DispelType::Curse) != nullptr) return true; - return ctx.bot.self_dispellable(DispelType::Curse); -} -void DoRemoveCurse(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* m = ctx.group.dispel_candidate(DispelType::Curse)) { e.cast(REMOVE_CURSE, m->guid); return; } - e.cast(REMOVE_CURSE, ctx.bot.raw().guid); -} - -// ---- Major offensive cooldowns ---- -bool ShouldTimeWarp(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(TIME_WARP)) return false; - if (!ctx.bot.is_ready(TIME_WARP)) return false; - if (BotHasSatedDebuff(ctx)) return false; - return BossLikeTargetEngaged(ctx); -} -void DoTimeWarp(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(TIME_WARP); } - -bool ShouldCombustion(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(COMBUSTION)) return false; - if (!ctx.bot.is_ready(COMBUSTION)) return false; - // Major 2min burst — gate to boss-tier or 3+ enemy AoE cluster. - // Previous unconditional fire wasted the CD on first-encountered - // trash mob; missed entire boss windows ~30% of pulls. Matches the - // synergy pattern in ShouldTimeWarp / ShouldAvatar / ShouldThunderousRoar. - return BossLikeTargetEngaged(ctx) || ctx.bot.enemies_within(8.0f) >= 3; -} -void DoCombustion(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(COMBUSTION); } - -bool ShouldMeteor(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(METEOR)) return false; - if (!ctx.bot.is_ready(METEOR)) return false; - // 45s CD with delayed landing — wasted on trash mobs that die before - // it lands. Gate to boss-tier targets or a 2+ enemy cluster (the - // ground AoE benefits from any extra body in the splash). - return BossLikeTargetEngaged(ctx) || ctx.bot.enemies_within(8.0f) >= 2; -} -void DoMeteor(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* v = ctx.bot.victim_info()) - e.cast_at(METEOR, v->x, v->y, v->z); - else - e.cast(METEOR); -} - -// ---- AoE ---- -bool ShouldFlamestrikeHotStreak(ApPredicateContext const& ctx) -{ - // Hot Streak Pyroblast vs Flamestrike: prefer Flamestrike when 3+ in - // its 8yd ground area. The Hot Streak proc gets consumed regardless. - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(FLAMESTRIKE)) return false; - if (!ctx.bot.has_aura(HOT_STREAK)) return false; - // aoe_preference is a soft owner hint — still require 2+ enemies in - // range so a stale `.aoe on` from the prior pack doesn't waste Hot - // Streak on Flamestrike during a boss pull (single-target loss ~30%). - const int near = ctx.bot.enemies_within(8.0f); - return near >= 3 || (ctx.aoe_preference && near >= 2); -} -void DoFlamestrike(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* v = ctx.bot.victim_info()) e.cast_at(FLAMESTRIKE, v->x, v->y, v->z); - else e.cast(FLAMESTRIKE); -} - -// ---- Proc spending ---- -bool ShouldPyroblastHotStreak(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(PYROBLAST)) return false; - return ctx.bot.has_aura(HOT_STREAK); -} -void DoPyroblast(ApPredicateContext const& ctx, BotIntentEmitter& e) { e.cast(PYROBLAST, ctx.bot.victim()); } - -// Fire Blast — burns a charge to instantly proc Heating Up → Hot Streak. -// Save charges for Combustion window if it's coming up soon (less than -// ~20s remaining); otherwise spend on cooldown. -bool ShouldFireBlast(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(FIRE_BLAST)) return false; - if (!ctx.bot.is_ready(FIRE_BLAST)) return false; - // If we already have Hot Streak, no point burning a Fire Blast charge - // (it'd just generate Heating Up which can't stack with Hot Streak). - if (ctx.bot.has_aura(HOT_STREAK)) return false; - // Combustion lookahead: when Combustion is < 20s from ready and we - // already know the spell, hoard Fire Blast charges so the burst - // window opens with 3 instant-Pyro chains queued. Skip during the - // Combustion buff itself — every Fire Blast crits guaranteed under - // the buff, so spend freely. - if (ctx.bot.knows_spell(COMBUSTION) && !ctx.bot.has_aura(COMBUSTION)) - { - const int64_t cd_ms = ctx.bot.cd_remaining(COMBUSTION).count(); - if (cd_ms > 0 && cd_ms <= 20000) return false; - } - // Spend the proc trigger when Heating Up is up — converts to Hot Streak. - return ctx.bot.has_aura(HEATING_UP); -} -void DoFireBlast(ApPredicateContext const& ctx, BotIntentEmitter& e) { e.cast(FIRE_BLAST, ctx.bot.victim()); } - -// ---- Filler ---- -bool ShouldScorch(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(SCORCH)) return false; - // Heat Shimmer proc: next Scorch is instant and counts as execute - - // always worth the GCD. - if (ctx.bot.has_aura(HEAT_SHIMMER)) return true; - // Scorch is the cast-while-moving filler + guaranteed crit sub-30%. Use - // it when moving (no cast-time penalty) OR in the execute window. - return TargetExecuteRange(ctx) || ctx.bot.is_moving(); -} -void DoScorch(ApPredicateContext const& ctx, BotIntentEmitter& e) { e.cast(SCORCH, ctx.bot.victim()); } - -// Frostfire Bolt (hero talent) replaces Fireball. Frostfire Empowerment makes -// the next one instant, so fire it even while moving under the proc. -bool ShouldFrostfireBolt(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(FROSTFIRE_BOLT)) return false; - if (ctx.bot.has_aura(FROSTFIRE_EMPOWER)) return true; - if (ctx.bot.is_moving() && !ctx.bot.can_cast_while_moving(FROSTFIRE_BOLT)) return false; - return true; -} -void DoFrostfireBolt(ApPredicateContext const& ctx, BotIntentEmitter& e) { e.cast(FROSTFIRE_BOLT, ctx.bot.victim()); } - -bool ShouldFireball(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (ctx.bot.knows_spell(FROSTFIRE_BOLT)) return false; // overridden - if (!ctx.bot.knows_spell(FIREBALL)) return false; - // Hard-cast - defer to Scorch when moving so we don't silently fail. - if (ctx.bot.is_moving() && !ctx.bot.can_cast_while_moving(FIREBALL)) return false; - return true; -} -void DoFireball(ApPredicateContext const& ctx, BotIntentEmitter& e) { e.cast(FIREBALL, ctx.bot.victim()); } - -bool AlwaysInCombat(ApPredicateContext const& ctx) { return ctx.bot.in_combat(); } -void DoAutoAttack(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - ObjectGuid t = ctx.bot.victim(); - if (t.IsEmpty()) t = ctx.bot.current_target(); - // Retaliate fallback (2026-06-17): in combat with no victim/target the bot - // looped "Engage auto attack" as a no-op while taking damage (the CombatLoop - // wedge cluster). Engage whatever is meleeing us (attackers are adjacent and - // reachable), else the nearest visible enemy, so combat actually resolves. - // Strictly additive: only runs when no target was already selected. - if (t.IsEmpty()) - for (auto const& u : ctx.bot.attackers()) - if (u.hp > 0) { t = u.guid; break; } - if (t.IsEmpty()) - for (auto const& u : ctx.bot.nearby_enemies()) - if (u.hp > 0 && u.in_los) { t = u.guid; break; } - if (!t.IsEmpty()) e.start_attack(t); -} - -// ---- Rule table ---- -// -// Ordering matches the documented Mage spec ordering (most-urgent first): -// 1. Survival panic (Ice Block / Greater Invisibility) -// 2. Defensives (Blazing Barrier / Mirror Image / Alter Time / -// Shimmer or Blink) -// 3. Interrupt (Counterspell) + group dispel (Remove Curse) -// 4. Kite (Frost Nova / Dragon's Breath) -// 5. CC (Polymorph) -// 6. Major offensive CDs (Time Warp / Combustion / Meteor) -// 7. Procs (Hot Streak: Flamestrike-AoE > Pyroblast-ST; then -// Fire Blast to convert Heating Up into the next Hot Streak) -// 8. Filler (Scorch / Frostfire Bolt or Fireball) -// 9. Auto-attack fallback -// -// Critical Fire mechanic: Pyroblast MUST be gated on the Hot Streak -// proc aura (48108). Without the proc it is a 4s hardcast that gets -// interrupted; with it, instant + huge crit. ShouldPyroblastHotStreak -// enforces this - no unconditional Pyroblast rule exists. -ApRule const kRules[] = { - // 1. Survival panic - { ShouldIceBlock, DoIceBlock, "Ice Block (panic <=20% / <=40% PvP)" }, - { ShouldGreaterInvis, DoGreaterInvis, "Greater Invis (threat wipe)" }, - // 2. Defensives - { ShouldBlazingBarrier, DoBlazingBarrier, "Blazing Barrier (shield)" }, - { ShouldMirrorImage, DoMirrorImage, "Mirror Image (threat / boss)" }, - { ShouldAlterTime, DoAlterTime, "Alter Time (snapshot HP)" }, - { ShouldShimmerAway, DoShimmer, "Shimmer (escape melee)" }, - { ShouldBlinkAway, DoBlink, "Blink (escape melee)" }, - // 3. Interrupt / dispel - { ShouldCounterspell, DoCounterspell, "Counterspell (interrupt)" }, - { ShouldRemoveCurse, DoRemoveCurse, "Remove Curse (group)" }, - // 4. Kite - { ShouldFrostNova, DoFrostNova, "Frost Nova (kite melee)" }, - { ShouldDragonsBreath, DoDragonsBreath, "Dragon's Breath (2+ AoE)" }, - // 5. CC - { ShouldPolymorph, DoPolymorph, "Polymorph (off-target CC)" }, - // 6. Major offensive CDs - { ShouldTimeWarp, DoTimeWarp, "Time Warp (boss)" }, - { ShouldCombustion, DoCombustion, "Combustion (burst window)" }, - { ShouldMeteor, DoMeteor, "Meteor (boss / 2+ AoE)" }, - // 7. Procs (Hot Streak consumption - AoE first, then ST) - { ShouldFlamestrikeHotStreak,DoFlamestrike, "Flamestrike (HS + 3 AoE)" }, - { ShouldPyroblastHotStreak, DoPyroblast, "Pyroblast (Hot Streak)" }, - { ShouldFireBlast, DoFireBlast, "Fire Blast (HU -> HS)" }, - // 8. Filler (Frostfire Bolt overrides Fireball when talented) - { ShouldScorch, DoScorch, "Scorch (execute / moving)" }, - { ShouldFrostfireBolt, DoFrostfireBolt, "Frostfire Bolt (filler)" }, - { ShouldFireball, DoFireball, "Fireball (filler)" }, - // 9. Auto attack fallback - { AlwaysInCombat, DoAutoAttack, "Engage auto attack" }, -}; - -} // anonymous - -void RegisterApl_Mage_Fire() -{ - constexpr uint32 SPEC_MAGE_FIRE = 63; - RegisterRotation(CLASS_MAGE, SPEC_MAGE_FIRE, ApRotation{kRules}); -} - -} // namespace Playerbot::Combat diff --git a/src/modules/PlayerbotV2/Combat/Apl/Apl_Mage_Frost.cpp b/src/modules/PlayerbotV2/Combat/Apl/Apl_Mage_Frost.cpp deleted file mode 100644 index 83b03ad2fe..0000000000 --- a/src/modules/PlayerbotV2/Combat/Apl/Apl_Mage_Frost.cpp +++ /dev/null @@ -1,521 +0,0 @@ -// Frost Mage - WoW 12.1.0.69587 (Midnight) rotation. Caster DPS, mana -// resource. Midnight reworked the shatter loop around FREEZING stacks: -// Frostbolt / Flurry apply Freezing (debuff 1221389) to the target, Ice Lance -// Shatters those stacks for bonus damage, Fingers of Frost lets Ice Lance -// Shatter without consuming stacks, Brain Freeze resets Flurry. Icicles now -// auto-upgrade Frostbolt into Glacial Spike, so no separate Glacial Spike -// cast exists. Ray of Frost is a core rotational channel, Frozen Orb the -// AoE / proc engine, Blizzard the 3+ AoE. -// -// ---- Validated spell IDs (WoW 12.1.0.69587) ---- -// 116 Frostbolt 431044 Frostfire Bolt (hero, overrides Frostbolt) -// 30455 Ice Lance (talent) 431177 Frostfire Empowerment (proc aura) -// 44614 Flurry (talent) 84714 Frozen Orb (talent) -// 205021 Ray of Frost (talent) 190356 Blizzard (talent) -// 11426 Ice Barrier (talent) 235219 Cold Snap (talent) -// 113724 Ring of Frost 120 Cone of Cold -// 157997 Ice Nova (overrides Cone of Cold) -// 190446 Brain Freeze (proc) 44544 Fingers of Frost (proc) -// 1221389 Freezing (debuff) 55342 Mirror Image (talent) -// 342245 Alter Time (talent) 45438 Ice Block (talent) -// 110959 Greater Invisibility 110960 Greater Invisibility (aura) -// 1953 Blink 212653 Shimmer (talent, overrides Blink) -// 2139 Counterspell 475 Remove Curse -// 122 Frost Nova 118 Polymorph -// 80353 Time Warp -// -// ---- Skipped spells (and why) ---- -// 199786 Glacial Spike - no longer a castable; Icicles (1246832) -// upgrade Frostbolt automatically. -// 153595 / 1247777 Comet Storm - 12.1 Comet Storm is a PASSIVE that -// replaces Ray of Frost; not in the -// curated build. Ray of Frost rule covers. -// 257537 / 214634 Ebonbolt - 214634 is a Legion artifact spell -// (no learn level); never granted. -// 12472 Icy Veins - removed from the Frost tree. -// 108839 Ice Floes - removed from the Mage class tree. -// 228358 Winter's Chill - replaced by Freezing stacks. -// 205473 Icicles (old aura) - Glacial Spike is automatic now. -// 31687 Summon Water Elemental - Lonely Winter [R][M] forgoes the pet. -// 1248829 Blizzard (target) - alt variant; we cast_at with 190356. -// 157980 Supernova / 383121 Mass Polymorph - not in the raid build. - -#include "../ApRegistry.h" -#include "../ApRotation.h" -#include "ApCrowdControl.h" -#include "Bot/BotIntentEmitter.h" -#include "Bot/BotSnapshotView.h" -#include "Group/GroupSnapshot.h" -#include "SharedDefines.h" - -namespace Playerbot::Combat { - -namespace { - -// ---- Spell IDs (WoW 12.1.0.69587, validated) ---- -constexpr uint32 FROSTBOLT = 116; -constexpr uint32 FROSTFIRE_BOLT = 431044; // hero talent - replaces Frostbolt -constexpr uint32 ICE_LANCE = 30455; // Shatters Freezing stacks -constexpr uint32 FLURRY = 44614; // applies Freezing stacks -constexpr uint32 FROZEN_ORB = 84714; -constexpr uint32 ICE_BARRIER = 11426; -constexpr uint32 RAY_OF_FROST = 205021; // talent - 4s channel, applies Freezing -constexpr uint32 MIRROR_IMAGE = 55342; // 3x clones, 2min CD -constexpr uint32 COLD_SNAP = 235219; // resets Ice Barrier / Frost Nova / Ice Block -constexpr uint32 RING_OF_FROST = 113724; // 10s AoE incapacitate, 45s CD -constexpr uint32 POLYMORPH = 118; // CC - sheep humanoid/beast/etc. -constexpr uint32 ALTER_TIME = 342245; // snapshots HP/position; reverts after 10s - -// Procs / triggers -constexpr uint32 BRAIN_FREEZE = 190446; // resets Flurry, empowers next Flurry -constexpr uint32 FINGERS_OF_FROST = 44544; // next Ice Lance Shatters without consuming Freezing -constexpr uint32 FREEZING = 1221389; // debuff on target - stacks, Shattered by Ice Lance -constexpr uint32 FROSTFIRE_EMPOWER = 431177; // proc aura - next Frostfire Bolt instant - -constexpr uint32 COUNTERSPELL = 2139; // 40yd interrupt -constexpr uint32 REMOVE_CURSE = 475; // friendly curse dispel, 8s CD -constexpr uint32 BLIZZARD = 190356; -constexpr uint32 CONE_OF_COLD = 120; -constexpr uint32 ICE_NOVA = 157997; // talent - replaces Cone of Cold, targeted freeze -constexpr uint32 FROST_NOVA = 122; -constexpr uint32 ICE_BLOCK = 45438; // 10s immunity, 4min CD -constexpr uint32 GREATER_INVIS = 110959; // threat wipe, 2min CD -constexpr uint32 GREATER_INVIS_AURA = 110960; // active invisibility aura -constexpr uint32 BLINK = 1953; // 20yd reposition -constexpr uint32 SHIMMER = 212653; // talent - replaces Blink, off-GCD -constexpr uint32 TIME_WARP = 80353; -constexpr uint32 SATED_DEBUFF = 57724; -constexpr uint32 TEMPORAL_DISPL_DEBUFF = 80354; -constexpr uint32 INSANITY_HUNTER_DEBUFF = 95809; -constexpr uint32 FATIGUED_DEBUFF = 264689; - -// ---- Helpers ---- -bool HasLiveTarget(ApPredicateContext const& ctx) -{ - return !ctx.bot.victim().IsEmpty(); -} - -bool BotHasSatedDebuff(ApPredicateContext const& ctx) -{ - return ctx.bot.has_aura(SATED_DEBUFF) - || ctx.bot.has_aura(TEMPORAL_DISPL_DEBUFF) - || ctx.bot.has_aura(INSANITY_HUNTER_DEBUFF) - || ctx.bot.has_aura(FATIGUED_DEBUFF); -} - -bool BossLikeTargetEngaged(ApPredicateContext const& ctx) -{ - constexpr int32 kBossHpThreshold = 5'000'000; - NearbyUnit const* t = ctx.bot.victim_info(); - if (t && t->max_hp >= kBossHpThreshold) return true; - for (auto const& a : ctx.bot.raw().combat.attackers) - if (a.max_hp >= kBossHpThreshold) return true; - return false; -} - -// ---- Survival ---- -bool ShouldIceBlock(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(ICE_BLOCK)) return false; - if (!ctx.bot.is_ready(ICE_BLOCK)) return false; - // PvP burst kills clothies from 40% in <2s. The 20% raid threshold - // is too late once a real player is on you — by the time HP touches - // 20 the next instant has already landed. Bump the trigger when - // under_player_attack so the iceblock catches the danger window. - const int32 threshold = ctx.pvp.under_player_attack ? 40 : 20; - return ctx.bot.hp_pct() <= threshold; -} -void DoIceBlock(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(ICE_BLOCK); } - -// Greater Invisibility - instant threat wipe. The invisibility breaks on our -// next action, but the threat reset already happened on cast, so it is the -// "get the pack off me" button once Ice Block is gone. -bool ShouldGreaterInvis(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(GREATER_INVIS)) return false; - if (!ctx.bot.is_ready(GREATER_INVIS)) return false; - if (ctx.bot.has_aura(GREATER_INVIS_AURA)) return false; - if (ctx.bot.attackers_count() < 1) return false; - return ctx.bot.hp_pct() <= 35; -} -void DoGreaterInvis(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(GREATER_INVIS); } - -// Emergency reposition when low HP and a melee is on us. Shimmer (talent) -// replaces Blink; two-branch so both talented and untalented bots escape. -bool ShouldShimmerAway(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(SHIMMER)) return false; - if (!ctx.bot.is_ready(SHIMMER)) return false; - return ctx.bot.hp_pct() <= 35 && ctx.bot.enemies_within(8.0f) >= 1; -} -void DoShimmer(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(SHIMMER); } - -bool ShouldBlinkAway(ApPredicateContext const& ctx) -{ - if (ctx.bot.knows_spell(SHIMMER)) return false; - if (!ctx.bot.knows_spell(BLINK)) return false; - if (!ctx.bot.is_ready(BLINK)) return false; - return ctx.bot.hp_pct() <= 35 && ctx.bot.enemies_within(8.0f) >= 1; -} -void DoBlink(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(BLINK); } - -// ---- CC (PvP-aware Polymorph) ---- -// Sheep an off-target enemy via the shared PickOffTargetCC gate: PvE fires -// only on a genuine 2+ ATTACKER pull (never on a 40y scan bystander while -// solo-questing) and skips already-sheeped mobs through NearbyUnit:: -// is_cc_locked; PvP escalates to enemy Healer > caster. See ApCrowdControl.h -// for the full rationale (this replaced the old nearby_enemies.size()>=2 + -// has_aura gate that made the bot Polymorph every GCD and never DPS). -bool ShouldPolymorph(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(POLYMORPH)) return false; - if (!ctx.bot.is_ready(POLYMORPH)) return false; - return !PickOffTargetCC(ctx, POLYMORPH, ApInPvp(ctx)).IsEmpty(); -} -void DoPolymorph(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - ObjectGuid const t = PickOffTargetCC(ctx, POLYMORPH, ApInPvp(ctx)); - if (!t.IsEmpty()) e.cast(POLYMORPH, t); -} - -bool ShouldAlterTime(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(ALTER_TIME)) return false; - if (!ctx.bot.is_ready(ALTER_TIME)) return false; - // Snapshot HP at 80%+; if we drop below 35% within 10s, the revert - // restores us to the snapshot. Effectively a delayed self-heal cooldown. - // Predicate: only snapshot when HP is high (no point recording a low - // snapshot we'd never want to revert to). - return ctx.bot.hp_pct() >= 80 && !ctx.bot.has_aura(ALTER_TIME); -} -void DoAlterTime(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(ALTER_TIME); } - -bool ShouldIceBarrier(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(ICE_BARRIER)) return false; - if (!ctx.bot.is_ready(ICE_BARRIER)) return false; - if (ctx.bot.has_aura(ICE_BARRIER)) return false; // already up - return ctx.bot.in_combat() && ctx.bot.hp_pct() <= 90; -} -void DoIceBarrier(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(ICE_BARRIER); } - -bool ShouldMirrorImage(ApPredicateContext const& ctx) -{ - // Mirror Image is both a damage cooldown AND a threat dump. Use it on - // pull (early in combat) or when low HP. - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(MIRROR_IMAGE)) return false; - if (!ctx.bot.is_ready(MIRROR_IMAGE)) return false; - return ctx.bot.hp_pct() <= 70 || BossLikeTargetEngaged(ctx); -} -void DoMirrorImage(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(MIRROR_IMAGE); } - -bool ShouldColdSnap(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(COLD_SNAP)) return false; - if (!ctx.bot.is_ready(COLD_SNAP)) return false; - // Resets Ice Block / Ice Barrier / Frost Nova. Worth firing when - // Ice Block is on CD AND we're going to need it (low HP). - return ctx.bot.hp_pct() <= 25 && !ctx.bot.is_ready(ICE_BLOCK); -} -void DoColdSnap(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(COLD_SNAP); } - -// Remove Curse - group utility. Prefer a cursed group member, else self. -bool ShouldRemoveCurse(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(REMOVE_CURSE)) return false; - if (!ctx.bot.is_ready(REMOVE_CURSE)) return false; - if (ctx.group.dispel_candidate(DispelType::Curse) != nullptr) return true; - return ctx.bot.self_dispellable(DispelType::Curse); -} -void DoRemoveCurse(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* m = ctx.group.dispel_candidate(DispelType::Curse)) { e.cast(REMOVE_CURSE, m->guid); return; } - e.cast(REMOVE_CURSE, ctx.bot.raw().guid); -} - -// ---- Interrupt + CC ---- -bool ShouldCounterspell(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(COUNTERSPELL)) return false; - if (!ctx.bot.is_ready(COUNTERSPELL)) return false; - const bool pvp = ctx.pvp.in_battleground || ctx.pvp.in_arena; - return ctx.bot.kick_target(pvp, 40.0f) != nullptr; -} -void DoCounterspell(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - const bool pvp = ctx.pvp.in_battleground || ctx.pvp.in_arena; - if (auto const* c = ctx.bot.kick_target(pvp, 40.0f)) - e.cast(COUNTERSPELL, c->guid); -} - -// Frost Nova used both defensively (root attackers in melee) and as a -// shatter-combo setup (Frozen target → Ice Lance crits guaranteed). -// Conservative gate: only kite when WE are the one being beaten on in melee -// (an enemy is attacking us inside 8y) AND there's no group tank to hold the -// pack — rooting the tank's pack mid-pull peels mobs off the tank and -// scatters them. Solo (no tank) keeps the original defensive behavior. -bool ShouldFrostNova(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(FROST_NOVA)) return false; - if (!ctx.bot.is_ready(FROST_NOVA)) return false; - // Must be personally under melee attack: something is on our threat list - // AND a hostile is within Frost Nova's 8y radius. - if (ctx.bot.attackers_count() < 1) return false; - if (ctx.bot.enemies_within(8.0f) < 1) return false; - // If a living group tank exists, let them hold aggro — don't root the - // pack. tank() returns nullptr solo / tankless, preserving the kite. - GroupMemberSummary const* tank = ctx.group.tank(); - if (tank && tank->online && tank->hp > 0) - return false; - return true; -} -void DoFrostNova(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(FROST_NOVA); } - -bool ShouldRingOfFrost(ApPredicateContext const& ctx) -{ - // Ground-target AoE root — useful when leader hasn't pulled and we - // need to lock down adds before they reach us. Skip if already - // surrounded (the cast time is too long to land). - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(RING_OF_FROST)) return false; - if (!ctx.bot.is_ready(RING_OF_FROST)) return false; - return ctx.bot.enemies_within(20.0f) >= 3 && ctx.bot.enemies_within(8.0f) == 0; -} -void DoRingOfFrost(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* v = ctx.bot.victim_info()) - e.cast_at(RING_OF_FROST, v->x, v->y, v->z); - else - e.cast(RING_OF_FROST); -} - -// ---- Major offensive cooldowns ---- -bool ShouldTimeWarp(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(TIME_WARP)) return false; - if (!ctx.bot.is_ready(TIME_WARP)) return false; - if (BotHasSatedDebuff(ctx)) return false; - return BossLikeTargetEngaged(ctx); -} -void DoTimeWarp(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(TIME_WARP); } - -// Ray of Frost (12.1) is a core rotational 4s channel that stacks Freezing -// on the target and (Spellslinger) conjures Splinters. Fire it on cooldown -// whenever we can stand still; the channel drops on the first step. -bool ShouldRayOfFrost(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(RAY_OF_FROST)) return false; - if (!ctx.bot.is_ready(RAY_OF_FROST)) return false; - return !ctx.bot.is_moving(); -} -void DoRayOfFrost(ApPredicateContext const& ctx, BotIntentEmitter& e) { e.cast(RAY_OF_FROST, ctx.bot.victim()); } - -bool ShouldFrozenOrb(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(FROZEN_ORB)) return false; - return ctx.bot.is_ready(FROZEN_ORB); -} -void DoFrozenOrb(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* v = ctx.bot.victim_info()) e.cast_at(FROZEN_ORB, v->x, v->y, v->z); - else e.cast(FROZEN_ORB); -} - -// ---- Proc spending ---- -bool ShouldFlurry(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(FLURRY)) return false; - if (!ctx.bot.is_ready(FLURRY)) return false; - // Only spend Flurry when Brain Freeze procs (otherwise it has a long - // cast — we'd rather Frostbolt). - return ctx.bot.has_aura(BRAIN_FREEZE); -} -void DoFlurry(ApPredicateContext const& ctx, BotIntentEmitter& e) { e.cast(FLURRY, ctx.bot.victim()); } - -bool ShouldIceLance(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(ICE_LANCE)) return false; - if (!ctx.bot.is_ready(ICE_LANCE)) return false; - // Spend Fingers of Frost charges (Shatter without consuming Freezing). - // Otherwise Shatter once the target carries a Freezing stack pile from - // Flurry / Frostbolt hits - 3 is roughly one Flurry's worth, so the bot - // alternates builder and Shatter instead of lancing every other GCD. - if (ctx.bot.has_aura(FINGERS_OF_FROST)) return true; - if (ctx.bot.aura_stacks(FREEZING, ctx.bot.victim()) >= 3) return true; - // Moving-fallback: when the bot is moving and Frostbolt is locked - // out (can_cast_while_moving=false), Ice Lance maintains DPS - // uptime even without proc. Real Frost Mages refuse to lose - // global cooldowns to movement — the GCD is too valuable to drop. - // Skipped when Ice Floes / Slipstream lets Frostbolt cast on the - // move (those still resolve via ShouldFrostbolt). - if (ctx.bot.is_moving() && !ctx.bot.can_cast_while_moving(FROSTBOLT)) - return true; - return false; -} -void DoIceLance(ApPredicateContext const& ctx, BotIntentEmitter& e) { e.cast(ICE_LANCE, ctx.bot.victim()); } - -// ---- AoE ---- -bool ShouldBlizzard(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(BLIZZARD)) return false; - if (!ctx.bot.is_ready(BLIZZARD)) return false; - // aoe_preference is a soft hint; still require ≥2 enemies so stale - // `.aoe on` doesn't fire on a boss pull. - const int near = ctx.bot.enemies_within(20.0f); - return near >= 3 || (ctx.aoe_preference && near >= 2); -} -void DoBlizzard(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* v = ctx.bot.victim_info()) e.cast_at(BLIZZARD, v->x, v->y, v->z); - else e.cast(BLIZZARD); -} - -// Ice Nova (talent) replaces Cone of Cold: targeted 40y freeze + AoE around -// the victim. Two-branch with Cone of Cold so untalented bots keep the cone. -bool ShouldIceNova(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(ICE_NOVA)) return false; - if (!ctx.bot.is_ready(ICE_NOVA)) return false; - return ctx.bot.enemies_within(8.0f) >= 2; -} -void DoIceNova(ApPredicateContext const& ctx, BotIntentEmitter& e) { e.cast(ICE_NOVA, ctx.bot.victim()); } - -bool ShouldConeOfCold(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (ctx.bot.knows_spell(ICE_NOVA)) return false; // overridden by Ice Nova - if (!ctx.bot.knows_spell(CONE_OF_COLD)) return false; - if (!ctx.bot.is_ready(CONE_OF_COLD)) return false; - // Short cone in front - usable only when 3+ enemies in melee range. - return ctx.bot.enemies_within(8.0f) >= 3; -} -void DoConeOfCold(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(CONE_OF_COLD); } - -// ---- Filler ---- -// Frostfire Bolt (hero talent) replaces Frostbolt and still applies Freezing. -// Frostfire Empowerment makes the next one instant, so fire it even while -// moving under the proc. -bool ShouldFrostfireBolt(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(FROSTFIRE_BOLT)) return false; - if (ctx.bot.has_aura(FROSTFIRE_EMPOWER)) return true; - if (ctx.bot.is_moving() && !ctx.bot.can_cast_while_moving(FROSTFIRE_BOLT)) return false; - return true; -} -void DoFrostfireBolt(ApPredicateContext const& ctx, BotIntentEmitter& e) { e.cast(FROSTFIRE_BOLT, ctx.bot.victim()); } - -bool ShouldFrostbolt(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (ctx.bot.knows_spell(FROSTFIRE_BOLT)) return false; // overridden - if (!ctx.bot.knows_spell(FROSTBOLT)) return false; - // Frostbolt is hard-cast; bots in motion would silently fail the cast. - if (ctx.bot.is_moving() && !ctx.bot.can_cast_while_moving(FROSTBOLT)) return false; - return true; -} -void DoFrostbolt(ApPredicateContext const& ctx, BotIntentEmitter& e) { e.cast(FROSTBOLT, ctx.bot.victim()); } - -bool AlwaysInCombat(ApPredicateContext const& ctx) { return ctx.bot.in_combat(); } -void DoAutoAttack(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - ObjectGuid t = ctx.bot.victim(); - if (t.IsEmpty()) t = ctx.bot.current_target(); - // Retaliate fallback (2026-06-17): in combat with no victim/target the bot - // looped "Engage auto attack" as a no-op while taking damage (the CombatLoop - // wedge cluster). Engage whatever is meleeing us (attackers are adjacent and - // reachable), else the nearest visible enemy, so combat actually resolves. - // Strictly additive: only runs when no target was already selected. - if (t.IsEmpty()) - for (auto const& u : ctx.bot.attackers()) - if (u.hp > 0) { t = u.guid; break; } - if (t.IsEmpty()) - for (auto const& u : ctx.bot.nearby_enemies()) - if (u.hp > 0 && u.in_los) { t = u.guid; break; } - if (!t.IsEmpty()) e.start_attack(t); -} - -// ---- Rule table ---- -// -// Ordering matches the documented Mage spec ordering (most-urgent first): -// 1. Survival panic (Ice Block + Cold Snap to reset it / Greater Invis) -// 2. Defensives (Mirror Image / Alter Time / Ice Barrier / Shimmer or -// Blink) -// 3. Interrupt (Counterspell) + group dispel (Remove Curse) -// 4. Kite (Frost Nova / Ring of Frost / Ice Nova or Cone of Cold) -// 5. CC (Polymorph - healer-pref off-target sheep) -// 6. Major offensive CDs (Time Warp / Frozen Orb / Ray of Frost) -// 7. Procs - Frost's Freezing / Shatter loop: -// a. Flurry (Brain Freeze proc - stacks Freezing on the target) -// b. Ice Lance (Fingers of Frost or 3+ Freezing stacks -> Shatter; -// also moving-fallback when the bolt is locked) -// 8. AoE (Blizzard at 3+) -// 9. Filler (Frostfire Bolt or Frostbolt - auto-upgrades to Glacial -// Spike at max Icicles) -// 10. Auto-attack fallback -// -// Critical Frost mechanic: Ice Lance is gated by Freezing / proc state -// (Fingers of Frost aura 44544, Freezing stacks 1221389 on the target, or -// moving-fallback). Never an unconditional ST spam - that would waste -// mana on a low-damage cast lacking the Shatter multiplier. -// -// Critical proc priority: Brain Freeze MUST be consumed by Flurry BEFORE -// Ice Lance so the Freezing stacks are on the target when the lance lands. -ApRule const kRules[] = { - // 1. Survival panic - { ShouldIceBlock, DoIceBlock, "Ice Block (panic <=20% / <=40% PvP)" }, - { ShouldColdSnap, DoColdSnap, "Cold Snap (reset Ice Block)" }, - { ShouldGreaterInvis, DoGreaterInvis, "Greater Invis (threat wipe)" }, - // 2. Defensives - { ShouldMirrorImage, DoMirrorImage, "Mirror Image (threat / boss)" }, - { ShouldAlterTime, DoAlterTime, "Alter Time (snapshot HP)" }, - { ShouldIceBarrier, DoIceBarrier, "Ice Barrier (defensive)" }, - { ShouldShimmerAway, DoShimmer, "Shimmer (escape melee)" }, - { ShouldBlinkAway, DoBlink, "Blink (escape melee)" }, - // 3. Interrupt / dispel - { ShouldCounterspell, DoCounterspell, "Counterspell (interrupt)" }, - { ShouldRemoveCurse, DoRemoveCurse, "Remove Curse (group)" }, - // 4. Kite (Ice Nova overrides Cone of Cold when talented) - { ShouldFrostNova, DoFrostNova, "Frost Nova (root attackers)" }, - { ShouldRingOfFrost, DoRingOfFrost, "Ring of Frost (3+ approaching)" }, - { ShouldIceNova, DoIceNova, "Ice Nova (2+ freeze)" }, - { ShouldConeOfCold, DoConeOfCold, "Cone of Cold (3+ melee)" }, - // 5. CC - { ShouldPolymorph, DoPolymorph, "Polymorph (off-target CC, healer-pref)" }, - // 6. Major offensive CDs - { ShouldTimeWarp, DoTimeWarp, "Time Warp (boss)" }, - { ShouldFrozenOrb, DoFrozenOrb, "Frozen Orb (cooldown)" }, - { ShouldRayOfFrost, DoRayOfFrost, "Ray of Frost (channel)" }, - // 7. Procs (Flurry first so Freezing stacks land before the lance) - { ShouldFlurry, DoFlurry, "Flurry (Brain Freeze)" }, - { ShouldIceLance, DoIceLance, "Ice Lance (FoF / Shatter)" }, - // 8. AoE - { ShouldBlizzard, DoBlizzard, "Blizzard (3+ targets)" }, - // 9. Filler (Frostfire Bolt overrides Frostbolt when talented) - { ShouldFrostfireBolt, DoFrostfireBolt, "Frostfire Bolt (filler)" }, - { ShouldFrostbolt, DoFrostbolt, "Frostbolt (filler)" }, - // 10. Auto attack fallback - { AlwaysInCombat, DoAutoAttack, "Engage auto attack" }, -}; - -} // anonymous - -void RegisterApl_Mage_Frost() -{ - constexpr uint32 SPEC_MAGE_FROST = 64; - RegisterRotation(CLASS_MAGE, SPEC_MAGE_FROST, ApRotation{kRules}); -} - -} // namespace Playerbot::Combat diff --git a/src/modules/PlayerbotV2/Combat/Apl/Apl_Paladin_Holy.cpp b/src/modules/PlayerbotV2/Combat/Apl/Apl_Paladin_Holy.cpp deleted file mode 100644 index 7147eb8683..0000000000 --- a/src/modules/PlayerbotV2/Combat/Apl/Apl_Paladin_Holy.cpp +++ /dev/null @@ -1,666 +0,0 @@ -// Holy Paladin - WoW 12.1.0.69587 (Midnight) rotation. Holy Power healer -// with Beacon of Light / Beacon of Virtue transfer, Holy Shock as the -// primary heal + HP generator, Word of Glory (or Eternal Flame with the -// Herald of the Sun hero tree) burst heal, Light of Dawn AoE, and -// Avenging Wrath / Divine Toll throughput cooldowns. Aura Mastery is the -// raid-wide DR (Ringing of the Heavens also fires a Divine Toll). -// -// ================================================================= -// Validated spell IDs (WoW 12.1.0.69587, kit Apl_Paladin_Holy.md) -// ================================================================= -// 275773 - Judgment (Holy spec spell; overrides 20271) -// 20271 - Judgment (baseline L3; pre-spec fallback) -// 20473 - Holy Shock (spec talent [R]; replaces Crusader Strike) -// 19750 - Flash of Light (baseline L4) -// 82326 - Holy Light (spec spell L11) -// 85222 - Light of Dawn (spec talent [R]) -// 85673 - Word of Glory (baseline L7) -// 156322 - Eternal Flame (Herald of the Sun [R] - overrides WoG) -// 633 - Lay on Hands (class talent [R]) -// 642 - Divine Shield (baseline L10) -// 498 - Divine Protection (spec spell L26 - 20% self DR) -// 465 - Devotion Aura (Auras of the Resolute [R]) -// 6940 - Blessing of Sacrifice (class talent [R]) -// 1022 - Blessing of Protection (class talent [R]) -// 1044 - Blessing of Freedom (class talent [R]) -// 31821 - Aura Mastery (spec talent [R]) -// 31884 - Avenging Wrath (spec talent [R]; buff aura is the same id) -// 375576 - Divine Toll (class talent [R]; was 304971) -// 200652 - Tyr's Deliverance (class baseline; 90s cd cone heal) -// 53563 - Beacon of Light (spec spell L16; overridden by 200025) -// 156910 - Beacon of Faith (spec talent [M]) -// 200025 - Beacon of Virtue (spec talent [R]; replaces Beacon of Light) -// 4987 - Cleanse (spec spell L10; Magic, +Poison/Disease -// with Improved Cleanse 393024 [R]) -// 853 - Hammer of Justice (baseline L5) -// 115750 - Blinding Light (class talent [R]) -// 62124 - Hand of Reckoning (baseline L9) -// 24275 - Hammer of Wrath (class baseline) -// 25771 - Forbearance (debuff only - never cast) -// 393024 - Improved Cleanse (passive [R] - knows_spell gate only) -// -// ================================================================= -// Skipped spells (and why) -// ================================================================= -// 96231 - Rebuke: Retribution/Protection class-tree node only in 12.1; -// Holy cannot learn it. Hammer of Justice is the interrupt. -// 105809 - Holy Avenger: removed from the Holy tree in 12.1. -// 203538 - Blessing of Kings: does not exist in 12.1 SpellName. -// 20066 - Repentance: not available to Holy in 12.1. -// 384376 - Avenging Wrath (rank passive): not castable; 31884 is both -// the cast and the buff aura. -// 315867 - Judgment (Holy Power passive): not castable; would hijack the -// multi-id pick and stall the rule. -// 440013 - Cleanse Toxins: overridden by Cleanse 4987 the moment Holy -// spec is chosen (L10); Improved Cleanse folds poison/disease -// into Cleanse for the [R] build. -// 35395 - Crusader Strike: overridden by Holy Shock for Holy in 12.1. -// 415091 - Shield of the Righteous (Holy): 5y melee spender; the healer -// bot does not hold melee position, so not wired. -// 114165 - Holy Prism: choice node vs Divine Toll; [R]/[M] both pick Toll. -// 212056 - Absolution / 391054 Intercession: resurrections, handled by -// the out-of-combat revive logic, not the combat APL. -// 190784 - Divine Steed / 433568 Rites: movement / pre-pull weapon imbue. -// -// ================================================================= -// Decision tree (top-down) -// ================================================================= -// 0) Aura maintenance: Devotion Aura -// 1) Cast-swap shim: cancel slow heal if better target appears -// 2) Emergency self: Lay on Hands -> Divine Shield -> WoG/EF self -// 3) Tank duty: Hand of Reckoning (self peel) -// 4) Interrupt / CC: Hammer of Justice -> Blinding Light -// 5) Freedom self: rooted / snared -// 6) Defensive CD: Divine Protection (self DR) -// 7) BoP/BoSac group save: ally <=25% / tank <=30% -// 8) Beacon maintenance: Beacon of Light tank (non-BoV), Beacon of Faith -// 9) Big raid CDs: Aura Mastery, Avenging Wrath, Divine Toll, -// Tyr's Deliverance, Beacon of Virtue -// 10) Dispel: Cleanse (Magic; +Poison/Disease when improved) -// 11) AoE heal: Light of Dawn (HP3) -// 12) Spike heal: Holy Shock, Word of Glory / Eternal Flame, -// Flash of Light -// 13) Filler heal: Holy Light -// 14) Offensive filler: Judgment, Holy Shock dmg, Hammer of Wrath - -#include "../ApRegistry.h" -#include "../ApRotation.h" -#include "ApDispelHelpers.h" -#include "ApHealHelpers.h" -#include "Bot/BotIntentEmitter.h" -#include "Bot/BotSnapshotView.h" -#include "Group/GroupSnapshot.h" -#include "SharedDefines.h" - -#include - -namespace Playerbot::Combat { - -namespace { - -// ---- Spell IDs (WoW 12.1.0.69587, validated against the kit) ---- -constexpr uint32 HOLY_SHOCK = 20473; -constexpr uint32 WORD_OF_GLORY = 85673; -constexpr uint32 ETERNAL_FLAME = 156322; // Herald of the Sun - overrides WoG -constexpr uint32 FLASH_OF_LIGHT = 19750; -constexpr uint32 HOLY_LIGHT = 82326; -constexpr uint32 LAY_ON_HANDS = 633; -constexpr uint32 BLESSING_OF_PROTECTION = 1022; -constexpr uint32 BLESSING_OF_FREEDOM = 1044; -constexpr uint32 LIGHT_OF_DAWN = 85222; -constexpr uint32 AVENGING_WRATH = 31884; // cast + buff aura -constexpr uint32 AURA_MASTERY = 31821; -constexpr uint32 DIVINE_TOLL = 375576; // 12.1 id (was 304971) -constexpr uint32 TYRS_DELIVERANCE = 200652; // 90s cd cone heal -constexpr uint32 BEACON_OF_LIGHT = 53563; -constexpr uint32 BEACON_OF_FAITH = 156910; // talent [M] - 2nd beacon -constexpr uint32 BEACON_OF_VIRTUE = 200025; // talent [R] - replaces Beacon of Light -constexpr uint32 CLEANSE = 4987; -constexpr uint32 IMPROVED_CLEANSE = 393024; // passive [R] - Cleanse also strips poison/disease -constexpr uint32 DIVINE_SHIELD = 642; -constexpr uint32 DIVINE_PROTECTION = 498; // defensive - 20% DR -constexpr uint32 BLESSING_OF_SACRIFICE = 6940; -constexpr uint32 HAMMER_OF_JUSTICE = 853; -constexpr uint32 BLINDING_LIGHT = 115750; -constexpr uint32 DEVOTION_AURA = 465; -constexpr uint32 FORBEARANCE = 25771; // debuff only -constexpr uint32 HAND_OF_RECKONING = 62124; -constexpr uint32 JUDGMENT_HOLY = 275773; // Holy spec spell (overrides baseline) -constexpr uint32 JUDGMENT_BASELINE = 20271; -constexpr uint32 HAMMER_OF_WRATH = 24275; - -constexpr uint8 POWER_HOLY_POWER_IDX = 9; - -// Mechanic ids (SharedDefines.h) for the Freedom self-cast. -constexpr uint32 MECHANIC_ROOT_ID = 7; -constexpr uint32 MECHANIC_SNARE_ID = 11; - -// ---- Multi-ID helpers (try spec variant first, fall back to baseline) ---- -// Why this matters: a level-5 Holy paladin has the baseline 20271 -// Judgment but not 275773. A level-10+ Holy paladin has the spec spell. -// Picking the first known + ready spell is the cleanest way to support -// the entire 1-90 level band without per-level branching. -uint32 PickKnownAndReady(ApPredicateContext const& ctx, std::initializer_list ids) -{ - for (uint32 id : ids) - if (ctx.bot.knows_spell(id) && ctx.bot.is_ready(id)) return id; - return 0; -} - -// Word of Glory is overridden by Eternal Flame when the Herald of the Sun -// hero talent is known ([R] build). Cast whichever the bot actually has. -uint32 WogId(ApPredicateContext const& ctx) -{ - return ctx.bot.knows_spell(ETERNAL_FLAME) ? ETERNAL_FLAME : WORD_OF_GLORY; -} - -// ---- Heal target picker ---- -struct HealTarget -{ - ObjectGuid guid; - int32 hp_pct; - bool valid; -}; - -HealTarget PickHealTarget(ApPredicateContext const& ctx) -{ - HealTarget t{}; - t.guid = ctx.bot.raw().guid; - t.hp_pct = ctx.bot.hp_pct(); - t.valid = true; - - GroupMemberSummary const* low = ctx.group.heal_assignment(ctx.bot.raw().guid, ctx.bot.map_id(), ctx.bot.raw().position.x, ctx.bot.raw().position.y, ctx.bot.raw().position.z, 45.0f); - if (low && low->online && low->max_hp > 0 && low->hp > 0) { - const int32 pct = (low->hp * 100) / low->max_hp; - if (pct < t.hp_pct) { - t.guid = low->guid; - t.hp_pct = pct; - } - } - return t; -} - -int WoundedFriendCount(ApPredicateContext const& ctx, int below_pct) -{ - int n = 0; - auto const* members = ctx.group.members(); - // SOLO (audit B22): ungrouped, "wounded friend" used to collapse to - // "my own HP <= below_pct" - the 92% GroupTopped gates then froze ALL - // damage the moment a questing healer took two melee hits, degenerating - // solo healer-spec leveling into heal-regen-nuke loops (3-10x kill - // time). Cap the solo threshold at a 45% survival floor: topped-style - // gates (92) stay open while merely scratched, true emergency heals - // (<=45) keep their thresholds. - if (!members) return ctx.bot.hp_pct() <= std::min(below_pct, 45) ? 1 : 0; - for (auto const& m : *members) { - if (!m.online || m.max_hp <= 0 || m.hp <= 0) continue; - if ((m.hp * 100) / m.max_hp <= below_pct) ++n; - } - return n; -} - -bool GroupTopped(ApPredicateContext const& ctx) -{ - return WoundedFriendCount(ctx, 92) == 0; -} - -uint8 HolyPower(ApPredicateContext const& ctx) -{ - return static_cast(ctx.bot.power(POWER_HOLY_POWER_IDX)); -} - -// Cleanse strips Magic baseline; Poison/Disease only once Improved Cleanse -// (393024, [R]) is known. Without the gate a non-talented bot would burn -// the 8s Cleanse cooldown on a poison it cannot remove. -GroupMemberSummary const* DispelTarget(ApPredicateContext const& ctx) -{ - const bool toxins = ctx.bot.knows_spell(IMPROVED_CLEANSE); - return DispelTargetWithPriority(ctx, [toxins](GroupSnapshotView const& g) - -> GroupMemberSummary const* - { - if (auto const* m = g.dispel_candidate(DispelType::Magic)) return m; - if (!toxins) return nullptr; - if (auto const* m = g.dispel_candidate(DispelType::Disease)) return m; - if (auto const* m = g.dispel_candidate(DispelType::Poison)) return m; - return nullptr; - }); -} - -bool SelfNeedsDispel(ApPredicateContext const& ctx) -{ - if (ctx.bot.self_dispellable(DispelType::Magic)) return true; - if (!ctx.bot.knows_spell(IMPROVED_CLEANSE)) return false; - return ctx.bot.self_dispellable(DispelType::Disease) - || ctx.bot.self_dispellable(DispelType::Poison); -} - -// ---- Aura maintenance ---- -bool ShouldDevotionAura(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(DEVOTION_AURA)) return false; - return !ctx.bot.has_aura(DEVOTION_AURA); -} -void DoDevotionAura(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(DEVOTION_AURA); } - -// ---- Emergency / survival (top of ladder) ---- -bool ShouldLayOnHands(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(LAY_ON_HANDS)) return false; - if (!ctx.bot.is_ready(LAY_ON_HANDS)) return false; - HealTarget t = PickHealTarget(ctx); - if (t.guid != ctx.bot.raw().guid && ctx.bot.has_aura(FORBEARANCE, t.guid)) return false; - if (t.guid == ctx.bot.raw().guid && ctx.bot.has_aura(FORBEARANCE)) return false; - return t.hp_pct <= 15; -} -void DoLayOnHands(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(LAY_ON_HANDS, PickHealTarget(ctx).guid); -} - -bool ShouldDivineShield(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(DIVINE_SHIELD)) return false; - if (!ctx.bot.is_ready(DIVINE_SHIELD)) return false; - if (ctx.bot.has_aura(FORBEARANCE)) return false; - if (ctx.bot.hp_pct() > 15) return false; - return !ctx.bot.is_ready(LAY_ON_HANDS); -} -void DoDivineShield(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(DIVINE_SHIELD); } - -// Self Word of Glory / Eternal Flame at <=50% HP. The wider heal-target -// loop picks WoG for allies; this rule is the ordered self-preservation -// step. -bool ShouldWordOfGlorySelf(ApPredicateContext const& ctx) -{ - const uint32 id = WogId(ctx); - if (!ctx.bot.knows_spell(id)) return false; - if (!ctx.bot.is_ready(id)) return false; - if (HolyPower(ctx) < 3) return false; - return ctx.bot.hp_pct() <= 50; -} -void DoWordOfGlorySelf(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(WogId(ctx), ctx.bot.raw().guid); -} - -// Blessing of Freedom on self when rooted / snared - a healer that cannot -// reposition out of a puddle or back to range dies to it. -bool ShouldBlessingOfFreedom(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(BLESSING_OF_FREEDOM)) return false; - if (!ctx.bot.is_ready(BLESSING_OF_FREEDOM)) return false; - if (ctx.bot.has_aura(BLESSING_OF_FREEDOM)) return false; - return ctx.bot.has_mechanic(MECHANIC_ROOT_ID) || ctx.bot.has_mechanic(MECHANIC_SNARE_ID); -} -void DoBlessingOfFreedom(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(BLESSING_OF_FREEDOM, ctx.bot.raw().guid); -} - -// Divine Protection - 20% all-school DR self CD; complements the ladder -// when Forbearance is up (no DS) or DS+LoH are on CD. -bool ShouldDivineProtection(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(DIVINE_PROTECTION)) return false; - if (!ctx.bot.is_ready(DIVINE_PROTECTION)) return false; - if (ctx.bot.has_aura(DIVINE_PROTECTION)) return false; - return ctx.bot.hp_pct() <= 45; -} -void DoDivineProtection(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(DIVINE_PROTECTION); } - -// ---- Tank duty (Holy paladins are sometimes the only ranged taunt -// available in 5-mans when the pull goes sideways) ---- -bool ShouldHandOfReckoning(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(HAND_OF_RECKONING)) return false; - if (!ctx.bot.is_ready(HAND_OF_RECKONING)) return false; - // Only peel for self - Holy paladins should not be steady-state tanking. - if (ctx.bot.hp_pct() > 40) return false; - return ctx.bot.untaunted_enemy(40.0f) != nullptr; -} -void DoHandOfReckoning(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* t = ctx.bot.untaunted_enemy(40.0f)) - e.cast(HAND_OF_RECKONING, t->guid); -} - -// ---- Interrupt / CC ---- -// Holy has no Rebuke in 12.1 (Ret/Prot class-tree node only); Hammer of -// Justice's stun is the healer's only interrupt. -bool ShouldHammerOfJustice(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(HAMMER_OF_JUSTICE)) return false; - if (!ctx.bot.is_ready(HAMMER_OF_JUSTICE)) return false; - const bool pvp = ctx.pvp.in_battleground || ctx.pvp.in_arena; - return ctx.bot.kick_target(pvp, 10.0f) != nullptr; -} -void DoHammerOfJustice(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - const bool pvp = ctx.pvp.in_battleground || ctx.pvp.in_arena; - if (auto const* c = ctx.bot.kick_target(pvp, 10.0f)) - e.cast(HAMMER_OF_JUSTICE, c->guid); -} - -bool ShouldBlindingLight(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(BLINDING_LIGHT)) return false; - if (!ctx.bot.is_ready(BLINDING_LIGHT)) return false; - return ctx.bot.enemies_within(10.0f) >= 3 && ctx.bot.hp_pct() <= 50; -} -void DoBlindingLight(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(BLINDING_LIGHT); } - -// ---- Group saves ---- -bool ShouldBlessingOfProtection(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(BLESSING_OF_PROTECTION)) return false; - if (!ctx.bot.is_ready(BLESSING_OF_PROTECTION)) return false; - HealTarget t = PickHealTarget(ctx); - if (!t.valid || t.guid == ctx.bot.raw().guid) return false; - if (ctx.bot.has_aura(FORBEARANCE, t.guid)) return false; - return t.hp_pct <= 25; -} -void DoBlessingOfProtection(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(BLESSING_OF_PROTECTION, PickHealTarget(ctx).guid); -} - -bool ShouldBlessingOfSacrifice(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(BLESSING_OF_SACRIFICE)) return false; - if (!ctx.bot.is_ready(BLESSING_OF_SACRIFICE)) return false; - if (ctx.bot.hp_pct() <= 80) return false; - GroupMemberSummary const* tank = ctx.group.tank(); - if (!tank || !tank->online || tank->max_hp <= 0 || tank->hp <= 0) return false; - return (tank->hp * 100) / tank->max_hp <= 30; -} -void DoBlessingOfSacrifice(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* tank = ctx.group.tank()) - e.cast(BLESSING_OF_SACRIFICE, tank->guid); -} - -// ---- Beacon maintenance ---- -// Beacon of Light is overridden by Beacon of Virtue in the [R] build - -// the permanent tank beacon only exists for non-Virtue loadouts. -bool ShouldBeaconOfLight(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(BEACON_OF_LIGHT)) return false; - if (ctx.bot.knows_spell(BEACON_OF_VIRTUE)) return false; - GroupMemberSummary const* tank = ctx.group.tank(); - if (!tank || !tank->online) return false; - AuraEntry const* a = ctx.bot.find_aura(BEACON_OF_LIGHT, tank->guid); - return a == nullptr; -} -void DoBeaconOfLight(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* tank = ctx.group.tank()) - e.cast(BEACON_OF_LIGHT, tank->guid); -} - -bool ShouldBeaconOfFaith(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(BEACON_OF_FAITH)) return false; - // Place the second beacon on the second-most-vulnerable melee tank/dps. - auto const* members = ctx.group.members(); - if (!members) return false; - for (auto const& m : *members) { - if (!m.online || m.hp <= 0) continue; - if (m.guid == ctx.bot.raw().guid) continue; - if (ctx.bot.has_aura(BEACON_OF_LIGHT, m.guid)) continue; - if (m.role == Role::Tank || m.role == Role::Dps) { - if (!ctx.bot.has_aura(BEACON_OF_FAITH, m.guid)) return true; - } - } - return false; -} -void DoBeaconOfFaith(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - auto const* members = ctx.group.members(); - if (!members) return; - for (auto const& m : *members) { - if (!m.online || m.hp <= 0) continue; - if (m.guid == ctx.bot.raw().guid) continue; - if (ctx.bot.has_aura(BEACON_OF_LIGHT, m.guid)) continue; - if (m.role != Role::Tank && m.role != Role::Dps) continue; - if (ctx.bot.has_aura(BEACON_OF_FAITH, m.guid)) continue; - e.cast(BEACON_OF_FAITH, m.guid); - return; - } -} - -// Beacon of Virtue (mana, 15s cd, 9s duration): beacon the heal target -// plus injured allies so the following Holy Shock / WoG / LoD transfer. -// Fire whenever two or more allies are hurt so the transfer window -// actually overlaps the heals below it in the ladder. -bool ShouldBeaconOfVirtue(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(BEACON_OF_VIRTUE)) return false; - if (!ctx.bot.is_ready(BEACON_OF_VIRTUE)) return false; - return WoundedFriendCount(ctx, 80) >= 2; -} -void DoBeaconOfVirtue(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(BEACON_OF_VIRTUE, PickHealTarget(ctx).guid); -} - -// ---- Major CDs ---- -bool ShouldAuraMastery(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(AURA_MASTERY)) return false; - if (!ctx.bot.is_ready(AURA_MASTERY)) return false; - return WoundedFriendCount(ctx, 50) >= 2; -} -void DoAuraMastery(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(AURA_MASTERY); } - -// Avenging Wrath 31884 - the spec-tree talent is the cast AND the buff -// aura (384376 is only the rank passive and must not be cast). -bool ShouldAvengingWrath(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(AVENGING_WRATH)) return false; - if (!ctx.bot.is_ready(AVENGING_WRATH)) return false; - return WoundedFriendCount(ctx, 60) >= 2; -} -void DoAvengingWrath(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(AVENGING_WRATH); } - -// Divine Toll 375576 - Holy Shock on up to 5 targets around the heal -// target (each generating Holy Power). -bool ShouldDivineToll(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(DIVINE_TOLL)) return false; - if (!ctx.bot.is_ready(DIVINE_TOLL)) return false; - return WoundedFriendCount(ctx, 70) >= 2; -} -void DoDivineToll(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(DIVINE_TOLL, PickHealTarget(ctx).guid); -} - -bool ShouldTyrsDeliverance(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(TYRS_DELIVERANCE)) return false; - if (!ctx.bot.is_ready(TYRS_DELIVERANCE)) return false; - return WoundedFriendCount(ctx, 80) >= 3; -} -void DoTyrsDeliverance(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(TYRS_DELIVERANCE); } - -// ---- Dispel ---- -// Cleanse (Holy spec spell, replaces Cleanse Toxins): Magic always, -// Poison/Disease once Improved Cleanse is known - see DispelTarget(). -bool ShouldCleanse(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(CLEANSE)) return false; - if (!ctx.bot.is_ready(CLEANSE)) return false; - return DispelTarget(ctx) != nullptr || SelfNeedsDispel(ctx); -} -void DoCleanse(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* t = DispelTarget(ctx)) { - e.cast(CLEANSE, t->guid); - return; - } - if (SelfNeedsDispel(ctx)) - e.cast(CLEANSE, ctx.bot.raw().guid); -} - -// ---- AoE / cone heal ---- -bool ShouldLightOfDawn(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(LIGHT_OF_DAWN)) return false; - if (!ctx.bot.is_ready(LIGHT_OF_DAWN)) return false; - if (HolyPower(ctx) < 3) return false; - return WoundedFriendCount(ctx, 75) >= 2; -} -void DoLightOfDawn(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(LIGHT_OF_DAWN); } - -// ---- Spike heals ---- -bool ShouldHolyShockHeal(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(HOLY_SHOCK)) return false; - if (!ctx.bot.is_ready(HOLY_SHOCK)) return false; - return PickHealTarget(ctx).hp_pct < 100; -} -void DoHolyShockHeal(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(HOLY_SHOCK, PickHealTarget(ctx).guid); -} - -// Word of Glory / Eternal Flame (3 HP) on the heal target. -bool ShouldWordOfGlory(ApPredicateContext const& ctx) -{ - const uint32 id = WogId(ctx); - if (!ctx.bot.knows_spell(id)) return false; - if (!ctx.bot.is_ready(id)) return false; - if (HolyPower(ctx) < 3) return false; - return PickHealTarget(ctx).hp_pct <= 80; -} -void DoWordOfGlory(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(WogId(ctx), PickHealTarget(ctx).guid); -} - -bool ShouldFlashOfLight(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(FLASH_OF_LIGHT)) return false; - return PickHealTarget(ctx).hp_pct <= 50; -} -void DoFlashOfLight(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(FLASH_OF_LIGHT, PickHealTarget(ctx).guid); -} - -bool ShouldHolyLight(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(HOLY_LIGHT)) return false; - if (PickHealTarget(ctx).hp_pct > 85) return false; - if (ctx.bot.is_moving() && !ctx.bot.can_cast_while_moving(HOLY_LIGHT)) return false; - return true; -} -void DoHolyLight(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(HOLY_LIGHT, PickHealTarget(ctx).guid); -} - -// ---- Offensive filler when group is topped (Glimmer / HP gen) ---- -bool ShouldHolyShockDamage(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!GroupTopped(ctx)) return false; - if (!ctx.bot.knows_spell(HOLY_SHOCK)) return false; - if (!ctx.bot.is_ready(HOLY_SHOCK)) return false; - return !ctx.bot.victim().IsEmpty(); -} -void DoHolyShockDamage(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(HOLY_SHOCK, ctx.bot.victim()); -} - -// Judgment: Holy spec spell 275773 (overrides baseline) -> baseline 20271. -bool ShouldJudgment(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (ctx.bot.victim().IsEmpty()) return false; - return PickKnownAndReady(ctx, { JUDGMENT_HOLY, JUDGMENT_BASELINE }) != 0; -} -void DoJudgment(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - uint32 id = PickKnownAndReady(ctx, { JUDGMENT_HOLY, JUDGMENT_BASELINE }); - if (id) e.cast(id, ctx.bot.victim()); -} - -// Hammer of Wrath: execute (<=20%) or any target during Avenging Wrath. -bool ShouldHammerOfWrath(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!GroupTopped(ctx)) return false; - if (!ctx.bot.knows_spell(HAMMER_OF_WRATH)) return false; - if (!ctx.bot.is_ready(HAMMER_OF_WRATH)) return false; - if (ctx.bot.victim().IsEmpty()) return false; - NearbyUnit const* t = ctx.bot.victim_info(); - if (!t || t->max_hp <= 0 || t->hp <= 0) return false; - return (t->hp * 100) / t->max_hp <= 20 - || ctx.bot.has_aura(AVENGING_WRATH); -} -void DoHammerOfWrath(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(HAMMER_OF_WRATH, ctx.bot.victim()); -} - -bool AlwaysAlive(ApPredicateContext const& ctx) { return ctx.bot.is_alive(); } -void DoNothing(ApPredicateContext const&, BotIntentEmitter&) {} - -// Cast-swap shim - Holy Paladin's slow single-target heals. Holy Light -// 2.5s, Flash of Light 1.5s. See ApHealHelpers.h. -bool ShouldCancelHealForSwap(ApPredicateContext const& ctx) -{ - return ShouldCancelHealForSwapImpl(ctx, { HOLY_LIGHT, FLASH_OF_LIGHT }); -} - -// Rule order (top-down). Lay on Hands -> Divine Shield -> Word of Glory -// self -> Hand of Reckoning -> Hammer of Justice -> group saves -> -// beacons -> raid CDs -> dispel -> heals -> offensive filler -> Idle. -ApRule const kRules[] = { - { ShouldCancelHealForSwap, DoCancelHealForSwap, "Cancel heal - swap to lower target" }, - { ShouldDevotionAura, DoDevotionAura, "Devotion Aura" }, - { ShouldLayOnHands, DoLayOnHands, "Lay on Hands (<=15%)" }, - { ShouldDivineShield, DoDivineShield, "Divine Shield (panic)" }, - { ShouldWordOfGlorySelf, DoWordOfGlorySelf, "Word of Glory self (<=50%)" }, - { ShouldHandOfReckoning, DoHandOfReckoning, "Hand of Reckoning (peel)" }, - { ShouldHammerOfJustice, DoHammerOfJustice, "Hammer of Justice (kick)" }, - { ShouldBlindingLight, DoBlindingLight, "Blinding Light (3+ AoE)" }, - { ShouldBlessingOfFreedom, DoBlessingOfFreedom, "Blessing of Freedom (self)" }, - { ShouldDivineProtection, DoDivineProtection, "Divine Protection (<=45%)" }, - { ShouldBlessingOfProtection, DoBlessingOfProtection, "Blessing of Protection" }, - { ShouldBlessingOfSacrifice, DoBlessingOfSacrifice, "BoSac (tank <=30%)" }, - { ShouldBeaconOfLight, DoBeaconOfLight, "Beacon of Light (tank)" }, - { ShouldBeaconOfFaith, DoBeaconOfFaith, "Beacon of Faith (2nd tank)" }, - { ShouldAuraMastery, DoAuraMastery, "Aura Mastery" }, - { ShouldAvengingWrath, DoAvengingWrath, "Avenging Wrath" }, - { ShouldDivineToll, DoDivineToll, "Divine Toll" }, - { ShouldTyrsDeliverance, DoTyrsDeliverance, "Tyr's Deliverance" }, - { ShouldBeaconOfVirtue, DoBeaconOfVirtue, "Beacon of Virtue (2+ wounded)" }, - { ShouldCleanse, DoCleanse, "Cleanse (dispel)" }, - { ShouldLightOfDawn, DoLightOfDawn, "Light of Dawn (2+ wounded)" }, - { ShouldHolyShockHeal, DoHolyShockHeal, "Holy Shock (heal)" }, - { ShouldWordOfGlory, DoWordOfGlory, "Word of Glory (<=80%)" }, - { ShouldFlashOfLight, DoFlashOfLight, "Flash of Light (<=50%)" }, - { ShouldHolyLight, DoHolyLight, "Holy Light (<=85%)" }, - { ShouldJudgment, DoJudgment, "Judgment (filler)" }, - { ShouldHolyShockDamage, DoHolyShockDamage, "Holy Shock damage (filler)" }, - { ShouldHammerOfWrath, DoHammerOfWrath, "Hammer of Wrath (filler)" }, - { AlwaysAlive, DoNothing, "Idle" }, -}; - -} // anonymous - -void RegisterApl_Paladin_Holy() -{ - constexpr uint32 SPEC_PALADIN_HOLY = 65; - RegisterRotation(CLASS_PALADIN, SPEC_PALADIN_HOLY, ApRotation{kRules}); -} - -} // namespace Playerbot::Combat diff --git a/src/modules/PlayerbotV2/Combat/Apl/Apl_Paladin_Protection.cpp b/src/modules/PlayerbotV2/Combat/Apl/Apl_Paladin_Protection.cpp deleted file mode 100644 index bbe33d8699..0000000000 --- a/src/modules/PlayerbotV2/Combat/Apl/Apl_Paladin_Protection.cpp +++ /dev/null @@ -1,528 +0,0 @@ -// Protection Paladin - WoW 12.1.0.69587 (Midnight) rotation. Plate tank -// with Holy Power as the active-mitigation resource (Shield of the -// Righteous), pull + interrupt + cleave from Avenger's Shield, Consecration -// ground tick for AoE threat, Divine Toll for burst Holy Power, and Word of -// Glory as the Holy Power self heal. Lightsmith hero tree adds Holy Bulwark -// / Sacred Weapon armaments. -// -// Survival ladder: Lay on Hands (full heal panic) -> Divine Shield -// (immunity bail) -> Word of Glory self -> Ardent Defender (cheat death) -// -> Guardian of Ancient Kings (50% DR) -> Holy Bulwark (absorb) -> Eye of -// Tyr (25% enemy damage DR). Group utility: Blessing of Sacrifice, -// Blessing of Protection, Blessing of Freedom. Tank duties: Hand of -// Reckoning taunt, Rebuke interrupt, Hammer of Justice fallback, Avenger's -// Shield ranged silence. -// -// ================================================================= -// Validated spell IDs (WoW 12.1.0.69587, kit Apl_Paladin_Protection.md) -// ================================================================= -// 31935 - Avenger's Shield (spec talent [R]) -// 53600 - Shield of the Righteous (baseline L2) -// 53595 - Hammer of the Righteous (spec talent, choice vs Blessed Hammer) -// 204019 - Blessed Hammer (spec talent [R]; replaces HotR) -// 275779 - Judgment (Prot spec spell; overrides 20271) -// 20271 - Judgment (baseline L3; pre-spec fallback) -// 26573 - Consecration (baseline L6) -// 209202 - Eye of Tyr (class baseline; was 387174) -// 31850 - Ardent Defender (spec talent [R]) -// 86659 - Guardian of Ancient Kings (spec talent [R]) -// 432459 - Holy Bulwark (Lightsmith [R]; becomes Sacred Weapon) -// 432472 - Sacred Weapon (Lightsmith; other half of the armament) -// 633 - Lay on Hands (class talent [R]) -// 24275 - Hammer of Wrath (class baseline) -// 96231 - Rebuke (class talent [R]) -// 853 - Hammer of Justice (baseline L5) -// 62124 - Hand of Reckoning (baseline L9) -// 642 - Divine Shield (baseline L10) -// 6940 - Blessing of Sacrifice (class talent [R]) -// 1022 - Blessing of Protection (class talent [R]) -// 1044 - Blessing of Freedom (class talent [R]) -// 465 - Devotion Aura (Auras of the Resolute [R]) -// 31884 - Avenging Wrath (spec talent [R]; cast + buff aura) -// 389539 - Sentinel (spec talent [M]; overrides Avenging Wrath) -// 375576 - Divine Toll (class talent [R]) -// 85673 - Word of Glory (baseline L7) -// 25771 - Forbearance (debuff only - never cast) -// -// ================================================================= -// Skipped spells (and why) -// ================================================================= -// 498 - Divine Protection: Holy spec spell in 12.1; Prot cannot learn it. -// 353367 / 358934 - Aegis of Light: not an active Prot talent in 12.1 -// (only a passive of that name remains); no cast surface. -// 31821 - Aura Mastery: Holy spec talent only in 12.1. -// 203538 - Blessing of Kings / 152262 Seraphim: not in 12.1 SpellName. -// 327193 - Moment of Glory: removed from the Prot tree in 12.1. -// 384376 - Avenging Wrath rank passive, 327980 Consecration rank passive, -// 315921 Word of Glory rank passive, 315867 Judgment passive: -// not castable - a multi-id pick that lists them first stalls -// the rule, so only the real cast ids are used. -// 204018 - Blessing of Spellwarding [M]: shares the BoP cooldown; BoP -// covers the ally-save slot for both builds. -// 213644 - Cleanse Toxins [M] / 115750 Blinding Light [M]: M+-only picks -// the default build does not own; not wired to keep the ladder -// readable. -// 433568 - Rite of Sanctification: pre-pull weapon imbue, not combat. -// 35395 - Crusader Strike: Prot generates HP with Blessed Hammer / -// Hammer of the Righteous; CS stays out of the ladder. -// -// ================================================================= -// Decision tree (top-down) -// ================================================================= -// 0) Aura maintenance: Devotion Aura -// 1) Survival ladder: LoH -> DS -> WoG self -> Ardent Defender -// -> GoAK -> Holy Bulwark -// 2) Tank duty: Hand of Reckoning -// 3) Interrupt: Rebuke -> Hammer of Justice -// 4) Freedom self: rooted / snared -// 5) Group utility: BoSac, BoP -// 6) Major offensive CDs: Avenging Wrath / Sentinel, Divine Toll -// 7) Active mitigation: Shield of the Righteous (HP3) -// 8) Threat/pull: Avenger's Shield (opener + ranged silence) -// 9) Damage: Judgment -> Eye of Tyr -> HoW -> Consecration -// -> Blessed Hammer / HotR -// 10) AutoAttack fallback - -#include "../ApRegistry.h" -#include "../ApRotation.h" -#include "Bot/BotIntentEmitter.h" -#include "Bot/BotSnapshotView.h" -#include "Group/GroupSnapshot.h" -#include "SharedDefines.h" - -#include - -namespace Playerbot::Combat { - -namespace { - -// ---- Spell IDs (WoW 12.1.0.69587, validated against the kit) ---- -constexpr uint32 AVENGERS_SHIELD = 31935; -constexpr uint32 SHIELD_OF_THE_RIGHTEOUS = 53600; -constexpr uint32 HAMMER_OF_THE_RIGHTEOUS = 53595; -constexpr uint32 BLESSED_HAMMER = 204019; // talent [R] - replaces HotR -constexpr uint32 JUDGMENT_PROT = 275779; // Prot spec spell (overrides baseline) -constexpr uint32 JUDGMENT_BASELINE = 20271; -constexpr uint32 CONSECRATION = 26573; // cast + ground aura -constexpr uint32 EYE_OF_TYR = 209202; // 12.1 id (was 387174) -constexpr uint32 ARDENT_DEFENDER = 31850; -constexpr uint32 GUARDIAN_OF_ANCIENT_KINGS = 86659; -constexpr uint32 HOLY_BULWARK = 432459; // Lightsmith [R] - self absorb armament -constexpr uint32 SACRED_WEAPON = 432472; // Lightsmith - Bulwark toggles into this -constexpr uint32 LAY_ON_HANDS = 633; -constexpr uint32 HAMMER_OF_WRATH = 24275; -constexpr uint32 REBUKE = 96231; -constexpr uint32 HAMMER_OF_JUSTICE = 853; -constexpr uint32 HAND_OF_RECKONING = 62124; -constexpr uint32 DIVINE_SHIELD = 642; -constexpr uint32 BLESSING_OF_SACRIFICE = 6940; -constexpr uint32 BLESSING_OF_PROTECTION = 1022; -constexpr uint32 BLESSING_OF_FREEDOM = 1044; -constexpr uint32 DEVOTION_AURA = 465; -constexpr uint32 AVENGING_WRATH = 31884; // cast + buff aura -constexpr uint32 SENTINEL = 389539; // talent [M] - overrides Avenging Wrath -constexpr uint32 DIVINE_TOLL = 375576; // class talent [R] - 5x Avenger's Shield -constexpr uint32 WORD_OF_GLORY = 85673; -constexpr uint32 FORBEARANCE = 25771; // debuff only - -constexpr uint8 POWER_HOLY_POWER_IDX = 9; - -// Mechanic ids (SharedDefines.h) for the Freedom self-cast. -constexpr uint32 MECHANIC_ROOT_ID = 7; -constexpr uint32 MECHANIC_SNARE_ID = 11; - -// ---- Multi-ID helpers ---- -uint32 PickKnownAndReady(ApPredicateContext const& ctx, std::initializer_list ids) -{ - for (uint32 id : ids) - if (ctx.bot.knows_spell(id) && ctx.bot.is_ready(id)) return id; - return 0; -} - -bool HasLiveTarget(ApPredicateContext const& ctx) -{ - return !ctx.bot.victim().IsEmpty(); -} - -bool BossLikeTargetEngaged(ApPredicateContext const& ctx) -{ - constexpr int32 kBossHpThreshold = 5'000'000; - NearbyUnit const* t = ctx.bot.victim_info(); - if (t && t->max_hp >= kBossHpThreshold) return true; - for (auto const& a : ctx.bot.raw().combat.attackers) - if (a.max_hp >= kBossHpThreshold) return true; - return false; -} - -uint8 HolyPower(ApPredicateContext const& ctx) -{ - return static_cast(ctx.bot.power(POWER_HOLY_POWER_IDX)); -} - -// ---- Aura maintenance ---- -bool ShouldDevotionAura(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(DEVOTION_AURA)) return false; - return !ctx.bot.has_aura(DEVOTION_AURA); -} -void DoDevotionAura(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(DEVOTION_AURA); } - -// ---- Survival ladder ---- -bool ShouldLayOnHands(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(LAY_ON_HANDS)) return false; - if (!ctx.bot.is_ready(LAY_ON_HANDS)) return false; - if (ctx.bot.has_aura(FORBEARANCE)) return false; - return ctx.bot.hp_pct() <= 15; -} -void DoLayOnHands(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(LAY_ON_HANDS, ctx.bot.raw().guid); -} - -bool ShouldDivineShield(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(DIVINE_SHIELD)) return false; - if (!ctx.bot.is_ready(DIVINE_SHIELD)) return false; - if (ctx.bot.has_aura(FORBEARANCE)) return false; - if (ctx.bot.hp_pct() > 15) return false; - return !ctx.bot.is_ready(LAY_ON_HANDS); -} -void DoDivineShield(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(DIVINE_SHIELD); } - -// Word of Glory self heal (85673; the Prot "rank 2" 315921 is a passive -// and must not be in the cast list). -bool ShouldWordOfGlorySelf(ApPredicateContext const& ctx) -{ - if (HolyPower(ctx) < 3) return false; - // Emergency-only threshold (<=35%): both WoG-self and Shield of the - // Righteous drain Holy Power, but SotR is ranked below WoG in kRules. - // With the old <=60% gate, a Prot Paladin tanking at normal (<60%) HP - // dumped all HP into WoG every tick and never cast SotR, dropping - // physical active-mitigation uptime to ~zero. Reserve WoG for real - // spikes so SotR wins the Holy Power during normal tanking. - if (ctx.bot.hp_pct() > 35) return false; - return ctx.bot.knows_spell(WORD_OF_GLORY) && ctx.bot.is_ready(WORD_OF_GLORY); -} -void DoWordOfGlorySelf(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(WORD_OF_GLORY, ctx.bot.raw().guid); -} - -bool ShouldArdentDefender(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(ARDENT_DEFENDER)) return false; - if (!ctx.bot.is_ready(ARDENT_DEFENDER)) return false; - return ctx.bot.hp_pct() <= 30; -} -void DoArdentDefender(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(ARDENT_DEFENDER); } - -bool ShouldGuardianOfAncientKings(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(GUARDIAN_OF_ANCIENT_KINGS)) return false; - if (!ctx.bot.is_ready(GUARDIAN_OF_ANCIENT_KINGS)) return false; - return ctx.bot.hp_pct() <= 50; -} -void DoGuardianOfAncientKings(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(GUARDIAN_OF_ANCIENT_KINGS); } - -// Holy Bulwark (Lightsmith [R]) - self absorb armament; the button -// toggles into Sacred Weapon after use, so both ids are candidates and -// whichever is currently castable goes on the bot. Mid-tier defensive -// that fills the gap when AD/GoAK are down. -bool ShouldHolyArmament(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (PickKnownAndReady(ctx, { HOLY_BULWARK, SACRED_WEAPON }) == 0) return false; - return ctx.bot.hp_pct() <= 75; -} -void DoHolyArmament(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - uint32 id = PickKnownAndReady(ctx, { HOLY_BULWARK, SACRED_WEAPON }); - if (id) e.cast(id, ctx.bot.raw().guid); -} - -// Blessing of Freedom on self when rooted / snared - a tank that cannot -// reposition loses the pull. -bool ShouldBlessingOfFreedom(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(BLESSING_OF_FREEDOM)) return false; - if (!ctx.bot.is_ready(BLESSING_OF_FREEDOM)) return false; - if (ctx.bot.has_aura(BLESSING_OF_FREEDOM)) return false; - return ctx.bot.has_mechanic(MECHANIC_ROOT_ID) || ctx.bot.has_mechanic(MECHANIC_SNARE_ID); -} -void DoBlessingOfFreedom(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(BLESSING_OF_FREEDOM, ctx.bot.raw().guid); -} - -// ---- Tank utility ---- -bool ShouldHandOfReckoning(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(HAND_OF_RECKONING)) return false; - if (!ctx.bot.is_ready(HAND_OF_RECKONING)) return false; - return ctx.bot.untaunted_enemy() != nullptr; -} -void DoHandOfReckoning(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* t = ctx.bot.untaunted_enemy()) - e.cast(HAND_OF_RECKONING, t->guid); -} - -// ---- Interrupt / CC ---- -bool ShouldRebuke(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(REBUKE)) return false; - if (!ctx.bot.is_ready(REBUKE)) return false; - const bool pvp = ctx.pvp.in_battleground || ctx.pvp.in_arena; - return ctx.bot.kick_target(pvp, 5.0f) != nullptr; -} -void DoRebuke(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - const bool pvp = ctx.pvp.in_battleground || ctx.pvp.in_arena; - if (auto const* c = ctx.bot.kick_target(pvp, 5.0f)) - e.cast(REBUKE, c->guid); -} - -bool ShouldHammerOfJustice(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(HAMMER_OF_JUSTICE)) return false; - if (!ctx.bot.is_ready(HAMMER_OF_JUSTICE)) return false; - if (ctx.bot.is_ready(REBUKE)) return false; - const bool pvp = ctx.pvp.in_battleground || ctx.pvp.in_arena; - return ctx.bot.kick_target(pvp, 10.0f) != nullptr; -} -void DoHammerOfJustice(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - const bool pvp = ctx.pvp.in_battleground || ctx.pvp.in_arena; - if (auto const* c = ctx.bot.kick_target(pvp, 10.0f)) - e.cast(HAMMER_OF_JUSTICE, c->guid); -} - -// ---- Group utility ---- -bool ShouldBlessingOfSacrifice(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(BLESSING_OF_SACRIFICE)) return false; - if (!ctx.bot.is_ready(BLESSING_OF_SACRIFICE)) return false; - if (ctx.bot.hp_pct() <= 70) return false; - auto const* low = ctx.group.lowest_hp_on_map(ctx.bot.map_id(), Role::Unknown, ctx.bot.raw().position.x, ctx.bot.raw().position.y, ctx.bot.raw().position.z, 45.0f); - return low && low->online && low->max_hp > 0 - && (low->hp * 100) / low->max_hp <= 30 - && low->guid != ctx.bot.raw().guid; -} -void DoBlessingOfSacrifice(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* low = ctx.group.lowest_hp_on_map(ctx.bot.map_id(), Role::Unknown, ctx.bot.raw().position.x, ctx.bot.raw().position.y, ctx.bot.raw().position.z, 45.0f)) - e.cast(BLESSING_OF_SACRIFICE, low->guid); -} - -bool ShouldBlessingOfProtection(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(BLESSING_OF_PROTECTION)) return false; - if (!ctx.bot.is_ready(BLESSING_OF_PROTECTION)) return false; - if (auto const* low = ctx.group.lowest_hp_on_map(ctx.bot.map_id(), Role::Unknown, ctx.bot.raw().position.x, ctx.bot.raw().position.y, ctx.bot.raw().position.z, 45.0f)) { - if (low->role != Role::Tank && low->online && low->hp > 0 - && (low->hp * 100) / low->max_hp <= 25 - && !ctx.bot.has_aura(FORBEARANCE, low->guid)) - return true; - } - return false; -} -void DoBlessingOfProtection(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* low = ctx.group.lowest_hp_on_map(ctx.bot.map_id(), Role::Unknown, ctx.bot.raw().position.x, ctx.bot.raw().position.y, ctx.bot.raw().position.z, 45.0f)) - e.cast(BLESSING_OF_PROTECTION, low->guid); -} - -// ---- Major offensive cooldowns ---- -// Avenging Wrath 31884 is overridden by Sentinel 389539 when that talent -// is known ([M] build); cast whichever the bot actually has. 384376 is -// only the rank passive and is never cast. -uint32 WingsId(ApPredicateContext const& ctx) -{ - return ctx.bot.knows_spell(SENTINEL) ? SENTINEL : AVENGING_WRATH; -} - -bool ShouldAvengingWrath(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - const uint32 id = WingsId(ctx); - if (!ctx.bot.knows_spell(id) || !ctx.bot.is_ready(id)) return false; - return BossLikeTargetEngaged(ctx) || ctx.bot.attackers_count() >= 3; -} -void DoAvengingWrath(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(WingsId(ctx)); -} - -// Divine Toll - Avenger's Shield on up to 5 enemies, each generating Holy -// Power. Fire on a pull with 2+ attackers or when starved for HP. -bool ShouldDivineToll(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(DIVINE_TOLL)) return false; - if (!ctx.bot.is_ready(DIVINE_TOLL)) return false; - return ctx.bot.attackers_count() >= 2 || HolyPower(ctx) <= 1; -} -void DoDivineToll(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(DIVINE_TOLL, ctx.bot.victim()); -} - -// ---- Active mitigation ---- -bool ShouldShieldOfTheRighteous(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(SHIELD_OF_THE_RIGHTEOUS)) return false; - if (!ctx.bot.is_ready(SHIELD_OF_THE_RIGHTEOUS)) return false; - return HolyPower(ctx) >= 3; -} -void DoShieldOfTheRighteous(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(SHIELD_OF_THE_RIGHTEOUS); } - -// ---- Threat / damage ---- -bool ShouldAvengersShield(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(AVENGERS_SHIELD)) return false; - return ctx.bot.is_ready(AVENGERS_SHIELD); -} -void DoAvengersShield(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(AVENGERS_SHIELD, ctx.bot.victim()); -} - -// Eye of Tyr 209202 - AoE Holy damage + 25% less damage dealt to the -// bot by every enemy hit for 9s. Cleave threat on 2+, or a defensive -// when the tank is getting low even on a single target. -bool ShouldEyeOfTyr(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(EYE_OF_TYR)) return false; - if (!ctx.bot.is_ready(EYE_OF_TYR)) return false; - return ctx.bot.enemies_within(8.0f) >= 2 || ctx.bot.hp_pct() <= 60; -} -void DoEyeOfTyr(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(EYE_OF_TYR); } - -// Hammer of Wrath: execute (<=20%) or any target during Wings. -bool ShouldHammerOfWrath(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(HAMMER_OF_WRATH)) return false; - if (!ctx.bot.is_ready(HAMMER_OF_WRATH)) return false; - NearbyUnit const* t = ctx.bot.victim_info(); - if (!t || t->max_hp <= 0 || t->hp <= 0) return false; - return (t->hp * 100) / t->max_hp <= 20 - || ctx.bot.has_aura(AVENGING_WRATH) - || ctx.bot.has_aura(SENTINEL); -} -void DoHammerOfWrath(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(HAMMER_OF_WRATH, ctx.bot.victim()); -} - -// Judgment: Prot spec spell 275779 (overrides baseline) -> baseline 20271. -bool ShouldJudgment(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - return PickKnownAndReady(ctx, { JUDGMENT_PROT, JUDGMENT_BASELINE }) != 0; -} -void DoJudgment(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - uint32 id = PickKnownAndReady(ctx, { JUDGMENT_PROT, JUDGMENT_BASELINE }); - if (id) e.cast(id, ctx.bot.victim()); -} - -// Consecration 26573 - maintain the ground tick (the 12.1 Prot "rank 3" -// 327980 is a passive cooldown reduction, not a separate cast). -bool ShouldConsecration(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(CONSECRATION)) return false; - if (!ctx.bot.is_ready(CONSECRATION)) return false; - return !ctx.bot.has_aura(CONSECRATION); -} -void DoConsecration(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(CONSECRATION); } - -bool ShouldBlessedHammer(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(BLESSED_HAMMER)) return false; - return ctx.bot.is_ready(BLESSED_HAMMER); -} -void DoBlessedHammer(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(BLESSED_HAMMER); } - -bool ShouldHammerOfTheRighteous(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (ctx.bot.knows_spell(BLESSED_HAMMER)) return false; - if (!ctx.bot.knows_spell(HAMMER_OF_THE_RIGHTEOUS)) return false; - return ctx.bot.is_ready(HAMMER_OF_THE_RIGHTEOUS); -} -void DoHammerOfTheRighteous(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(HAMMER_OF_THE_RIGHTEOUS, ctx.bot.victim()); -} - -bool AlwaysInCombat(ApPredicateContext const& ctx) { return ctx.bot.in_combat(); } -void DoAutoAttack(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - ObjectGuid t = ctx.bot.victim(); - if (t.IsEmpty()) t = ctx.bot.current_target(); - // Retaliate fallback (2026-06-17): in combat with no victim/target the bot - // looped "Engage auto attack" as a no-op while taking damage (the CombatLoop - // wedge cluster). Engage whatever is meleeing us (attackers are adjacent and - // reachable), else the nearest visible enemy, so combat actually resolves. - // Strictly additive: only runs when no target was already selected. - if (t.IsEmpty()) - for (auto const& u : ctx.bot.attackers()) - if (u.hp > 0) { t = u.guid; break; } - if (t.IsEmpty()) - for (auto const& u : ctx.bot.nearby_enemies()) - if (u.hp > 0 && u.in_los) { t = u.guid; break; } - if (!t.IsEmpty()) e.start_attack(t); -} - -// Rule order: cross-spec paladin ladder first (LoH -> DS -> WoG self -> -// HandOfReckoning -> HoJ -> Judgment) then Prot-specific (active -// mitigation + threat + AoE + filler). -ApRule const kRules[] = { - { ShouldDevotionAura, DoDevotionAura, "Devotion Aura" }, - { ShouldLayOnHands, DoLayOnHands, "Lay on Hands (<=15%)" }, - { ShouldDivineShield, DoDivineShield, "Divine Shield (panic)" }, - { ShouldWordOfGlorySelf, DoWordOfGlorySelf, "Word of Glory (self heal)" }, - { ShouldHandOfReckoning, DoHandOfReckoning, "Hand of Reckoning (taunt)" }, - { ShouldRebuke, DoRebuke, "Rebuke (interrupt)" }, - { ShouldHammerOfJustice, DoHammerOfJustice, "Hammer of Justice (fb)" }, - { ShouldArdentDefender, DoArdentDefender, "Ardent Defender (<=30%)" }, - { ShouldGuardianOfAncientKings,DoGuardianOfAncientKings,"Guardian of Ancient Kings" }, - { ShouldHolyArmament, DoHolyArmament, "Holy Bulwark (<=75%)" }, - { ShouldBlessingOfFreedom, DoBlessingOfFreedom, "Blessing of Freedom (self)"}, - { ShouldBlessingOfSacrifice, DoBlessingOfSacrifice, "BoSac (low ally)" }, - { ShouldBlessingOfProtection, DoBlessingOfProtection, "Blessing of Protection" }, - { ShouldAvengingWrath, DoAvengingWrath, "Avenging Wrath / Sentinel" }, - { ShouldDivineToll, DoDivineToll, "Divine Toll" }, - { ShouldShieldOfTheRighteous, DoShieldOfTheRighteous, "Shield of the Righteous" }, - { ShouldAvengersShield, DoAvengersShield, "Avenger's Shield" }, - { ShouldJudgment, DoJudgment, "Judgment" }, - { ShouldEyeOfTyr, DoEyeOfTyr, "Eye of Tyr (AoE / DR)" }, - { ShouldHammerOfWrath, DoHammerOfWrath, "Hammer of Wrath" }, - { ShouldConsecration, DoConsecration, "Consecration (maintain)" }, - { ShouldBlessedHammer, DoBlessedHammer, "Blessed Hammer" }, - { ShouldHammerOfTheRighteous, DoHammerOfTheRighteous, "Hammer of the Righteous" }, - { AlwaysInCombat, DoAutoAttack, "Engage auto attack" }, -}; - -} // anonymous - -void RegisterApl_Paladin_Protection() -{ - constexpr uint32 SPEC_PALADIN_PROTECTION = 66; - RegisterRotation(CLASS_PALADIN, SPEC_PALADIN_PROTECTION, ApRotation{kRules}); -} - -} // namespace Playerbot::Combat diff --git a/src/modules/PlayerbotV2/Combat/Apl/Apl_Paladin_Retribution.cpp b/src/modules/PlayerbotV2/Combat/Apl/Apl_Paladin_Retribution.cpp deleted file mode 100644 index dbeec47a17..0000000000 --- a/src/modules/PlayerbotV2/Combat/Apl/Apl_Paladin_Retribution.cpp +++ /dev/null @@ -1,508 +0,0 @@ -// Retribution Paladin - WoW 12.1.0.69587 (Midnight) rotation. Two-handed -// melee with Holy Power as the spending resource. Generators: Judgment, -// Blade of Justice, Wake of Ashes, Divine Toll (5x Judgment), Hammer of -// Wrath (execute / during Avenging Wrath), Crusader Strike (only when -// Crusading Strikes is NOT taken - the [R] build turns CS into the auto -// attack). Spenders: Final Verdict (overrides Templar's Verdict, 3 HP), -// Divine Storm (AoE, 3 HP), Word of Glory / Eternal Flame (heal, 3 HP). -// -// Layered survival: Lay on Hands (full heal panic) -> Divine Shield -// (immunity bail) -> WoG/EF self -> Divine Protection (Ret spec 403876; -// with Shield of Vengeance [R] it also fires the absorb). Group utility: -// Blessing of Sacrifice, Blessing of Freedom, Blessing of Protection, -// Devotion Aura, Hand of Reckoning (peel). CC: Rebuke interrupt, Hammer of -// Justice stun, Blinding Light. Major CDs: Avenging Wrath (Crusade is a -// passive haste rider in 12.1), Execution Sentence, Divine Toll. -// -// ================================================================= -// Validated spell IDs (WoW 12.1.0.69587, kit Apl_Paladin_Retribution.md) -// ================================================================= -// 20271 - Judgment (baseline L3; no Ret spec override) -// 35395 - Crusader Strike (baseline L1; replaced by Crusading Strikes [R]) -// 404542 - Crusading Strikes (passive [R] - knows_spell gate only) -// 184575 - Blade of Justice (spec talent [R]) -// 24275 - Hammer of Wrath (class baseline) -// 255937 - Wake of Ashes (spec talent [R]) -// 85256 - Templar's Verdict (spec spell L10; overridden by 383328) -// 383328 - Final Verdict (spec talent [R]; replaces TV) -// 53385 - Divine Storm (spec talent [R]) -// 343527 - Execution Sentence (spec talent [R]; no HP cost in 12.1) -// 375576 - Divine Toll (class talent [R]) -// 31884 - Avenging Wrath (spec talent [R]; cast + buff aura) -// 96231 - Rebuke (class talent [R]) -// 853 - Hammer of Justice (baseline L5) -// 115750 - Blinding Light (class talent [M]) -// 633 - Lay on Hands (class talent [R]) -// 642 - Divine Shield (baseline L10) -// 403876 - Divine Protection (Ret spec spell L10) -// 85673 - Word of Glory (baseline L7) -// 156322 - Eternal Flame (Herald of the Sun [R] - overrides WoG) -// 25771 - Forbearance (debuff only - never cast) -// 6940 - Blessing of Sacrifice (class talent [R]) -// 1022 - Blessing of Protection (class talent [R]) -// 1044 - Blessing of Freedom (class talent [R]) -// 62124 - Hand of Reckoning (baseline L9) -// 465 - Devotion Aura (Auras of the Resolute [R]) -// -// ================================================================= -// Skipped spells (and why) -// ================================================================= -// 184662 - Shield of Vengeance: no longer a cast; 1261562 is a passive -// [R] that makes Divine Protection fire the absorb. -// 343721 - Final Reckoning: only the Execution Sentence damage sub-spell -// remains under this id in 12.1; not castable. -// 231895 - Crusade: the 12.1 Crusade is passive 1253598 (haste during -// Avenging Wrath); Avenging Wrath 31884 is the cast. -// 384376 - Avenging Wrath rank passive / 342348 Crusader Strike rank -// passive / 315867 Judgment passive: not castable, would hijack -// a multi-id pick and stall the rule. -// 275773 - Judgment (Holy spec spell): not learnable by Ret. -// 20066 - Repentance / 203538 Blessing of Kings / 152262 Seraphim: -// gone from the game or not available to Ret in 12.1. -// 404834 - Consecrated Blade: passive proc, not cast. -// 498 - Divine Protection (Holy): Ret casts the spec spell 403876. -// 213644 - Cleanse Toxins [M]: M+-only utility, not wired. -// 183435 - Retribution Aura: Devotion Aura is the maintained aura. -// 190784 - Divine Steed / 433568 Rites: movement / pre-pull imbue. - -#include "../ApRegistry.h" -#include "../ApRotation.h" -#include "Bot/BotIntentEmitter.h" -#include "Bot/BotSnapshotView.h" -#include "Group/GroupSnapshot.h" -#include "SharedDefines.h" - -namespace Playerbot::Combat { - -namespace { - -// ---- Spell IDs (WoW 12.1.0.69587, validated against the kit) ---- -constexpr uint32 JUDGMENT = 20271; // baseline; Ret has no spec override -constexpr uint32 CRUSADER_STRIKE = 35395; // baseline; replaced by Crusading Strikes [R] -constexpr uint32 CRUSADING_STRIKES = 404542; // passive [R] - CS becomes the auto attack -constexpr uint32 BLADE_OF_JUSTICE = 184575; -constexpr uint32 HAMMER_OF_WRATH = 24275; -constexpr uint32 WAKE_OF_ASHES = 255937; -constexpr uint32 TEMPLARS_VERDICT = 85256; -constexpr uint32 FINAL_VERDICT = 383328; // talent [R] - overrides Templar's Verdict -constexpr uint32 DIVINE_STORM = 53385; -constexpr uint32 EXECUTION_SENTENCE = 343527; -constexpr uint32 DIVINE_TOLL = 375576; // class talent [R] - 5x Judgment -constexpr uint32 AVENGING_WRATH = 31884; // cast + buff aura -constexpr uint32 REBUKE = 96231; -constexpr uint32 HAMMER_OF_JUSTICE = 853; // 6sec stun -constexpr uint32 BLINDING_LIGHT = 115750; // talent [M] - AoE disorient -constexpr uint32 LAY_ON_HANDS = 633; -constexpr uint32 DIVINE_SHIELD = 642; -constexpr uint32 DIVINE_PROTECTION = 403876; // Ret spec spell (+Shield of Vengeance [R]) -constexpr uint32 WORD_OF_GLORY = 85673; -constexpr uint32 ETERNAL_FLAME = 156322; // Herald of the Sun [R] - overrides WoG -constexpr uint32 FORBEARANCE = 25771; // debuff only -constexpr uint32 BLESSING_SACRIFICE = 6940; -constexpr uint32 BLESSING_PROTECTION = 1022; -constexpr uint32 BLESSING_FREEDOM = 1044; -constexpr uint32 HAND_OF_RECKONING = 62124; -constexpr uint32 DEVOTION_AURA = 465; - -// Holy Power lives in POWER_HOLY_POWER index of the power array. -constexpr uint8 POWER_HOLY_POWER_IDX = 9; - -// Mechanic ids (SharedDefines.h) for the Freedom self-cast. -constexpr uint32 MECHANIC_ROOT_ID = 7; -constexpr uint32 MECHANIC_SNARE_ID = 11; - -bool HasLiveTarget(ApPredicateContext const& ctx) -{ - return !ctx.bot.victim().IsEmpty(); -} - -bool BossLikeTargetEngaged(ApPredicateContext const& ctx) -{ - constexpr int32 kBossHpThreshold = 5'000'000; - NearbyUnit const* t = ctx.bot.victim_info(); - if (t && t->max_hp >= kBossHpThreshold) return true; - for (auto const& a : ctx.bot.raw().combat.attackers) - if (a.max_hp >= kBossHpThreshold) return true; - return false; -} - -bool TargetExecuteRange(ApPredicateContext const& ctx) -{ - NearbyUnit const* t = ctx.bot.victim_info(); - if (!t || t->max_hp <= 0 || t->hp <= 0) return false; - return (t->hp * 100) / t->max_hp <= 20; -} - -uint8 HolyPower(ApPredicateContext const& ctx) -{ - return static_cast(ctx.bot.power(POWER_HOLY_POWER_IDX)); -} - -// Talent overrides: cast whichever id the bot actually owns. -uint32 WogId(ApPredicateContext const& ctx) -{ - return ctx.bot.knows_spell(ETERNAL_FLAME) ? ETERNAL_FLAME : WORD_OF_GLORY; -} -uint32 VerdictId(ApPredicateContext const& ctx) -{ - return ctx.bot.knows_spell(FINAL_VERDICT) ? FINAL_VERDICT : TEMPLARS_VERDICT; -} - -// ---- Aura maintenance ---- -bool ShouldDevotionAura(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(DEVOTION_AURA)) return false; - return !ctx.bot.has_aura(DEVOTION_AURA); -} -void DoDevotionAura(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(DEVOTION_AURA); } - -// ---- Survival ---- -bool ShouldLayOnHands(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(LAY_ON_HANDS)) return false; - if (!ctx.bot.is_ready(LAY_ON_HANDS)) return false; - if (ctx.bot.has_aura(FORBEARANCE)) return false; - return ctx.bot.hp_pct() <= 15; -} -void DoLayOnHands(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(LAY_ON_HANDS, ctx.bot.raw().guid); -} - -bool ShouldDivineShield(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(DIVINE_SHIELD)) return false; - if (!ctx.bot.is_ready(DIVINE_SHIELD)) return false; - if (ctx.bot.has_aura(FORBEARANCE)) return false; - // Bail at sub-15% if Lay on Hands is on cooldown. - return ctx.bot.hp_pct() <= 15 && !ctx.bot.is_ready(LAY_ON_HANDS); -} -void DoDivineShield(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(DIVINE_SHIELD); } - -// Word of Glory / Eternal Flame self heal (3 HP). -bool ShouldWordOfGlorySelf(ApPredicateContext const& ctx) -{ - const uint32 id = WogId(ctx); - if (!ctx.bot.knows_spell(id)) return false; - if (!ctx.bot.is_ready(id)) return false; - if (HolyPower(ctx) < 3) return false; - return ctx.bot.hp_pct() <= 50; -} -void DoWordOfGlorySelf(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(WogId(ctx), ctx.bot.raw().guid); -} - -// Divine Protection 403876 - all-school DR, usable while stunned; with -// the Shield of Vengeance passive [R] it also pops the absorb, so it is -// the Ret bot's main mid-fight defensive. -bool ShouldDivineProtection(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(DIVINE_PROTECTION)) return false; - if (!ctx.bot.is_ready(DIVINE_PROTECTION)) return false; - if (ctx.bot.has_aura(DIVINE_PROTECTION)) return false; - return ctx.bot.hp_pct() <= 60; -} -void DoDivineProtection(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(DIVINE_PROTECTION); } - -// Blessing of Freedom on self when rooted / snared - melee that cannot -// reach the target does no damage. -bool ShouldBlessingOfFreedom(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(BLESSING_FREEDOM)) return false; - if (!ctx.bot.is_ready(BLESSING_FREEDOM)) return false; - if (ctx.bot.has_aura(BLESSING_FREEDOM)) return false; - return ctx.bot.has_mechanic(MECHANIC_ROOT_ID) || ctx.bot.has_mechanic(MECHANIC_SNARE_ID); -} -void DoBlessingOfFreedom(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(BLESSING_FREEDOM, ctx.bot.raw().guid); -} - -// ---- Group utility ---- -bool ShouldBlessingOfSacrifice(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(BLESSING_SACRIFICE)) return false; - if (!ctx.bot.is_ready(BLESSING_SACRIFICE)) return false; - if (ctx.bot.hp_pct() <= 50) return false; // don't trade hp when ours is low - if (auto const* tank = ctx.group.tank()) - return tank->online && tank->hp > 0 && (tank->hp * 100) / tank->max_hp <= 35; - return false; -} -void DoBlessingOfSacrifice(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* tank = ctx.group.tank()) - e.cast(BLESSING_SACRIFICE, tank->guid); -} - -bool ShouldBlessingOfProtection(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(BLESSING_PROTECTION)) return false; - if (!ctx.bot.is_ready(BLESSING_PROTECTION)) return false; - // Pop on a non-tank ally taking heavy melee damage and at <=25%. - if (auto const* low = ctx.group.lowest_hp_on_map(ctx.bot.map_id(), Role::Unknown, ctx.bot.raw().position.x, ctx.bot.raw().position.y, ctx.bot.raw().position.z, 45.0f)) { - if (low->online && low->hp > 0 && low->role != Role::Tank) { - int32 pct = (low->hp * 100) / low->max_hp; - if (pct <= 25 && !ctx.bot.has_aura(FORBEARANCE, low->guid)) - return true; - } - } - return false; -} -void DoBlessingOfProtection(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* low = ctx.group.lowest_hp_on_map(ctx.bot.map_id(), Role::Unknown, ctx.bot.raw().position.x, ctx.bot.raw().position.y, ctx.bot.raw().position.z, 45.0f)) - e.cast(BLESSING_PROTECTION, low->guid); -} - -bool ShouldHandOfReckoning(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(HAND_OF_RECKONING)) return false; - if (!ctx.bot.is_ready(HAND_OF_RECKONING)) return false; - // Use as a peel - pull an add off a low-HP healer. - auto const* m = ctx.group.lowest_hp_on_map(ctx.bot.map_id(), Role::Healer, ctx.bot.raw().position.x, ctx.bot.raw().position.y, ctx.bot.raw().position.z, 45.0f); - if (!m || !m->online || m->hp <= 0) return false; - if ((m->hp * 100) / m->max_hp > 50) return false; - return ctx.bot.untaunted_enemy(40.f) != nullptr; -} -void DoHandOfReckoning(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* t = ctx.bot.untaunted_enemy(40.f)) - e.cast(HAND_OF_RECKONING, t->guid); -} - -// ---- Interrupt / CC ---- -bool ShouldRebuke(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(REBUKE)) return false; - if (!ctx.bot.is_ready(REBUKE)) return false; - const bool pvp = ctx.pvp.in_battleground || ctx.pvp.in_arena; - return ctx.bot.kick_target(pvp, 5.0f) != nullptr; -} -void DoRebuke(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - const bool pvp = ctx.pvp.in_battleground || ctx.pvp.in_arena; - if (auto const* c = ctx.bot.kick_target(pvp, 5.0f)) - e.cast(REBUKE, c->guid); -} - -// HoJ as PvP kick-with-stun: prefer enemy healer (friendly-target casts the -// regular interrupt selector misses), then any interruptible enemy caster. -NearbyUnit const* PickHammerOfJusticeTarget(ApPredicateContext const& ctx) -{ - if (ctx.pvp.in_battleground || ctx.pvp.in_arena) - if (auto const* h = ctx.bot.enemy_healer_to_interrupt(10.0f)) - return h; - return ctx.bot.interruptible_caster(); -} - -bool ShouldHammerOfJustice(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(HAMMER_OF_JUSTICE)) return false; - if (!ctx.bot.is_ready(HAMMER_OF_JUSTICE)) return false; - if (ctx.bot.is_ready(REBUKE)) return false; - return PickHammerOfJusticeTarget(ctx) != nullptr; -} -void DoHammerOfJustice(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* c = PickHammerOfJusticeTarget(ctx)) - e.cast(HAMMER_OF_JUSTICE, c->guid); -} - -bool ShouldBlindingLight(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(BLINDING_LIGHT)) return false; - if (!ctx.bot.is_ready(BLINDING_LIGHT)) return false; - return ctx.bot.enemies_within(10.0f) >= 3 && ctx.bot.hp_pct() <= 50; -} -void DoBlindingLight(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(BLINDING_LIGHT); } - -// ---- Major offensive cooldowns ---- -// Avenging Wrath 31884 is the cast AND the buff aura (384376 is only the -// rank passive; Crusade 1253598 is a passive haste rider in 12.1). -bool ShouldAvengingWrath(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(AVENGING_WRATH)) return false; - if (!ctx.bot.is_ready(AVENGING_WRATH)) return false; - return BossLikeTargetEngaged(ctx) || ctx.bot.enemies_within(10.0f) >= 3; -} -void DoAvengingWrath(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(AVENGING_WRATH); } - -// Execution Sentence: 60s cd, no Holy Power cost in 12.1 - fire on -// cooldown against the current target. -bool ShouldExecutionSentence(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(EXECUTION_SENTENCE)) return false; - return ctx.bot.is_ready(EXECUTION_SENTENCE); -} -void DoExecutionSentence(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(EXECUTION_SENTENCE, ctx.bot.victim()); -} - -// Divine Toll - Judgment on up to 5 enemies, each generating Holy Power. -// Use it as a burst generator when low on HP. -bool ShouldDivineToll(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(DIVINE_TOLL)) return false; - if (!ctx.bot.is_ready(DIVINE_TOLL)) return false; - return HolyPower(ctx) <= 2; -} -void DoDivineToll(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(DIVINE_TOLL, ctx.bot.victim()); -} - -// ---- Generators / spenders ---- -bool ShouldHammerOfWrath(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(HAMMER_OF_WRATH)) return false; - if (!ctx.bot.is_ready(HAMMER_OF_WRATH)) return false; - return TargetExecuteRange(ctx) - || ctx.bot.has_aura(AVENGING_WRATH); -} -void DoHammerOfWrath(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(HAMMER_OF_WRATH, ctx.bot.victim()); -} - -bool ShouldWakeOfAshes(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(WAKE_OF_ASHES)) return false; - if (!ctx.bot.is_ready(WAKE_OF_ASHES)) return false; - return HolyPower(ctx) <= 2; // burst generator - don't overcap -} -void DoWakeOfAshes(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(WAKE_OF_ASHES, ctx.bot.victim()); -} - -bool ShouldDivineStorm(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(DIVINE_STORM)) return false; - if (!ctx.bot.is_ready(DIVINE_STORM)) return false; - if (HolyPower(ctx) < 3) return false; - return ctx.aoe_preference || - ctx.bot.attackers_count() >= 2 || ctx.bot.enemies_within(8.0f) >= 2; -} -void DoDivineStorm(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(DIVINE_STORM); } - -// Templar's Verdict / Final Verdict (3 HP single-target spender). -bool ShouldTemplarsVerdict(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - const uint32 id = VerdictId(ctx); - if (!ctx.bot.knows_spell(id)) return false; - if (!ctx.bot.is_ready(id)) return false; - return HolyPower(ctx) >= 3; -} -void DoTemplarsVerdict(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(VerdictId(ctx), ctx.bot.victim()); -} - -bool ShouldBladeOfJustice(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(BLADE_OF_JUSTICE)) return false; - return ctx.bot.is_ready(BLADE_OF_JUSTICE); -} -void DoBladeOfJustice(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(BLADE_OF_JUSTICE, ctx.bot.victim()); -} - -// Judgment 20271 - Ret has no spec override in 12.1. -bool ShouldJudgment(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(JUDGMENT)) return false; - return ctx.bot.is_ready(JUDGMENT); -} -void DoJudgment(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(JUDGMENT, ctx.bot.victim()); -} - -// Crusader Strike 35395 - only for bots WITHOUT Crusading Strikes; the -// [R] build converts CS into the auto attack and the button disappears. -bool ShouldCrusaderStrike(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (ctx.bot.knows_spell(CRUSADING_STRIKES)) return false; - if (!ctx.bot.knows_spell(CRUSADER_STRIKE)) return false; - return ctx.bot.is_ready(CRUSADER_STRIKE); -} -void DoCrusaderStrike(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(CRUSADER_STRIKE, ctx.bot.victim()); -} - -bool AlwaysInCombat(ApPredicateContext const& ctx) { return ctx.bot.in_combat(); } -void DoAutoAttack(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - ObjectGuid t = ctx.bot.victim(); - if (t.IsEmpty()) t = ctx.bot.current_target(); - // Retaliate fallback (2026-06-17): in combat with no victim/target the bot - // looped "Engage auto attack" as a no-op while taking damage (the CombatLoop - // wedge cluster). Engage whatever is meleeing us (attackers are adjacent and - // reachable), else the nearest visible enemy, so combat actually resolves. - // Strictly additive: only runs when no target was already selected. - if (t.IsEmpty()) - for (auto const& u : ctx.bot.attackers()) - if (u.hp > 0) { t = u.guid; break; } - if (t.IsEmpty()) - for (auto const& u : ctx.bot.nearby_enemies()) - if (u.hp > 0 && u.in_los) { t = u.guid; break; } - if (!t.IsEmpty()) e.start_attack(t); -} - -// Rule order: cross-spec ladder first (LoH -> DS -> WoG self -> -// HandOfReckoning -> HoJ -> Judgment) then Ret-specific spenders / -// generators / CDs. -ApRule const kRules[] = { - { ShouldDevotionAura, DoDevotionAura, "Devotion Aura" }, - { ShouldLayOnHands, DoLayOnHands, "Lay on Hands (<=15%)" }, - { ShouldDivineShield, DoDivineShield, "Divine Shield (panic)" }, - { ShouldWordOfGlorySelf, DoWordOfGlorySelf, "Word of Glory (self heal)" }, - { ShouldHandOfReckoning, DoHandOfReckoning, "Hand of Reckoning (peel)" }, - { ShouldRebuke, DoRebuke, "Rebuke (interrupt)" }, - { ShouldHammerOfJustice, DoHammerOfJustice, "Hammer of Justice (fb)" }, - { ShouldBlindingLight, DoBlindingLight, "Blinding Light (3+ AoE)" }, - { ShouldBlessingOfFreedom, DoBlessingOfFreedom, "Blessing of Freedom (self)" }, - { ShouldDivineProtection, DoDivineProtection, "Divine Protection (<=60%)" }, - { ShouldBlessingOfSacrifice, DoBlessingOfSacrifice, "Blessing of Sacrifice (tank)"}, - { ShouldBlessingOfProtection, DoBlessingOfProtection, "Blessing of Protection" }, - { ShouldJudgment, DoJudgment, "Judgment" }, - { ShouldAvengingWrath, DoAvengingWrath, "Avenging Wrath" }, - { ShouldExecutionSentence, DoExecutionSentence, "Execution Sentence" }, - { ShouldHammerOfWrath, DoHammerOfWrath, "Hammer of Wrath" }, - { ShouldWakeOfAshes, DoWakeOfAshes, "Wake of Ashes" }, - { ShouldDivineToll, DoDivineToll, "Divine Toll (HP <= 2)" }, - { ShouldDivineStorm, DoDivineStorm, "Divine Storm (2+ targets)" }, - { ShouldTemplarsVerdict, DoTemplarsVerdict, "Templar's / Final Verdict" }, - { ShouldBladeOfJustice, DoBladeOfJustice, "Blade of Justice" }, - { ShouldCrusaderStrike, DoCrusaderStrike, "Crusader Strike" }, - { AlwaysInCombat, DoAutoAttack, "Engage auto attack" }, -}; - -} // anonymous - -void RegisterApl_Paladin_Retribution() -{ - constexpr uint32 SPEC_PALADIN_RETRIBUTION = 70; - RegisterRotation(CLASS_PALADIN, SPEC_PALADIN_RETRIBUTION, ApRotation{kRules}); -} - -} // namespace Playerbot::Combat diff --git a/src/modules/PlayerbotV2/Combat/Apl/Apl_Priest_Discipline.cpp b/src/modules/PlayerbotV2/Combat/Apl/Apl_Priest_Discipline.cpp deleted file mode 100644 index 89ec01bc02..0000000000 --- a/src/modules/PlayerbotV2/Combat/Apl/Apl_Priest_Discipline.cpp +++ /dev/null @@ -1,640 +0,0 @@ -// Discipline Priest - WoW 12.1.0.69587 enterprise rotation. Atonement-driven -// healer: damage dealt to enemies heals every ally carrying Atonement (the -// buff is applied by PW: Shield / PW: Radiance / Evangelism). Decision tree: -// -// 1) OOC rez: Mass Resurrection / Resurrection -// 2) Hard panic peel: Pain Suppression (ally <=30%), Power Word: -// Barrier (3+ at <=50%), Desperate Prayer -// (self <=40%) -// 3) Personal survival: Leap of Faith (tank peel), Fade -// 4) Dispel: Purify (Magic; + Disease with Improved -// Purify), Mass Dispel -// 5) CC: Psychic Scream (panic AoE fear) -// 6) Big CDs: Evangelism (instant Radiance + next two -// Radiances instant), Ultimate Penitence -// (burst), Power Infusion -// 7) Atonement application: PW: Radiance (3+ wounded), PW: Shield on -// tank / lowest -// 8) Spike heal: Penance (heal branch), Flash Heal, Plea -// 9) Atonement damage rotor: Holy Nova (3+ enemies), Penance (dmg), -// Shadow Word: Death (execute), Mind Blast, -// Shadow Word: Pain / Purge the Wicked -// refresh, Smite filler -// -// Server-side overrides (Unit::GetCastSpellInfo resolves OVERRIDE_ACTIONBAR -// auras) swap talent versions in when the bot casts the base id: SW: Pain -// -> Purge the Wicked (1250218 [R]), Smite -> Void Blast while an Entropic -// Rift is open (450405 [R][M]), Flash Heal -> Shadow Mend (1252217 [M]), -// Purify Disease -> Purify. No extra rules are needed for those. -// -// ---- Validated spell IDs (WoW 12.1.0.69587 SpellName.csv / kit) ---- -// 17 Power Word: Shield (L4 baseline; 7.5s category CD) -// 527 Purify (spec L10; Magic dispel, overrides 440006) -// 585 Smite (L1 baseline) -// 586 Fade (class talent [R][M]) -// 589 Shadow Word: Pain (L2 baseline) -// 2006 Resurrection (L10 baseline) -// 2061 Flash Heal (L3 baseline) -// 8092 Mind Blast (class talent [R][M]) -// 8122 Psychic Scream (class talent [M]) -// 10060 Power Infusion (class talent [R][M]) -// 19236 Desperate Prayer (class talent [R][M]) -// 32375 Mass Dispel (class talent [R][M]) -// 32379 Shadow Word: Death (class talent [R][M]) -// 33206 Pain Suppression (spec talent [R][M]) -// 47540 Penance (spec L11 - heal/dmg channel) -// 62618 Power Word: Barrier (spec talent - choice vs Ult. Penitence) -// 73325 Leap of Faith (class talent [R][M]) -// 81749 Atonement (AURA - applied by Shield / Radiance) -// 132157 Holy Nova (class talent [R]) -// 194509 Power Word: Radiance (spec talent [R][M]) -// 200829 Plea (spec L80 - cheap instant heal) -// 204213 Purge the Wicked (AURA - DoT applied when 1250218 taken) -// 212036 Mass Resurrection (spec L37 OOC) -// 390632 Improved Purify (PASSIVE gate - Purify removes Disease) -// 421453 Ultimate Penitence (spec talent [R][M]) -// 472433 Evangelism (spec talent [R][M] - instant Radiance) -// -// ---- Skipped spells (and why) ---- -// - Power Word: Life (373481), Schism (424509), Rapture (47536), Spirit -// Shell (109964), Boon of the Ascended (325013), Divine Star (110744), -// Mindgames (375901): not learnable by Discipline in 12.1. -// - Silence (15487), Vampiric Embrace (15286): Shadow spec spells now. -// - Halo (120517 / 120644): Holy (Archon) / Shadow hero talent; the Disc -// hero trees (Voidweaver / Oracle) have no active Halo. -// - Evangelism legacy row 246287: no longer exists in SpellName. -// - Shadowfiend (34433): PASSIVE in 12.1 ("SW: Death has a chance to -// summon a Shadowfiend"). Mindbender (1280137 [M]): PASSIVE -// ("Evangelism summons a Mindbender"). Neither is castable. -// - Purify Disease (440006): learned together with Purify (527), which -// overrides it, so the cast always resolves to Purify; disease removal -// exists only through Improved Purify (390632), which gates it here. -// - Weakened Soul (6788): nothing applies it in 12.1 - is_ready() on -// PW: Shield covers the category cooldown instead. -// - Light's Wrath (207946) / Light of T'uure (208065) / Void Torrent -// (205065): legacy Artifact rows in the baseline list, no learn level. -// - Angelic Feather (121536), Dominate Mind (205364), Mind Control (605), -// Shackle Horror (9484), Dispel Magic (528 [M]): positioning / niche. -// - Single-Button Assistant (1229376): the APL is the assistant. - -#include "../ApRegistry.h" -#include "../ApRotation.h" -#include "ApDispelHelpers.h" -#include "ApHealHelpers.h" -#include "Bot/BotIntentEmitter.h" -#include "Bot/BotSnapshotView.h" -#include "Group/GroupSnapshot.h" -#include "SharedDefines.h" - -namespace Playerbot::Combat { - -namespace { - -// ---- Spell IDs (WoW 12.1.0.69587, validated) ---- -constexpr uint32 PW_SHIELD = 17; // 7.5s category CD (Weakened Soul is gone) -constexpr uint32 PENANCE = 47540; // channel heal+damage (Disc spec L11) -constexpr uint32 PAIN_SUPPRESSION = 33206; -constexpr uint32 PW_RADIANCE = 194509; -constexpr uint32 PW_BARRIER = 62618; -constexpr uint32 FLASH_HEAL = 2061; // L3 baseline spike heal (Shadow Mend [M] upgrades it via override) -constexpr uint32 PLEA = 200829; // spec L80 - cheap instant heal -constexpr uint32 SHADOW_WORD_PAIN_D = 589; -constexpr uint32 PURGE_THE_WICKED_DOT = 204213; // DoT applied instead of SW:P when Purge the Wicked (1250218 [R]) is taken -constexpr uint32 SHADOW_WORD_DEATH = 32379; // execute (class talent) -constexpr uint32 ATONEMENT = 81749; -constexpr uint32 MIND_BLAST = 8092; -constexpr uint32 SMITE = 585; -constexpr uint32 HOLY_NOVA = 132157; // class talent [R] - 12yd AoE dmg + heal -constexpr uint32 PURIFY = 527; // Magic dispel (spec L10; + Disease with Improved Purify) -constexpr uint32 IMPROVED_PURIFY = 390632; // PASSIVE gate - Purify additionally removes Disease -constexpr uint32 MASS_DISPEL = 32375; // group magic dispel + cleanses CC -constexpr uint32 EVANGELISM = 472433; // instant Radiance + next 2 Radiances instant/cheap -constexpr uint32 ULTIMATE_PENITENCE = 421453; // talent - channeled burst penance -constexpr uint32 DESPERATE_PRAYER = 19236; // self heal CD -constexpr uint32 FADE = 586; // threat drop / temp DR talent -constexpr uint32 POWER_INFUSION = 10060; // haste CD -constexpr uint32 LEAP_OF_FAITH = 73325; // friendly pull / peel -constexpr uint32 PSYCHIC_SCREAM = 8122; // AoE fear -constexpr uint32 RESURRECTION = 2006; -constexpr uint32 MASS_RESURRECTION = 212036; // OOC raid rez - -// ---- Helpers ---- -struct HealTarget -{ - ObjectGuid guid; - int32 hp_pct; -}; - -HealTarget LowestFriendOrSelf(ApPredicateContext const& ctx) -{ - HealTarget t{ ctx.bot.raw().guid, ctx.bot.hp_pct() }; - if (auto const* low = ctx.group.heal_assignment(ctx.bot.raw().guid, ctx.bot.map_id(), ctx.bot.raw().position.x, ctx.bot.raw().position.y, ctx.bot.raw().position.z, 45.0f)) - { - if (low->online && low->max_hp > 0) - { - const int32 pct = (low->hp * 100) / low->max_hp; - if (pct < t.hp_pct) { t.guid = low->guid; t.hp_pct = pct; } - } - } - return t; -} - -int WoundedFriendCount(ApPredicateContext const& ctx, int below_pct) -{ - int n = 0; - auto const* members = ctx.group.members(); - // SOLO (audit B22): ungrouped, "wounded friend" used to collapse to - // "my own HP <= below_pct" — the 92% GroupTopped gates then froze ALL - // damage the moment a questing healer took two melee hits, degenerating - // solo healer-spec leveling into heal-regen-nuke loops (3-10x kill - // time). Cap the solo threshold at a 45% survival floor: topped-style - // gates (92) stay open while merely scratched, true emergency heals - // (<=45) keep their thresholds. - if (!members) return ctx.bot.hp_pct() <= std::min(below_pct, 45) ? 1 : 0; - for (auto const& m : *members) - { - if (!m.online || m.max_hp <= 0 || m.hp <= 0) continue; - if ((m.hp * 100) / m.max_hp <= below_pct) ++n; - } - return n; -} - -bool GroupTopped(ApPredicateContext const& ctx) -{ - return WoundedFriendCount(ctx, 92) == 0; -} - -bool BossLikeTargetEngaged(ApPredicateContext const& ctx) -{ - constexpr int32 kBossHpThreshold = 5'000'000; - NearbyUnit const* t = ctx.bot.victim_info(); - if (t && t->max_hp >= kBossHpThreshold) return true; - for (auto const& a : ctx.bot.raw().combat.attackers) - if (a.max_hp >= kBossHpThreshold) return true; - return false; -} - -bool HasLiveTargetInline(ApPredicateContext const& ctx) -{ - return !ctx.bot.victim().IsEmpty(); -} - -// PW: Shield carries a 7.5s category cooldown in 12.1 (Weakened Soul no -// longer exists) - is_ready() is the re-cast gate for every target. -bool ShieldEligible(ApPredicateContext const& ctx) -{ - return ctx.bot.is_ready(PW_SHIELD); -} - -GroupMemberSummary const* OffensivePIBeneficiary(ApPredicateContext const& ctx) -{ - auto const* members = ctx.group.members(); - if (!members) return nullptr; - GroupMemberSummary const* best = nullptr; - for (auto const& m : *members) - { - if (!m.online || m.hp <= 0) continue; - if (m.guid == ctx.bot.raw().guid) continue; - if (m.role != Role::Dps) continue; - if (!best) best = &m; - } - return best; -} - -// ---- OOC rez ---- -bool ShouldResurrection(ApPredicateContext const& ctx) -{ - if (ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(RESURRECTION)) return false; - if (!ctx.bot.is_ready(RESURRECTION)) return false; - return ctx.group.dead_member(ctx.bot.map_id()) != nullptr; -} -void DoResurrection(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* m = ctx.group.dead_member(ctx.bot.map_id())) - e.cast(RESURRECTION, m->guid); -} - -bool ShouldMassResurrection(ApPredicateContext const& ctx) -{ - if (ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(MASS_RESURRECTION)) return false; - if (!ctx.bot.is_ready(MASS_RESURRECTION)) return false; - // Worth the long cast only if multiple are dead. - int dead = 0; - auto const* members = ctx.group.members(); - if (!members) return false; - for (auto const& m : *members) - if (m.online && m.hp <= 0) ++dead; - return dead >= 2; -} -void DoMassResurrection(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(MASS_RESURRECTION); } - -// ---- Personal survival ---- -bool ShouldDesperatePrayer(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(DESPERATE_PRAYER)) return false; - if (!ctx.bot.is_ready(DESPERATE_PRAYER)) return false; - return ctx.bot.hp_pct() <= 40; -} -void DoDesperatePrayer(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(DESPERATE_PRAYER); } - -bool ShouldFade(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(FADE)) return false; - if (!ctx.bot.is_ready(FADE)) return false; - // With Phantasm/Fade talent provides DR; baseline is threat drop. Pop when - // we're being hit and our HP is dipping while the tank is alive. - if (ctx.bot.hp_pct() > 55) return false; - return ctx.bot.attackers_count() >= 1; -} -void DoFade(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(FADE); } - -// ---- Dispel ---- -// Purify (527) removes Magic; with the Improved Purify passive (390632) it -// also removes Disease. Purify Disease (440006) is learned alongside but -// always overridden by 527, so every friendly dispel goes through PURIFY. -bool ShouldPurify(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(PURIFY) || !ctx.bot.is_ready(PURIFY)) return false; - const bool can_disease = ctx.bot.knows_spell(IMPROVED_PURIFY); - if (ctx.group.dispel_candidate(DispelType::Magic)) return true; - if (can_disease && ctx.group.dispel_candidate(DispelType::Disease)) return true; - if (ctx.bot.self_dispellable(DispelType::Magic)) return true; - if (can_disease && ctx.bot.self_dispellable(DispelType::Disease)) return true; - return false; -} -void DoPurify(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - const bool can_disease = ctx.bot.knows_spell(IMPROVED_PURIFY); - if (auto const* mg = ctx.group.dispel_candidate(DispelType::Magic)) { e.cast(PURIFY, mg->guid); return; } - if (can_disease) - if (auto const* ds = ctx.group.dispel_candidate(DispelType::Disease)) { e.cast(PURIFY, ds->guid); return; } - if (ctx.bot.self_dispellable(DispelType::Magic)) { e.cast(PURIFY, ctx.bot.raw().guid); return; } - if (can_disease && ctx.bot.self_dispellable(DispelType::Disease)) { e.cast(PURIFY, ctx.bot.raw().guid); return; } -} - -// CB-P1d (Discipline sibling of the Holy fix): Mass Dispel is a GROUND-targeted -// AoE that strips Magic from allies in the area. Fire when MULTIPLE grouped -// allies share a dispellable Magic debuff and aim at their centroid — NOT when -// the priest itself happens to be debuffed, aimed at self (the old gate, which -// meant Mass Dispel essentially never fired for its real raid use). -int MagicAfflictedAllyCount(ApPredicateContext const& ctx, - float* out_cx = nullptr, float* out_cy = nullptr, float* out_cz = nullptr) -{ - auto const* members = ctx.group.members(); - if (!members) return 0; - uint32 const my_map = ctx.bot.map_id(); - int n = 0; - double sx = 0.0, sy = 0.0, sz = 0.0; - for (auto const& m : *members) - { - if (!m.online || m.hp <= 0 || m.map_id != my_map) continue; - bool magic = false; - for (auto const& d : m.debuffs) - if (d.is_harmful && d.dispel_type == DispelType::Magic) { magic = true; break; } - if (!magic) continue; - ++n; - sx += m.x; sy += m.y; sz += m.z; - } - if (n > 0 && out_cx) { *out_cx = static_cast(sx / n); *out_cy = static_cast(sy / n); *out_cz = static_cast(sz / n); } - return n; -} - -bool ShouldMassDispel(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(MASS_DISPEL)) return false; - if (!ctx.bot.is_ready(MASS_DISPEL)) return false; - return MagicAfflictedAllyCount(ctx) >= 3; -} -void DoMassDispel(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - float cx = 0.f, cy = 0.f, cz = 0.f; - if (MagicAfflictedAllyCount(ctx, &cx, &cy, &cz) > 0) - e.cast_at(MASS_DISPEL, cx, cy, cz); -} - -// ---- CC ---- -// Discipline has no interrupt in 12.1 (Silence is a Shadow spec spell); -// Psychic Scream ([M] class talent) is the only emergency CC. -bool ShouldPsychicScream(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(PSYCHIC_SCREAM)) return false; - if (!ctx.bot.is_ready(PSYCHIC_SCREAM)) return false; - return ctx.bot.attackers_count() >= 3 && ctx.bot.hp_pct() <= 50; -} -void DoPsychicScream(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(PSYCHIC_SCREAM); } - -bool ShouldLeapOfFaith(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(LEAP_OF_FAITH)) return false; - if (!ctx.bot.is_ready(LEAP_OF_FAITH)) return false; - GroupMemberSummary const* tank = ctx.group.tank(); - if (!tank || !tank->online || tank->hp <= 0) return false; - if (tank->guid == ctx.bot.raw().guid) return false; - if (tank->max_hp <= 0) return false; - return (tank->hp * 100) / tank->max_hp <= 30; -} -void DoLeapOfFaith(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* tank = ctx.group.tank()) - e.cast(LEAP_OF_FAITH, tank->guid); -} - -bool ShouldPowerInfusion(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(POWER_INFUSION)) return false; - if (!ctx.bot.is_ready(POWER_INFUSION)) return false; - // Self-PI when group is healthy and we're in burn mode, otherwise hand - // it to a DPS (best DPS heuristic — first non-self Dps in the snapshot). - if (BossLikeTargetEngaged(ctx)) return true; - return GroupTopped(ctx); -} -void DoPowerInfusion(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* dps = OffensivePIBeneficiary(ctx)) - e.cast(POWER_INFUSION, dps->guid); - else - e.cast(POWER_INFUSION, ctx.bot.raw().guid); -} - -// ---- Hard panic ---- -bool ShouldPowerWordBarrier(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(PW_BARRIER)) return false; - if (!ctx.bot.is_ready(PW_BARRIER)) return false; - return WoundedFriendCount(ctx, 50) >= 3; -} -void DoPowerWordBarrier(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* tank = ctx.group.tank()) - { - e.cast(PW_BARRIER, tank->guid); - return; - } - e.cast(PW_BARRIER, ctx.bot.raw().guid); -} - -bool ShouldPainSuppression(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(PAIN_SUPPRESSION)) return false; - if (!ctx.bot.is_ready(PAIN_SUPPRESSION)) return false; - return LowestFriendOrSelf(ctx).hp_pct <= 30; -} -void DoPainSuppression(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(PAIN_SUPPRESSION, LowestFriendOrSelf(ctx).guid); -} - -// ---- Big CDs ---- -// Evangelism (472433): 12.1 version is an instant Power Word: Radiance on -// the target plus two instant, cheaper Radiances afterwards - the raid -// Atonement opener. Needs a friendly target. The Mindbender [M] passive -// (1280137) summons its pet off this cast. -bool ShouldEvangelism(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(EVANGELISM)) return false; - if (!ctx.bot.is_ready(EVANGELISM)) return false; - return WoundedFriendCount(ctx, 80) >= 3; -} -void DoEvangelism(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(EVANGELISM, LowestFriendOrSelf(ctx).guid); -} - -bool ShouldUltimatePenitence(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(ULTIMATE_PENITENCE)) return false; - if (!ctx.bot.is_ready(ULTIMATE_PENITENCE)) return false; - return WoundedFriendCount(ctx, 60) >= 2; -} -void DoUltimatePenitence(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(ULTIMATE_PENITENCE, LowestFriendOrSelf(ctx).guid); -} - -// ---- Atonement application ---- -bool ShouldRadiance(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(PW_RADIANCE)) return false; - if (!ctx.bot.is_ready(PW_RADIANCE)) return false; - return WoundedFriendCount(ctx, 90) >= 3; -} -void DoRadiance(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(PW_RADIANCE, LowestFriendOrSelf(ctx).guid); -} - -bool ShouldShieldTankAtonement(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(PW_SHIELD)) return false; - GroupMemberSummary const* tank = ctx.group.tank(); - if (!tank || !tank->online || tank->hp <= 0) return false; - if (!ShieldEligible(ctx)) return false; - AuraEntry const* shield = ctx.bot.find_aura(PW_SHIELD, tank->guid); - AuraEntry const* atone = ctx.bot.find_aura(ATONEMENT, tank->guid); - return !shield && (!atone || atone->remaining.count() <= 4000); -} -void DoShieldTankAtonement(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* tank = ctx.group.tank()) - e.cast(PW_SHIELD, tank->guid); -} - -bool ShouldShield(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(PW_SHIELD)) return false; - HealTarget t = LowestFriendOrSelf(ctx); - if (t.hp_pct >= 95) return false; - if (!ShieldEligible(ctx)) return false; - AuraEntry const* shield = ctx.bot.find_aura(PW_SHIELD, t.guid); - AuraEntry const* atone = ctx.bot.find_aura(ATONEMENT, t.guid); - return !shield && (!atone || atone->remaining.count() <= 4000); -} -void DoShield(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(PW_SHIELD, LowestFriendOrSelf(ctx).guid); -} - -// ---- Atonement-fed damage (heals via Atonement transfer) ---- -bool ShouldPenance(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(PENANCE)) return false; - if (!ctx.bot.is_ready(PENANCE)) return false; - // Penance is a heal+dmg cleave — cast on lowest friendly when wounded, - // otherwise on the victim to drive Atonement healing. - if (LowestFriendOrSelf(ctx).hp_pct <= 80) return true; - return HasLiveTargetInline(ctx); -} -void DoPenance(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - HealTarget t = LowestFriendOrSelf(ctx); - if (t.hp_pct <= 80) { e.cast(PENANCE, t.guid); return; } - e.cast(PENANCE, ctx.bot.victim()); -} - -// Flash Heal - direct spike heal when Penance is on cooldown or not enough. -// With the Shadow Mend [M] passive the server casts the upgraded version. -bool ShouldFlashHeal(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(FLASH_HEAL)) return false; - if (!ctx.bot.is_ready(FLASH_HEAL)) return false; - return LowestFriendOrSelf(ctx).hp_pct <= 50; -} -void DoFlashHeal(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(FLASH_HEAL, LowestFriendOrSelf(ctx).guid); -} - -// Plea (spec L80) - cheap instant top-off; fires in the band above Flash -// Heal so a moving priest still has a direct heal. -bool ShouldPlea(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(PLEA)) return false; - if (!ctx.bot.is_ready(PLEA)) return false; - return LowestFriendOrSelf(ctx).hp_pct <= 60; -} -void DoPlea(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(PLEA, LowestFriendOrSelf(ctx).guid); -} - -// Holy Nova (class talent [R]) - 12yd self-centred AoE damage + heal. With -// 3+ enemies in reach (or the owner /aoe pin) it is the best Atonement -// feed per GCD. -bool ShouldHolyNova(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(HOLY_NOVA)) return false; - if (!ctx.bot.is_ready(HOLY_NOVA)) return false; - const size_t near = ctx.bot.enemies_within(12.0f); - if (ctx.aoe_preference && near >= 1) return true; - return near >= 3; -} -void DoHolyNova(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(HOLY_NOVA); } - -bool ShouldShadowWordDeath(ApPredicateContext const& ctx) -{ - if (!HasLiveTargetInline(ctx)) return false; - if (!ctx.bot.knows_spell(SHADOW_WORD_DEATH)) return false; - if (!ctx.bot.is_ready(SHADOW_WORD_DEATH)) return false; - NearbyUnit const* t = ctx.bot.victim_info(); - if (!t || t->max_hp <= 0) return false; - int32 hp_pct = (t->hp * 100) / t->max_hp; - return hp_pct <= 20; -} -void DoShadowWordDeath(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(SHADOW_WORD_DEATH, ctx.bot.victim()); -} - -bool ShouldMindBlast(ApPredicateContext const& ctx) -{ - if (!HasLiveTargetInline(ctx)) return false; - if (!ctx.bot.knows_spell(MIND_BLAST)) return false; - return ctx.bot.is_ready(MIND_BLAST); -} -void DoMindBlast(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(MIND_BLAST, ctx.bot.victim()); -} - -// SW: Pain refresh. With Purge the Wicked ([R] passive 1250218) the server -// swaps the cast for Purge the Wicked and the victim carries its own DoT -// (204213) instead of 589 - check both so the talented bot does not -// re-cast every tick. -bool ShouldSWP(ApPredicateContext const& ctx) -{ - if (!HasLiveTargetInline(ctx)) return false; - if (!ctx.bot.knows_spell(SHADOW_WORD_PAIN_D)) return false; - AuraEntry const* a = ctx.bot.find_aura(SHADOW_WORD_PAIN_D, ctx.bot.victim()); - if (!a) a = ctx.bot.find_aura(PURGE_THE_WICKED_DOT, ctx.bot.victim()); - return !a || a->remaining.count() <= 3000; -} -void DoSWP(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(SHADOW_WORD_PAIN_D, ctx.bot.victim()); -} - -bool ShouldSmite(ApPredicateContext const& ctx) -{ - if (!HasLiveTargetInline(ctx)) return false; - if (!ctx.bot.knows_spell(SMITE)) return false; - if (ctx.bot.is_moving() && !ctx.bot.can_cast_while_moving(SMITE)) return false; - return true; -} -void DoSmite(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(SMITE, ctx.bot.victim()); -} - -bool AlwaysAlive(ApPredicateContext const& ctx) { return ctx.bot.is_alive(); } -void DoNothing(ApPredicateContext const&, BotIntentEmitter&) {} - -// Cast-swap shim - Disc's healing kit is mostly absorbs/Atonement (very -// short or instant casts); Penance (heal channel), Flash Heal and PW: -// Radiance (2s) are the casts long enough to be worth cancelling. See -// ApHealHelpers.h. -bool ShouldCancelHealForSwap(ApPredicateContext const& ctx) -{ - return ShouldCancelHealForSwapImpl(ctx, { PENANCE, FLASH_HEAL, PW_RADIANCE }); -} - -// ---- Rule table (priority order top-down) ---- -// Order follows the Discipline decision tree in the header comment block: -// emergencies first (cast-swap + OOC rez), hard panic (Pain Suppression -> -// PW: Barrier -> Desperate Prayer), survival/threat, dispels, CC, big CDs -// (Evangelism -> Ultimate Penitence -> Power Infusion), Atonement -// application (Radiance + Shield), spike heals (Penance heal branch -> -// Flash Heal -> Plea), then the Atonement-feed damage rotor (Holy Nova -> -// SW: Death -> Mind Blast -> SW: Pain -> Smite). -ApRule const kRules[] = { - { ShouldCancelHealForSwap, DoCancelHealForSwap, "Cancel heal — swap to lower target" }, - { ShouldMassResurrection, DoMassResurrection, "Mass Resurrection (OOC)" }, - { ShouldResurrection, DoResurrection, "Resurrection (OOC)" }, - // ---- Hard panic peels (highest priority - ally life-savers) ---- - { ShouldPainSuppression, DoPainSuppression, "Pain Suppression (ally <=30%)" }, - { ShouldPowerWordBarrier, DoPowerWordBarrier, "PW: Barrier (3+ at 50%)" }, - { ShouldDesperatePrayer, DoDesperatePrayer, "Desperate Prayer (self <=40%)" }, - // ---- Threat / personal survival ---- - { ShouldLeapOfFaith, DoLeapOfFaith, "Leap of Faith (peel tank)" }, - { ShouldFade, DoFade, "Fade (threat / DR)" }, - // ---- Dispel ---- - { ShouldPurify, DoPurify, "Purify (Magic / Disease)" }, - { ShouldMassDispel, DoMassDispel, "Mass Dispel (raid)" }, - // ---- CC ---- - { ShouldPsychicScream, DoPsychicScream, "Psychic Scream (panic AoE)" }, - // ---- Big CDs ---- - { ShouldEvangelism, DoEvangelism, "Evangelism (instant Radiance)" }, - { ShouldUltimatePenitence, DoUltimatePenitence, "Ultimate Penitence (burst)" }, - { ShouldPowerInfusion, DoPowerInfusion, "Power Infusion (DPS)" }, - // ---- Atonement application (PW: Shield = Atonement applicator) ---- - { ShouldRadiance, DoRadiance, "PW: Radiance (3+ at 90%)" }, - { ShouldShieldTankAtonement, DoShieldTankAtonement, "PW: Shield (tank atonement)" }, - { ShouldShield, DoShield, "PW: Shield (lowest atonement)" }, - // ---- Spike heal + Atonement-feed damage rotor ---- - { ShouldPenance, DoPenance, "Penance (heal/dmg channel)" }, - { ShouldFlashHeal, DoFlashHeal, "Flash Heal (<=50%)" }, - { ShouldPlea, DoPlea, "Plea (<=60% instant)" }, - { ShouldHolyNova, DoHolyNova, "Holy Nova (3+ atone-feed)" }, - { ShouldShadowWordDeath, DoShadowWordDeath, "SW: Death (<=20% execute)" }, - { ShouldMindBlast, DoMindBlast, "Mind Blast" }, - { ShouldSWP, DoSWP, "SW: Pain / PtW (refresh)" }, - { ShouldSmite, DoSmite, "Smite (atonement filler)" }, - { AlwaysAlive, DoNothing, "Idle" }, -}; - -} // anonymous - -void RegisterApl_Priest_Discipline() -{ - constexpr uint32 SPEC_PRIEST_DISCIPLINE = 256; - RegisterRotation(CLASS_PRIEST, SPEC_PRIEST_DISCIPLINE, ApRotation{kRules}); -} - -} // namespace Playerbot::Combat diff --git a/src/modules/PlayerbotV2/Combat/Apl/Apl_Priest_Holy.cpp b/src/modules/PlayerbotV2/Combat/Apl/Apl_Priest_Holy.cpp deleted file mode 100644 index a9ca1fdc8d..0000000000 --- a/src/modules/PlayerbotV2/Combat/Apl/Apl_Priest_Holy.cpp +++ /dev/null @@ -1,665 +0,0 @@ -// Holy Priest - WoW 12.1.0.69587 enterprise rotation. Direct-cast healer -// built around Flash Heal / Prayer of Healing feeding the Holy Word -// cooldowns (Serenity / Sanctify / Chastise), Prayer of Mending on the -// tank, and Halo (Archon hero tree) for raid healing. Mastery (Echo of -// Light 77489) proc-HoTs on direct heals - no rule needed. Heal (2060) and -// Renew (139) are gone from the 12.1 kit: Flash Heal is both the spike heal -// and the efficient filler (Improved Flash Heal / Surge of Light [R][M]). -// Decision tree: -// -// 1) OOC rez: Mass Resurrection / Resurrection -// 2) Interrupt / CC / threat:Holy Word: Chastise ([M]), Psychic Scream -// ([M]), Leap of Faith (peel), Fade -// 3) Personal survival: Desperate Prayer, PW: Shield self (only -// until Prayer of Mending overrides it at L11) -// 4) Dispel: Purify (Magic; + Disease with Improved -// Purify), Mass Dispel -// 5) Hard panic: Guardian Spirit (ally <=25%), Divine Hymn -// (3+ <=50%), Holy Word: Serenity (<=60%), -// Apotheosis (Holy Word reset) -// 6) Burst CD: Power Infusion -// 7) HoT maintenance: Prayer of Mending on tank -// 8) Spike heal: Flash Heal (<=50%) -// 9) AoE heal: Holy Word: Sanctify (or Serenity with the -// Ultimate Serenity passive), Prayer of -// Healing, Holy Nova, Halo -// 10) Filler: Flash Heal top-off (<=85%, mana-gated) -// 11) Offensive filler: Holy Fire / SW:P / Smite when group topped -// (also feeds Holy Word CDR) -// -// Server-side overrides (Unit::GetCastSpellInfo resolves OVERRIDE_ACTIONBAR -// auras): Prayer of Mending (33076) overrides PW: Shield (17), Holy Fire -// (14914 [R][M]) overrides SW: Pain (589), Ultimate Serenity (1246517 -// [R][M] passive) removes HW: Sanctify (34861), Purify overrides Purify -// Disease. Each base rule is knows_spell-gated on the override so both the -// talented and the untalented bot cast the right thing. -// -// ---- Validated spell IDs (WoW 12.1.0.69587 SpellName.csv / kit) ---- -// 17 Power Word: Shield (L4 baseline - self absorb until PoM) -// 527 Purify (spec L10 - Magic dispel) -// 585 Smite (L1 baseline - offensive filler / CDR) -// 586 Fade (class talent [R][M]) -// 589 Shadow Word: Pain (L2 baseline - DoT filler until Holy Fire) -// 596 Prayer of Healing (spec talent [R][M]) -// 2006 Resurrection (L10 baseline) -// 2050 Holy Word: Serenity (spec talent [R][M]) -// 2061 Flash Heal (L3 baseline - spike heal + filler) -// 8122 Psychic Scream (class talent [M]) -// 10060 Power Infusion (class talent [R][M]) -// 14914 Holy Fire (class talent [R][M] - overrides SW:P) -// 19236 Desperate Prayer (class talent [R][M]) -// 32375 Mass Dispel (class talent [R][M]) -// 33076 Prayer of Mending (spec L11 - overrides PW: Shield) -// 34861 Holy Word: Sanctify (spec talent [R][M]; gone with Ult. Serenity) -// 47788 Guardian Spirit (spec talent [R][M]) -// 64843 Divine Hymn (spec talent [R][M]) -// 73325 Leap of Faith (class talent [R][M]) -// 88625 Holy Word: Chastise (spec talent [M]) -// 120517 Halo (Archon hero talent [R][M] - Holy ring) -// 132157 Holy Nova (class talent [R][M]) -// 200183 Apotheosis (spec talent [R][M]) -// 212036 Mass Resurrection (spec L37 OOC) -// 390632 Improved Purify (PASSIVE gate - Purify removes Disease) -// 1246517 Ultimate Serenity (PASSIVE gate - Serenity AoE, no Sanctify) -// -// ---- Skipped spells (and why) ---- -// - Heal (2060), Renew (139), Circle of Healing (204883), Symbol of Hope -// (64901), Holy Word: Salvation (265202), Binding Heal (32546), Power -// Word: Life (373481), Premonition of Piety (438733), Divine Star -// (110744): not learnable by Holy in 12.1. -// - Vampiric Embrace (15286): Shadow spec spell now. -// - Empyreal Blaze (372616 [M]): a PASSIVE in 12.1 ("Holy Word: Chastise -// makes your next Holy Fires instant") - not castable. -// - Purify Disease (440006): learned with Purify (527), which overrides -// it; disease removal exists only via Improved Purify (390632). -// - Weakened Soul (6788): nothing applies it in 12.1 - is_ready() gates -// the PW: Shield re-cast (7.5s category cooldown). -// - Echo of Light (77489), Spirit of Redemption (215769 PvP talent), -// Light of T'uure (208065), Light's Wrath (207946), Void Torrent -// (205065): passives / legacy Artifact rows with no learn level. -// - Angelic Feather (121536), Dominate Mind (205364), Mind Control (605), -// Shackle Horror (9484), Dispel Magic (528 [M]): positioning / niche. -// - Single-Button Assistant (1229376): the APL is the assistant. - -#include "../ApRegistry.h" -#include "../ApRotation.h" -#include "ApDispelHelpers.h" -#include "ApHealHelpers.h" -#include "Bot/BotIntentEmitter.h" -#include "Bot/BotSnapshotView.h" -#include "Group/GroupSnapshot.h" -#include "SharedDefines.h" - -namespace Playerbot::Combat { - -namespace { - -// ---- Spell IDs (WoW 12.1.0.69587, validated) ---- -constexpr uint32 FLASH_HEAL = 2061; // spike heal AND efficient filler (Heal / Renew are gone) -constexpr uint32 PRAYER_OF_HEALING = 596; -constexpr uint32 PRAYER_OF_MENDING = 33076; // spec L11 - overrides PW: Shield -constexpr uint32 HOLY_WORD_SERENITY = 2050; -constexpr uint32 HOLY_WORD_SANCTIFY = 34861; // removed by the Ultimate Serenity passive -constexpr uint32 ULTIMATE_SERENITY = 1246517; // PASSIVE gate [R][M] - Serenity heals nearby allies, no Sanctify -constexpr uint32 HOLY_WORD_CHASTISE = 88625; -constexpr uint32 DIVINE_HYMN = 64843; -constexpr uint32 GUARDIAN_SPIRIT = 47788; -constexpr uint32 PURIFY = 527; // Magic dispel (+ Disease with Improved Purify) -constexpr uint32 IMPROVED_PURIFY = 390632; // PASSIVE gate - Purify additionally removes Disease -constexpr uint32 MASS_DISPEL = 32375; -constexpr uint32 HOLY_NOVA = 132157; // class talent [R][M] - AoE heal + dmg -constexpr uint32 APOTHEOSIS = 200183; // talent - Holy Word reset + buff -constexpr uint32 POWER_INFUSION = 10060; -constexpr uint32 DESPERATE_PRAYER = 19236; -constexpr uint32 POWER_WORD_SHIELD = 17; // self-absorb until Prayer of Mending overrides it -constexpr uint32 FADE = 586; -constexpr uint32 LEAP_OF_FAITH = 73325; -constexpr uint32 PSYCHIC_SCREAM = 8122; -constexpr uint32 RESURRECTION = 2006; -constexpr uint32 MASS_RESURRECTION = 212036; - -// Offensive filler -constexpr uint32 SMITE = 585; -constexpr uint32 HOLY_FIRE = 14914; // class talent [R][M] - overrides SW: Pain -constexpr uint32 SHADOW_WORD_PAIN = 589; -constexpr uint32 HALO = 120517; // Archon hero talent [R][M] - Holy variant - -// ---- Helpers ---- -struct HealTarget -{ - ObjectGuid guid; - int32 hp_pct; -}; - -HealTarget LowestFriendOrSelf(ApPredicateContext const& ctx) -{ - HealTarget t{ ctx.bot.raw().guid, ctx.bot.hp_pct() }; - if (auto const* low = ctx.group.heal_assignment(ctx.bot.raw().guid, ctx.bot.map_id(), ctx.bot.raw().position.x, ctx.bot.raw().position.y, ctx.bot.raw().position.z, 45.0f)) - { - if (low->online && low->max_hp > 0) - { - const int32 pct = (low->hp * 100) / low->max_hp; - if (pct < t.hp_pct) { t.guid = low->guid; t.hp_pct = pct; } - } - } - return t; -} - -int WoundedFriendCount(ApPredicateContext const& ctx, int below_pct) -{ - int n = 0; - auto const* members = ctx.group.members(); - // SOLO (audit B22): ungrouped, "wounded friend" used to collapse to - // "my own HP <= below_pct" — the 92% GroupTopped gates then froze ALL - // damage the moment a questing healer took two melee hits, degenerating - // solo healer-spec leveling into heal-regen-nuke loops (3-10x kill - // time). Cap the solo threshold at a 45% survival floor: topped-style - // gates (92) stay open while merely scratched, true emergency heals - // (<=45) keep their thresholds. - if (!members) return ctx.bot.hp_pct() <= std::min(below_pct, 45) ? 1 : 0; - for (auto const& m : *members) - { - if (!m.online || m.max_hp <= 0 || m.hp <= 0) continue; - if ((m.hp * 100) / m.max_hp <= below_pct) ++n; - } - return n; -} - -// Mana-floor gate. <=15% mana = only emergencies (LowestFriendOrSelf -// <=35% HP) - let Prayer of Mending bounces / Echo of Light carry the -// rest until the bot regenerates. Without this, Holy Priest spammed Flash -// Heal into OOM and had zero mana when the tank actually spiked (every -// spec other than Holy already had this gate). Apply at the top of normal- -// heal predicates ONLY - Guardian Spirit, Divine Hymn, HW: Serenity are -// the emergency floor and stay unmodified. -bool InManaFloor(ApPredicateContext const& ctx) -{ - return ctx.bot.max_power(0) > 0 && ctx.bot.power_pct(0) <= 15; -} - -bool GroupTopped(ApPredicateContext const& ctx) -{ - return WoundedFriendCount(ctx, 92) == 0; -} - -bool BossLikeTargetEngaged(ApPredicateContext const& ctx) -{ - constexpr int32 kBossHpThreshold = 5'000'000; - NearbyUnit const* t = ctx.bot.victim_info(); - if (t && t->max_hp >= kBossHpThreshold) return true; - for (auto const& a : ctx.bot.raw().combat.attackers) - if (a.max_hp >= kBossHpThreshold) return true; - return false; -} - -bool HasLiveTargetInline(ApPredicateContext const& ctx) -{ - return !ctx.bot.victim().IsEmpty(); -} - -GroupMemberSummary const* OffensivePIBeneficiary(ApPredicateContext const& ctx) -{ - auto const* members = ctx.group.members(); - if (!members) return nullptr; - for (auto const& m : *members) - { - if (!m.online || m.hp <= 0) continue; - if (m.guid == ctx.bot.raw().guid) continue; - if (m.role != Role::Dps) continue; - return &m; - } - return nullptr; -} - -// Cast-swap shim — Holy Priest's slow single-target heals worth -// cancelling when a different member spikes critical. See -// ApHealHelpers.h for the predicate body. -bool ShouldCancelHealForSwap(ApPredicateContext const& ctx) -{ - return ShouldCancelHealForSwapImpl(ctx, - { FLASH_HEAL, PRAYER_OF_HEALING }); -} - -// ---- OOC rez ---- -bool ShouldResurrection(ApPredicateContext const& ctx) -{ - if (ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(RESURRECTION)) return false; - if (!ctx.bot.is_ready(RESURRECTION)) return false; - return ctx.group.dead_member(ctx.bot.map_id()) != nullptr; -} -void DoResurrection(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* m = ctx.group.dead_member(ctx.bot.map_id())) - e.cast(RESURRECTION, m->guid); -} - -bool ShouldMassResurrection(ApPredicateContext const& ctx) -{ - if (ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(MASS_RESURRECTION)) return false; - if (!ctx.bot.is_ready(MASS_RESURRECTION)) return false; - int dead = 0; - auto const* members = ctx.group.members(); - if (!members) return false; - for (auto const& m : *members) - if (m.online && m.hp <= 0) ++dead; - return dead >= 2; -} -void DoMassResurrection(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(MASS_RESURRECTION); } - -// ---- Personal survival ---- -bool ShouldDesperatePrayer(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(DESPERATE_PRAYER)) return false; - if (!ctx.bot.is_ready(DESPERATE_PRAYER)) return false; - return ctx.bot.hp_pct() <= 40; -} -void DoDesperatePrayer(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(DESPERATE_PRAYER); } - -bool ShouldFade(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(FADE)) return false; - if (!ctx.bot.is_ready(FADE)) return false; - if (ctx.bot.hp_pct() > 60) return false; - return ctx.bot.attackers_count() >= 1; -} -void DoFade(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(FADE); } - -// ---- Dispel ---- -// Purify (527) removes Magic; with the Improved Purify passive (390632) it -// also removes Disease. Purify Disease (440006) is learned alongside but -// always overridden by 527, so every friendly dispel goes through PURIFY. -bool ShouldPurify(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(PURIFY) || !ctx.bot.is_ready(PURIFY)) return false; - const bool can_disease = ctx.bot.knows_spell(IMPROVED_PURIFY); - if (ctx.group.dispel_candidate(DispelType::Magic)) return true; - if (can_disease && ctx.group.dispel_candidate(DispelType::Disease)) return true; - if (ctx.bot.self_dispellable(DispelType::Magic)) return true; - if (can_disease && ctx.bot.self_dispellable(DispelType::Disease)) return true; - return false; -} -void DoPurify(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - const bool can_disease = ctx.bot.knows_spell(IMPROVED_PURIFY); - if (auto const* mg = ctx.group.dispel_candidate(DispelType::Magic)) { e.cast(PURIFY, mg->guid); return; } - if (can_disease) - if (auto const* ds = ctx.group.dispel_candidate(DispelType::Disease)) { e.cast(PURIFY, ds->guid); return; } - if (ctx.bot.self_dispellable(DispelType::Magic)) { e.cast(PURIFY, ctx.bot.raw().guid); return; } - if (can_disease && ctx.bot.self_dispellable(DispelType::Disease)) { e.cast(PURIFY, ctx.bot.raw().guid); return; } -} - -// CB-P1d: Mass Dispel is a GROUND-targeted AoE that strips Magic from allies -// in the area. The trigger must reflect that — fire when MULTIPLE grouped -// allies share a dispellable Magic debuff, and aim at the centroid of those -// allies (not at the bot's own guid). Counts allies on the bot's own map that -// are online + alive and carry at least one harmful Magic aura, accumulating -// their positions so DoMassDispel can target the affected cluster. -int MagicAfflictedAllyCount(ApPredicateContext const& ctx, - float* out_cx = nullptr, float* out_cy = nullptr, float* out_cz = nullptr) -{ - auto const* members = ctx.group.members(); - if (!members) return 0; - uint32 const my_map = ctx.bot.map_id(); - int n = 0; - double sx = 0.0, sy = 0.0, sz = 0.0; - for (auto const& m : *members) - { - if (!m.online || m.hp <= 0 || m.map_id != my_map) continue; - bool magic = false; - for (auto const& d : m.debuffs) - if (d.is_harmful && d.dispel_type == DispelType::Magic) { magic = true; break; } - if (!magic) continue; - ++n; - sx += m.x; sy += m.y; sz += m.z; - } - if (n > 0 && out_cx) { *out_cx = static_cast(sx / n); *out_cy = static_cast(sy / n); *out_cz = static_cast(sz / n); } - return n; -} - -bool ShouldMassDispel(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(MASS_DISPEL)) return false; - if (!ctx.bot.is_ready(MASS_DISPEL)) return false; - // Fire when at least 3 allies share a dispellable Magic effect — the - // scenario Mass Dispel actually exists for (raid-wide magic debuff, mass - // bubble dispel). Decoupled from SelfNeedsDispel (CB-P1d). - return MagicAfflictedAllyCount(ctx) >= 3; -} -void DoMassDispel(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - float cx = 0.f, cy = 0.f, cz = 0.f; - if (MagicAfflictedAllyCount(ctx, &cx, &cy, &cz) > 0) - e.cast_at(MASS_DISPEL, cx, cy, cz); -} - -// ---- Interrupt / CC ---- -bool ShouldHolyWordChastise(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(HOLY_WORD_CHASTISE)) return false; - if (!ctx.bot.is_ready(HOLY_WORD_CHASTISE)) return false; - const bool pvp = ctx.pvp.in_battleground || ctx.pvp.in_arena; - return ctx.bot.kick_target(pvp, 30.0f) != nullptr; -} -void DoHolyWordChastise(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - const bool pvp = ctx.pvp.in_battleground || ctx.pvp.in_arena; - if (auto const* c = ctx.bot.kick_target(pvp, 30.0f)) - e.cast(HOLY_WORD_CHASTISE, c->guid); -} - -bool ShouldPsychicScream(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(PSYCHIC_SCREAM)) return false; - if (!ctx.bot.is_ready(PSYCHIC_SCREAM)) return false; - return ctx.bot.attackers_count() >= 3 && ctx.bot.hp_pct() <= 50; -} -void DoPsychicScream(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(PSYCHIC_SCREAM); } - -bool ShouldLeapOfFaith(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(LEAP_OF_FAITH)) return false; - if (!ctx.bot.is_ready(LEAP_OF_FAITH)) return false; - GroupMemberSummary const* tank = ctx.group.tank(); - if (!tank || !tank->online || tank->hp <= 0) return false; - if (tank->guid == ctx.bot.raw().guid) return false; - if (tank->max_hp <= 0) return false; - return (tank->hp * 100) / tank->max_hp <= 30; -} -void DoLeapOfFaith(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* tank = ctx.group.tank()) - e.cast(LEAP_OF_FAITH, tank->guid); -} - -// ---- Hard panic ---- -bool ShouldGuardianSpirit(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(GUARDIAN_SPIRIT)) return false; - if (!ctx.bot.is_ready(GUARDIAN_SPIRIT)) return false; - return LowestFriendOrSelf(ctx).hp_pct <= 25; -} -void DoGuardianSpirit(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(GUARDIAN_SPIRIT, LowestFriendOrSelf(ctx).guid); -} - -bool ShouldDivineHymn(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(DIVINE_HYMN)) return false; - if (!ctx.bot.is_ready(DIVINE_HYMN)) return false; - return WoundedFriendCount(ctx, 50) >= 3; -} -void DoDivineHymn(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(DIVINE_HYMN); } - -// ---- Burst CDs ---- -bool ShouldApotheosis(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(APOTHEOSIS)) return false; - if (!ctx.bot.is_ready(APOTHEOSIS)) return false; - return WoundedFriendCount(ctx, 75) >= 3; -} -void DoApotheosis(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(APOTHEOSIS); } - -bool ShouldPowerInfusion(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(POWER_INFUSION)) return false; - if (!ctx.bot.is_ready(POWER_INFUSION)) return false; - if (BossLikeTargetEngaged(ctx)) return true; - return GroupTopped(ctx); -} -void DoPowerInfusion(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* dps = OffensivePIBeneficiary(ctx)) - e.cast(POWER_INFUSION, dps->guid); - else - e.cast(POWER_INFUSION, ctx.bot.raw().guid); -} - -// ---- AoE heal ---- -// Holy Word: Sanctify is removed by the Ultimate Serenity passive ([R][M]); -// the talented bot uses the Serenity AoE branch below instead. -bool ShouldHolyWordSanctify(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(HOLY_WORD_SANCTIFY)) return false; - if (ctx.bot.knows_spell(ULTIMATE_SERENITY)) return false; - if (!ctx.bot.is_ready(HOLY_WORD_SANCTIFY)) return false; - return WoundedFriendCount(ctx, 70) >= 3; -} -void DoHolyWordSanctify(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(HOLY_WORD_SANCTIFY, LowestFriendOrSelf(ctx).guid); -} - -// Ultimate Serenity branch: Serenity also heals nearby injured allies, so it -// takes over the 3+ wounded raid-spike slot. -bool ShouldHolyWordSerenityAoe(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(ULTIMATE_SERENITY)) return false; - if (!ctx.bot.knows_spell(HOLY_WORD_SERENITY)) return false; - if (!ctx.bot.is_ready(HOLY_WORD_SERENITY)) return false; - return WoundedFriendCount(ctx, 70) >= 3; -} -void DoHolyWordSerenityAoe(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(HOLY_WORD_SERENITY, LowestFriendOrSelf(ctx).guid); -} - -bool ShouldPrayerOfHealing(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(PRAYER_OF_HEALING)) return false; - if (InManaFloor(ctx) && LowestFriendOrSelf(ctx).hp_pct > 35) return false; - return WoundedFriendCount(ctx, 80) >= 3; -} -void DoPrayerOfHealing(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(PRAYER_OF_HEALING, LowestFriendOrSelf(ctx).guid); -} - -bool ShouldHolyNova(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(HOLY_NOVA)) return false; - if (ctx.bot.attackers_count() < 2) return false; - return WoundedFriendCount(ctx, 92) >= 2; -} -void DoHolyNova(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(HOLY_NOVA); } - -bool ShouldHaloHeal(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(HALO)) return false; - if (!ctx.bot.is_ready(HALO)) return false; - return WoundedFriendCount(ctx, 85) >= 2; -} -void DoHaloHeal(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(HALO); } - -// ---- Spike heal ---- -bool ShouldHolyWordSerenity(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(HOLY_WORD_SERENITY)) return false; - if (!ctx.bot.is_ready(HOLY_WORD_SERENITY)) return false; - return LowestFriendOrSelf(ctx).hp_pct <= 60; -} -void DoHolyWordSerenity(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(HOLY_WORD_SERENITY, LowestFriendOrSelf(ctx).guid); -} - -bool ShouldFlashHeal(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(FLASH_HEAL)) return false; - if (InManaFloor(ctx) && LowestFriendOrSelf(ctx).hp_pct > 35) return false; - return LowestFriendOrSelf(ctx).hp_pct <= 50; -} -void DoFlashHeal(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(FLASH_HEAL, LowestFriendOrSelf(ctx).guid); -} - -// ---- HoT maintenance ---- -bool ShouldPrayerOfMending(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(PRAYER_OF_MENDING)) return false; - if (!ctx.bot.is_ready(PRAYER_OF_MENDING)) return false; - GroupMemberSummary const* tank = ctx.group.tank(); - ObjectGuid target = tank && tank->online ? tank->guid : LowestFriendOrSelf(ctx).guid; - AuraEntry const* a = ctx.bot.find_aura(PRAYER_OF_MENDING, target); - return !a || a->remaining.count() <= 5000; -} -void DoPrayerOfMending(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - GroupMemberSummary const* tank = ctx.group.tank(); - ObjectGuid target = tank && tank->online ? tank->guid : LowestFriendOrSelf(ctx).guid; - e.cast(PRAYER_OF_MENDING, target); -} - -// ---- Filler ---- -// Flash Heal top-off - Heal (2060) and Renew (139) are gone in 12.1, so -// Flash Heal doubles as the efficient filler (Improved Flash Heal [R][M]) -// and drives the Serenity cooldown reduction. Mana-floor gated. -bool ShouldFlashHealFiller(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(FLASH_HEAL)) return false; - if (LowestFriendOrSelf(ctx).hp_pct > 85) return false; - if (InManaFloor(ctx) && LowestFriendOrSelf(ctx).hp_pct > 35) return false; - if (ctx.bot.is_moving() && !ctx.bot.can_cast_while_moving(FLASH_HEAL)) return false; - return true; -} -void DoFlashHealFiller(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(FLASH_HEAL, LowestFriendOrSelf(ctx).guid); -} - -// ---- Offensive filler (group topped — drives Holy Word CDR) ---- -bool ShouldHolyFireFiller(ApPredicateContext const& ctx) -{ - if (!HasLiveTargetInline(ctx)) return false; - if (!GroupTopped(ctx)) return false; - if (!ctx.bot.knows_spell(HOLY_FIRE)) return false; - return ctx.bot.is_ready(HOLY_FIRE); -} -void DoHolyFireFiller(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(HOLY_FIRE, ctx.bot.victim()); -} - -// SW: Pain filler - only for the untalented bot: the Holy Fire talent -// ([R][M]) overrides SW: Pain, so casting 589 would resolve to Holy Fire -// and fail against its 10s cooldown. -bool ShouldShadowWordPainFiller(ApPredicateContext const& ctx) -{ - if (!HasLiveTargetInline(ctx)) return false; - if (!GroupTopped(ctx)) return false; - if (!ctx.bot.knows_spell(SHADOW_WORD_PAIN)) return false; - if (ctx.bot.knows_spell(HOLY_FIRE)) return false; - AuraEntry const* a = ctx.bot.find_aura(SHADOW_WORD_PAIN, ctx.bot.victim()); - return !a || a->remaining.count() <= 3000; -} -void DoShadowWordPainFiller(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(SHADOW_WORD_PAIN, ctx.bot.victim()); -} - -bool ShouldSmiteFiller(ApPredicateContext const& ctx) -{ - if (!HasLiveTargetInline(ctx)) return false; - if (!GroupTopped(ctx)) return false; - if (!ctx.bot.knows_spell(SMITE)) return false; - return !(ctx.bot.is_moving() && !ctx.bot.can_cast_while_moving(SMITE)); -} -void DoSmiteFiller(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(SMITE, ctx.bot.victim()); -} - -bool AlwaysAlive(ApPredicateContext const& ctx) { return ctx.bot.is_alive(); } -void DoNothing(ApPredicateContext const&, BotIntentEmitter&) {} - -// Self Power Word: Shield - Holy's only non-talent damage-reduction CD on -// self, and only until L11: Prayer of Mending (spec spell) OVERRIDES PW: -// Shield, so once PoM is known casting 17 would resolve to PoM. PW: Shield -// carries a 7.5s category cooldown in 12.1 (Weakened Soul is gone), which -// is_ready() covers. Fires at <=55% with active fight + a nearby enemy. -bool ShouldPowerWordShieldSelf(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(POWER_WORD_SHIELD)) return false; - if (ctx.bot.knows_spell(PRAYER_OF_MENDING)) return false; - if (!ctx.bot.is_ready(POWER_WORD_SHIELD)) return false; - if (ctx.bot.hp_pct() > 55) return false; - if (ctx.bot.enemies_within(40.0f) == 0) return false; - if (ctx.bot.find_aura(POWER_WORD_SHIELD, ctx.bot.raw().guid)) return false; - return true; -} -void DoPowerWordShieldSelf(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(POWER_WORD_SHIELD, ctx.bot.raw().guid); -} - -// ---- Rule table (priority order) ---- -// Order follows the Holy decision tree: cast-swap first (so we can change -// targets mid-cast), OOC rez, interrupt / CC / threat, personal survival, -// dispels, hard panic CDs (Guardian Spirit ally -> Divine Hymn raid -> HW: -// Serenity instant -> Apotheosis reset), Power Infusion, Prayer of Mending -// bouncing HoT, Flash Heal spike, AoE heals (HW: Sanctify or the Ultimate -// Serenity branch -> Prayer of Healing -> Holy Nova -> Halo), the Flash -// Heal top-off filler, and finally the offensive filler that drives Holy -// Word CDR (Holy Fire / SW: Pain / Smite). -ApRule const kRules[] = { - // Cast-swap MUST be first in the priority list - if we don't - // cancel the in-flight cast immediately, lower rules can't change - // target because is_casting blocks them. - { ShouldCancelHealForSwap, DoCancelHealForSwap, "Cancel heal — swap to lower target" }, - { ShouldMassResurrection, DoMassResurrection, "Mass Resurrection (OOC)" }, - { ShouldResurrection, DoResurrection, "Resurrection (OOC)" }, - // ---- Interrupt / CC / threat ---- - { ShouldHolyWordChastise, DoHolyWordChastise, "HW: Chastise (interrupt)" }, - { ShouldPsychicScream, DoPsychicScream, "Psychic Scream (panic AoE)" }, - { ShouldLeapOfFaith, DoLeapOfFaith, "Leap of Faith (peel tank)" }, - { ShouldFade, DoFade, "Fade (threat)" }, - // ---- Personal survival ---- - { ShouldDesperatePrayer, DoDesperatePrayer, "Desperate Prayer (<=40%)" }, - { ShouldPowerWordShieldSelf, DoPowerWordShieldSelf, "PW: Shield self (<=55%)" }, - // ---- Dispel ---- - { ShouldPurify, DoPurify, "Purify (Magic / Disease)" }, - { ShouldMassDispel, DoMassDispel, "Mass Dispel (raid)" }, - // ---- Hard panic heals (ally life-savers, ordered by raw save power) ---- - { ShouldGuardianSpirit, DoGuardianSpirit, "Guardian Spirit (ally panic)" }, - { ShouldDivineHymn, DoDivineHymn, "Divine Hymn (raid panic)" }, - { ShouldHolyWordSerenity, DoHolyWordSerenity, "HW: Serenity (instant <=60%)" }, - { ShouldApotheosis, DoApotheosis, "Apotheosis (Holy Word reset)" }, - // ---- Burst CD ---- - { ShouldPowerInfusion, DoPowerInfusion, "Power Infusion" }, - // ---- HoT maintenance ---- - { ShouldPrayerOfMending, DoPrayerOfMending, "Prayer of Mending (tank)" }, - // ---- Spike heal ---- - { ShouldFlashHeal, DoFlashHeal, "Flash Heal (<=50%)" }, - // ---- AoE heals ---- - { ShouldHolyWordSanctify, DoHolyWordSanctify, "HW: Sanctify (raid spike)" }, - { ShouldHolyWordSerenityAoe, DoHolyWordSerenityAoe, "HW: Serenity (Ult. AoE)" }, - { ShouldPrayerOfHealing, DoPrayerOfHealing, "Prayer of Healing (3+ at 80%)" }, - { ShouldHolyNova, DoHolyNova, "Holy Nova (cleave heal+dmg)" }, - { ShouldHaloHeal, DoHaloHeal, "Halo (raid heal)" }, - // ---- Efficient filler ---- - { ShouldFlashHealFiller, DoFlashHealFiller, "Flash Heal (top-off <=85%)" }, - // ---- Offensive filler (group topped - drives Holy Word CDR) ---- - { ShouldHolyFireFiller, DoHolyFireFiller, "Holy Fire (filler / CDR)" }, - { ShouldShadowWordPainFiller,DoShadowWordPainFiller,"SW: Pain (filler, no HF)" }, - { ShouldSmiteFiller, DoSmiteFiller, "Smite (filler / CDR)" }, - { AlwaysAlive, DoNothing, "Idle" }, -}; - -} // anonymous - -void RegisterApl_Priest_Holy() -{ - constexpr uint32 SPEC_PRIEST_HOLY = 257; - RegisterRotation(CLASS_PRIEST, SPEC_PRIEST_HOLY, ApRotation{kRules}); -} - -} // namespace Playerbot::Combat diff --git a/src/modules/PlayerbotV2/Combat/Apl/Apl_Priest_Shadow.cpp b/src/modules/PlayerbotV2/Combat/Apl/Apl_Priest_Shadow.cpp deleted file mode 100644 index c328f1badb..0000000000 --- a/src/modules/PlayerbotV2/Combat/Apl/Apl_Priest_Shadow.cpp +++ /dev/null @@ -1,537 +0,0 @@ -// Shadow Priest - WoW 12.1.0.69587 enterprise rotation. Insanity-driven -// caster with two stacked DoTs (SW:P + VT) maintained on every nearby enemy, -// off-CD Mind Blast (Insanity generator), Shadow Word: Madness spending (the -// 12.1 Insanity spender - Devouring Plague is gone), Voidform burst (2 min -// CD, no Insanity cost in 12.1) with Void Bolt inside the window, Void -// Torrent (Voidweaver hero tree, opens an Entropic Rift) and Tentacle Slam -// (AoE damage that spreads Vampiric Touch). Self-survival via Dispersion + -// Desperate Prayer + Flash Heal + Power Word: Shield + Fade. Group utility -// via Vampiric Embrace + Purify Disease + Dispel Magic + Mass Dispel + Power -// Infusion. CC via Psychic Scream, interrupt via Silence. Multi-dot cycling -// piggybacks on the BotSnapshotBuilder enemy outbound scan (spec 258). -// -// Server-side overrides (Unit::GetCastSpellInfo resolves OVERRIDE_ACTIONBAR -// auras) mean the bot casts the BASE id and the game swaps in the talent -// version: Mind Blast -> Void Blast while an Entropic Rift is open (Void -// Blast 450405), Mind Flay -> Mind Flay: Insanity after a spender (Surge of -// Insanity 391399), Mind Flay replaces Smite (spec override). No extra rules. -// -// ---- Validated spell IDs (WoW 12.1.0.69587 SpellName.csv / kit) ---- -// 17 Power Word: Shield (L4 baseline - self absorb, 7.5s cat. CD) -// 528 Dispel Magic (class talent [R][M] - offensive purge) -// 586 Fade (class talent [R][M] - threat dump) -// 589 Shadow Word: Pain (L2 baseline - DoT) -// 2061 Flash Heal (L3 baseline - self heal) -// 8092 Mind Blast (class talent [R][M] - Insanity generator) -// 8122 Psychic Scream (class talent [R][M] - AoE fear, 40s CD) -// 10060 Power Infusion (class talent [R][M]) -// 15286 Vampiric Embrace (spec spell L25 - group lifelink) -// 15407 Mind Flay (spec spell L10 - channel filler) -// 15487 Silence (spec spell L26 - 40yd interrupt) -// 19236 Desperate Prayer (class talent [R][M] - self heal) -// 32375 Mass Dispel (class talent [R][M]) -// 32379 Shadow Word: Death (class talent [R][M] - execute) -// 34914 Vampiric Touch (spec spell L10 - DoT) -// 47585 Dispersion (spec spell L13 - 75% DR, 2 min CD) -// 120644 Halo (Archon hero talent [R][M] - Shadow ring) -// 194249 Voidform (AURA while in Voidform - see 228260 text) -// 213634 Purify Disease (class talent [R][M] - friendly dispel) -// 228260 Voidform (spec talent [R][M] - enter Voidform) -// 228266 Void Bolt (taught by 228260 - only in Voidform) -// 232698 Shadowform (spec spell L10 - stance) -// 263165 Void Torrent (Voidweaver hero [R] - 3s channel, 30s CD) -// 335467 Shadow Word: Madness (spec talent [R][M] - 50 Insanity spender) -// 1227280 Tentacle Slam (spec talent [R][M] - AoE dmg, spreads VT) -// -// ---- Skipped spells (and why) ---- -// - Devouring Plague (369128), Mind Spike (171852), Dark Ascension (391109), -// Divine Star (122121), Mindgames (375901), Void Eruption (228361), -// Shadow Crash (205385): not learnable by Shadow in 12.1 (removed or -// replaced). SW: Madness / Voidform / Tentacle Slam take their slots. -// - Shadowfiend (34433): a PASSIVE in 12.1 ("SW: Death has a chance to -// summon a Shadowfiend") - not castable. Mindbender (1230339) is also -// passive ("Casting Voidform summons a Mindbender"); Voidwraith (451234) -// is a passive override of the summon. -// - Shadow Mend (186263 / 186440): 186263 is not learnable; 186440 is a -// passive placeholder with no cast text. Flash Heal is the self heal. -// - Weakened Soul (6788): nothing in 12.1 applies it (PW:S uses a 7.5s -// category cooldown) - is_ready() gates the re-cast instead. -// - Void Volley (1242173): replaces the Voidform button inside Voidform -// via override; the base id 228260 sits on its 2 min CD so is_ready() -// cannot see the Volley charges. Void Bolt covers the in-Voidform slot. -// - Void Torrent (205065) / Light's Wrath (207946) / Light of T'uure -// (208065): legacy Artifact rows in the baseline list, no learn level. -// - Power Word: Fortitude (21562): group buff applied by the class-buff -// table (Bot/ClassTables.cpp), not by the combat APL. -// - Leap of Faith (73325), Angelic Feather (121536), Dominate Mind -// (205364), Mind Control (605), Shackle Horror (9484): positioning / -// niche CC a DPS bot cannot use well. -// - Single-Button Assistant (1229376): the APL is the assistant. - -#include "../ApRegistry.h" -#include "../ApRotation.h" -#include "Bot/BotIntentEmitter.h" -#include "Bot/BotSnapshotView.h" -#include "Group/GroupSnapshot.h" -#include "SharedDefines.h" - -namespace Playerbot::Combat { - -namespace { - -// ---- Spell IDs (WoW 12.1.0.69587, validated) ---- -constexpr uint32 SHADOW_WORD_PAIN = 589; -constexpr uint32 VAMPIRIC_TOUCH = 34914; -constexpr uint32 MIND_BLAST = 8092; -constexpr uint32 MIND_FLAY = 15407; -constexpr uint32 SHADOW_WORD_MADNESS = 335467; // 50 Insanity spender (12.1 replacement for Devouring Plague) -constexpr uint32 VOIDFORM = 228260; // enter Voidform (1.5s cast, 2 min CD, no Insanity cost in 12.1) -constexpr uint32 VOID_BOLT = 228266; // taught by Voidform - available while in Voidform -constexpr uint32 VOIDFORM_AURA = 194249; // buff while in Voidform (referenced by the 228260 tooltip) -constexpr uint32 VOID_TORRENT = 263165; // Voidweaver hero talent - 3s channel, opens Entropic Rift -constexpr uint32 TENTACLE_SLAM = 1227280; // spec talent - AoE damage + applies VT to up to 3 enemies -constexpr uint32 SHADOW_WORD_DEATH = 32379; // execute < 20% -constexpr uint32 HALO = 120644; // Archon hero talent - Shadow variant 30yd ring -constexpr uint32 POWER_INFUSION = 10060; // 2min self/ally haste -constexpr uint32 SHADOWFORM = 232698; -constexpr uint32 DISPERSION = 47585; // 75% DR + heal, 2min CD -constexpr uint32 DESPERATE_PRAYER = 19236; // self heal + max HP, 90s CD -constexpr uint32 SILENCE = 15487; // 40yd interrupt -constexpr uint32 PSYCHIC_SCREAM = 8122; // 8yd fear, 40s CD -constexpr uint32 PW_SHIELD = 17; // self absorb (7.5s category CD) -constexpr uint32 FLASH_HEAL = 2061; // L3 - self heal -constexpr uint32 FADE = 586; // threat dump -constexpr uint32 DISPEL_MAGIC = 528; // offensive purge (enemy Magic buff) -constexpr uint32 PURIFY_DISEASE = 213634; // friendly disease dispel (class talent) -constexpr uint32 MASS_DISPEL = 32375; // group Magic dispel -constexpr uint32 VAMPIRIC_EMBRACE = 15286; // 12s group leech CD - -// Power index for Insanity. Power array layout matches the WoW 12.1 -// Powers enum where POWER_INSANITY = 13 (snapshot stores display units). -constexpr uint8 POWER_INSANITY_IDX = 13; - -bool HasLiveTarget(ApPredicateContext const& ctx) -{ - return !ctx.bot.victim().IsEmpty(); -} - -bool BossLikeTargetEngaged(ApPredicateContext const& ctx) -{ - constexpr int32 kBossHpThreshold = 5'000'000; - NearbyUnit const* t = ctx.bot.victim_info(); - if (t && t->max_hp >= kBossHpThreshold) return true; - for (auto const& a : ctx.bot.raw().combat.attackers) - if (a.max_hp >= kBossHpThreshold) return true; - return false; -} - -bool TargetExecuteRange(ApPredicateContext const& ctx) -{ - NearbyUnit const* t = ctx.bot.victim_info(); - if (!t || t->max_hp <= 0 || t->hp <= 0) return false; - return (t->hp * 100) / t->max_hp <= 20; -} - -// ---- Stance / buffs ---- -bool ShouldShadowform(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(SHADOWFORM)) return false; - return !ctx.bot.has_aura(SHADOWFORM); -} -void DoShadowform(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(SHADOWFORM); } - -bool ShouldPowerWordShield(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(PW_SHIELD)) return false; - if (!ctx.bot.is_ready(PW_SHIELD)) return false; // 7.5s category CD replaces Weakened Soul - if (ctx.bot.has_aura(PW_SHIELD)) return false; - return ctx.bot.hp_pct() <= 75 || (ctx.bot.in_combat() && ctx.bot.hp_pct() <= 90); -} -void DoPowerWordShield(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(PW_SHIELD); } - -// ---- Survival ---- -bool ShouldDispersion(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(DISPERSION)) return false; - if (!ctx.bot.is_ready(DISPERSION)) return false; - return ctx.bot.hp_pct() <= 30; -} -void DoDispersion(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(DISPERSION); } - -bool ShouldDesperatePrayer(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(DESPERATE_PRAYER)) return false; - if (!ctx.bot.is_ready(DESPERATE_PRAYER)) return false; - return ctx.bot.hp_pct() <= 40; -} -void DoDesperatePrayer(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(DESPERATE_PRAYER); } - -bool ShouldFade(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(FADE)) return false; - if (!ctx.bot.is_ready(FADE)) return false; - // Fade if multiple attackers chose us — likely a threat problem the - // tank hasn't recovered from yet. - return ctx.bot.attackers_count() >= 2; -} -void DoFade(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(FADE); } - -// Flash Heal is the only direct self heal Shadow owns in 12.1 (Shadow Mend -// is a Discipline passive upgrade now). 1.5s cast - worth it below 45%. -bool ShouldFlashHealSelf(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(FLASH_HEAL)) return false; - if (!ctx.bot.is_ready(FLASH_HEAL)) return false; - return ctx.bot.hp_pct() <= 45; -} -void DoFlashHealSelf(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(FLASH_HEAL, ctx.bot.raw().guid); -} - -// ---- Group utility ---- -bool ShouldVampiricEmbrace(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(VAMPIRIC_EMBRACE)) return false; - if (!ctx.bot.is_ready(VAMPIRIC_EMBRACE)) return false; - if (auto const* low = ctx.group.lowest_hp_on_map(ctx.bot.map_id(), Role::Unknown, ctx.bot.raw().position.x, ctx.bot.raw().position.y, ctx.bot.raw().position.z, 45.0f)) - return low->online && low->max_hp > 0 && (low->hp * 100) / low->max_hp <= 70; - return ctx.bot.hp_pct() <= 70; -} -void DoVampiricEmbrace(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(VAMPIRIC_EMBRACE); } - -bool ShouldPowerInfusion(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(POWER_INFUSION)) return false; - if (!ctx.bot.is_ready(POWER_INFUSION)) return false; - // Pop on boss-tier target — the haste burst window is wasted on trash. - return BossLikeTargetEngaged(ctx); -} -void DoPowerInfusion(ApPredicateContext const&, BotIntentEmitter& e) -{ - // Self-cast: with no specific assignment the bot will benefit itself. - e.cast(POWER_INFUSION); -} - -// Dispel Magic (class talent [R][M]) - cheap single-target purge of an -// enemy Magic buff. Preferred over Mass Dispel for the same job. -bool ShouldDispelMagic(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(DISPEL_MAGIC)) return false; - if (!ctx.bot.is_ready(DISPEL_MAGIC)) return false; - return ctx.bot.target_dispellable(Playerbot::DispelType::Magic); -} -void DoDispelMagic(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(DISPEL_MAGIC, ctx.bot.victim()); -} - -// Purify Disease (class talent [R][M]) - friendly disease cleanse; the -// only friendly dispel Shadow owns (Purify is Disc/Holy-only). -bool ShouldPurifyDisease(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(PURIFY_DISEASE)) return false; - if (!ctx.bot.is_ready(PURIFY_DISEASE)) return false; - if (ctx.group.dispel_candidate(Playerbot::DispelType::Disease)) return true; - return ctx.bot.self_dispellable(Playerbot::DispelType::Disease); -} -void DoPurifyDisease(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* ds = ctx.group.dispel_candidate(Playerbot::DispelType::Disease)) { e.cast(PURIFY_DISEASE, ds->guid); return; } - e.cast(PURIFY_DISEASE, ctx.bot.raw().guid); -} - -bool ShouldMassDispel(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(MASS_DISPEL)) return false; - if (!ctx.bot.is_ready(MASS_DISPEL)) return false; - // Only when the cheap Dispel Magic cannot do the job (unknown or on CD): - // Mass Dispel is 2 min / 20% mana and also strips immunities. We - // approximate "useful" by a dispellable buff on the current victim. - if (ctx.bot.knows_spell(DISPEL_MAGIC) && ctx.bot.is_ready(DISPEL_MAGIC)) return false; - if (ctx.bot.target_dispellable(Playerbot::DispelType::Magic)) return true; - return false; -} -void DoMassDispel(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* v = ctx.bot.victim_info()) - e.cast_at(MASS_DISPEL, v->x, v->y, v->z); - else - e.cast(MASS_DISPEL, ctx.bot.victim()); -} - -// ---- Interrupt / CC ---- -bool ShouldSilence(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(SILENCE)) return false; - if (!ctx.bot.is_ready(SILENCE)) return false; - const bool pvp = ctx.pvp.in_battleground || ctx.pvp.in_arena; - return ctx.bot.kick_target(pvp, 40.0f) != nullptr; -} -void DoSilence(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - const bool pvp = ctx.pvp.in_battleground || ctx.pvp.in_arena; - if (auto const* c = ctx.bot.kick_target(pvp, 40.0f)) - e.cast(SILENCE, c->guid); -} - -bool ShouldPsychicScream(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(PSYCHIC_SCREAM)) return false; - if (!ctx.bot.is_ready(PSYCHIC_SCREAM)) return false; - // Personal panic button — at least 2 in melee and we're hurting. - return ctx.bot.enemies_within(8.0f) >= 2 && ctx.bot.hp_pct() <= 50; -} -void DoPsychicScream(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(PSYCHIC_SCREAM); } - -// ---- Major offensive cooldowns ---- -// Voidform (228260) is the 12.1 entry cast: 1.5s, 2 min CD, no Insanity -// cost. Enter once Vampiric Touch is rolling on the victim so the Void Bolt -// DoT extensions inside the window have something to extend. The Mindbender -// (1230339) and Voidwraith (451234) passives summon their pets off this cast. -bool ShouldVoidform(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(VOIDFORM)) return false; - if (!ctx.bot.is_ready(VOIDFORM)) return false; - if (ctx.bot.has_aura(VOIDFORM_AURA)) return false; - return ctx.bot.find_aura(VAMPIRIC_TOUCH, ctx.bot.victim()) != nullptr; -} -void DoVoidform(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(VOIDFORM, ctx.bot.victim()); -} - -bool ShouldVoidBolt(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(VOID_BOLT)) return false; - if (!ctx.bot.is_ready(VOID_BOLT)) return false; - return ctx.bot.has_aura(VOIDFORM_AURA); -} -void DoVoidBolt(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(VOID_BOLT, ctx.bot.victim()); -} - -// Void Torrent (Voidweaver hero talent) - 3s channel, 30s CD, generates -// Insanity and tears open an Entropic Rift (which turns Mind Blast into -// Void Blast via server-side override). Channel needs a standing bot and -// pays best with the DoTs already ticking. -bool ShouldVoidTorrent(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(VOID_TORRENT)) return false; - if (!ctx.bot.is_ready(VOID_TORRENT)) return false; - if (ctx.bot.is_moving()) return false; - return ctx.bot.find_aura(VAMPIRIC_TOUCH, ctx.bot.victim()) != nullptr; -} -void DoVoidTorrent(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(VOID_TORRENT, ctx.bot.victim()); -} - -// ---- Talent damage ---- -// Tentacle Slam (spec talent [R][M]) - instant AoE around the victim that -// applies Vampiric Touch to up to 3 enemies (VT-less ones first) and -// generates Insanity. It is the 12.1 DoT-spreader (Shadow Crash is gone): -// fire on 2+ enemies / owner AoE pin, or whenever an enemy in range still -// lacks our VT. -bool ShouldTentacleSlam(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(TENTACLE_SLAM)) return false; - if (!ctx.bot.is_ready(TENTACLE_SLAM)) return false; - if (ctx.aoe_preference || ctx.bot.enemies_within(15.0f) >= 2) return true; - return ctx.bot.enemy_without_my_aura(VAMPIRIC_TOUCH, 40.0f) != nullptr; -} -void DoTentacleSlam(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(TENTACLE_SLAM, ctx.bot.victim()); -} - -// Halo (Archon hero talent, Shadow variant 120644) - 1.5s cast ring, 60s -// category CD, damages enemies / heals allies / generates Insanity. -bool ShouldHalo(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(HALO)) return false; - if (!ctx.bot.is_ready(HALO)) return false; - return true; -} -void DoHalo(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(HALO); } - -// ---- Execute ---- -bool ShouldShadowWordDeath(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(SHADOW_WORD_DEATH)) return false; - if (!ctx.bot.is_ready(SHADOW_WORD_DEATH)) return false; - return TargetExecuteRange(ctx); -} -void DoShadowWordDeath(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(SHADOW_WORD_DEATH, ctx.bot.victim()); -} - -// ---- Insanity spender ---- -// Shadow Word: Madness (335467) - the 12.1 spender (50 Insanity, 6s DoT + -// self heal). Re-applying rolls the remaining damage into the new effect, -// so there is no clipping loss: spend freely near the 100 cap, otherwise -// wait for the current DoT to run down. -bool ShouldShadowWordMadness(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(SHADOW_WORD_MADNESS)) return false; - if (!ctx.bot.is_ready(SHADOW_WORD_MADNESS)) return false; - const int32 insanity = ctx.bot.power(POWER_INSANITY_IDX); - if (insanity < 50) return false; - if (insanity >= 85) return true; - AuraEntry const* a = ctx.bot.find_aura(SHADOW_WORD_MADNESS, ctx.bot.victim()); - return !a || a->remaining.count() <= 2000; -} -void DoShadowWordMadness(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(SHADOW_WORD_MADNESS, ctx.bot.victim()); -} - -// ---- DoT primary + multi-target expand ---- -bool ShouldShadowWordPainPrimary(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(SHADOW_WORD_PAIN)) return false; - AuraEntry const* a = ctx.bot.find_aura(SHADOW_WORD_PAIN, ctx.bot.victim()); - return !a || a->remaining.count() <= 3000; -} -void DoShadowWordPainPrimary(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(SHADOW_WORD_PAIN, ctx.bot.victim()); -} - -bool ShouldVampiricTouchPrimary(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(VAMPIRIC_TOUCH)) return false; - AuraEntry const* a = ctx.bot.find_aura(VAMPIRIC_TOUCH, ctx.bot.victim()); - return !a || a->remaining.count() <= 3000; -} -void DoVampiricTouchPrimary(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(VAMPIRIC_TOUCH, ctx.bot.victim()); -} - -bool ShouldShadowWordPainExpand(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(SHADOW_WORD_PAIN)) return false; - return ctx.bot.enemy_without_my_aura(SHADOW_WORD_PAIN, 40.0f) != nullptr; -} -void DoShadowWordPainExpand(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* off = ctx.bot.enemy_without_my_aura(SHADOW_WORD_PAIN, 40.0f)) - e.cast(SHADOW_WORD_PAIN, off->guid); -} - -bool ShouldVampiricTouchExpand(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(VAMPIRIC_TOUCH)) return false; - return ctx.bot.enemy_without_my_aura(VAMPIRIC_TOUCH, 40.0f) != nullptr; -} -void DoVampiricTouchExpand(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* off = ctx.bot.enemy_without_my_aura(VAMPIRIC_TOUCH, 40.0f)) - e.cast(VAMPIRIC_TOUCH, off->guid); -} - -// ---- Filler / generators ---- -bool ShouldMindBlast(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(MIND_BLAST)) return false; - return ctx.bot.is_ready(MIND_BLAST); -} -void DoMindBlast(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(MIND_BLAST, ctx.bot.victim()); -} - -// Mind Flay - the only filler left in 12.1 (Mind Spike / Mind Sear are -// gone). After a spender the Surge of Insanity override turns this cast -// into Mind Flay: Insanity server-side. -bool ShouldMindFlay(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - return ctx.bot.knows_spell(MIND_FLAY); -} -void DoMindFlay(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(MIND_FLAY, ctx.bot.victim()); -} - -bool AlwaysAlive(ApPredicateContext const& ctx) { return ctx.bot.is_alive(); } -void DoNothing(ApPredicateContext const&, BotIntentEmitter&) {} - -// ---- Rule table (priority order top-down) ---- -// Order follows the Shadow decision tree: Dispersion / Desperate Prayer -// (panic) -> Fade / Psychic Scream / Flash Heal / PW: Shield (survival) -> -// Vampiric Embrace + dispels (group utility) -> Silence (interrupt) -> -// Power Infusion / Voidform / Void Torrent / Halo (burst CDs) -> Tentacle -// Slam (AoE VT spread) -> SW: Death (execute) -> SW: Madness (50+ Insanity -// spender) -> Void Bolt (in Voidform) -> Vampiric Touch -> Shadow Word: -// Pain -> Mind Blast -> Mind Flay (channel filler). Survival CDs sit above -// the damage rotor so we can break combat to heal mid-fight. -ApRule const kRules[] = { - // ---- Panic / survival ---- - { ShouldDispersion, DoDispersion, "Dispersion (<=30%)" }, - { ShouldDesperatePrayer, DoDesperatePrayer, "Desperate Prayer (<=40%)" }, - { ShouldFade, DoFade, "Fade (threat dump)" }, - { ShouldPsychicScream, DoPsychicScream, "Psychic Scream (panic)" }, - { ShouldFlashHealSelf, DoFlashHealSelf, "Flash Heal self (<=45%)" }, - { ShouldPowerWordShield, DoPowerWordShield, "Power Word: Shield" }, - { ShouldShadowform, DoShadowform, "Shadowform stance" }, - // ---- Group utility ---- - { ShouldVampiricEmbrace, DoVampiricEmbrace, "Vampiric Embrace (group heal)" }, - { ShouldPurifyDisease, DoPurifyDisease, "Purify Disease (ally)" }, - { ShouldDispelMagic, DoDispelMagic, "Dispel Magic (purge)" }, - { ShouldMassDispel, DoMassDispel, "Mass Dispel" }, - // ---- Interrupt ---- - { ShouldSilence, DoSilence, "Silence (interrupt)" }, - // ---- Burst CDs ---- - { ShouldPowerInfusion, DoPowerInfusion, "Power Infusion (boss)" }, - { ShouldVoidform, DoVoidform, "Voidform (enter)" }, - { ShouldVoidTorrent, DoVoidTorrent, "Void Torrent (rift)" }, - { ShouldHalo, DoHalo, "Halo (Archon)" }, - // ---- AoE DoT spread ---- - { ShouldTentacleSlam, DoTentacleSlam, "Tentacle Slam (VT spread)" }, - // ---- Execute / spender ---- - { ShouldShadowWordDeath, DoShadowWordDeath, "Shadow Word: Death (execute)" }, - { ShouldShadowWordMadness, DoShadowWordMadness, "SW: Madness (50 ins)" }, - { ShouldVoidBolt, DoVoidBolt, "Void Bolt (in Voidform)" }, - // ---- DoT maintenance + expansion ---- - { ShouldVampiricTouchPrimary, DoVampiricTouchPrimary, "Vampiric Touch (primary)" }, - { ShouldShadowWordPainPrimary, DoShadowWordPainPrimary, "SW: Pain (primary refresh)" }, - { ShouldVampiricTouchExpand, DoVampiricTouchExpand, "Vampiric Touch (expand)" }, - { ShouldShadowWordPainExpand, DoShadowWordPainExpand, "SW: Pain (expand off-target)" }, - // ---- Insanity generator (Mind Blast) ---- - { ShouldMindBlast, DoMindBlast, "Mind Blast" }, - // ---- Filler ---- - { ShouldMindFlay, DoMindFlay, "Mind Flay (channel filler)" }, - { AlwaysAlive, DoNothing, "Idle" }, -}; - -} // anonymous - -void RegisterApl_Priest_Shadow() -{ - constexpr uint32 SPEC_PRIEST_SHADOW = 258; - RegisterRotation(CLASS_PRIEST, SPEC_PRIEST_SHADOW, ApRotation{kRules}); -} - -} // namespace Playerbot::Combat diff --git a/src/modules/PlayerbotV2/Combat/Apl/Apl_Rogue_Assassination.cpp b/src/modules/PlayerbotV2/Combat/Apl/Apl_Rogue_Assassination.cpp deleted file mode 100644 index 7c6ad1d576..0000000000 --- a/src/modules/PlayerbotV2/Combat/Apl/Apl_Rogue_Assassination.cpp +++ /dev/null @@ -1,592 +0,0 @@ -// Assassination Rogue - WoW 12.1.0.69587 (Midnight) enterprise rotation. -// Bleed-driven melee with Garrote/Rupture maintenance, Envenom spend at -// 5+ CP, Slice and Dice attack-speed buff, Crimson Tempest AoE generator -// (copies Garrote/Rupture to nearby enemies), Fan of Knives AoE generator -// / poison spread, Deathmark + Kingsbane damage windows, Shiv poison amp. -// Weapon poisons are kept up out of combat: Deadly Poison (+ Amplifying -// Poison with Dragon-Tempered Blades) lethal, Atrophic / Crippling -// non-lethal. Thistle Tea restores Energy when starved. -// -// Survival: Crimson Vial, Evasion, Cloak of Shadows (magic immune), Feint -// (DR), Vanish (combat drop). Group utility: Tricks of the Trade (tank -// threat). CC: Kick interrupt, Kidney Shot (CP stun), Blind (panic CC). -// Gap-close via Shadowstep (36554, learned through spec spell 394932). -// -// Validated spell IDs (SpellName.csv lookup, WoW 12.1.0.69587): -// 1329 Mutilate - CP gen, melee (spec override of 1752) -// 32645 Envenom - finisher (poison amp; overrides Eviscerate) -// 703 Garrote - bleed (stealth opener + maintained) -// 1943 Rupture - bleed finisher -// 360194 Deathmark - talent [R] burst CD -// 385627 Kingsbane - talent [R] Nature DoT CD -// 1247227 Crimson Tempest - talent [M] AoE generator (was 121411) -// 315496 Slice and Dice - attack-speed self-buff finisher -// 185565 Poisoned Knife - ranged poison applicator -// 51723 Fan of Knives - AoE generator + poison spread -// 5938 Shiv - talent [R] poison amp -// 2823 Deadly Poison - talent [R] lethal poison -// 381664 Amplifying Poison - talent [R] second lethal poison -// 315584 Instant Poison - baseline lethal poison (fallback) -// 381637 Atrophic Poison - talent [R] non-lethal poison -// 3408 Crippling Poison - baseline non-lethal poison (fallback) -// 381623 Thistle Tea - taught by class passive 469779 [R] -// 1298826 Thistle Tea - active class talent variant (same effect) -// 36554 Shadowstep - cast id; 394932 is the Sin spec learn-spell -// 1766 Kick / 408 Kidney Shot / 2094 Blind / 57934 Tricks -// 114018 Shroud of Concealment (declared, no combat rule) -// 185311 Crimson Vial / 5277 Evasion / 31224 Cloak / 1966 Feint / 1856 Vanish -// 1784 Stealth / 115191 Stealth (Subterfuge) / 115192 Subterfuge window -// Passive gate: 381801 Dragon-Tempered Blades (allows two lethal poisons) -// -// Skipped (with reason): -// 79140 Vendetta - not learnable in 12.1 (replaced by Deathmark). -// 385408 Sepsis - not learnable in 12.1. -// 137619 Marked for Death - not learnable in 12.1. -// 385616 Echoing Reprimand - 12.1 version (470669) is a passive. -// 381802 Indiscriminate Carnage - passive/removed in 12.1. -// 76577 Smoke Bomb - not learnable in 12.1. -// 1776 Gouge - class talent not in the curated Sin builds; needs facing. -// 1229376 Single-Button Assistant - client convenience macro, not a rotation ability. -// 1293340 Mark for Death (Deathstalker) - hero-tree passive-driven, no cast rule. - -#include "../ApRegistry.h" -#include "../ApRotation.h" -#include "Bot/BotIntentEmitter.h" -#include "Bot/BotSnapshotView.h" -#include "Group/GroupSnapshot.h" -#include "SharedDefines.h" - -namespace Playerbot::Combat { - -namespace { - -// ---- Spell IDs (WoW 12.1.0.69587, validated) ---- -constexpr uint32 MUTILATE = 1329; -constexpr uint32 ENVENOM = 32645; -constexpr uint32 GARROTE = 703; -constexpr uint32 RUPTURE = 1943; -constexpr uint32 DEATHMARK = 360194; // talent [R] burst CD -constexpr uint32 CRIMSON_TEMPEST = 1247227; // talent [M] AoE generator (was 121411) -constexpr uint32 SLICE_AND_DICE = 315496; -constexpr uint32 POISONED_KNIFE = 185565; // ranged -constexpr uint32 FAN_OF_KNIVES = 51723; // AoE generator + poison spread -constexpr uint32 SHIV = 5938; // talent [R] poison amplifier -constexpr uint32 KINGSBANE = 385627; // talent [R] Nature DoT CD -// Weapon poisons: the self-buff aura carries the cast spell's id. -constexpr uint32 DEADLY_POISON = 2823; // talent [R] lethal -constexpr uint32 AMPLIFYING_POISON = 381664; // talent [R] lethal (second, via 381801) -constexpr uint32 INSTANT_POISON = 315584; // baseline lethal fallback -constexpr uint32 ATROPHIC_POISON = 381637; // talent [R] non-lethal -constexpr uint32 CRIPPLING_POISON = 3408; // baseline non-lethal fallback -constexpr uint32 DRAGON_TEMPERED_BLADES = 381801; // passive [R]: two lethal + two non-lethal -// Thistle Tea: the [R] class passive 469779 teaches 381623; the active -// talent node variant is 1298826. Same effect (restore Energy) - cast -// whichever is in the spellbook. -constexpr uint32 THISTLE_TEA = 381623; -constexpr uint32 THISTLE_TEA_ALT = 1298826; -constexpr uint32 KICK = 1766; -constexpr uint32 KIDNEY_SHOT = 408; -constexpr uint32 BLIND = 2094; -constexpr uint32 TRICKS_OF_TRADE = 57934; -// Shadowstep: 36554 is the castable. 394932 is the Assassination spec -// spell that teaches it (SpellLearnSpell 394932 -> 36554); gate on either -// being known, always cast 36554. -constexpr uint32 SHADOWSTEP = 36554; -constexpr uint32 SHADOWSTEP_SIN = 394932; -constexpr uint32 CRIMSON_VIAL = 185311; -constexpr uint32 EVASION = 5277; -constexpr uint32 CLOAK_OF_SHADOWS = 31224; -constexpr uint32 FEINT = 1966; -constexpr uint32 VANISH = 1856; -constexpr uint32 SHROUD_OF_CONCEAL = 114018; -constexpr uint32 STEALTH = 1784; -constexpr uint32 STEALTH_AURA = 115191; // Subterfuge improved -constexpr uint32 SUBTERFUGE_AURA = 115192; // post-stealth-break talent window - -constexpr uint8 POWER_ENERGY_IDX = 3; -constexpr uint8 POWER_COMBO_POINTS_IDX = 4; - -bool HasLiveTarget(ApPredicateContext const& ctx) -{ - return !ctx.bot.victim().IsEmpty(); -} - -bool BossLikeTargetEngaged(ApPredicateContext const& ctx) -{ - constexpr int32 kBossHpThreshold = 5'000'000; - NearbyUnit const* t = ctx.bot.victim_info(); - if (t && t->max_hp >= kBossHpThreshold) return true; - for (auto const& a : ctx.bot.raw().combat.attackers) - if (a.max_hp >= kBossHpThreshold) return true; - return false; -} - -uint8 ComboPoints(ApPredicateContext const& ctx) -{ - return static_cast(ctx.bot.power(POWER_COMBO_POINTS_IDX)); -} - -int32 Energy(ApPredicateContext const& ctx) -{ - return ctx.bot.power(POWER_ENERGY_IDX); -} - -bool InStealth(ApPredicateContext const& ctx) -{ - return ctx.bot.has_aura(STEALTH) - || ctx.bot.has_aura(STEALTH_AURA) - || ctx.bot.has_aura(SUBTERFUGE_AURA); -} - -// ---- Weapon poisons (OOC upkeep, 1.5s cast, 1h buff) ---- -// Lethal: Deadly Poison when talented, else baseline Instant Poison. With -// Dragon-Tempered Blades a second lethal (Amplifying) is layered on top - -// without that passive the second application would replace the first -// and the two rules would flip-flop, so Amplifying is gated on 381801 -// AND Deadly already being up. -uint32 PickLethalPoison(ApPredicateContext const& ctx) -{ - if (ctx.bot.knows_spell(DEADLY_POISON)) - { - if (!ctx.bot.has_aura(DEADLY_POISON)) return DEADLY_POISON; - if (ctx.bot.knows_spell(AMPLIFYING_POISON) && ctx.bot.knows_spell(DRAGON_TEMPERED_BLADES) - && !ctx.bot.has_aura(AMPLIFYING_POISON)) - return AMPLIFYING_POISON; - return 0; - } - if (ctx.bot.knows_spell(INSTANT_POISON) && !ctx.bot.has_aura(INSTANT_POISON)) - return INSTANT_POISON; - return 0; -} -uint32 PickNonLethalPoison(ApPredicateContext const& ctx) -{ - if (ctx.bot.knows_spell(ATROPHIC_POISON)) - return ctx.bot.has_aura(ATROPHIC_POISON) ? 0 : ATROPHIC_POISON; - if (ctx.bot.knows_spell(CRIPPLING_POISON) && !ctx.bot.has_aura(CRIPPLING_POISON)) - return CRIPPLING_POISON; - return 0; -} -bool PoisonCastWindow(ApPredicateContext const& ctx) -{ - // Poisons are a 1.5s cast: only out of combat, standing still, and - // not mounted (the cast would dismount mid-travel). - if (ctx.bot.in_combat()) return false; - if (ctx.bot.is_moving()) return false; - if (ctx.bot.is_mounted()) return false; - return true; -} -bool ShouldLethalPoison(ApPredicateContext const& ctx) -{ - if (!PoisonCastWindow(ctx)) return false; - const uint32 sid = PickLethalPoison(ctx); - return sid != 0 && ctx.bot.is_ready(sid); -} -void DoLethalPoison(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - const uint32 sid = PickLethalPoison(ctx); - if (sid != 0) e.cast(sid); -} -bool ShouldNonLethalPoison(ApPredicateContext const& ctx) -{ - if (!PoisonCastWindow(ctx)) return false; - const uint32 sid = PickNonLethalPoison(ctx); - return sid != 0 && ctx.bot.is_ready(sid); -} -void DoNonLethalPoison(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - const uint32 sid = PickNonLethalPoison(ctx); - if (sid != 0) e.cast(sid); -} - -// ---- Stealth (OOC opener prep) ---- -bool ShouldStealthOOC(ApPredicateContext const& ctx) -{ - if (ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(STEALTH)) return false; - return !InStealth(ctx); -} -void DoStealth(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(STEALTH); } - -// ---- Thistle Tea (Energy restore, charge-based, off-GCD) ---- -uint32 BestThistleTeaSpell(ApPredicateContext const& ctx) -{ - if (ctx.bot.knows_spell(THISTLE_TEA) && ctx.bot.is_ready(THISTLE_TEA)) - return THISTLE_TEA; - if (ctx.bot.knows_spell(THISTLE_TEA_ALT) && ctx.bot.is_ready(THISTLE_TEA_ALT)) - return THISTLE_TEA_ALT; - return 0; -} -bool ShouldThistleTea(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.in_combat()) return false; - if (BestThistleTeaSpell(ctx) == 0) return false; - // Energy-starved during a burst window (Deathmark/Kingsbane up) or - // plainly empty - the restore is wasted above ~40 Energy. - if (Energy(ctx) > 40) return false; - return ctx.bot.has_aura(DEATHMARK, ctx.bot.victim()) || ctx.bot.has_aura(KINGSBANE, ctx.bot.victim()) - || Energy(ctx) <= 20; -} -void DoThistleTea(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - const uint32 sid = BestThistleTeaSpell(ctx); - if (sid != 0) e.cast(sid); -} - -// ---- Survival ---- -bool ShouldCrimsonVial(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(CRIMSON_VIAL)) return false; - if (!ctx.bot.is_ready(CRIMSON_VIAL)) return false; - return ctx.bot.hp_pct() <= 60; -} -void DoCrimsonVial(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(CRIMSON_VIAL); } - -bool ShouldEvasion(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(EVASION)) return false; - if (!ctx.bot.is_ready(EVASION)) return false; - return ctx.bot.hp_pct() <= 40; -} -void DoEvasion(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(EVASION); } - -bool ShouldCloakOfShadows(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(CLOAK_OF_SHADOWS)) return false; - if (!ctx.bot.is_ready(CLOAK_OF_SHADOWS)) return false; - for (auto const& a : ctx.bot.raw().auras.own_auras) - if (a.is_harmful && a.dispel_type == DispelType::Magic) - return true; - return false; -} -void DoCloakOfShadows(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(CLOAK_OF_SHADOWS); } - -bool ShouldFeint(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(FEINT)) return false; - if (!ctx.bot.is_ready(FEINT)) return false; - return ctx.bot.hp_pct() <= 60; -} -void DoFeint(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(FEINT); } - -bool ShouldVanish(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(VANISH)) return false; - if (!ctx.bot.is_ready(VANISH)) return false; - return ctx.bot.hp_pct() <= 25 && ctx.bot.attackers_count() >= 1; -} -void DoVanish(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(VANISH); } - -// ---- Group utility ---- -bool ShouldTricks(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(TRICKS_OF_TRADE)) return false; - if (!ctx.bot.is_ready(TRICKS_OF_TRADE)) return false; - auto const* tank = ctx.group.tank(); - return tank && tank->online && tank->guid != ctx.bot.raw().guid; -} -void DoTricks(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* tank = ctx.group.tank()) - e.cast(TRICKS_OF_TRADE, tank->guid); -} - -// ---- Interrupt / CC ---- -bool ShouldKick(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(KICK)) return false; - if (!ctx.bot.is_ready(KICK)) return false; - const bool pvp = ctx.pvp.in_battleground || ctx.pvp.in_arena; - return ctx.bot.kick_target(pvp, 5.0f) != nullptr; -} -void DoKick(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - const bool pvp = ctx.pvp.in_battleground || ctx.pvp.in_arena; - if (auto const* c = ctx.bot.kick_target(pvp, 5.0f)) - e.cast(KICK, c->guid); -} - -bool ShouldKidneyShot(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(KIDNEY_SHOT)) return false; - if (!ctx.bot.is_ready(KIDNEY_SHOT)) return false; - if (ComboPoints(ctx) < 5) return false; - if (ctx.bot.is_ready(KICK)) return false; - return ctx.bot.interruptible_caster() != nullptr; -} -void DoKidneyShot(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(KIDNEY_SHOT, ctx.bot.victim()); -} - -bool ShouldBlind(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(BLIND)) return false; - if (!ctx.bot.is_ready(BLIND)) return false; - if (ctx.bot.attackers_count() < 2) return false; - return ctx.bot.hp_pct() <= 50; -} -void DoBlind(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(BLIND, ctx.bot.victim()); -} - -// ---- Maintenance ---- -bool ShouldSliceAndDice(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(SLICE_AND_DICE)) return false; - if (ComboPoints(ctx) < 4) return false; - AuraEntry const* a = ctx.bot.find_aura(SLICE_AND_DICE); - return !a || a->remaining.count() <= 5000; -} -void DoSliceAndDice(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(SLICE_AND_DICE); } - -// ---- Major offensive cooldowns ---- -bool ShouldDeathmark(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(DEATHMARK)) return false; - if (!ctx.bot.is_ready(DEATHMARK)) return false; - return BossLikeTargetEngaged(ctx); -} -void DoDeathmark(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(DEATHMARK, ctx.bot.victim()); -} - -bool ShouldKingsbane(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(KINGSBANE)) return false; - if (!ctx.bot.is_ready(KINGSBANE)) return false; - // Kingsbane wants Rupture already ticking so its amp uptime is paid out; - // gate on Rupture-up OR boss-tier so we never delay it past the burst. - AuraEntry const* r = ctx.bot.find_aura(RUPTURE, ctx.bot.victim()); - return (r && r->remaining.count() >= 4000) || BossLikeTargetEngaged(ctx); -} -void DoKingsbane(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(KINGSBANE, ctx.bot.victim()); -} - -bool ShouldShiv(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(SHIV)) return false; - if (!ctx.bot.is_ready(SHIV)) return false; - // Shiv amps poison damage on the current victim — pop on cooldown - // during Envenom windows. Gate on Rupture being present so the amp - // window overlaps the highest-value DoT. - AuraEntry const* r = ctx.bot.find_aura(RUPTURE, ctx.bot.victim()); - return r != nullptr; -} -void DoShiv(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(SHIV, ctx.bot.victim()); -} - -// Shadowstep: 36554 is the castable in 12.1; the Assassination spec spell -// 394932 only teaches it. Gate on either id being in the spellbook, cast -// 36554. Teleports behind the victim - used as a gap-closer when OoR. -bool KnowsShadowstep(ApPredicateContext const& ctx) -{ - return ctx.bot.knows_spell(SHADOWSTEP) || ctx.bot.knows_spell(SHADOWSTEP_SIN); -} -bool ShouldShadowstep(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!KnowsShadowstep(ctx)) return false; - if (!ctx.bot.is_ready(SHADOWSTEP)) return false; - return ctx.bot.enemies_within(8.0f) == 0; -} -void DoShadowstep(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(SHADOWSTEP, ctx.bot.victim()); -} - -// ---- Bleeds + spender ---- -// Stealth-opener Garrote: from stealth Garrote silences for 3s + applies -// a full-duration bleed. We want this BEFORE Mutilate spam consumes the -// stealth break (Mutilate from stealth has no stealth-only effect for Sin). -bool ShouldGarroteOpener(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(GARROTE)) return false; - if (!InStealth(ctx)) return false; - return true; -} -void DoGarroteOpener(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(GARROTE, ctx.bot.victim()); -} - -bool ShouldGarrote(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(GARROTE)) return false; - AuraEntry const* a = ctx.bot.find_aura(GARROTE, ctx.bot.victim()); - return !a || a->remaining.count() <= 4500; -} -void DoGarrote(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(GARROTE, ctx.bot.victim()); -} - -bool ShouldRupture(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(RUPTURE)) return false; - if (ComboPoints(ctx) < 4) return false; - AuraEntry const* a = ctx.bot.find_aura(RUPTURE, ctx.bot.victim()); - return !a || a->remaining.count() <= 4500; -} -void DoRupture(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(RUPTURE, ctx.bot.victim()); -} - -bool ShouldEnvenom(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(ENVENOM)) return false; - if (!ctx.bot.is_ready(ENVENOM)) return false; - return ComboPoints(ctx) >= 5; -} -void DoEnvenom(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(ENVENOM, ctx.bot.victim()); -} - -// Crimson Tempest (12.1): no longer a finisher - a 60 Energy AoE -// GENERATOR that copies the longest Garrote and Rupture on the enemies it -// hits onto nearby enemies. Fire in AoE with CP headroom once the victim -// carries Rupture (so there is a bleed worth copying); preferred over Fan -// of Knives while a bleed is up. -bool ShouldCrimsonTempest(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(CRIMSON_TEMPEST)) return false; - if (!ctx.bot.is_ready(CRIMSON_TEMPEST)) return false; - if (ComboPoints(ctx) >= 4) return false; - if (!(ctx.aoe_preference || ctx.bot.enemies_within(8.0f) >= 2)) return false; - return ctx.bot.has_aura(RUPTURE, ctx.bot.victim()) || ctx.bot.has_aura(GARROTE, ctx.bot.victim()); -} -void DoCrimsonTempest(ApPredicateContext const&, BotIntentEmitter& e) -{ - e.cast(CRIMSON_TEMPEST); -} - -// Fan of Knives: AoE CP generator that also spreads Deadly/Wound Poison -// from the current victim to nearby enemies. Use whenever we see 2+ enemies -// and have CP headroom (don't spam past 5 — it's wasted resource gen). -bool ShouldFanOfKnives(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(FAN_OF_KNIVES)) return false; - if (!ctx.bot.is_ready(FAN_OF_KNIVES)) return false; - if (ComboPoints(ctx) >= 5) return false; - return ctx.bot.enemies_within(10.0f) >= 2; -} -void DoFanOfKnives(ApPredicateContext const&, BotIntentEmitter& e) -{ - e.cast(FAN_OF_KNIVES); -} - -bool ShouldMutilate(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (ComboPoints(ctx) >= 5) return false; - return ctx.bot.knows_spell(MUTILATE); -} -void DoMutilate(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(MUTILATE, ctx.bot.victim()); -} - -// Poisoned Knife: ranged poison applicator. Fires when target is out of -// melee range (no other enemies on us so Shadowstep would be smarter, but -// PK is a no-cooldown filler so it stays useful when stepping is on CD). -bool ShouldPoisonedKnife(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(POISONED_KNIFE)) return false; - if (ComboPoints(ctx) >= 5) return false; - return ctx.bot.enemies_within(8.0f) == 0; -} -void DoPoisonedKnife(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(POISONED_KNIFE, ctx.bot.victim()); -} - -bool AlwaysInCombat(ApPredicateContext const& ctx) { return ctx.bot.in_combat(); } -void DoAutoAttack(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - ObjectGuid t = ctx.bot.victim(); - if (t.IsEmpty()) t = ctx.bot.current_target(); - // Retaliate fallback (2026-06-17): in combat with no victim/target the bot - // looped "Engage auto attack" as a no-op while taking damage (the CombatLoop - // wedge cluster). Engage whatever is meleeing us (attackers are adjacent and - // reachable), else the nearest visible enemy, so combat actually resolves. - // Strictly additive: only runs when no target was already selected. - if (t.IsEmpty()) - for (auto const& u : ctx.bot.attackers()) - if (u.hp > 0) { t = u.guid; break; } - if (t.IsEmpty()) - for (auto const& u : ctx.bot.nearby_enemies()) - if (u.hp > 0 && u.in_los) { t = u.guid; break; } - if (!t.IsEmpty()) e.start_attack(t); -} - -// Rule order: -// Cloak (magic emerg) -> Vanish (panic) -> Evasion (defensive) -// -> Crimson Vial (heal) -> Feint (DR) -> Kick -> Kidney Shot (kick fb) -// -> Blind -> poisons (OOC upkeep) -> Stealth (OOC) -> Stealth-opener Garrote -// -> Tricks -> Shadowstep (gap close) -> Thistle Tea -> major CDs (Deathmark, -// Kingsbane, Shiv) -> maintenance (SnD, Garrote, Rupture) -> Envenom -// -> AoE generators (Crimson Tempest, Fan of Knives) -> Mutilate -> Poisoned Knife -> AA. -ApRule const kRules[] = { - { ShouldCloakOfShadows, DoCloakOfShadows, "Cloak of Shadows (magic emergency)" }, - { ShouldVanish, DoVanish, "Vanish (panic <=25%)" }, - { ShouldEvasion, DoEvasion, "Evasion (<=40%)" }, - { ShouldCrimsonVial, DoCrimsonVial, "Crimson Vial (<=60%)" }, - { ShouldFeint, DoFeint, "Feint (<=60% DR)" }, - { ShouldKick, DoKick, "Kick (interrupt)" }, - { ShouldKidneyShot, DoKidneyShot, "Kidney Shot (interrupt fb)" }, - { ShouldBlind, DoBlind, "Blind (panic CC)" }, - { ShouldLethalPoison, DoLethalPoison, "Lethal poison (OOC upkeep)" }, - { ShouldNonLethalPoison, DoNonLethalPoison, "Non-lethal poison (OOC upkeep)" }, - { ShouldStealthOOC, DoStealth, "Stealth (OOC opener prep)" }, - { ShouldGarroteOpener, DoGarroteOpener, "Garrote (stealth opener)" }, - { ShouldTricks, DoTricks, "Tricks of the Trade" }, - { ShouldShadowstep, DoShadowstep, "Shadowstep (gap close)" }, - { ShouldThistleTea, DoThistleTea, "Thistle Tea (energy restore)" }, - { ShouldDeathmark, DoDeathmark, "Deathmark" }, - { ShouldKingsbane, DoKingsbane, "Kingsbane (Nature DoT CD)" }, - { ShouldShiv, DoShiv, "Shiv (poison amp)" }, - { ShouldSliceAndDice, DoSliceAndDice, "Slice and Dice (refresh)" }, - { ShouldGarrote, DoGarrote, "Garrote (refresh bleed)" }, - { ShouldRupture, DoRupture, "Rupture (refresh 4 CP)" }, - { ShouldEnvenom, DoEnvenom, "Envenom (5 CP spend)" }, - { ShouldCrimsonTempest, DoCrimsonTempest, "Crimson Tempest (AoE bleed copy)" }, - { ShouldFanOfKnives, DoFanOfKnives, "Fan of Knives (AoE gen + spread)" }, - { ShouldMutilate, DoMutilate, "Mutilate (filler)" }, - { ShouldPoisonedKnife, DoPoisonedKnife, "Poisoned Knife (ranged filler)" }, - { AlwaysInCombat, DoAutoAttack, "Engage auto attack" }, -}; - -} // anonymous - -void RegisterApl_Rogue_Assassination() -{ - constexpr uint32 SPEC_ROGUE_ASSASSINATION = 259; - RegisterRotation(CLASS_ROGUE, SPEC_ROGUE_ASSASSINATION, ApRotation{kRules}); -} - -} // namespace Playerbot::Combat diff --git a/src/modules/PlayerbotV2/Combat/Apl/Apl_Rogue_Outlaw.cpp b/src/modules/PlayerbotV2/Combat/Apl/Apl_Rogue_Outlaw.cpp deleted file mode 100644 index 695aecd874..0000000000 --- a/src/modules/PlayerbotV2/Combat/Apl/Apl_Rogue_Outlaw.cpp +++ /dev/null @@ -1,579 +0,0 @@ -// Outlaw Rogue - WoW 12.1.0.69587 (Midnight) enterprise rotation. -// Pistol-style melee with the reworked Roll the Bones (dice "sets": -// One of a Kind / Double Trouble / Triple Threat / Jackpot) driving DPS, -// Keep It Rolling to extend a strong roll, Adrenaline Rush burst phase -// with Preparation resetting the burst kit, Blade Flurry cleave, Killing -// Spree finisher, Between the Eyes / Dispatch spend, Pistol Shot proc -// spend (Opportunity), Sinister Strike builder, Ambush stealth opener, -// Slice and Dice upkeep, Instant + Atrophic poison upkeep, Thistle Tea. -// -// Survival: Crimson Vial, Evasion, Cloak of Shadows, Feint (DR), Vanish. -// Group utility: Tricks of the Trade. CC: Kick interrupt, Kidney Shot stun -// (CP), Blind (panic CC). Gap-close: Grappling Hook, Blade Rush. -// -// Validated spell IDs (SpellName.csv lookup, WoW 12.1.0.69587): -// 193315 Sinister Strike (spec override of 1752) -// 185763 Pistol Shot -// 315341 Between the Eyes -// 2098 Dispatch (spec override of Eviscerate 196819) -// 1214909 Roll the Bones (12.1 cast id; 315508 no longer learnable) -// 1214933 One of a Kind (RtB 1-set buff) -// 1214934 Double Trouble (RtB 2-set buff) -// 1214935 Triple Threat (RtB 3-set buff) -// 1214937 Jackpot (RtB top buff) -// 381989 Keep It Rolling (talent [R] - extends RtB) -// 13750 Adrenaline Rush (talent [R]) -// 1277933 Preparation (talent [R] - resets AR/BtE/BF/Blade Rush/KS) -// 13877 Blade Flurry -// 195627 Opportunity (proc aura - gates Pistol Shot) -// 51690 Killing Spree (talent [R] - now a CP finisher) -// 271877 Blade Rush (talent, not in curated build - gated) -// 195457 Grappling Hook (gap-close) -// 8676 Ambush (stealth opener) -// 315496 Slice and Dice -// 315584 Instant Poison / 8679 Wound Poison (lethal, baseline) -// 381637 Atrophic Poison (talent [R] non-lethal) / 3408 Crippling Poison fallback -// 381623 Thistle Tea (taught by class passive 469779 [R]) / 1298826 active variant -// 1766/408/2094 Kick / Kidney Shot / Blind -// 57934 Tricks of the Trade -// 185311/5277/31224/1966/1856 Crimson Vial / Evasion / Cloak / Feint / Vanish -// 1784/115191/115192 Stealth / Subterfuge stealth / Subterfuge window -// -// Skipped (with reason): -// 196937 Ghostly Strike - removed from the game (not in 12.1 SpellName). -// 385408 Sepsis / 137619 Marked for Death / 76577 Smoke Bomb - not learnable in 12.1. -// 385616 Echoing Reprimand - 12.1 version (470669) is a passive. -// 315508 Roll the Bones (old) - not learnable in 12.1; 1214909 is the cast. -// 193356/193357/193358/193359/199600/199603 - pre-12.1 RtB buffs, replaced by dice sets. -// 79096 Restless Blades / 256170 Loaded Dice / 279876 Opportunity - passives. -// 199736 Find Treasure - passive utility (minimap treasure); no cast rule. -// 1776 Gouge - [R] but needs facing and Kidney Shot covers the CC slot. -// 1229376 Single-Button Assistant - client convenience macro, not a rotation ability. - -#include "../ApRegistry.h" -#include "../ApRotation.h" -#include "Bot/BotIntentEmitter.h" -#include "Bot/BotSnapshotView.h" -#include "Group/GroupSnapshot.h" -#include "SharedDefines.h" - -namespace Playerbot::Combat { - -namespace { - -// ---- Spell IDs (WoW 12.1.0.69587, validated) ---- -constexpr uint32 SINISTER_STRIKE = 193315; -constexpr uint32 PISTOL_SHOT = 185763; -constexpr uint32 BETWEEN_THE_EYES = 315341; -constexpr uint32 DISPATCH = 2098; -// Roll the Bones (12.1 rework): 25 Energy, 45s CD, no CP cost. Rolls dice -// and applies ONE of four tiered buffs instead of the old six named ones. -constexpr uint32 ROLL_THE_BONES = 1214909; -constexpr uint32 RTB_ONE_OF_A_KIND = 1214933; // 1 set - reroll -constexpr uint32 RTB_DOUBLE_TROUBLE = 1214934; // 2 sets - keep -constexpr uint32 RTB_TRIPLE_THREAT = 1214935; // 3 sets - keep, Keep It Rolling -constexpr uint32 RTB_JACKPOT = 1214937; // top - keep, Keep It Rolling -constexpr uint32 KEEP_IT_ROLLING = 381989; // talent [R] - extend active roll -constexpr uint32 ADRENALINE_RUSH = 13750; // talent [R] -constexpr uint32 PREPARATION = 1277933; // talent [R] - resets AR/BtE/BF/Blade Rush/KS -constexpr uint32 BLADE_FLURRY = 13877; -constexpr uint32 OPPORTUNITY = 195627; // proc aura (from passive 279876) -constexpr uint32 KILLING_SPREE = 51690; // talent [R] - CP finisher burst -constexpr uint32 BLADE_RUSH = 271877; // talent - gap close + AoE -constexpr uint32 SLICE_AND_DICE = 315496; -// Weapon poisons: the self-buff aura carries the cast spell's id. -constexpr uint32 INSTANT_POISON = 315584; // baseline lethal -constexpr uint32 ATROPHIC_POISON = 381637; // talent [R] non-lethal -constexpr uint32 CRIPPLING_POISON = 3408; // baseline non-lethal fallback -// Thistle Tea: class passive 469779 [R] teaches 381623; the active talent -// node variant is 1298826. Cast whichever is in the spellbook. -constexpr uint32 THISTLE_TEA = 381623; -constexpr uint32 THISTLE_TEA_ALT = 1298826; -constexpr uint32 KICK = 1766; -constexpr uint32 KIDNEY_SHOT = 408; -constexpr uint32 BLIND = 2094; -constexpr uint32 TRICKS_OF_TRADE = 57934; -constexpr uint32 CRIMSON_VIAL = 185311; -constexpr uint32 EVASION = 5277; -constexpr uint32 CLOAK_OF_SHADOWS = 31224; -constexpr uint32 FEINT = 1966; -constexpr uint32 VANISH = 1856; -constexpr uint32 GRAPPLING_HOOK = 195457; // gap-close -constexpr uint32 STEALTH = 1784; -constexpr uint32 STEALTH_AURA = 115191; // Subterfuge improved -constexpr uint32 SUBTERFUGE_AURA = 115192; // post-stealth-break talent window -constexpr uint32 AMBUSH = 8676; // stealth-only opener - -constexpr uint8 POWER_ENERGY_IDX = 3; -constexpr uint8 POWER_COMBO_POINTS_IDX = 4; - -bool HasLiveTarget(ApPredicateContext const& ctx) -{ - return !ctx.bot.victim().IsEmpty(); -} - -bool BossLikeTargetEngaged(ApPredicateContext const& ctx) -{ - constexpr int32 kBossHpThreshold = 5'000'000; - NearbyUnit const* t = ctx.bot.victim_info(); - if (t && t->max_hp >= kBossHpThreshold) return true; - for (auto const& a : ctx.bot.raw().combat.attackers) - if (a.max_hp >= kBossHpThreshold) return true; - return false; -} - -uint8 ComboPoints(ApPredicateContext const& ctx) -{ - return static_cast(ctx.bot.power(POWER_COMBO_POINTS_IDX)); -} - -int32 Energy(ApPredicateContext const& ctx) -{ - return ctx.bot.power(POWER_ENERGY_IDX); -} - -bool InStealth(ApPredicateContext const& ctx) -{ - return ctx.bot.has_aura(STEALTH) - || ctx.bot.has_aura(STEALTH_AURA) - || ctx.bot.has_aura(SUBTERFUGE_AURA); -} - -// ---- Weapon poisons (OOC upkeep, 1.5s cast, 1h buff) ---- -bool PoisonCastWindow(ApPredicateContext const& ctx) -{ - if (ctx.bot.in_combat()) return false; - if (ctx.bot.is_moving()) return false; - if (ctx.bot.is_mounted()) return false; - return true; -} -bool ShouldInstantPoison(ApPredicateContext const& ctx) -{ - if (!PoisonCastWindow(ctx)) return false; - if (!ctx.bot.knows_spell(INSTANT_POISON)) return false; - if (!ctx.bot.is_ready(INSTANT_POISON)) return false; - return !ctx.bot.has_aura(INSTANT_POISON); -} -void DoInstantPoison(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(INSTANT_POISON); } - -uint32 PickNonLethalPoison(ApPredicateContext const& ctx) -{ - if (ctx.bot.knows_spell(ATROPHIC_POISON)) - return ctx.bot.has_aura(ATROPHIC_POISON) ? 0 : ATROPHIC_POISON; - if (ctx.bot.knows_spell(CRIPPLING_POISON) && !ctx.bot.has_aura(CRIPPLING_POISON)) - return CRIPPLING_POISON; - return 0; -} -bool ShouldNonLethalPoison(ApPredicateContext const& ctx) -{ - if (!PoisonCastWindow(ctx)) return false; - const uint32 sid = PickNonLethalPoison(ctx); - return sid != 0 && ctx.bot.is_ready(sid); -} -void DoNonLethalPoison(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - const uint32 sid = PickNonLethalPoison(ctx); - if (sid != 0) e.cast(sid); -} - -// ---- Stealth opener: Stealth OOC, Ambush from stealth ---- -bool ShouldStealthOOC(ApPredicateContext const& ctx) -{ - if (ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(STEALTH)) return false; - return !InStealth(ctx); -} -void DoStealthOOC(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(STEALTH); } - -bool ShouldAmbushOpener(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(AMBUSH)) return false; - if (!ctx.bot.is_ready(AMBUSH)) return false; - return InStealth(ctx); -} -void DoAmbushOpener(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(AMBUSH, ctx.bot.victim()); -} - -// ---- Survival ---- -bool ShouldCrimsonVial(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(CRIMSON_VIAL)) return false; - if (!ctx.bot.is_ready(CRIMSON_VIAL)) return false; - return ctx.bot.hp_pct() <= 60; -} -void DoCrimsonVial(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(CRIMSON_VIAL); } - -bool ShouldEvasion(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(EVASION)) return false; - if (!ctx.bot.is_ready(EVASION)) return false; - return ctx.bot.hp_pct() <= 40; -} -void DoEvasion(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(EVASION); } - -bool ShouldCloakOfShadows(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(CLOAK_OF_SHADOWS)) return false; - if (!ctx.bot.is_ready(CLOAK_OF_SHADOWS)) return false; - for (auto const& a : ctx.bot.raw().auras.own_auras) - if (a.is_harmful && a.dispel_type == DispelType::Magic) return true; - return false; -} -void DoCloakOfShadows(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(CLOAK_OF_SHADOWS); } - -bool ShouldFeint(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(FEINT)) return false; - if (!ctx.bot.is_ready(FEINT)) return false; - return ctx.bot.hp_pct() <= 60; -} -void DoFeint(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(FEINT); } - -bool ShouldVanish(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(VANISH)) return false; - if (!ctx.bot.is_ready(VANISH)) return false; - return ctx.bot.hp_pct() <= 25 && ctx.bot.attackers_count() >= 1; -} -void DoVanish(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(VANISH); } - -// ---- Group utility ---- -bool ShouldTricks(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(TRICKS_OF_TRADE)) return false; - if (!ctx.bot.is_ready(TRICKS_OF_TRADE)) return false; - auto const* tank = ctx.group.tank(); - return tank && tank->online && tank->guid != ctx.bot.raw().guid; -} -void DoTricks(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* tank = ctx.group.tank()) - e.cast(TRICKS_OF_TRADE, tank->guid); -} - -// ---- Interrupt / CC ---- -bool ShouldKick(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(KICK)) return false; - if (!ctx.bot.is_ready(KICK)) return false; - const bool pvp = ctx.pvp.in_battleground || ctx.pvp.in_arena; - return ctx.bot.kick_target(pvp, 5.0f) != nullptr; -} -void DoKick(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - const bool pvp = ctx.pvp.in_battleground || ctx.pvp.in_arena; - if (auto const* c = ctx.bot.kick_target(pvp, 5.0f)) - e.cast(KICK, c->guid); -} - -bool ShouldKidneyShot(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(KIDNEY_SHOT)) return false; - if (!ctx.bot.is_ready(KIDNEY_SHOT)) return false; - if (ComboPoints(ctx) < 5) return false; - if (ctx.bot.is_ready(KICK)) return false; - return ctx.bot.interruptible_caster() != nullptr; -} -void DoKidneyShot(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(KIDNEY_SHOT, ctx.bot.victim()); -} - -bool ShouldBlind(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(BLIND)) return false; - if (!ctx.bot.is_ready(BLIND)) return false; - if (ctx.bot.attackers_count() < 2) return false; - return ctx.bot.hp_pct() <= 50; -} -void DoBlind(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(BLIND, ctx.bot.victim()); -} - -bool ShouldGrapplingHook(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(GRAPPLING_HOOK)) return false; - if (!ctx.bot.is_ready(GRAPPLING_HOOK)) return false; - return ctx.bot.enemies_within(8.0f) == 0; // gap close -} -void DoGrapplingHook(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* v = ctx.bot.victim_info()) - e.cast_at(GRAPPLING_HOOK, v->x, v->y, v->z); - else - e.cast(GRAPPLING_HOOK); -} - -// ---- Major offensive cooldowns ---- -bool ShouldAdrenalineRush(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(ADRENALINE_RUSH)) return false; - if (!ctx.bot.is_ready(ADRENALINE_RUSH)) return false; - return BossLikeTargetEngaged(ctx) || ctx.bot.enemies_within(10.0f) >= 3; -} -void DoAdrenalineRush(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(ADRENALINE_RUSH); } - -// Killing Spree (12.1): a CP FINISHER (45 Energy + CP) on a 180s CD that -// gains strikes per combo point. Spend it at 5+ CP on boss-tier targets or -// dense packs so the 3-minute CD is not wasted on a single trash mob. -bool ShouldKillingSpree(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(KILLING_SPREE)) return false; - if (!ctx.bot.is_ready(KILLING_SPREE)) return false; - if (ComboPoints(ctx) < 5) return false; - return BossLikeTargetEngaged(ctx) || ctx.bot.enemies_within(8.0f) >= 3; -} -void DoKillingSpree(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(KILLING_SPREE, ctx.bot.victim()); -} - -// Preparation: resets Adrenaline Rush, Between the Eyes, Blade Flurry, -// Blade Rush and Killing Spree. Worth it once AR is deep on cooldown and -// the target will still be around (boss-tier) - the reset re-opens a -// full burst window. -bool ShouldPreparation(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(PREPARATION)) return false; - if (!ctx.bot.is_ready(PREPARATION)) return false; - if (!ctx.bot.knows_spell(ADRENALINE_RUSH)) return false; - if (ctx.bot.is_ready(ADRENALINE_RUSH)) return false; - if (ctx.bot.cd_remaining(ADRENALINE_RUSH).count() < 60000) return false; - if (ctx.bot.knows_spell(KILLING_SPREE) && ctx.bot.is_ready(KILLING_SPREE)) return false; - return BossLikeTargetEngaged(ctx); -} -void DoPreparation(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(PREPARATION); } - -bool ShouldBladeRush(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(BLADE_RUSH)) return false; - if (!ctx.bot.is_ready(BLADE_RUSH)) return false; - return ctx.bot.enemies_within(8.0f) == 0 || ctx.bot.enemies_within(10.0f) >= 2; -} -void DoBladeRush(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(BLADE_RUSH); } - -// ---- Thistle Tea (Energy restore, charge-based, off-GCD) ---- -uint32 BestThistleTeaSpell(ApPredicateContext const& ctx) -{ - if (ctx.bot.knows_spell(THISTLE_TEA) && ctx.bot.is_ready(THISTLE_TEA)) - return THISTLE_TEA; - if (ctx.bot.knows_spell(THISTLE_TEA_ALT) && ctx.bot.is_ready(THISTLE_TEA_ALT)) - return THISTLE_TEA_ALT; - return 0; -} -bool ShouldThistleTea(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.in_combat()) return false; - if (BestThistleTeaSpell(ctx) == 0) return false; - if (Energy(ctx) > 40) return false; - // Starved inside Adrenaline Rush, or plainly empty. - return ctx.bot.has_aura(ADRENALINE_RUSH) || Energy(ctx) <= 20; -} -void DoThistleTea(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - const uint32 sid = BestThistleTeaSpell(ctx); - if (sid != 0) e.cast(sid); -} - -// ---- Maintenance ---- -// Roll the Bones (12.1): the cast applies exactly ONE tiered buff - -// One of a Kind (1 set), Double Trouble (2), Triple Threat (3) or -// Jackpot. Returns the active tier's aura, or nullptr when no roll is up. -// `tier` is 1..4 for the four buffs. -AuraEntry const* ActiveRtbBuff(ApPredicateContext const& ctx, int& tier) -{ - constexpr uint32 kTiers[] = { RTB_ONE_OF_A_KIND, RTB_DOUBLE_TROUBLE, RTB_TRIPLE_THREAT, RTB_JACKPOT }; - for (int i = 3; i >= 0; --i) - if (AuraEntry const* a = ctx.bot.find_aura(kTiers[i])) - { - tier = i + 1; - return a; - } - tier = 0; - return nullptr; -} -bool ShouldRollTheBones(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(ROLL_THE_BONES)) return false; - if (!ctx.bot.is_ready(ROLL_THE_BONES)) return false; - if (Energy(ctx) < 25) return false; - int tier = 0; - AuraEntry const* a = ActiveRtbBuff(ctx, tier); - // No roll -> roll. A 1-set roll (One of a Kind) -> reroll; Loaded Dice - // [R] guarantees an upgrade right after Adrenaline Rush. 2+ sets -> - // keep, refresh only inside the last 6s so uptime is not lost. - if (!a) return true; - if (tier <= 1) return true; - return a->remaining.count() <= 6000; -} -void DoRollTheBones(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(ROLL_THE_BONES); } - -// Keep It Rolling: 6-minute CD that extends the current roll. Only worth -// spending on a Triple Threat / Jackpot roll with enough time left that -// the extension is not immediately overwritten. -bool ShouldKeepItRolling(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(KEEP_IT_ROLLING)) return false; - if (!ctx.bot.is_ready(KEEP_IT_ROLLING)) return false; - int tier = 0; - AuraEntry const* a = ActiveRtbBuff(ctx, tier); - if (!a || tier < 3) return false; - return a->remaining.count() >= 8000; -} -void DoKeepItRolling(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(KEEP_IT_ROLLING); } - -// Slice and Dice: Outlaw keeps SnD up manually (Ruthlessness/Fatal -// Flourish feed CP). Refresh at 4+ CP when missing or in the last 5s. -bool ShouldSliceAndDice(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(SLICE_AND_DICE)) return false; - if (!ctx.bot.is_ready(SLICE_AND_DICE)) return false; - if (ComboPoints(ctx) < 4) return false; - AuraEntry const* a = ctx.bot.find_aura(SLICE_AND_DICE); - return !a || a->remaining.count() <= 5000; -} -void DoSliceAndDice(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(SLICE_AND_DICE); } - -bool ShouldBladeFlurry(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(BLADE_FLURRY)) return false; - if (!ctx.bot.is_ready(BLADE_FLURRY)) return false; - if (ctx.bot.has_aura(BLADE_FLURRY)) return false; - return ctx.aoe_preference || ctx.bot.enemies_within(8.0f) >= 2; -} -void DoBladeFlurry(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(BLADE_FLURRY); } - -// ---- Spenders / generators ---- -bool ShouldBetweenTheEyes(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(BETWEEN_THE_EYES)) return false; - if (!ctx.bot.is_ready(BETWEEN_THE_EYES)) return false; - return ComboPoints(ctx) >= 5; -} -void DoBetweenTheEyes(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(BETWEEN_THE_EYES, ctx.bot.victim()); -} - -bool ShouldDispatch(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(DISPATCH)) return false; - if (!ctx.bot.is_ready(DISPATCH)) return false; - return ComboPoints(ctx) >= 5; -} -void DoDispatch(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(DISPATCH, ctx.bot.victim()); -} - -bool ShouldPistolShot(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(PISTOL_SHOT)) return false; - if (ComboPoints(ctx) >= 5) return false; - return ctx.bot.has_aura(OPPORTUNITY); -} -void DoPistolShot(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(PISTOL_SHOT, ctx.bot.victim()); -} - -bool ShouldSinisterStrike(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (ComboPoints(ctx) >= 5) return false; // never overcap CP - return ctx.bot.knows_spell(SINISTER_STRIKE); -} -void DoSinisterStrike(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(SINISTER_STRIKE, ctx.bot.victim()); -} - -bool AlwaysInCombat(ApPredicateContext const& ctx) { return ctx.bot.in_combat(); } -void DoAutoAttack(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - ObjectGuid t = ctx.bot.victim(); - if (t.IsEmpty()) t = ctx.bot.current_target(); - // Retaliate fallback (2026-06-17): in combat with no victim/target the bot - // looped "Engage auto attack" as a no-op while taking damage (the CombatLoop - // wedge cluster). Engage whatever is meleeing us (attackers are adjacent and - // reachable), else the nearest visible enemy, so combat actually resolves. - // Strictly additive: only runs when no target was already selected. - if (t.IsEmpty()) - for (auto const& u : ctx.bot.attackers()) - if (u.hp > 0) { t = u.guid; break; } - if (t.IsEmpty()) - for (auto const& u : ctx.bot.nearby_enemies()) - if (u.hp > 0 && u.in_los) { t = u.guid; break; } - if (!t.IsEmpty()) e.start_attack(t); -} - -// Rule order: -// Cloak (magic emerg) -> Vanish (panic) -> Evasion -> Crimson Vial -> Feint -// -> Kick -> Kidney Shot (kick fb) -> Blind -> poisons (OOC upkeep) -// -> Stealth (OOC) -> Ambush opener -> Tricks -> Grappling Hook (gap close) -// -> Thistle Tea -> major CDs (Adrenaline Rush, Preparation, Blade Rush) -// -> Roll the Bones / Keep It Rolling -> Blade Flurry -> Slice and Dice -// -> finishers (Killing Spree, BtE, Dispatch) -> Pistol Shot proc -> Sinister Strike -> AA. -ApRule const kRules[] = { - { ShouldCloakOfShadows, DoCloakOfShadows, "Cloak of Shadows (magic emergency)" }, - { ShouldVanish, DoVanish, "Vanish (panic <=25%)" }, - { ShouldEvasion, DoEvasion, "Evasion (<=40%)" }, - { ShouldCrimsonVial, DoCrimsonVial, "Crimson Vial (<=60%)" }, - { ShouldFeint, DoFeint, "Feint (<=60% DR)" }, - { ShouldKick, DoKick, "Kick (interrupt)" }, - { ShouldKidneyShot, DoKidneyShot, "Kidney Shot (interrupt fb)" }, - { ShouldBlind, DoBlind, "Blind (panic CC)" }, - { ShouldInstantPoison, DoInstantPoison, "Instant Poison (OOC upkeep)" }, - { ShouldNonLethalPoison, DoNonLethalPoison, "Non-lethal poison (OOC upkeep)" }, - { ShouldStealthOOC, DoStealthOOC, "Stealth (OOC opener)" }, - { ShouldAmbushOpener, DoAmbushOpener, "Ambush (stealth opener)" }, - { ShouldTricks, DoTricks, "Tricks of the Trade" }, - { ShouldGrapplingHook, DoGrapplingHook, "Grappling Hook (gap close)" }, - { ShouldThistleTea, DoThistleTea, "Thistle Tea (energy restore)" }, - { ShouldAdrenalineRush, DoAdrenalineRush, "Adrenaline Rush" }, - { ShouldPreparation, DoPreparation, "Preparation (reset burst CDs)" }, - { ShouldBladeRush, DoBladeRush, "Blade Rush" }, - { ShouldRollTheBones, DoRollTheBones, "Roll the Bones (reroll/refresh)" }, - { ShouldKeepItRolling, DoKeepItRolling, "Keep It Rolling (3+ sets)" }, - { ShouldBladeFlurry, DoBladeFlurry, "Blade Flurry (2+ AoE)" }, - { ShouldSliceAndDice, DoSliceAndDice, "Slice and Dice (refresh)" }, - { ShouldKillingSpree, DoKillingSpree, "Killing Spree (5 CP finisher)" }, - { ShouldBetweenTheEyes, DoBetweenTheEyes, "Between the Eyes (5 CP finisher)" }, - { ShouldDispatch, DoDispatch, "Dispatch (5 CP spend)" }, - { ShouldPistolShot, DoPistolShot, "Pistol Shot (Opportunity)" }, - { ShouldSinisterStrike, DoSinisterStrike, "Sinister Strike (filler)" }, - { AlwaysInCombat, DoAutoAttack, "Engage auto attack" }, -}; - -} // anonymous - -void RegisterApl_Rogue_Outlaw() -{ - constexpr uint32 SPEC_ROGUE_OUTLAW = 260; - RegisterRotation(CLASS_ROGUE, SPEC_ROGUE_OUTLAW, ApRotation{kRules}); -} - -} // namespace Playerbot::Combat diff --git a/src/modules/PlayerbotV2/Combat/Apl/Apl_Rogue_Subtlety.cpp b/src/modules/PlayerbotV2/Combat/Apl/Apl_Rogue_Subtlety.cpp deleted file mode 100644 index 0a4ec1e954..0000000000 --- a/src/modules/PlayerbotV2/Combat/Apl/Apl_Rogue_Subtlety.cpp +++ /dev/null @@ -1,586 +0,0 @@ -// Subtlety Rogue - WoW 12.1.0.69587 (Midnight) enterprise rotation. -// Stealth-driven melee: Shadow Dance multi-Shadowstrike burst (2 charges -// with Double Dance), Shadow Blades burst window, Vanish as an offensive -// re-stealth inside Shadow Blades, Goremaw's Bite CP burst, Eviscerate at -// 5+ CP, Secret Technique burst finisher, Black Powder AoE finisher, -// Shuriken Storm AoE generator, Slice and Dice upkeep, Backstab / -// Gloomblade filler, Shuriken Toss ranged filler. Instant + Atrophic -// poison upkeep out of combat, Thistle Tea when Energy-starved. -// -// Survival: Crimson Vial, Evasion, Cloak of Shadows, Feint, Vanish. -// Group utility: Tricks of the Trade. CC: Kick, Cheap Shot (stealth -// opener vs casters / PvP), Kidney Shot stun, Blind, Sap (OOC). -// Gap-close: Shadowstep (36554, learned through spec spell 394935). -// -// Validated spell IDs (SpellName.csv lookup, WoW 12.1.0.69587): -// 53 Backstab - CP gen (spec override of 1752) -// 200758 Gloomblade - talent (replaces Backstab; not in curated build) -// 185438 Shadowstrike - stealth / Shadow Dance CP gen (overrides Ambush) -// 196819 Eviscerate - CP spender -// 319175 Black Powder - AoE finisher -// 280719 Secret Technique - spec finisher (L25) -// 185313 Shadow Dance - stealth CD (charges) -// 121471 Shadow Blades - talent [R] burst CD -// 426591 Goremaw's Bite - talent [R] 45s CP burst + bleed -// 197835 Shuriken Storm - AoE generator -// 114014 Shuriken Toss - ranged CP gen -// 315496 Slice and Dice - attack-speed self-buff finisher -// 1833 Cheap Shot - stealth stun opener -// 315584 Instant Poison - baseline lethal poison -// 381637 Atrophic Poison - talent [R] non-lethal / 3408 Crippling Poison fallback -// 381623 Thistle Tea - taught by class passive 469779 / 1298826 active variant -// 36554 Shadowstep - cast id; 394935 is the Sub spec learn-spell -// 1766/408/2094/6770/57934 Kick / Kidney Shot / Blind / Sap / Tricks -// 185311/5277/31224/1966/1856 Crimson Vial / Evasion / Cloak / Feint / Vanish -// 1784/115191/115192 Stealth / Subterfuge stealth / Subterfuge window -// -// Skipped (with reason): -// 212283 Symbols of Death - not learnable in 12.1 (removed from Sub). -// 703 Garrote / 1943 Rupture - Assassination-only in 12.1; Sub cannot learn them. -// 277925 Shuriken Tornado - 12.1 version (1264764) is a passive (Shadow Clone proc). -// 1279401 Shuriken Storm Rank 2 - passive damage modifier, not a cast. -// 385408 Sepsis / 137619 Marked for Death / 76577 Smoke Bomb - not learnable in 12.1. -// 385616 Echoing Reprimand - 12.1 version (470669) is a passive. -// 196912 Shadow Techniques / 91023 Find Weakness / 245687 Dark Shadow - passives. -// 1776 Gouge - class talent not in the curated Sub build; needs facing. -// 1229376 Single-Button Assistant - client convenience macro, not a rotation ability. - -#include "../ApRegistry.h" -#include "../ApRotation.h" -#include "Bot/BotIntentEmitter.h" -#include "Bot/BotSnapshotView.h" -#include "Group/GroupSnapshot.h" -#include "SharedDefines.h" - -namespace Playerbot::Combat { - -namespace { - -// ---- Spell IDs (WoW 12.1.0.69587, validated) ---- -constexpr uint32 BACKSTAB = 53; -constexpr uint32 SHADOWSTRIKE = 185438; -constexpr uint32 EVISCERATE = 196819; -constexpr uint32 SHADOW_BLADES = 121471; // talent [R] burst CD -constexpr uint32 SHADOW_DANCE = 185313; // charges (Double Dance [R]) -constexpr uint32 GOREMAWS_BITE = 426591; // talent [R] CP burst + bleed -constexpr uint32 SHURIKEN_STORM = 197835; -constexpr uint32 BLACK_POWDER = 319175; -constexpr uint32 SECRET_TECHNIQUE = 280719; // spec finisher (L25) -constexpr uint32 SHURIKEN_TOSS = 114014; -constexpr uint32 GLOOMBLADE = 200758; // talent - replaces Backstab -constexpr uint32 SLICE_AND_DICE = 315496; -// Weapon poisons: the self-buff aura carries the cast spell's id. -constexpr uint32 INSTANT_POISON = 315584; // baseline lethal -constexpr uint32 ATROPHIC_POISON = 381637; // talent [R] non-lethal -constexpr uint32 CRIPPLING_POISON = 3408; // baseline non-lethal fallback -// Thistle Tea: class passive 469779 teaches 381623; the active talent -// node variant is 1298826. Cast whichever is in the spellbook. -constexpr uint32 THISTLE_TEA = 381623; -constexpr uint32 THISTLE_TEA_ALT = 1298826; -constexpr uint32 KICK = 1766; -constexpr uint32 KIDNEY_SHOT = 408; -constexpr uint32 CHEAP_SHOT = 1833; -constexpr uint32 BLIND = 2094; -constexpr uint32 SAP = 6770; -constexpr uint32 STEALTH = 1784; -constexpr uint32 STEALTH_AURA = 115191; // Subterfuge improved version -constexpr uint32 SUBTERFUGE_AURA = 115192; // post-stealth-break talent window -constexpr uint32 TRICKS_OF_TRADE = 57934; -// Shadowstep: 36554 is the castable. 394935 is the Subtlety spec spell -// that teaches it (SpellLearnSpell 394935 -> 36554); gate on either being -// known, always cast 36554. -constexpr uint32 SHADOWSTEP = 36554; -constexpr uint32 SHADOWSTEP_SUB = 394935; -constexpr uint32 CRIMSON_VIAL = 185311; -constexpr uint32 EVASION = 5277; -constexpr uint32 CLOAK_OF_SHADOWS = 31224; -constexpr uint32 FEINT = 1966; -constexpr uint32 VANISH = 1856; - -constexpr uint8 POWER_ENERGY_IDX = 3; -constexpr uint8 POWER_COMBO_POINTS_IDX = 4; - -bool HasLiveTarget(ApPredicateContext const& ctx) -{ - return !ctx.bot.victim().IsEmpty(); -} - -bool BossLikeTargetEngaged(ApPredicateContext const& ctx) -{ - constexpr int32 kBossHpThreshold = 5'000'000; - NearbyUnit const* t = ctx.bot.victim_info(); - if (t && t->max_hp >= kBossHpThreshold) return true; - for (auto const& a : ctx.bot.raw().combat.attackers) - if (a.max_hp >= kBossHpThreshold) return true; - return false; -} - -uint8 ComboPoints(ApPredicateContext const& ctx) -{ - return static_cast(ctx.bot.power(POWER_COMBO_POINTS_IDX)); -} - -int32 Energy(ApPredicateContext const& ctx) -{ - return ctx.bot.power(POWER_ENERGY_IDX); -} - -bool InStealth(ApPredicateContext const& ctx) -{ - return ctx.bot.has_aura(STEALTH) - || ctx.bot.has_aura(STEALTH_AURA) - || ctx.bot.has_aura(SUBTERFUGE_AURA) - || ctx.bot.has_aura(SHADOW_DANCE); -} - -// ---- Weapon poisons (OOC upkeep, 1.5s cast, 1h buff) ---- -bool PoisonCastWindow(ApPredicateContext const& ctx) -{ - if (ctx.bot.in_combat()) return false; - if (ctx.bot.is_moving()) return false; - if (ctx.bot.is_mounted()) return false; - return true; -} -bool ShouldInstantPoison(ApPredicateContext const& ctx) -{ - if (!PoisonCastWindow(ctx)) return false; - if (!ctx.bot.knows_spell(INSTANT_POISON)) return false; - if (!ctx.bot.is_ready(INSTANT_POISON)) return false; - return !ctx.bot.has_aura(INSTANT_POISON); -} -void DoInstantPoison(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(INSTANT_POISON); } - -uint32 PickNonLethalPoison(ApPredicateContext const& ctx) -{ - if (ctx.bot.knows_spell(ATROPHIC_POISON)) - return ctx.bot.has_aura(ATROPHIC_POISON) ? 0 : ATROPHIC_POISON; - if (ctx.bot.knows_spell(CRIPPLING_POISON) && !ctx.bot.has_aura(CRIPPLING_POISON)) - return CRIPPLING_POISON; - return 0; -} -bool ShouldNonLethalPoison(ApPredicateContext const& ctx) -{ - if (!PoisonCastWindow(ctx)) return false; - const uint32 sid = PickNonLethalPoison(ctx); - return sid != 0 && ctx.bot.is_ready(sid); -} -void DoNonLethalPoison(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - const uint32 sid = PickNonLethalPoison(ctx); - if (sid != 0) e.cast(sid); -} - -// ---- Stealth ---- -bool ShouldStealthOOC(ApPredicateContext const& ctx) -{ - if (ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(STEALTH)) return false; - return !InStealth(ctx); -} -void DoStealth(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(STEALTH); } - -// ---- Thistle Tea (Energy restore, charge-based, off-GCD) ---- -uint32 BestThistleTeaSpell(ApPredicateContext const& ctx) -{ - if (ctx.bot.knows_spell(THISTLE_TEA) && ctx.bot.is_ready(THISTLE_TEA)) - return THISTLE_TEA; - if (ctx.bot.knows_spell(THISTLE_TEA_ALT) && ctx.bot.is_ready(THISTLE_TEA_ALT)) - return THISTLE_TEA_ALT; - return 0; -} -bool ShouldThistleTea(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.in_combat()) return false; - if (BestThistleTeaSpell(ctx) == 0) return false; - if (Energy(ctx) > 40) return false; - // Starved inside a Shadow Dance / Shadow Blades window, or plainly empty. - return ctx.bot.has_aura(SHADOW_DANCE) || ctx.bot.has_aura(SHADOW_BLADES) || Energy(ctx) <= 20; -} -void DoThistleTea(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - const uint32 sid = BestThistleTeaSpell(ctx); - if (sid != 0) e.cast(sid); -} - -// ---- Survival ---- -bool ShouldCrimsonVial(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(CRIMSON_VIAL)) return false; - if (!ctx.bot.is_ready(CRIMSON_VIAL)) return false; - return ctx.bot.hp_pct() <= 60; -} -void DoCrimsonVial(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(CRIMSON_VIAL); } - -bool ShouldEvasion(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(EVASION)) return false; - if (!ctx.bot.is_ready(EVASION)) return false; - return ctx.bot.hp_pct() <= 40; -} -void DoEvasion(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(EVASION); } - -bool ShouldCloakOfShadows(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(CLOAK_OF_SHADOWS)) return false; - if (!ctx.bot.is_ready(CLOAK_OF_SHADOWS)) return false; - for (auto const& a : ctx.bot.raw().auras.own_auras) - if (a.is_harmful && a.dispel_type == DispelType::Magic) return true; - return false; -} -void DoCloakOfShadows(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(CLOAK_OF_SHADOWS); } - -bool ShouldFeint(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(FEINT)) return false; - if (!ctx.bot.is_ready(FEINT)) return false; - return ctx.bot.hp_pct() <= 60; -} -void DoFeint(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(FEINT); } - -bool ShouldVanish(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(VANISH)) return false; - if (!ctx.bot.is_ready(VANISH)) return false; - // Sub uses Vanish as a damage CD (re-stealth -> Shadowstrike) too - - // pop offensively inside Shadow Blades when not already stealthed / - // dancing, defensively when low. In PvP, bump the defensive threshold - // so the stealth catches the burst. - const int32 panic = ctx.pvp.under_player_attack ? 40 : 25; - const bool offensive = ctx.bot.has_aura(SHADOW_BLADES) && !InStealth(ctx) && ComboPoints(ctx) <= 3; - return offensive || ctx.bot.hp_pct() <= panic; -} -void DoVanish(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(VANISH); } - -// ---- Group utility ---- -bool ShouldTricks(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(TRICKS_OF_TRADE)) return false; - if (!ctx.bot.is_ready(TRICKS_OF_TRADE)) return false; - auto const* tank = ctx.group.tank(); - return tank && tank->online && tank->guid != ctx.bot.raw().guid; -} -void DoTricks(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* tank = ctx.group.tank()) - e.cast(TRICKS_OF_TRADE, tank->guid); -} - -// ---- Interrupt / CC ---- -bool ShouldKick(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(KICK)) return false; - if (!ctx.bot.is_ready(KICK)) return false; - const bool pvp = ctx.pvp.in_battleground || ctx.pvp.in_arena; - return ctx.bot.kick_target(pvp, 5.0f) != nullptr; -} -void DoKick(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - const bool pvp = ctx.pvp.in_battleground || ctx.pvp.in_arena; - if (auto const* c = ctx.bot.kick_target(pvp, 5.0f)) - e.cast(KICK, c->guid); -} - -// Cheap Shot from stealth: only worth the stealth break (and 40 Energy) -// when it locks down a caster or a player - otherwise Shadowstrike is the -// DPS opener and Kidney Shot covers stuns later. -bool ShouldCheapShotOpener(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(CHEAP_SHOT)) return false; - if (!ctx.bot.is_ready(CHEAP_SHOT)) return false; - if (!InStealth(ctx)) return false; - if (ctx.pvp.in_battleground || ctx.pvp.in_arena) return true; - NearbyUnit const* v = ctx.bot.victim_info(); - return v && v->is_casting; -} -void DoCheapShot(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(CHEAP_SHOT, ctx.bot.victim()); -} - -bool ShouldKidneyShot(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(KIDNEY_SHOT)) return false; - if (!ctx.bot.is_ready(KIDNEY_SHOT)) return false; - if (ComboPoints(ctx) < 5) return false; - if (ctx.bot.is_ready(KICK)) return false; - return ctx.bot.interruptible_caster() != nullptr; -} -void DoKidneyShot(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(KIDNEY_SHOT, ctx.bot.victim()); -} - -bool ShouldBlind(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(BLIND)) return false; - if (!ctx.bot.is_ready(BLIND)) return false; - if (ctx.bot.attackers_count() < 2) return false; - return ctx.bot.hp_pct() <= 50; -} -void DoBlind(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(BLIND, ctx.bot.victim()); -} - -// Shadowstep: 36554 is the castable in 12.1; the Subtlety spec spell -// 394935 only teaches it. Gate on either id being in the spellbook, cast -// 36554. Gating on no nearby enemy keeps it as a pure gap-close. -bool KnowsShadowstep(ApPredicateContext const& ctx) -{ - return ctx.bot.knows_spell(SHADOWSTEP) || ctx.bot.knows_spell(SHADOWSTEP_SUB); -} -bool ShouldShadowstep(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!KnowsShadowstep(ctx)) return false; - if (!ctx.bot.is_ready(SHADOWSTEP)) return false; - return ctx.bot.enemies_within(8.0f) == 0; -} -void DoShadowstep(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(SHADOWSTEP, ctx.bot.victim()); -} - -// ---- Major offensive cooldowns ---- -// Shadow Blades (90s): burst window - double CP generation. Boss-tier or -// a real pack; trash singles do not deserve the 90s CD. -bool ShouldShadowBlades(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(SHADOW_BLADES)) return false; - if (!ctx.bot.is_ready(SHADOW_BLADES)) return false; - return BossLikeTargetEngaged(ctx) || ctx.bot.enemies_within(10.0f) >= 3; -} -void DoShadowBlades(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(SHADOW_BLADES); } - -// Shadow Dance (charges): enables Shadowstrike spam. Enter it with CP -// headroom so the empowered generators are not wasted, never while a -// stealth state is already active. -bool ShouldShadowDance(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(SHADOW_DANCE)) return false; - if (!ctx.bot.is_ready(SHADOW_DANCE)) return false; - if (InStealth(ctx)) return false; - if (Energy(ctx) < 50) return false; // need at least one Shadowstrike - return ComboPoints(ctx) <= 3 || ctx.bot.has_aura(SHADOW_BLADES); -} -void DoShadowDance(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(SHADOW_DANCE); } - -// Goremaw's Bite (45s): hits the target + 2 nearby, generates CP and a -// bleed, and echoes finisher damage as Shadow. Use with CP headroom. -bool ShouldGoremawsBite(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(GOREMAWS_BITE)) return false; - if (!ctx.bot.is_ready(GOREMAWS_BITE)) return false; - return ComboPoints(ctx) <= 2; -} -void DoGoremawsBite(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(GOREMAWS_BITE, ctx.bot.victim()); -} - -// ---- Maintenance ---- -bool ShouldSliceAndDice(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(SLICE_AND_DICE)) return false; - if (!ctx.bot.is_ready(SLICE_AND_DICE)) return false; - if (ComboPoints(ctx) < 4) return false; - AuraEntry const* a = ctx.bot.find_aura(SLICE_AND_DICE); - return !a || a->remaining.count() <= 5000; -} -void DoSliceAndDice(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(SLICE_AND_DICE); } - -// ---- Spenders ---- -bool ShouldSecretTechnique(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(SECRET_TECHNIQUE)) return false; - if (!ctx.bot.is_ready(SECRET_TECHNIQUE)) return false; - return ComboPoints(ctx) >= 5; -} -void DoSecretTechnique(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(SECRET_TECHNIQUE, ctx.bot.victim()); -} - -bool ShouldBlackPowder(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(BLACK_POWDER)) return false; - if (ComboPoints(ctx) < 5) return false; - return ctx.aoe_preference || ctx.bot.enemies_within(10.0f) >= 3; -} -void DoBlackPowder(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(BLACK_POWDER); } - -bool ShouldEviscerate(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(EVISCERATE)) return false; - if (!ctx.bot.is_ready(EVISCERATE)) return false; - return ComboPoints(ctx) >= 5; -} -void DoEviscerate(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(EVISCERATE, ctx.bot.victim()); -} - -// ---- Generators ---- -// Shuriken Storm: AoE CP generator (10y). 1279401 "Rank 2" is a passive -// stealth damage modifier, not a second cast id. -bool ShouldShurikenStorm(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(SHURIKEN_STORM)) return false; - if (!ctx.bot.is_ready(SHURIKEN_STORM)) return false; - if (ComboPoints(ctx) >= 5) return false; - return ctx.aoe_preference || ctx.bot.enemies_within(10.0f) >= 2; -} -void DoShurikenStorm(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(SHURIKEN_STORM); } - -bool ShouldShadowstrike(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(SHADOWSTRIKE)) return false; - if (!ctx.bot.is_ready(SHADOWSTRIKE)) return false; - if (ComboPoints(ctx) >= 5) return false; - // Shadowstrike requires stealth/Shadow Dance — gate accordingly. - return InStealth(ctx); -} -void DoShadowstrike(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(SHADOWSTRIKE, ctx.bot.victim()); -} - -bool ShouldGloomblade(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(GLOOMBLADE)) return false; - if (ComboPoints(ctx) >= 5) return false; - return ctx.bot.is_ready(GLOOMBLADE); -} -void DoGloomblade(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(GLOOMBLADE, ctx.bot.victim()); -} - -bool ShouldBackstab(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (ctx.bot.knows_spell(GLOOMBLADE)) return false; - if (ComboPoints(ctx) >= 5) return false; - return ctx.bot.knows_spell(BACKSTAB); -} -void DoBackstab(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(BACKSTAB, ctx.bot.victim()); -} - -bool ShouldShurikenToss(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(SHURIKEN_TOSS)) return false; - if (ComboPoints(ctx) >= 5) return false; - return ctx.bot.enemies_within(8.0f) == 0; -} -void DoShurikenToss(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(SHURIKEN_TOSS, ctx.bot.victim()); -} - -// Sap: OOC CC. Stealthed, premium-target CC for pulls. Fires only when -// OOC + stealthed + an enemy is within 10y AND isn't already our -// engagement target (we don't want to Sap the mob we just opened on). -bool ShouldSap(ApPredicateContext const& ctx) -{ - if (ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(SAP)) return false; - if (!ctx.bot.is_ready(SAP)) return false; - if (!InStealth(ctx)) return false; - // Don't Sap our combat target — that would break a planned pull. - // Only useful when we have a second nearby enemy. - return ctx.bot.enemies_within(10.0f) >= 2; -} -void DoSap(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(SAP, ctx.bot.victim()); -} - -bool AlwaysInCombat(ApPredicateContext const& ctx) { return ctx.bot.in_combat(); } -void DoAutoAttack(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - ObjectGuid t = ctx.bot.victim(); - if (t.IsEmpty()) t = ctx.bot.current_target(); - // Retaliate fallback (2026-06-17): in combat with no victim/target the bot - // looped "Engage auto attack" as a no-op while taking damage (the CombatLoop - // wedge cluster). Engage whatever is meleeing us (attackers are adjacent and - // reachable), else the nearest visible enemy, so combat actually resolves. - // Strictly additive: only runs when no target was already selected. - if (t.IsEmpty()) - for (auto const& u : ctx.bot.attackers()) - if (u.hp > 0) { t = u.guid; break; } - if (t.IsEmpty()) - for (auto const& u : ctx.bot.nearby_enemies()) - if (u.hp > 0 && u.in_los) { t = u.guid; break; } - if (!t.IsEmpty()) e.start_attack(t); -} - -// Rule order: -// Cloak (magic emerg) -> Vanish (panic/offensive) -> Evasion -> Crimson Vial -// -> Feint -> Kick -> Kidney Shot (kick fb) -> Sap (OOC CC) -> Blind -// -> poisons (OOC upkeep) -> Stealth (OOC) -> Cheap Shot (stealth open vs caster) -// -> Shadowstrike (stealth) -> Tricks -> Shadowstep (gap close) -> Thistle Tea -// -> major CDs (Shadow Blades, Shadow Dance, Goremaw's Bite) -> Slice and Dice -// -> Secret Tech -> Black Powder (AoE finisher) -> Eviscerate (5 CP) -// -> Shuriken Storm (AoE gen) -> Gloomblade / Backstab -> Shuriken Toss -> AA. -ApRule const kRules[] = { - { ShouldCloakOfShadows, DoCloakOfShadows, "Cloak of Shadows (magic emergency)"}, - { ShouldVanish, DoVanish, "Vanish (offensive/panic)" }, - { ShouldEvasion, DoEvasion, "Evasion (<=40%)" }, - { ShouldCrimsonVial, DoCrimsonVial, "Crimson Vial (<=60%)" }, - { ShouldFeint, DoFeint, "Feint (<=60% DR)" }, - { ShouldKick, DoKick, "Kick (interrupt)" }, - { ShouldKidneyShot, DoKidneyShot, "Kidney Shot (interrupt fb)" }, - { ShouldSap, DoSap, "Sap (OOC CC second target)" }, - { ShouldBlind, DoBlind, "Blind (panic CC)" }, - { ShouldInstantPoison, DoInstantPoison, "Instant Poison (OOC upkeep)" }, - { ShouldNonLethalPoison, DoNonLethalPoison, "Non-lethal poison (OOC upkeep)" }, - { ShouldStealthOOC, DoStealth, "Stealth (OOC opener prep)" }, - { ShouldCheapShotOpener, DoCheapShot, "Cheap Shot (stealth stun opener)" }, - { ShouldShadowstrike, DoShadowstrike, "Shadowstrike (stealth CP gen)" }, - { ShouldTricks, DoTricks, "Tricks of the Trade" }, - { ShouldShadowstep, DoShadowstep, "Shadowstep (gap close)" }, - { ShouldThistleTea, DoThistleTea, "Thistle Tea (energy restore)" }, - { ShouldShadowBlades, DoShadowBlades, "Shadow Blades" }, - { ShouldShadowDance, DoShadowDance, "Shadow Dance" }, - { ShouldGoremawsBite, DoGoremawsBite, "Goremaw's Bite (CP burst)" }, - { ShouldSliceAndDice, DoSliceAndDice, "Slice and Dice (refresh)" }, - { ShouldSecretTechnique, DoSecretTechnique, "Secret Technique (5 CP)" }, - { ShouldBlackPowder, DoBlackPowder, "Black Powder (3+ AoE 5 CP)" }, - { ShouldEviscerate, DoEviscerate, "Eviscerate (5 CP finisher)" }, - { ShouldShurikenStorm, DoShurikenStorm, "Shuriken Storm (AoE gen)" }, - { ShouldGloomblade, DoGloomblade, "Gloomblade (filler)" }, - { ShouldBackstab, DoBackstab, "Backstab (filler)" }, - { ShouldShurikenToss, DoShurikenToss, "Shuriken Toss (range filler)" }, - { AlwaysInCombat, DoAutoAttack, "Engage auto attack" }, -}; - -} // anonymous - -void RegisterApl_Rogue_Subtlety() -{ - constexpr uint32 SPEC_ROGUE_SUBTLETY = 261; - RegisterRotation(CLASS_ROGUE, SPEC_ROGUE_SUBTLETY, ApRotation{kRules}); -} - -} // namespace Playerbot::Combat diff --git a/src/modules/PlayerbotV2/Combat/Apl/Apl_Shaman_Elemental.cpp b/src/modules/PlayerbotV2/Combat/Apl/Apl_Shaman_Elemental.cpp deleted file mode 100644 index f6f5fded32..0000000000 --- a/src/modules/PlayerbotV2/Combat/Apl/Apl_Shaman_Elemental.cpp +++ /dev/null @@ -1,721 +0,0 @@ -// Elemental Shaman - WoW 12.1.0.69587 (Midnight) enterprise rotation. -// Maelstrom-builder caster: Lava Burst (instant via Lava Surge proc), -// Elemental Blast (90 Maelstrom, curated builds) / Earth Shock (60, choice -// node) single-target spender, Earthquake AoE spender (61882 ground-target -// in the raid build, 462620 target-cast in the M+ build), Chain Lightning -// AoE filler, Tempest (Stormbringer proc that replaces Lightning Bolt). -// Major CDs: Stormkeeper, Ascendance (Flame Ascendant burst), Ancestral -// Swiftness (Farseer instant), Nature's Swiftness (instant Nature spell -// while moving). Group utility: Bloodlust/Heroism, Skyfury (group Mastery), -// Cleanse Spirit (Curse), Chain Heal (emergency group heal), Healing Stream -// Totem, Earth Elemental (panic taunt / Primordial Bond HP), Spiritwalker's -// Grace (cast while moving). CC: Wind Shear interrupt, Hex, Capacitor Totem -// (stun), Earthgrab / Earthbind Totem (root / slow), Thunderstorm (knockback -// panic peel). Survival: Astral Shift, Earth Shield, Lightning Shield -// (Elemental Orbit lets both shields sit on the bot), Healing Surge. -// -// Validated spell IDs (WoW 12.1.0.69587): -// 188196 Lightning Bolt | 51505 Lava Burst | 470411 Flame Shock -// 8042 Earth Shock | 117014 Elemental Blast | 191634 Stormkeeper -// 188443 Chain Lightning | 61882 Earthquake (ground)| 462620 Earthquake (target) -// 196840 Frost Shock | 51490 Thunderstorm | 114050 Ascendance -// 470057 Voltaic Blaze | 452201 Tempest | 443454 Ancestral Swiftness -// 378081 Nature's Swiftness | 79206 Spiritwalker's Gr. | 198103 Earth Elemental -// 2484 Earthbind Totem | 51485 Earthgrab Totem | 192058 Capacitor Totem -// 51514 Hex | 370 Purge | 57994 Wind Shear -// 2825 Bloodlust | 32182 Heroism | 462854 Skyfury -// 108271 Astral Shift | 974 Earth Shield | 192106 Lightning Shield -// 5394 Healing Stream Totem| 8004 Healing Surge | 1064 Chain Heal -// 51886 Cleanse Spirit | 2008 Ancestral Spirit | 318038 Flametongue Weapon -// Aura-only: 77762 Lava Surge proc | 188389 Flame Shock DoT (legacy debuff row) -// 454015 Tempest ready | 319778 Flametongue imbue | 57724/80354/95809/264689 sated -// Passive gates: 383010 Elemental Orbit | 392915 Healing Stream Totem talent (teaches 5394) -// -// Skipped spells (and why): -// 210714 Icefury - removed from the Elemental tree in 12.1 (Frost Shock is now -// a plain instant / moving filler) -// 192222 Liquid Magma Totem - removed from the Elemental tree in 12.1 -// 198067 Fire Elemental / 192249 Storm Elemental - no longer castable talents in 12.1 -// (elemental passives Call of Fire / Fury of the Storms remain) -// 108270 Stone Bulwark Totem - removed from the class tree in 12.1 -// 98008 Spirit Link Totem - Restoration-only talent in 12.1 -// 187828 / 343725 Maelstrom - passive resource, consumed via power(11) -// 77756 Lava Surge - spec passive that grants the 77762 proc aura -// 20608 Reincarnation - passive out-of-combat death recovery, not APL -// 192063 Gust of Wind / 192077 Wind Rush Totem - movement utility the bot cannot aim -// 205495 Stormkeeper (artifact row) - unlearnable Legion artifact spell; 191634 is the talent -// 1229376 Single-Button Assistant - client convenience macro, not a rotation ability - -#include "../ApRegistry.h" -#include "../ApRotation.h" -#include "ApCrowdControl.h" -#include "ApDispelHelpers.h" -#include "Bot/BotIntentEmitter.h" -#include "Bot/BotSnapshotView.h" -#include "Group/GroupSnapshot.h" -#include "SharedDefines.h" - -namespace Playerbot::Combat { - -namespace { - -// ---- Spell IDs (WoW 12.1.0.69587, validated against SpellName.csv) ---- -constexpr uint32 LIGHTNING_BOLT = 188196; -constexpr uint32 LAVA_BURST = 51505; -// Lava Surge proc - the aura applied to the player that makes the next -// Lava Burst instant + ignores CD. Two distinct DB2 rows share the name -// "Lava Surge": 77756 is the spec passive, 77762 is the proc aura applied -// at runtime when the passive triggers. APL checks `has_aura(LAVA_SURGE)` -// against the on-bot aura, so 77762 is correct. -constexpr uint32 LAVA_SURGE = 77762; -// Flame Shock was renumbered in Midnight: 470411 is the castable (its -// description aliases 188389). The legacy row still exists and may be the -// id the periodic debuff lands under, so the refresh check probes both. -constexpr uint32 FLAME_SHOCK = 470411; -constexpr uint32 FLAME_SHOCK_DOT_LEGACY = 188389; // aura-only -constexpr uint32 EARTH_SHOCK = 8042; // choice node vs Elemental Blast -constexpr uint32 ELEMENTAL_BLAST = 117014; // [R][M] - 90 Maelstrom -constexpr uint32 STORMKEEPER = 191634; -constexpr uint32 CHAIN_LIGHTNING = 188443; -constexpr uint32 EARTHQUAKE = 61882; // [R] ground-target variant -constexpr uint32 EARTHQUAKE_TARGETED = 462620; // [M] cast-at-target variant -constexpr uint32 FROST_SHOCK = 196840; // instant moving filler -constexpr uint32 THUNDERSTORM = 51490; // knockback AoE panic -constexpr uint32 VOLTAIC_BLAZE = 470057; // [M] AoE Flame Shock applicator -constexpr uint32 TEMPEST = 452201; // Stormbringer proc cast -constexpr uint32 TEMPEST_READY_AURA = 454015; // "Lightning Bolt replaced by Tempest" -constexpr uint32 ANCESTRAL_SWIFTNESS = 443454; // Farseer - taught by 448861 -constexpr uint32 NATURES_SWIFTNESS = 378081; -constexpr uint32 ASCENDANCE_ELE = 114050; -constexpr uint32 EARTH_ELEMENTAL = 198103; -constexpr uint32 SPIRITWALKER_GRACE = 79206; -constexpr uint32 EARTHBIND_TOTEM = 2484; -constexpr uint32 EARTHGRAB_TOTEM = 51485; // [R] talent overriding Earthbind -constexpr uint32 CAPACITOR_TOTEM = 192058; -constexpr uint32 HEX = 51514; -constexpr uint32 PURGE = 370; -constexpr uint32 BLOODLUST = 2825; -constexpr uint32 HEROISM = 32182; -constexpr uint32 SKYFURY = 462854; // group Mastery buff (L16) -constexpr uint32 SATED_DEBUFF = 57724; -constexpr uint32 TEMPORAL_DISPL_DEBUFF = 80354; -constexpr uint32 INSANITY_HUNTER_DEBUFF = 95809; -constexpr uint32 FATIGUED_DEBUFF = 264689; -constexpr uint32 WIND_SHEAR = 57994; -constexpr uint32 ASTRAL_SHIFT = 108271; -constexpr uint32 EARTH_SHIELD = 974; -constexpr uint32 LIGHTNING_SHIELD = 192106; -constexpr uint32 ELEMENTAL_ORBIT = 383010; // passive: +1 shield on self -constexpr uint32 FLAMETONGUE_WEAPON = 318038; // [R][M] imbue (+Fire damage) -constexpr uint32 FLAMETONGUE_AURA = 319778; // aura-only -// Healing Stream Totem: the class-tree talent row is 392915 and it teaches -// the castable 5394. Cast 5394; accept either id in the spellbook. -constexpr uint32 HEALING_STREAM_TOTEM = 5394; -constexpr uint32 HEALING_STREAM_TALENT = 392915; -constexpr uint32 HEALING_SURGE = 8004; -constexpr uint32 CHAIN_HEAL = 1064; // [R][M] class talent -constexpr uint32 CLEANSE_SPIRIT = 51886; // Curse only in 12.1 -constexpr uint32 ANCESTRAL_SPIRIT = 2008; - -constexpr uint8 POWER_MAELSTROM_IDX = 11; - -bool HasLiveTarget(ApPredicateContext const& ctx) -{ - return !ctx.bot.victim().IsEmpty(); -} - -bool BotHasSatedDebuff(ApPredicateContext const& ctx) -{ - return ctx.bot.has_aura(SATED_DEBUFF) - || ctx.bot.has_aura(TEMPORAL_DISPL_DEBUFF) - || ctx.bot.has_aura(INSANITY_HUNTER_DEBUFF) - || ctx.bot.has_aura(FATIGUED_DEBUFF); -} - -bool BossLikeTargetEngaged(ApPredicateContext const& ctx) -{ - constexpr int32 kBossHpThreshold = 5'000'000; - NearbyUnit const* t = ctx.bot.victim_info(); - if (t && t->max_hp >= kBossHpThreshold) return true; - for (auto const& a : ctx.bot.raw().combat.attackers) - if (a.max_hp >= kBossHpThreshold) return true; - return false; -} - -int32 Maelstrom(ApPredicateContext const& ctx) { return ctx.bot.power(POWER_MAELSTROM_IDX); } - -// ---- Group utility ---- -bool ShouldBloodlust(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - const uint32 sid = ctx.bot.knows_spell(BLOODLUST) ? BLOODLUST - : ctx.bot.knows_spell(HEROISM) ? HEROISM - : 0; - if (!sid) return false; - if (!ctx.bot.is_ready(sid)) return false; - if (BotHasSatedDebuff(ctx)) return false; - // Multi-shaman dedup: skip if any group member is already casting - // Bloodlust/Heroism/Time Warp/Primal Rage/Drums of Fury this tick. - // Without this, two Shamans in the same group both fire on boss - // pull, wasting the second cast (server applies Sated immediately - // after the first). Audit 2026-05-22. - if (auto const* members = ctx.group.members()) - { - constexpr uint32 TIME_WARP = 80353; - constexpr uint32 PRIMAL_RAGE = 264667; // Hunter pet - constexpr uint32 DRUMS_FURY = 178207; // Engineering drums - for (auto const& m : *members) - { - if (m.guid == ctx.bot.raw().guid) continue; - if (!m.is_casting) continue; - if (m.casting_spell == BLOODLUST || - m.casting_spell == HEROISM || - m.casting_spell == TIME_WARP || - m.casting_spell == PRIMAL_RAGE || - m.casting_spell == DRUMS_FURY) - return false; - } - } - return BossLikeTargetEngaged(ctx); -} -void DoBloodlust(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - const uint32 sid = ctx.bot.knows_spell(BLOODLUST) ? BLOODLUST : HEROISM; - e.cast(sid); -} - -bool ShouldAncestralSpirit(ApPredicateContext const& ctx) -{ - if (ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(ANCESTRAL_SPIRIT)) return false; - return ctx.group.dead_member(ctx.bot.map_id()) != nullptr; -} -void DoAncestralSpirit(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* m = ctx.group.dead_member(ctx.bot.map_id())) - e.cast(ANCESTRAL_SPIRIT, m->guid); -} - -// Cleanse Spirit (51886) is Curse-only in 12.1 ("Removes all Curse -// effects"); Magic dispel belongs to Restoration's Purify Spirit. -bool ShouldCleanseSpirit(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(CLEANSE_SPIRIT)) return false; - if (!ctx.bot.is_ready(CLEANSE_SPIRIT)) return false; - if (ctx.group.dispel_candidate(DispelType::Curse)) return true; - return ctx.bot.self_dispellable(DispelType::Curse); -} -void DoCleanseSpirit(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - GroupMemberSummary const* tgt = DispelTargetWithPriority(ctx, - [](GroupSnapshotView const& g) -> GroupMemberSummary const* - { - return g.dispel_candidate(DispelType::Curse); - }); - if (tgt) { e.cast(CLEANSE_SPIRIT, tgt->guid); return; } - e.cast(CLEANSE_SPIRIT, ctx.bot.raw().guid); -} - -bool KnowsHealingStreamTotem(ApPredicateContext const& ctx) -{ - return ctx.bot.knows_spell(HEALING_STREAM_TOTEM) || ctx.bot.knows_spell(HEALING_STREAM_TALENT); -} -bool ShouldHealingStreamTotem(ApPredicateContext const& ctx) -{ - if (!KnowsHealingStreamTotem(ctx)) return false; - if (!ctx.bot.is_ready(HEALING_STREAM_TOTEM)) return false; - if (ctx.bot.has_aura(HEALING_STREAM_TOTEM)) return false; - return ctx.bot.in_combat(); -} -void DoHealingStreamTotem(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(HEALING_STREAM_TOTEM); } - -// Chain Heal (1064) - class talent in the curated Elemental builds. A DPS -// only reaches for it when the group is genuinely collapsing (2+ members -// at or below 45%) and the 2s cast is not going to be interrupted by -// movement; below that it is a Healing Surge self-heal question. -int WoundedFriendCount(ApPredicateContext const& ctx, int below_pct) -{ - auto const* members = ctx.group.members(); - if (!members) return 0; - int n = 0; - for (auto const& m : *members) - { - if (!m.online || m.max_hp <= 0 || m.hp <= 0) continue; - if ((m.hp * 100) / m.max_hp <= below_pct) ++n; - } - return n; -} -bool ShouldChainHeal(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(CHAIN_HEAL)) return false; - if (ctx.bot.is_moving() && !ctx.bot.can_cast_while_moving(CHAIN_HEAL)) return false; - return WoundedFriendCount(ctx, 45) >= 2; -} -void DoChainHeal(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - auto const* low = ctx.group.lowest_hp_on_map(ctx.bot.map_id(), Role::Unknown, ctx.bot.raw().position.x, ctx.bot.raw().position.y, ctx.bot.raw().position.z, 40.0f); - e.cast(CHAIN_HEAL, low ? low->guid : ctx.bot.raw().guid); -} - -// Skyfury (462854) - group Mastery + extra-attack buff, 1h duration. Keep -// it up like a Battle Shout; the party/raid inherits it from the self cast. -bool ShouldSkyfury(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(SKYFURY)) return false; - return !ctx.bot.has_aura(SKYFURY); -} -void DoSkyfury(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(SKYFURY, ctx.bot.raw().guid); -} - -// Flametongue Weapon (318038) - Elemental imbue that buffs Fire spell -// damage. 1h self-buff; the imbue shows as aura 319778 on the bot. -bool ShouldFlametongueWeapon(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(FLAMETONGUE_WEAPON)) return false; - return !ctx.bot.has_aura(FLAMETONGUE_AURA); -} -void DoFlametongueWeapon(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(FLAMETONGUE_WEAPON); } - -// ---- Survival ---- -bool ShouldAstralShift(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(ASTRAL_SHIFT)) return false; - if (!ctx.bot.is_ready(ASTRAL_SHIFT)) return false; - return ctx.bot.hp_pct() <= 40; -} -void DoAstralShift(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(ASTRAL_SHIFT); } - -// Earth Elemental (198103) - panic button. Without Primordial Bond it is a -// taunting Greater Earth Elemental that pulls melee off the caster; with -// the [M] Primordial Bond talent it is a max-HP buff instead. Both make -// sense at the same trigger: real pressure on the bot itself. -bool ShouldEarthElemental(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(EARTH_ELEMENTAL)) return false; - if (!ctx.bot.is_ready(EARTH_ELEMENTAL)) return false; - return ctx.bot.hp_pct() <= 50 && ctx.bot.fightable_attackers_count() >= 1; -} -void DoEarthElemental(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(EARTH_ELEMENTAL); } - -bool ShouldEarthShield(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(EARTH_SHIELD)) return false; - return !ctx.bot.has_aura(EARTH_SHIELD); -} -void DoEarthShield(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(EARTH_SHIELD, ctx.bot.raw().guid); -} - -// Lightning Shield (192106) - baseline L9 elemental shield. Only one -// elemental shield may sit on the bot unless Elemental Orbit (383010, -// [R][M]) is known, so without Orbit a bot that already runs Earth Shield -// on itself must NOT alternate the two every tick. -bool ShouldLightningShield(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(LIGHTNING_SHIELD)) return false; - if (ctx.bot.has_aura(LIGHTNING_SHIELD)) return false; - if (ctx.bot.knows_spell(EARTH_SHIELD) && !ctx.bot.knows_spell(ELEMENTAL_ORBIT)) return false; - return true; -} -void DoLightningShield(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(LIGHTNING_SHIELD); } - -bool ShouldHealingSurgeSelf(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(HEALING_SURGE)) return false; - return ctx.bot.hp_pct() <= 40; -} -void DoHealingSurgeSelf(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(HEALING_SURGE, ctx.bot.raw().guid); -} - -// ---- Interrupt / CC ---- -bool ShouldWindShear(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(WIND_SHEAR)) return false; - if (!ctx.bot.is_ready(WIND_SHEAR)) return false; - const bool pvp = ctx.pvp.in_battleground || ctx.pvp.in_arena; - return ctx.bot.kick_target(pvp, 30.0f) != nullptr; -} -void DoWindShear(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - const bool pvp = ctx.pvp.in_battleground || ctx.pvp.in_arena; - if (auto const* c = ctx.bot.kick_target(pvp, 30.0f)) - e.cast(WIND_SHEAR, c->guid); -} - -bool ShouldCapacitorTotem(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(CAPACITOR_TOTEM)) return false; - if (!ctx.bot.is_ready(CAPACITOR_TOTEM)) return false; - return ctx.bot.enemies_within(8.0f) >= 3; -} -void DoCapacitorTotem(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(CAPACITOR_TOTEM); } - -// Earthgrab Totem (51485, [R] talent) overrides Earthbind Totem (2484, -// baseline L5). Two-branch so both talent and non-talent bots peel melee: -// drop it when 2+ mobs are on the caster in the open world. Skipped in -// instances - a root/slow totem on the tank's pack is griefing. -uint32 PickSnareTotem(ApPredicateContext const& ctx) -{ - if (ctx.bot.knows_spell(EARTHGRAB_TOTEM)) return EARTHGRAB_TOTEM; - if (ctx.bot.knows_spell(EARTHBIND_TOTEM)) return EARTHBIND_TOTEM; - return 0; -} -bool ShouldSnareTotem(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (ctx.bot.is_in_instance()) return false; - const uint32 sid = PickSnareTotem(ctx); - if (!sid || !ctx.bot.is_ready(sid)) return false; - return ctx.bot.melee_attackers_within(8.0f) >= 2; -} -void DoSnareTotem(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (const uint32 sid = PickSnareTotem(ctx)) e.cast(sid); -} - -// Off-target Hex via the shared PickOffTargetCC gate. Hex outranks Polymorph -// in PvP because it can't be broken by damage from the Hex'd target's allies -// until 8s; the picker escalates to enemy Healer > caster there. In PvE it -// only fires on a genuine 2+ ATTACKER pull (never a 40y scan bystander while -// solo-questing) and skips already-CC'd mobs via NearbyUnit::is_cc_locked. -// See ApCrowdControl.h for why the old has_aura gate CC-spammed every GCD. -bool ShouldHex(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(HEX)) return false; - if (!ctx.bot.is_ready(HEX)) return false; - return !PickOffTargetCC(ctx, HEX, ApInPvp(ctx)).IsEmpty(); -} -void DoHex(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - ObjectGuid const t = PickOffTargetCC(ctx, HEX, ApInPvp(ctx)); - if (!t.IsEmpty()) e.cast(HEX, t); -} - -bool ShouldPurge(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(PURGE)) return false; - return ctx.bot.target_dispellable(Playerbot::DispelType::Magic); -} -void DoPurge(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(PURGE, ctx.bot.victim()); -} - -bool ShouldSpiritwalkerGrace(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(SPIRITWALKER_GRACE)) return false; - if (!ctx.bot.is_ready(SPIRITWALKER_GRACE)) return false; - return ctx.bot.is_moving(); -} -void DoSpiritwalkerGrace(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(SPIRITWALKER_GRACE); } - -// Nature's Swiftness (378081, [R][M]) - next Nature spell instant and free. -// Fired when the bot is moving without Spiritwalker's Grace so the next -// Lightning Bolt / Chain Lightning goes off mid-run instead of being held. -bool ShouldNaturesSwiftness(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(NATURES_SWIFTNESS)) return false; - if (!ctx.bot.is_ready(NATURES_SWIFTNESS)) return false; - if (ctx.bot.has_aura(NATURES_SWIFTNESS)) return false; - if (ctx.bot.has_aura(SPIRITWALKER_GRACE)) return false; - return ctx.bot.is_moving(); -} -void DoNaturesSwiftness(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(NATURES_SWIFTNESS); } - -// ---- Major offensive cooldowns ---- -// Ancestral Swiftness (443454) - Farseer hero active taught by the 448861 -// [R][M] passive: next damaging spell instant, free and amplified. Used on -// cooldown against a live target; the following Lava Burst / Lightning -// Bolt in the ladder consumes it. -bool ShouldAncestralSwiftness(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(ANCESTRAL_SWIFTNESS)) return false; - if (!ctx.bot.is_ready(ANCESTRAL_SWIFTNESS)) return false; - return !ctx.bot.has_aura(ANCESTRAL_SWIFTNESS); -} -void DoAncestralSwiftness(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(ANCESTRAL_SWIFTNESS); } - -bool ShouldAscendance(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(ASCENDANCE_ELE)) return false; - if (!ctx.bot.is_ready(ASCENDANCE_ELE)) return false; - return BossLikeTargetEngaged(ctx); -} -void DoAscendance(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(ASCENDANCE_ELE); } - -bool ShouldStormkeeper(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(STORMKEEPER)) return false; - if (!ctx.bot.is_ready(STORMKEEPER)) return false; - return true; -} -void DoStormkeeper(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(STORMKEEPER); } - -// Frost Shock (196840, [R] class talent) - with Icefury gone in 12.1 this is -// a plain instant: the Maelstrom-generating filler while the bot is moving -// and cannot hard-cast Lightning Bolt (no Spiritwalker's Grace up). -bool ShouldFrostShockMoving(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(FROST_SHOCK)) return false; - if (!ctx.bot.is_ready(FROST_SHOCK)) return false; - return ctx.bot.is_moving() && !ctx.bot.can_cast_while_moving(LIGHTNING_BOLT); -} -void DoFrostShock(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(FROST_SHOCK, ctx.bot.victim()); -} - -// ---- Damage rotation ---- -// Flame Shock DoT presence - the 12.1 castable is 470411 but the periodic -// debuff may still be tracked under the legacy 188389 row; accept either. -AuraEntry const* FlameShockOnVictim(ApPredicateContext const& ctx) -{ - if (AuraEntry const* a = ctx.bot.find_aura(FLAME_SHOCK, ctx.bot.victim())) return a; - return ctx.bot.find_aura(FLAME_SHOCK_DOT_LEGACY, ctx.bot.victim()); -} - -// Voltaic Blaze (470057, [M]) - instant Flame Shock on the target plus -// nearby enemies, always crits, generates Maelstrom. When known it is the -// preferred Flame Shock applicator: fire on cooldown whenever the DoT is -// missing/expiring or there is a second target to spread onto. -bool ShouldVoltaicBlaze(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(VOLTAIC_BLAZE)) return false; - if (!ctx.bot.is_ready(VOLTAIC_BLAZE)) return false; - AuraEntry const* a = FlameShockOnVictim(ctx); - return !a || a->remaining.count() <= 6000 || ctx.bot.enemies_within(10.0f) >= 2; -} -void DoVoltaicBlaze(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(VOLTAIC_BLAZE, ctx.bot.victim()); -} - -bool ShouldFlameShock(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(FLAME_SHOCK)) return false; - AuraEntry const* a = FlameShockOnVictim(ctx); - return !a || a->remaining.count() <= 4000; -} -void DoFlameShock(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(FLAME_SHOCK, ctx.bot.victim()); -} - -// Lava Burst - split into two rules so the rotation can prioritize the -// Lava Surge proc cast (instant, no CD) at the top of the damage chain, -// then fall through to a hardcast version after spenders are exhausted. -bool ShouldLavaBurstSurgeProc(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(LAVA_BURST)) return false; - if (!ctx.bot.is_ready(LAVA_BURST)) return false; - return ctx.bot.has_aura(LAVA_SURGE); -} -bool ShouldLavaBurstHardcast(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(LAVA_BURST)) return false; - if (!ctx.bot.is_ready(LAVA_BURST)) return false; - // Hard-cast Lava Burst is a 2s cast - never start mid-move. - if (ctx.bot.is_moving() && !ctx.bot.can_cast_while_moving(LAVA_BURST)) return false; - return true; -} -void DoLavaBurst(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(LAVA_BURST, ctx.bot.victim()); -} - -// Thunderstorm - 51490, 30y AoE knockback + small damage on a 45s CD. -// Used as a panic / peel button when melee converge on the caster: -// fires when at least 2 hostiles are within 10y AND bot HP is under -// pressure. Not used as a general AoE damage tool; the knockback is -// the value, and using it on a pack the tank just established would -// be griefing in a group context. -bool ShouldThunderstorm(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(THUNDERSTORM)) return false; - if (!ctx.bot.is_ready(THUNDERSTORM)) return false; - // Solo / open-world only - in dungeons / raids the tank's positioning - // shouldn't be disrupted by a stray knockback. is_in_instance covers - // both dungeon and raid maps. - if (ctx.bot.is_in_instance()) return false; - return ctx.bot.enemies_within(10.0f) >= 2 && ctx.bot.hp_pct() <= 55; -} -void DoThunderstorm(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(THUNDERSTORM); } - -bool ShouldElementalBlast(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(ELEMENTAL_BLAST)) return false; - if (!ctx.bot.is_ready(ELEMENTAL_BLAST)) return false; - return Maelstrom(ctx) >= 90; -} -void DoElementalBlast(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(ELEMENTAL_BLAST, ctx.bot.victim()); -} - -// Earthquake is a choice node in 12.1: 61882 (raid build) is placed at a -// location, 462620 (M+ build) is cast at the target. Pick whichever the -// bot knows; both cost 60 Maelstrom. -uint32 PickEarthquake(ApPredicateContext const& ctx) -{ - if (ctx.bot.knows_spell(EARTHQUAKE_TARGETED)) return EARTHQUAKE_TARGETED; - if (ctx.bot.knows_spell(EARTHQUAKE)) return EARTHQUAKE; - return 0; -} -bool ShouldEarthquake(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - const uint32 sid = PickEarthquake(ctx); - if (!sid || !ctx.bot.is_ready(sid)) return false; - if (Maelstrom(ctx) < 60) return false; - return ctx.aoe_preference || ctx.bot.enemies_within(20.0f) >= 3; -} -void DoEarthquake(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - const uint32 sid = PickEarthquake(ctx); - if (!sid) return; - if (sid == EARTHQUAKE_TARGETED) { e.cast(sid, ctx.bot.victim()); return; } - if (auto const* v = ctx.bot.victim_info()) - e.cast_at(sid, v->x, v->y, v->z); - else - e.cast(sid, ctx.bot.victim()); -} - -bool ShouldEarthShock(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(EARTH_SHOCK)) return false; - if (!ctx.bot.is_ready(EARTH_SHOCK)) return false; - return Maelstrom(ctx) >= 60; -} -void DoEarthShock(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(EARTH_SHOCK, ctx.bot.victim()); -} - -bool ShouldChainLightning(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(CHAIN_LIGHTNING)) return false; - if (ctx.bot.is_moving() && !ctx.bot.can_cast_while_moving(CHAIN_LIGHTNING)) return false; - // 3+ targets matches modern Elemental AoE breakpoint - at 2 targets - // Lightning Bolt + spender is comparable damage and generates more - // Maelstrom per GCD. owner-flagged aoe_preference still overrides. - return ctx.aoe_preference || ctx.bot.enemies_within(20.0f) >= 3; -} -void DoChainLightning(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(CHAIN_LIGHTNING, ctx.bot.victim()); -} - -// Tempest (452201) - Stormbringer hero cast. Spending Maelstrom can upgrade -// the next Lightning Bolt into Tempest; the 454015 aura ("Lightning Bolt -// replaced by Tempest") marks the window. Cast the Tempest id explicitly: -// emitting the base Lightning Bolt would fire the un-upgraded spell. -bool ShouldTempest(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(TEMPEST)) return false; - if (!ctx.bot.has_aura(TEMPEST_READY_AURA)) return false; - if (ctx.bot.is_moving() && !ctx.bot.can_cast_while_moving(TEMPEST)) return false; - return true; -} -void DoTempest(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(TEMPEST, ctx.bot.victim()); -} - -bool ShouldLightningBolt(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(LIGHTNING_BOLT)) return false; - // Hard-cast - bots in motion need an instant alternative (Frost Shock). - if (ctx.bot.is_moving() && !ctx.bot.can_cast_while_moving(LIGHTNING_BOLT)) return false; - return true; -} -void DoLightningBolt(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(LIGHTNING_BOLT, ctx.bot.victim()); -} - -bool AlwaysAlive(ApPredicateContext const& ctx) { return ctx.bot.is_alive(); } -void DoNothing(ApPredicateContext const&, BotIntentEmitter&) {} - -// Rule ORDER (12.1 Elemental): -// OOC rez -> self buffs (Skyfury, Earth Shield, Lightning Shield, -// Flametongue) -> panic (Astral Shift <=40%, Earth Elemental <=50%, -// Healing Surge <=40%, Thunderstorm peel, snare totem) -> interrupt / CC -// (Wind Shear, Capacitor, Hex, Purge) -> group (Cleanse Spirit, Chain Heal -// collapse, Healing Stream, Spiritwalker's Grace, Nature's Swiftness, -// Bloodlust) -> major CDs (Ascendance, Ancestral Swiftness) -> Lava Surge -// instant Lava Burst -> Voltaic Blaze / Flame Shock upkeep -> Stormkeeper -// -> Tempest proc -> Elemental Blast (90) -> Chain Lightning (3+) -> -// Earthquake (3+, 60) -> Earth Shock (60) -> Lava Burst hardcast -> Frost -// Shock (moving) -> Lightning Bolt filler -> Idle. -ApRule const kRules[] = { - { ShouldAncestralSpirit, DoAncestralSpirit, "Ancestral Spirit (rez OOC)" }, - { ShouldSkyfury, DoSkyfury, "Skyfury (group buff)" }, - { ShouldEarthShield, DoEarthShield, "Earth Shield (self)" }, - { ShouldLightningShield, DoLightningShield, "Lightning Shield (self)" }, - { ShouldFlametongueWeapon, DoFlametongueWeapon, "Flametongue Weapon (imbue)" }, - { ShouldAstralShift, DoAstralShift, "Astral Shift (<=40%)" }, - { ShouldEarthElemental, DoEarthElemental, "Earth Elemental (<=50%)" }, - { ShouldHealingSurgeSelf, DoHealingSurgeSelf, "Healing Surge (<=40% self)" }, - { ShouldThunderstorm, DoThunderstorm, "Thunderstorm (panic peel)" }, - { ShouldSnareTotem, DoSnareTotem, "Earthgrab/Earthbind (peel)" }, - { ShouldWindShear, DoWindShear, "Wind Shear (interrupt)" }, - { ShouldCapacitorTotem, DoCapacitorTotem, "Capacitor Totem (3+ AoE)" }, - { ShouldHex, DoHex, "Hex (off-target CC)" }, - { ShouldPurge, DoPurge, "Purge (Magic dispel)" }, - { ShouldCleanseSpirit, DoCleanseSpirit, "Cleanse Spirit (Curse)" }, - { ShouldChainHeal, DoChainHeal, "Chain Heal (2+ <=45%)" }, - { ShouldHealingStreamTotem, DoHealingStreamTotem, "Healing Stream Totem" }, - { ShouldSpiritwalkerGrace, DoSpiritwalkerGrace, "Spiritwalker's Grace" }, - { ShouldNaturesSwiftness, DoNaturesSwiftness, "Nature's Swiftness (moving)"}, - { ShouldBloodlust, DoBloodlust, "Bloodlust/Heroism (boss)" }, - { ShouldAscendance, DoAscendance, "Ascendance" }, - { ShouldAncestralSwiftness, DoAncestralSwiftness, "Ancestral Swiftness" }, - { ShouldLavaBurstSurgeProc, DoLavaBurst, "Lava Burst (Lava Surge proc)"}, - { ShouldVoltaicBlaze, DoVoltaicBlaze, "Voltaic Blaze (Flame Shock)"}, - { ShouldFlameShock, DoFlameShock, "Flame Shock (refresh)" }, - { ShouldStormkeeper, DoStormkeeper, "Stormkeeper" }, - { ShouldTempest, DoTempest, "Tempest (proc)" }, - { ShouldElementalBlast, DoElementalBlast, "Elemental Blast (90 maelstr)"}, - { ShouldChainLightning, DoChainLightning, "Chain Lightning (3+ AoE)" }, - { ShouldEarthquake, DoEarthquake, "Earthquake (3+ AoE)" }, - { ShouldEarthShock, DoEarthShock, "Earth Shock (60 maelstr)" }, - { ShouldLavaBurstHardcast, DoLavaBurst, "Lava Burst (hardcast)" }, - { ShouldFrostShockMoving, DoFrostShock, "Frost Shock (moving)" }, - { ShouldLightningBolt, DoLightningBolt, "Lightning Bolt (filler)" }, - { AlwaysAlive, DoNothing, "Idle" }, -}; - -} // anonymous - -void RegisterApl_Shaman_Elemental() -{ - constexpr uint32 SPEC_SHAMAN_ELEMENTAL = 262; - RegisterRotation(CLASS_SHAMAN, SPEC_SHAMAN_ELEMENTAL, ApRotation{kRules}); -} - -} // namespace Playerbot::Combat diff --git a/src/modules/PlayerbotV2/Combat/Apl/Apl_Shaman_Enhancement.cpp b/src/modules/PlayerbotV2/Combat/Apl/Apl_Shaman_Enhancement.cpp deleted file mode 100644 index 8453b5b9a1..0000000000 --- a/src/modules/PlayerbotV2/Combat/Apl/Apl_Shaman_Enhancement.cpp +++ /dev/null @@ -1,622 +0,0 @@ -// Enhancement Shaman - WoW 12.1.0.69587 (Midnight) enterprise rotation. -// Dual-wield melee with Maelstrom Weapon (5-stack proc) gating instant -// Lightning Bolt / Tempest / Chain Lightning / Chain Heal / Healing Surge. -// Stormstrike (Windstrike while Ascendant) is the signature strike, Lava -// Lash spreads Flame Shock (Molten Assault), Voltaic Blaze applies Flame -// Shock to a pack and feeds Maelstrom Weapon. Major CDs: Ascendance (which -// also unleashes Doom Winds in 12.1) / Doom Winds (non-talent fallback), -// Sundering (line damage; summons Fire Feral Spirits via the passive). -// Gap closer: Feral Lunge. Imbues: Windfury Weapon (MH), Flametongue -// Weapon (OH). -// -// Group utility: Bloodlust/Heroism, Skyfury (group Mastery), Healing -// Stream Totem, Cleanse Spirit (Curse), Chain Heal (MW-instant group -// heal), Earth Shield. CC: Wind Shear, Capacitor Totem, Hex, Purge. -// Survival: Astral Shift, Healing Surge (MW-instant self heal), Earth -// Shield, Lightning Shield (Elemental Orbit lets both sit on the bot). -// -// Validated spell IDs (WoW 12.1.0.69587): -// 17364 Stormstrike | 115356 Windstrike | 60103 Lava Lash -// 187874 Crash Lightning | 196840 Frost Shock | 470411 Flame Shock -// 470057 Voltaic Blaze | 188196 Lightning Bolt | 452201 Tempest -// 188443 Chain Lightning | 1064 Chain Heal | 384352 Doom Winds -// 114051 Ascendance (enh) | 197214 Sundering | 196884 Feral Lunge -// 33757 Windfury Weapon | 318038 Flametongue Weapon | 57994 Wind Shear -// 108271 Astral Shift | 974 Earth Shield | 192106 Lightning Shield -// 8004 Healing Surge | 5394 Healing Stream | 192058 Capacitor Totem -// 51514 Hex | 370 Purge -// 51886 Cleanse Spirit | 2008 Ancestral Spirit | 462854 Skyfury -// 2825 Bloodlust | 32182 Heroism -// Aura-only: 344179 Maelstrom Weapon stacks | 454015 Tempest ready -// 188389 Flame Shock DoT (legacy debuff row) | 319773 Windfury imbue -// 319778 Flametongue imbue | 57724/80354/95809/264689 sated -// Passive gates: 383010 Elemental Orbit | 392915 Healing Stream Totem talent (teaches 5394) -// -// Skipped spells (and why): -// 117014 Elemental Blast - Elemental-only talent in 12.1 -// 51533 Feral Spirit - no longer castable: 469314 Feral Spirit is a passive -// (Sundering / Doom Winds summon the wolves) -// 333974 Fire Nova - no longer castable: 1260666 Fire Nova is a passive -// (Voltaic Blaze has a chance to trigger it); 466620 is -// the internal detonation row, not learnable -// 375982 Primordial Wave - removed from the Enhancement tree; 327163 is the -// Shadowlands Necrolord covenant row, not learnable -// 342240 Ice Strike - removed from the Enhancement tree in 12.1 -// 108270 Stone Bulwark Totem - removed from the class tree in 12.1 -// 98008 Spirit Link Totem - Restoration-only talent in 12.1 -// 1218047 Primordial Storm - passive that morphs Sundering; not in the curated builds -// 187880 Maelstrom Weapon - passive; the 344179 stack aura is what the APL reads -// 1252197 Ascendance - empty companion row taught by the 114051 talent; 114051 -// is the castable (cd/duration) -// 58875 Spirit Walk / 192063 Gust of Wind / 192077 Wind Rush Totem - movement utility -// the bot cannot aim -// 79206 Spiritwalker's Grace - not in the Enhancement builds; MW procs cover casts -// 1229376 Single-Button Assistant - client convenience macro, not a rotation ability - -#include "../ApRegistry.h" -#include "../ApRotation.h" -#include "ApCrowdControl.h" -#include "ApDispelHelpers.h" -#include "Bot/BotIntentEmitter.h" -#include "Bot/BotSnapshotView.h" -#include "Group/GroupSnapshot.h" -#include "SharedDefines.h" - -namespace Playerbot::Combat { - -namespace { - -// ---- Spell IDs (WoW 12.1.0.69587, validated against SpellName.csv) ---- -constexpr uint32 STORMSTRIKE = 17364; -constexpr uint32 WINDSTRIKE = 115356; // Stormstrike while Ascendant -constexpr uint32 LAVA_LASH = 60103; -constexpr uint32 CRASH_LIGHTNING = 187874; -constexpr uint32 FROST_SHOCK_ENH = 196840; -// Flame Shock was renumbered in Midnight: 470411 is the castable (its -// description aliases 188389). The legacy row still exists and may be the -// id the periodic debuff lands under, so the refresh check probes both. -constexpr uint32 FLAME_SHOCK = 470411; -constexpr uint32 FLAME_SHOCK_DOT_LEGACY = 188389; // aura-only -constexpr uint32 VOLTAIC_BLAZE = 470057; // [R][M] AoE Flame Shock + MW -constexpr uint32 LIGHTNING_BOLT_ENH = 188196; -constexpr uint32 TEMPEST = 452201; // Stormbringer proc cast -constexpr uint32 TEMPEST_READY_AURA = 454015; // "Lightning Bolt replaced by Tempest" -constexpr uint32 CHAIN_LIGHTNING_ENH = 188443; -constexpr uint32 CHAIN_HEAL = 1064; // [R][M] class talent -constexpr uint32 DOOM_WINDS = 384352; // overridden by Ascendance when talented -constexpr uint32 ASCENDANCE_ENH = 114051; -constexpr uint32 SUNDERING = 197214; // talent (not in curated builds) -constexpr uint32 FERAL_LUNGE = 196884; // spec spell - gap closer -constexpr uint32 WINDFURY_WEAPON = 33757; // [R][M] main-hand imbue -constexpr uint32 WINDFURY_AURA = 319773; // aura-only -constexpr uint32 FLAMETONGUE_WEAPON = 318038; // [R][M] off-hand imbue -constexpr uint32 FLAMETONGUE_AURA = 319778; // aura-only -constexpr uint32 MAELSTROM_WEAPON = 344179; // stack aura (passive is 187880) -constexpr uint32 WIND_SHEAR = 57994; -constexpr uint32 ASTRAL_SHIFT = 108271; -constexpr uint32 EARTH_SHIELD = 974; -constexpr uint32 LIGHTNING_SHIELD = 192106; -constexpr uint32 ELEMENTAL_ORBIT = 383010; // passive: +1 shield on self -constexpr uint32 HEALING_SURGE = 8004; -// Healing Stream Totem: the class-tree talent row is 392915 and it teaches -// the castable 5394. Cast 5394; accept either id in the spellbook. -constexpr uint32 HEALING_STREAM_TOTEM = 5394; -constexpr uint32 HEALING_STREAM_TALENT= 392915; -constexpr uint32 CAPACITOR_TOTEM = 192058; -constexpr uint32 HEX = 51514; -constexpr uint32 PURGE = 370; -constexpr uint32 CLEANSE_SPIRIT = 51886; -constexpr uint32 ANCESTRAL_SPIRIT = 2008; -constexpr uint32 BLOODLUST = 2825; -constexpr uint32 HEROISM = 32182; -constexpr uint32 SKYFURY = 462854; // group Mastery buff (L16) -constexpr uint32 SATED_DEBUFF = 57724; -constexpr uint32 TEMPORAL_DISPL_DEBUFF= 80354; -constexpr uint32 INSANITY_HUNTER_DEBUFF = 95809; -constexpr uint32 FATIGUED_DEBUFF = 264689; - -bool HasLiveTarget(ApPredicateContext const& ctx) -{ - return !ctx.bot.victim().IsEmpty(); -} - -bool BotHasSatedDebuff(ApPredicateContext const& ctx) -{ - return ctx.bot.has_aura(SATED_DEBUFF) - || ctx.bot.has_aura(TEMPORAL_DISPL_DEBUFF) - || ctx.bot.has_aura(INSANITY_HUNTER_DEBUFF) - || ctx.bot.has_aura(FATIGUED_DEBUFF); -} - -bool BossLikeTargetEngaged(ApPredicateContext const& ctx) -{ - constexpr int32 kBossHpThreshold = 5'000'000; - NearbyUnit const* t = ctx.bot.victim_info(); - if (t && t->max_hp >= kBossHpThreshold) return true; - for (auto const& a : ctx.bot.raw().combat.attackers) - if (a.max_hp >= kBossHpThreshold) return true; - return false; -} - -uint8 MaelstromStacks(ApPredicateContext const& ctx) -{ - return ctx.bot.aura_stacks(MAELSTROM_WEAPON); -} - -// ---- Group utility ---- -bool ShouldBloodlust(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - const uint32 sid = ctx.bot.knows_spell(BLOODLUST) ? BLOODLUST - : ctx.bot.knows_spell(HEROISM) ? HEROISM - : 0; - if (!sid) return false; - if (!ctx.bot.is_ready(sid)) return false; - if (BotHasSatedDebuff(ctx)) return false; - return BossLikeTargetEngaged(ctx); -} -void DoBloodlust(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - const uint32 sid = ctx.bot.knows_spell(BLOODLUST) ? BLOODLUST : HEROISM; - e.cast(sid); -} - -bool ShouldAncestralSpirit(ApPredicateContext const& ctx) -{ - if (ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(ANCESTRAL_SPIRIT)) return false; - return ctx.group.dead_member(ctx.bot.map_id()) != nullptr; -} -void DoAncestralSpirit(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* m = ctx.group.dead_member(ctx.bot.map_id())) - e.cast(ANCESTRAL_SPIRIT, m->guid); -} - -bool KnowsHealingStreamTotem(ApPredicateContext const& ctx) -{ - return ctx.bot.knows_spell(HEALING_STREAM_TOTEM) || ctx.bot.knows_spell(HEALING_STREAM_TALENT); -} -bool ShouldHealingStreamTotem(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!KnowsHealingStreamTotem(ctx)) return false; - if (!ctx.bot.is_ready(HEALING_STREAM_TOTEM)) return false; - return !ctx.bot.has_aura(HEALING_STREAM_TOTEM); -} -void DoHealingStreamTotem(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(HEALING_STREAM_TOTEM); } - -// Chain Heal (1064, [R][M] class talent) - at 5+ Maelstrom Weapon stacks -// it is instant, so a melee DPS can plug a group collapse (2+ members at -// or below 45%) without stopping to hard-cast. -int WoundedFriendCount(ApPredicateContext const& ctx, int below_pct) -{ - auto const* members = ctx.group.members(); - if (!members) return 0; - int n = 0; - for (auto const& m : *members) - { - if (!m.online || m.max_hp <= 0 || m.hp <= 0) continue; - if ((m.hp * 100) / m.max_hp <= below_pct) ++n; - } - return n; -} -bool ShouldChainHealMW(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(CHAIN_HEAL)) return false; - if (MaelstromStacks(ctx) < 5) return false; - return WoundedFriendCount(ctx, 45) >= 2; -} -void DoChainHeal(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - auto const* low = ctx.group.lowest_hp_on_map(ctx.bot.map_id(), Role::Unknown, ctx.bot.raw().position.x, ctx.bot.raw().position.y, ctx.bot.raw().position.z, 40.0f); - e.cast(CHAIN_HEAL, low ? low->guid : ctx.bot.raw().guid); -} - -// Skyfury (462854) - group Mastery + extra-attack buff, 1h duration. Keep -// it up like a Battle Shout; the party/raid inherits it from the self cast. -bool ShouldSkyfury(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(SKYFURY)) return false; - return !ctx.bot.has_aura(SKYFURY); -} -void DoSkyfury(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(SKYFURY, ctx.bot.raw().guid); -} - -// Weapon imbues - Windfury on the main hand (33757 -> aura 319773), -// Flametongue on the off hand (318038 -> aura 319778). 1h self-buffs. -bool ShouldWindfuryWeapon(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(WINDFURY_WEAPON)) return false; - return !ctx.bot.has_aura(WINDFURY_AURA); -} -void DoWindfuryWeapon(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(WINDFURY_WEAPON); } - -bool ShouldFlametongueWeapon(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(FLAMETONGUE_WEAPON)) return false; - return !ctx.bot.has_aura(FLAMETONGUE_AURA); -} -void DoFlametongueWeapon(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(FLAMETONGUE_WEAPON); } - -bool ShouldCleanseSpirit(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(CLEANSE_SPIRIT)) return false; - if (!ctx.bot.is_ready(CLEANSE_SPIRIT)) return false; - if (auto const* m = ctx.group.dispel_candidate(DispelType::Curse)) return true; - return ctx.bot.self_dispellable(DispelType::Curse); -} -void DoCleanseSpirit(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - GroupMemberSummary const* tgt = DispelTargetWithPriority(ctx, - [](GroupSnapshotView const& g) -> GroupMemberSummary const* - { - return g.dispel_candidate(DispelType::Curse); - }); - if (tgt) { e.cast(CLEANSE_SPIRIT, tgt->guid); return; } - e.cast(CLEANSE_SPIRIT, ctx.bot.raw().guid); -} - -// ---- Survival ---- -bool ShouldAstralShift(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(ASTRAL_SHIFT)) return false; - if (!ctx.bot.is_ready(ASTRAL_SHIFT)) return false; - return ctx.bot.hp_pct() <= 40; -} -void DoAstralShift(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(ASTRAL_SHIFT); } - -bool ShouldEarthShield(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(EARTH_SHIELD)) return false; - return !ctx.bot.has_aura(EARTH_SHIELD); -} -void DoEarthShield(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(EARTH_SHIELD, ctx.bot.raw().guid); -} - -// Lightning Shield (192106) - baseline L9 elemental shield. Only one -// elemental shield may sit on the bot unless Elemental Orbit (383010, -// [R][M]) is known, so without Orbit a bot that already runs Earth Shield -// on itself must NOT alternate the two every tick. -bool ShouldLightningShield(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(LIGHTNING_SHIELD)) return false; - if (ctx.bot.has_aura(LIGHTNING_SHIELD)) return false; - if (ctx.bot.knows_spell(EARTH_SHIELD) && !ctx.bot.knows_spell(ELEMENTAL_ORBIT)) return false; - return true; -} -void DoLightningShield(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(LIGHTNING_SHIELD); } - -bool ShouldHealingSurgeProc(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(HEALING_SURGE)) return false; - if (MaelstromStacks(ctx) < 5) return false; - return ctx.bot.hp_pct() <= 60; -} -void DoHealingSurgeSelf(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(HEALING_SURGE, ctx.bot.raw().guid); -} - -// ---- Interrupt / CC ---- -bool ShouldWindShear(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(WIND_SHEAR)) return false; - if (!ctx.bot.is_ready(WIND_SHEAR)) return false; - const bool pvp = ctx.pvp.in_battleground || ctx.pvp.in_arena; - return ctx.bot.kick_target(pvp, 30.0f) != nullptr; -} -void DoWindShear(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - const bool pvp = ctx.pvp.in_battleground || ctx.pvp.in_arena; - if (auto const* c = ctx.bot.kick_target(pvp, 30.0f)) - e.cast(WIND_SHEAR, c->guid); -} - -bool ShouldCapacitorTotem(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(CAPACITOR_TOTEM)) return false; - if (!ctx.bot.is_ready(CAPACITOR_TOTEM)) return false; - return ctx.bot.enemies_within(8.0f) >= 3; -} -void DoCapacitorTotem(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(CAPACITOR_TOTEM); } - -// Off-target Hex via the shared PickOffTargetCC gate (PvE: only on a 2+ -// ATTACKER pull, skipping already-CC'd mobs; PvP: enemy Healer > caster). -// See ApCrowdControl.h - replaced the old nearby_enemies.size()>=2 + has_aura -// gate that fired every GCD on a 40y scan bystander during questing. -bool ShouldHex(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(HEX)) return false; - if (!ctx.bot.is_ready(HEX)) return false; - if (MaelstromStacks(ctx) < 5) return false; // costs MW stacks - return !PickOffTargetCC(ctx, HEX, ApInPvp(ctx)).IsEmpty(); -} -void DoHex(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - ObjectGuid const t = PickOffTargetCC(ctx, HEX, ApInPvp(ctx)); - if (!t.IsEmpty()) e.cast(HEX, t); -} - -bool ShouldPurge(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(PURGE)) return false; - if (MaelstromStacks(ctx) < 5) return false; - return ctx.bot.target_dispellable(Playerbot::DispelType::Magic); -} -void DoPurge(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(PURGE, ctx.bot.victim()); -} - -// ---- Major offensive cooldowns ---- -bool ShouldAscendance(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(ASCENDANCE_ENH)) return false; - if (!ctx.bot.is_ready(ASCENDANCE_ENH)) return false; - return BossLikeTargetEngaged(ctx); -} -void DoAscendance(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(ASCENDANCE_ENH); } - -// Doom Winds (384352) is overridden by Ascendance (114051) in 12.1: the -// talented Ascendance "unleashes Doom Winds" itself. Only bots WITHOUT the -// Ascendance talent keep a separate Doom Winds button. -bool ShouldDoomWinds(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(DOOM_WINDS)) return false; - if (ctx.bot.knows_spell(ASCENDANCE_ENH)) return false; - if (!ctx.bot.is_ready(DOOM_WINDS)) return false; - return BossLikeTargetEngaged(ctx); -} -void DoDoomWinds(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(DOOM_WINDS); } - -// Sundering (197214) - frontal line damage on a 30s CD. Not in the curated -// builds but gated anyway; with the 469314 Feral Spirit passive it also -// summons Fire Feral Spirits, so a lone boss target is worth it too. -bool ShouldSundering(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(SUNDERING)) return false; - if (!ctx.bot.is_ready(SUNDERING)) return false; - return ctx.bot.enemies_within(10.0f) >= 2 || BossLikeTargetEngaged(ctx); -} -void DoSundering(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(SUNDERING); } - -// ---- Damage rotation ---- -// Flame Shock DoT presence - the 12.1 castable is 470411 but the periodic -// debuff may still be tracked under the legacy 188389 row; accept either. -AuraEntry const* FlameShockOnVictim(ApPredicateContext const& ctx) -{ - if (AuraEntry const* a = ctx.bot.find_aura(FLAME_SHOCK, ctx.bot.victim())) return a; - return ctx.bot.find_aura(FLAME_SHOCK_DOT_LEGACY, ctx.bot.victim()); -} - -// Voltaic Blaze (470057, [R][M]) - instant Flame Shock on the target plus -// nearby enemies, always crits, generates Maelstrom Weapon (and can -// trigger Fire Nova via the 1260666 passive). Fire on cooldown whenever -// the DoT is missing/expiring or there is a pack to spread onto. -bool ShouldVoltaicBlaze(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(VOLTAIC_BLAZE)) return false; - if (!ctx.bot.is_ready(VOLTAIC_BLAZE)) return false; - AuraEntry const* a = FlameShockOnVictim(ctx); - return !a || a->remaining.count() <= 6000 || ctx.bot.enemies_within(10.0f) >= 2; -} -void DoVoltaicBlaze(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(VOLTAIC_BLAZE, ctx.bot.victim()); -} - -bool ShouldFlameShock(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(FLAME_SHOCK)) return false; - AuraEntry const* a = FlameShockOnVictim(ctx); - return !a || a->remaining.count() <= 4000; -} -void DoFlameShock(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(FLAME_SHOCK, ctx.bot.victim()); -} - -// Tempest (452201) - Stormbringer hero cast. Spending Maelstrom Weapon can -// upgrade the next Lightning Bolt into Tempest; the 454015 aura marks the -// window. Cast the Tempest id explicitly at 5+ stacks: emitting the base -// Lightning Bolt would fire the un-upgraded spell. -bool ShouldTempestMW(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(TEMPEST)) return false; - if (!ctx.bot.has_aura(TEMPEST_READY_AURA)) return false; - return MaelstromStacks(ctx) >= 5; -} -void DoTempest(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(TEMPEST, ctx.bot.victim()); -} - -bool ShouldChainLightningMW(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(CHAIN_LIGHTNING_ENH)) return false; - if (MaelstromStacks(ctx) < 5) return false; - return ctx.aoe_preference || ctx.bot.enemies_within(20.0f) >= 2; -} -void DoChainLightning(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(CHAIN_LIGHTNING_ENH, ctx.bot.victim()); -} - -bool ShouldLightningBoltMW(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(LIGHTNING_BOLT_ENH)) return false; - return MaelstromStacks(ctx) >= 5; -} -void DoLightningBolt(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(LIGHTNING_BOLT_ENH, ctx.bot.victim()); -} - -// Feral Lunge - 196884, 25y leap to a target. Enhancement gap-closer. -// Fires when the bot's victim sits outside melee range so Stormstrike / -// Lava Lash / Crash Lightning don't fall through to ranged fillers. -// Uses victim_info() position; bails when the victim isn't a tracked -// nearby unit (e.g. fresh tab-target the snapshot hasn't seen yet). -bool ShouldFeralLunge(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(FERAL_LUNGE)) return false; - if (!ctx.bot.is_ready(FERAL_LUNGE)) return false; - NearbyUnit const* v = ctx.bot.victim_info(); - if (!v) return false; - float bx, by, bz; - ctx.bot.position(bx, by, bz); - const float dx = v->x - bx, dy = v->y - by, dz = v->z - bz; - const float d2 = dx*dx + dy*dy + dz*dz; - // Trigger past melee swing range (~5y) but inside the spell's 25y - // cap. Squared so we avoid sqrt: 8y^2 = 64, 25y^2 = 625. - return d2 > 64.0f && d2 <= 625.0f; -} -void DoFeralLunge(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(FERAL_LUNGE, ctx.bot.victim()); -} - -// Stormstrike (17364) becomes Windstrike (115356, baseline L15) while the -// bot is an Air Ascendant: cheaper, armor-bypassing, 30y range. Cast the -// Windstrike id explicitly during the Ascendance aura so the override -// actually applies instead of the base strike. -uint32 PickStormstrike(ApPredicateContext const& ctx) -{ - if (ctx.bot.has_aura(ASCENDANCE_ENH) && ctx.bot.knows_spell(WINDSTRIKE)) return WINDSTRIKE; - if (ctx.bot.knows_spell(STORMSTRIKE)) return STORMSTRIKE; - return 0; -} -bool ShouldStormstrike(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - const uint32 sid = PickStormstrike(ctx); - return sid != 0 && ctx.bot.is_ready(sid); -} -void DoStormstrike(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (const uint32 sid = PickStormstrike(ctx)) e.cast(sid, ctx.bot.victim()); -} - -bool ShouldCrashLightning(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(CRASH_LIGHTNING)) return false; - if (!ctx.bot.is_ready(CRASH_LIGHTNING)) return false; - return ctx.aoe_preference || ctx.bot.enemies_within(8.0f) >= 2; -} -void DoCrashLightning(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(CRASH_LIGHTNING); } - -bool ShouldLavaLash(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(LAVA_LASH)) return false; - return ctx.bot.is_ready(LAVA_LASH); -} -void DoLavaLash(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(LAVA_LASH, ctx.bot.victim()); -} - -bool ShouldFrostShock(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - return ctx.bot.knows_spell(FROST_SHOCK_ENH); -} -void DoFrostShock(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(FROST_SHOCK_ENH, ctx.bot.victim()); -} - -bool AlwaysInCombat(ApPredicateContext const& ctx) { return ctx.bot.in_combat(); } -void DoAutoAttack(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - ObjectGuid t = ctx.bot.victim(); - if (t.IsEmpty()) t = ctx.bot.current_target(); - // Retaliate fallback (2026-06-17): in combat with no victim/target the bot - // looped "Engage auto attack" as a no-op while taking damage (the CombatLoop - // wedge cluster). Engage whatever is meleeing us (attackers are adjacent and - // reachable), else the nearest visible enemy, so combat actually resolves. - // Strictly additive: only runs when no target was already selected. - if (t.IsEmpty()) - for (auto const& u : ctx.bot.attackers()) - if (u.hp > 0) { t = u.guid; break; } - if (t.IsEmpty()) - for (auto const& u : ctx.bot.nearby_enemies()) - if (u.hp > 0 && u.in_los) { t = u.guid; break; } - if (!t.IsEmpty()) e.start_attack(t); -} - -// Rule ORDER (12.1 Enhancement): OOC rez -> self buffs (Skyfury, Earth -// Shield, Lightning Shield, Windfury / Flametongue imbues) -> Astral Shift -// -> Healing Surge self (MW gate) -> Wind Shear -> Capacitor / Hex / Purge -// -> Cleanse Spirit -> Chain Heal (MW, group collapse) -> Healing Stream -// -> Bloodlust -> Ascendance (or Doom Winds when untalented) -> Feral -// Lunge gap-close -> Voltaic Blaze / Flame Shock DoT -> Maelstrom Weapon -// 5-stack spenders (Tempest proc / Chain Lightning AoE / Lightning Bolt) -// -> Stormstrike / Windstrike (signature) -> Crash Lightning (AoE 2+) -> -// Lava Lash -> Sundering -> Frost Shock filler / snare -> AutoAttack. -// The MW spenders sit ABOVE the melee builders because the evaluator fires -// only the first matching rule per tick: the builders gate only on -// knows_spell+is_ready (essentially always true off-GCD) and would otherwise -// consume the tick at 5+ MW stacks, wasting Enhancement's instant procs. -// The spenders gate on MaelstromStacks>=5, so below 5 stacks they fall -// through to the builders unchanged. -ApRule const kRules[] = { - { ShouldAncestralSpirit, DoAncestralSpirit, "Ancestral Spirit (rez OOC)" }, - { ShouldSkyfury, DoSkyfury, "Skyfury (group buff)" }, - { ShouldEarthShield, DoEarthShield, "Earth Shield (self)" }, - { ShouldLightningShield, DoLightningShield, "Lightning Shield (self)" }, - { ShouldWindfuryWeapon, DoWindfuryWeapon, "Windfury Weapon (MH imbue)" }, - { ShouldFlametongueWeapon,DoFlametongueWeapon,"Flametongue Weapon (OH)" }, - { ShouldAstralShift, DoAstralShift, "Astral Shift (<=40%)" }, - { ShouldHealingSurgeProc, DoHealingSurgeSelf, "Healing Surge (MW self)" }, - { ShouldWindShear, DoWindShear, "Wind Shear (interrupt)" }, - { ShouldCapacitorTotem, DoCapacitorTotem, "Capacitor Totem (3+ AoE)" }, - { ShouldHex, DoHex, "Hex (off-target CC)" }, - { ShouldPurge, DoPurge, "Purge (Magic dispel)" }, - { ShouldCleanseSpirit, DoCleanseSpirit, "Cleanse Spirit (Curse)" }, - { ShouldChainHealMW, DoChainHeal, "Chain Heal (MW, 2+ <=45%)" }, - { ShouldHealingStreamTotem,DoHealingStreamTotem,"Healing Stream Totem" }, - { ShouldBloodlust, DoBloodlust, "Bloodlust/Heroism (boss)" }, - { ShouldAscendance, DoAscendance, "Ascendance (+Doom Winds)" }, - { ShouldDoomWinds, DoDoomWinds, "Doom Winds (untalented)" }, - { ShouldFeralLunge, DoFeralLunge, "Feral Lunge (gap close)" }, - { ShouldVoltaicBlaze, DoVoltaicBlaze, "Voltaic Blaze (Flame Shock)"}, - { ShouldFlameShock, DoFlameShock, "Flame Shock" }, - { ShouldTempestMW, DoTempest, "Tempest (MW proc)" }, - { ShouldChainLightningMW, DoChainLightning, "Chain Lightning (MW 2+)" }, - { ShouldLightningBoltMW, DoLightningBolt, "Lightning Bolt (MW)" }, - { ShouldStormstrike, DoStormstrike, "Stormstrike / Windstrike" }, - { ShouldCrashLightning, DoCrashLightning, "Crash Lightning (2+ AoE)" }, - { ShouldLavaLash, DoLavaLash, "Lava Lash" }, - { ShouldSundering, DoSundering, "Sundering (2+ AoE / boss)" }, - { ShouldFrostShock, DoFrostShock, "Frost Shock (filler)" }, - { AlwaysInCombat, DoAutoAttack, "Engage auto attack" }, -}; - -} // anonymous - -void RegisterApl_Shaman_Enhancement() -{ - constexpr uint32 SPEC_SHAMAN_ENHANCEMENT = 263; - RegisterRotation(CLASS_SHAMAN, SPEC_SHAMAN_ENHANCEMENT, ApRotation{kRules}); -} - -} // namespace Playerbot::Combat diff --git a/src/modules/PlayerbotV2/Combat/Apl/Apl_Shaman_Restoration.cpp b/src/modules/PlayerbotV2/Combat/Apl/Apl_Shaman_Restoration.cpp deleted file mode 100644 index 573be1ba21..0000000000 --- a/src/modules/PlayerbotV2/Combat/Apl/Apl_Shaman_Restoration.cpp +++ /dev/null @@ -1,747 +0,0 @@ -// Restoration Shaman - WoW 12.1.0.69587 (Midnight) enterprise rotation. -// Reactive healer with strong group tools (Chain Heal, Healing Tide Totem, -// Spirit Link Totem, Healing Rain / Surging Totem in the Totemic builds), -// Riptide HoT priming chained heals, Unleash Life amplifying the next heal, -// and Earth Shield on the tank. Healing Wave replaces Healing Surge for -// Restoration in 12.1 (spec spell override); Nature's Swiftness makes the -// emergency cast instant. Major CDs: Ascendance (raid build) / Healing -// Tide Totem (M+ build), Spirit Link Totem (HP redistribute). Self -// maintenance: Water Shield (mana regen), Earthliving Weapon and -// Tidecaller's Guard imbues, Skyfury group buff. -// -// Survival: Astral Shift, Earth Elemental (panic taunt / Primordial Bond). -// CC / utility: Wind Shear, Capacitor Totem, Hex, Tremor Totem (anti-fear), -// Poison Cleansing Totem, Spiritwalker's Grace (cast while moving), -// Ancestral Spirit / Ancestral Vision (OOC rez). Dispel: Purify Spirit -// (Magic; +Curse with Improved Purify Spirit), Cleanse Spirit (Curse -// fallback before Purify is learned). -// -// Validated spell IDs (WoW 12.1.0.69587): -// 8004 Healing Surge | 77472 Healing Wave | 61295 Riptide -// 1064 Chain Heal | 73920 Healing Rain | 444995 Surging Totem -// 73685 Unleash Life | 378081 Nature's Swiftness | 108280 Healing Tide Totem -// 98008 Spirit Link Totem | 114052 Ascendance (resto) | 974 Earth Shield -// 108271 Astral Shift | 5394 Healing Stream Totem| 383013 Poison Cleansing Totem -// 77130 Purify Spirit | 440012 Cleanse Spirit | 52127 Water Shield -// 382021 Earthliving Weapon | 457481 Tidecaller's Guard | 462854 Skyfury -// 57994 Wind Shear | 79206 Spiritwalker's Grace| 192058 Capacitor Totem -// 51514 Hex | 370 Purge | 8143 Tremor Totem -// 198103 Earth Elemental | 2008 Ancestral Spirit | 212048 Ancestral Vision -// 188196 Lightning Bolt | 188443 Chain Lightning | 470411 Flame Shock -// 51505 Lava Burst | 2825 Bloodlust | 32182 Heroism -// Aura-only: 188389 Flame Shock DoT (legacy debuff row) | 382022 Earthliving imbue -// 457496 Tidecaller's Guard imbue | 57724/80354/95809/264689 sated -// Passive gates: 383016 Improved Purify Spirit | 392915/392916 Healing Stream Totem -// talent rows (teach 5394) -// -// Skipped spells (and why): -// 16191 Mana Tide Totem - removed from the Restoration tree in 12.1 -// 108270 Stone Bulwark Totem - removed from the class tree in 12.1 -// 157153 Cloudburst Totem - id no longer exists in 12.1 SpellName -// 197995 Wellspring - removed from the Restoration tree in 12.1 -// 198838 Earthen Wall Totem - removed from the Restoration tree in 12.1 -// 77762 Lava Surge - Elemental-only proc; Restoration Lava Burst is hardcast -// 207778 Downpour - granted by the 462486 talent, not in the curated builds -// 108287 Totemic Projection / 192063 Gust of Wind / 192077 Wind Rush Totem - -// positioning utility the bot cannot aim -// 20608 Reincarnation - passive out-of-combat death recovery, not APL -// 1229376 Single-Button Assistant - client convenience macro, not a rotation ability -// MECH_FEAR / MECH_SLEEP / MECH_CHARM below are Mechanics ids, not spells - -#include "../ApRegistry.h" -#include "../ApRotation.h" -#include "ApCrowdControl.h" -#include "ApDispelHelpers.h" -#include "ApHealHelpers.h" -#include "Bot/BotIntentEmitter.h" -#include "Bot/BotSnapshotView.h" -#include "Group/GroupSnapshot.h" -#include "SharedDefines.h" - -namespace Playerbot::Combat { - -namespace { - -// ---- Spell IDs (WoW 12.1.0.69587, validated against SpellName.csv) ---- -constexpr uint32 HEALING_SURGE = 8004; // overridden by Healing Wave at L10 -constexpr uint32 HEALING_WAVE = 77472; // spec spell, overrides 8004 -constexpr uint32 RIPTIDE = 61295; -constexpr uint32 CHAIN_HEAL = 1064; -constexpr uint32 HEALING_RAIN = 73920; -constexpr uint32 SURGING_TOTEM = 444995; // Totemic hero: replaces Healing Rain -constexpr uint32 UNLEASH_LIFE = 73685; // [R][M] instant heal + next-heal amp -constexpr uint32 NATURES_SWIFTNESS = 378081; // [R][M] instant next Nature heal -constexpr uint32 HEALING_TIDE_TOTEM = 108280; // [M] choice node vs Ascendance -constexpr uint32 SPIRIT_LINK_TOTEM = 98008; -constexpr uint32 EARTH_SHIELD = 974; -constexpr uint32 ASTRAL_SHIFT = 108271; -// Healing Stream Totem: the talent rows 392915 (class) / 392916 (spec) -// teach the castable 5394. Cast 5394; accept any of the ids in the book. -constexpr uint32 HEALING_STREAM_TOTEM = 5394; -constexpr uint32 HEALING_STREAM_TALENT = 392915; -constexpr uint32 HEALING_STREAM_TALENT2 = 392916; -constexpr uint32 POISON_CLEANSING_TOTEM = 383013; // [R][M] -constexpr uint32 ASCENDANCE_RESTO = 114052; // [R] 15s burst -constexpr uint32 PURIFY_SPIRIT = 77130; // Magic (+Curse with 383016) -constexpr uint32 IMPROVED_PURIFY_SPIRIT = 383016; // [M] passive: Purify removes Curses -constexpr uint32 CLEANSE_SPIRIT = 440012; // Curse-only fallback -constexpr uint32 WATER_SHIELD = 52127; // self mana-regen buff -constexpr uint32 EARTHLIVING_WEAPON = 382021; // [R][M] imbue -constexpr uint32 EARTHLIVING_AURA = 382022; // aura-only -constexpr uint32 TIDECALLERS_GUARD = 457481; // Totemic shield imbue (taught by 445033) -constexpr uint32 TIDECALLERS_GUARD_AURA = 457496; // aura-only -constexpr uint32 SKYFURY = 462854; // group Mastery buff (L16) -constexpr uint32 WIND_SHEAR = 57994; -constexpr uint32 SPIRITWALKER_GRACE = 79206; -constexpr uint32 CAPACITOR_TOTEM = 192058; -constexpr uint32 HEX = 51514; -constexpr uint32 PURGE = 370; -constexpr uint32 ANCESTRAL_SPIRIT = 2008; -constexpr uint32 ANCESTRAL_VISION = 212048; // spec spell: mass OOC rez -constexpr uint32 EARTH_ELEMENTAL = 198103; -constexpr uint32 TREMOR_TOTEM = 8143; -constexpr uint32 LIGHTNING_BOLT = 188196; -constexpr uint32 CHAIN_LIGHTNING = 188443; // [R][M] AoE DPS filler -// Flame Shock was renumbered in Midnight: 470411 is the castable (its -// description aliases 188389). The legacy row may still carry the DoT. -constexpr uint32 FLAME_SHOCK = 470411; -constexpr uint32 FLAME_SHOCK_DOT_LEGACY = 188389; // aura-only -constexpr uint32 LAVA_BURST = 51505; -constexpr uint32 BLOODLUST = 2825; -constexpr uint32 HEROISM = 32182; -constexpr uint32 SATED_DEBUFF = 57724; -constexpr uint32 TEMPORAL_DISPL_DEBUFF = 80354; -constexpr uint32 INSANITY_HUNTER_DEBUFF = 95809; -constexpr uint32 FATIGUED_DEBUFF = 264689; - -// ---- Helpers ---- -struct HealTarget -{ - ObjectGuid guid; - int32 hp_pct; -}; - -HealTarget LowestFriendOrSelf(ApPredicateContext const& ctx) -{ - HealTarget t{ ctx.bot.raw().guid, ctx.bot.hp_pct() }; - if (auto const* low = ctx.group.heal_assignment(ctx.bot.raw().guid, ctx.bot.map_id(), ctx.bot.raw().position.x, ctx.bot.raw().position.y, ctx.bot.raw().position.z, 45.0f)) { - if (low->online && low->max_hp > 0) { - const int32 pct = (low->hp * 100) / low->max_hp; - if (pct < t.hp_pct) { t.guid = low->guid; t.hp_pct = pct; } - } - } - return t; -} - -int WoundedFriendCount(ApPredicateContext const& ctx, int below_pct) -{ - int n = 0; - auto const* members = ctx.group.members(); - // SOLO (audit B22): ungrouped, "wounded friend" used to collapse to - // "my own HP <= below_pct" - the 92% GroupTopped gates then froze ALL - // damage the moment a questing healer took two melee hits, degenerating - // solo healer-spec leveling into heal-regen-nuke loops (3-10x kill - // time). Cap the solo threshold at a 45% survival floor: topped-style - // gates (92) stay open while merely scratched, true emergency heals - // (<=45) keep their thresholds. - if (!members) return ctx.bot.hp_pct() <= std::min(below_pct, 45) ? 1 : 0; - for (auto const& m : *members) { - if (!m.online || m.max_hp <= 0 || m.hp <= 0) continue; - if ((m.hp * 100) / m.max_hp <= below_pct) ++n; - } - return n; -} - -bool GroupTopped(ApPredicateContext const& ctx) -{ - return WoundedFriendCount(ctx, 92) == 0; -} - -// Purify Spirit removes Magic; Curses only with Improved Purify Spirit -// (383016, [M]). Without it a Curse is not dispellable by Restoration at -// all (Cleanse Spirit is overridden once Purify is learned). -bool PurifyHandlesCurse(ApPredicateContext const& ctx) -{ - return ctx.bot.knows_spell(IMPROVED_PURIFY_SPIRIT); -} - -GroupMemberSummary const* DispelTarget(ApPredicateContext const& ctx) -{ - const bool curse = PurifyHandlesCurse(ctx); - if (curse) - return DispelTargetWithPriority(ctx, [](GroupSnapshotView const& g) - -> GroupMemberSummary const* - { - if (auto const* m = g.dispel_candidate(DispelType::Magic)) return m; - if (auto const* m = g.dispel_candidate(DispelType::Curse)) return m; - return nullptr; - }); - return DispelTargetWithPriority(ctx, [](GroupSnapshotView const& g) - -> GroupMemberSummary const* { return g.dispel_candidate(DispelType::Magic); }); -} - -bool SelfNeedsDispel(ApPredicateContext const& ctx) -{ - if (ctx.bot.self_dispellable(DispelType::Magic)) return true; - return PurifyHandlesCurse(ctx) && ctx.bot.self_dispellable(DispelType::Curse); -} - -bool BotHasSatedDebuff(ApPredicateContext const& ctx) -{ - return ctx.bot.has_aura(SATED_DEBUFF) - || ctx.bot.has_aura(TEMPORAL_DISPL_DEBUFF) - || ctx.bot.has_aura(INSANITY_HUNTER_DEBUFF) - || ctx.bot.has_aura(FATIGUED_DEBUFF); -} - -bool BossLikeTargetEngaged(ApPredicateContext const& ctx) -{ - constexpr int32 kBossHpThreshold = 5'000'000; - NearbyUnit const* t = ctx.bot.victim_info(); - if (t && t->max_hp >= kBossHpThreshold) return true; - for (auto const& a : ctx.bot.raw().combat.attackers) - if (a.max_hp >= kBossHpThreshold) return true; - return false; -} - -// ---- Group utility ---- -bool ShouldBloodlust(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - const uint32 sid = ctx.bot.knows_spell(BLOODLUST) ? BLOODLUST - : ctx.bot.knows_spell(HEROISM) ? HEROISM - : 0; - if (!sid) return false; - if (!ctx.bot.is_ready(sid)) return false; - if (BotHasSatedDebuff(ctx)) return false; - return BossLikeTargetEngaged(ctx); -} -void DoBloodlust(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - const uint32 sid = ctx.bot.knows_spell(BLOODLUST) ? BLOODLUST : HEROISM; - e.cast(sid); -} - -// Ancestral Vision (212048, spec spell) - 10s mass rez. Preferred over the -// single-target Ancestral Spirit when 2+ members are dead on this map. -int DeadMemberCount(ApPredicateContext const& ctx) -{ - auto const* members = ctx.group.members(); - if (!members) return 0; - int n = 0; - for (auto const& m : *members) - if (m.online && m.hp <= 0) ++n; - return n; -} -bool ShouldAncestralVision(ApPredicateContext const& ctx) -{ - if (ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(ANCESTRAL_VISION)) return false; - if (ctx.group.dead_member(ctx.bot.map_id()) == nullptr) return false; - return DeadMemberCount(ctx) >= 2; -} -void DoAncestralVision(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(ANCESTRAL_VISION); } - -bool ShouldAncestralSpirit(ApPredicateContext const& ctx) -{ - if (ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(ANCESTRAL_SPIRIT)) return false; - return ctx.group.dead_member(ctx.bot.map_id()) != nullptr; -} -void DoAncestralSpirit(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* m = ctx.group.dead_member(ctx.bot.map_id())) - e.cast(ANCESTRAL_SPIRIT, m->guid); -} - -// Earth Elemental (198103, [R]) - with Primordial Bond ([R]) it is a max-HP -// buff for the healer instead of a taunt pet, so it fires on the bot's own -// pressure as well as on a collapsing tank. -bool ShouldEarthElemental(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(EARTH_ELEMENTAL)) return false; - if (!ctx.bot.is_ready(EARTH_ELEMENTAL)) return false; - if (ctx.bot.hp_pct() <= 45 && ctx.bot.fightable_attackers_count() >= 1) return true; - auto const* tank = ctx.group.tank(); - if (tank && tank->online && tank->hp > 0 && (tank->hp * 100) / tank->max_hp > 30) return false; - return ctx.bot.attackers_count() >= 1 || (tank && (tank->hp * 100) / tank->max_hp <= 30); -} -void DoEarthElemental(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(EARTH_ELEMENTAL); } - -// Poison Cleansing Totem (383013, [R][M]) - pulses Poison removal on the -// group for 6s. Drop it when anyone (or the bot) carries a Poison. -bool ShouldPoisonCleansingTotem(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(POISON_CLEANSING_TOTEM)) return false; - if (!ctx.bot.is_ready(POISON_CLEANSING_TOTEM)) return false; - if (ctx.bot.self_dispellable(DispelType::Poison)) return true; - return ctx.group.dispel_candidate(DispelType::Poison) != nullptr; -} -void DoPoisonCleansingTotem(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(POISON_CLEANSING_TOTEM); } - -bool ShouldTremorTotem(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(TREMOR_TOTEM)) return false; - if (!ctx.bot.is_ready(TREMOR_TOTEM)) return false; - // Tremor Totem pulses anti-fear/sleep/charm. Drop it when any group - // member (or self) is currently affected by one of those mechanics. - constexpr uint32 MECH_FEAR = 5; - constexpr uint32 MECH_SLEEP = 10; - constexpr uint32 MECH_CHARM = 1; - if (ctx.bot.has_mechanic(MECH_FEAR) || - ctx.bot.has_mechanic(MECH_SLEEP) || - ctx.bot.has_mechanic(MECH_CHARM)) return true; - const uint32 map = ctx.bot.map_id(); - return ctx.group.group_has_mechanic(MECH_FEAR, map) || - ctx.group.group_has_mechanic(MECH_SLEEP, map) || - ctx.group.group_has_mechanic(MECH_CHARM, map); -} -void DoTremorTotem(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(TREMOR_TOTEM); } - -// ---- Survival ---- -bool ShouldAstralShift(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(ASTRAL_SHIFT)) return false; - if (!ctx.bot.is_ready(ASTRAL_SHIFT)) return false; - return ctx.bot.hp_pct() <= 50; -} -void DoAstralShift(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(ASTRAL_SHIFT); } - -bool ShouldSpiritwalkerGrace(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(SPIRITWALKER_GRACE)) return false; - if (!ctx.bot.is_ready(SPIRITWALKER_GRACE)) return false; - return ctx.bot.is_moving() && WoundedFriendCount(ctx, 75) >= 1; -} -void DoSpiritwalkerGrace(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(SPIRITWALKER_GRACE); } - -// ---- Dispel / interrupt ---- -bool ShouldPurifySpirit(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(PURIFY_SPIRIT)) return false; - if (!ctx.bot.is_ready(PURIFY_SPIRIT)) return false; - return DispelTarget(ctx) != nullptr || SelfNeedsDispel(ctx); -} -void DoPurifySpirit(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* t = DispelTarget(ctx)) { e.cast(PURIFY_SPIRIT, t->guid); return; } - if (SelfNeedsDispel(ctx)) e.cast(PURIFY_SPIRIT, ctx.bot.raw().guid); -} - -// Cleanse Spirit (440012) - modern Resto fallback when Purify Spirit isn't -// learned yet (pre-talent lock-in). Curse-only; Magic dispels still need -// Purify Spirit. Gate so we don't shadow Purify when both are known. -GroupMemberSummary const* CurseDispelTarget(ApPredicateContext const& ctx) -{ - return DispelTargetWithPriority(ctx, [](GroupSnapshotView const& g) - -> GroupMemberSummary const* { return g.dispel_candidate(DispelType::Curse); }); -} -bool ShouldCleanseSpirit(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(CLEANSE_SPIRIT)) return false; - if (ctx.bot.knows_spell(PURIFY_SPIRIT)) return false; // Purify supersedes - if (!ctx.bot.is_ready(CLEANSE_SPIRIT)) return false; - return CurseDispelTarget(ctx) != nullptr || ctx.bot.self_dispellable(DispelType::Curse); -} -void DoCleanseSpirit(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* t = CurseDispelTarget(ctx)) { e.cast(CLEANSE_SPIRIT, t->guid); return; } - if (ctx.bot.self_dispellable(DispelType::Curse)) - e.cast(CLEANSE_SPIRIT, ctx.bot.raw().guid); -} - -// Water Shield - 52127. Self-buff that restores mana on hit, refreshes -// every 60min. Resto's standard mana-regen blanket; should always be up -// out-of-combat-or-in. Cheap to maintain (instant, off-GCD when not -// already up). -bool ShouldWaterShield(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(WATER_SHIELD)) return false; - return !ctx.bot.has_aura(WATER_SHIELD); -} -void DoWaterShield(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(WATER_SHIELD, ctx.bot.raw().guid); -} - -// Skyfury (462854) - group Mastery + extra-attack buff, 1h duration. Keep -// it up like a Battle Shout; the party/raid inherits it from the self cast. -bool ShouldSkyfury(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(SKYFURY)) return false; - return !ctx.bot.has_aura(SKYFURY); -} -void DoSkyfury(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(SKYFURY, ctx.bot.raw().guid); -} - -// Imbues - Earthliving Weapon (382021 -> aura 382022, [R][M]) on the -// weapon, Tidecaller's Guard (457481 -> aura 457496, Totemic hero) on the -// shield. Both are 1h self-buffs. -bool ShouldEarthlivingWeapon(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(EARTHLIVING_WEAPON)) return false; - return !ctx.bot.has_aura(EARTHLIVING_AURA); -} -void DoEarthlivingWeapon(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(EARTHLIVING_WEAPON); } - -bool ShouldTidecallersGuard(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(TIDECALLERS_GUARD)) return false; - return !ctx.bot.has_aura(TIDECALLERS_GUARD_AURA); -} -void DoTidecallersGuard(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(TIDECALLERS_GUARD); } - -bool ShouldWindShear(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(WIND_SHEAR)) return false; - if (!ctx.bot.is_ready(WIND_SHEAR)) return false; - const bool pvp = ctx.pvp.in_battleground || ctx.pvp.in_arena; - return ctx.bot.kick_target(pvp, 30.0f) != nullptr; -} -void DoWindShear(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - const bool pvp = ctx.pvp.in_battleground || ctx.pvp.in_arena; - if (auto const* c = ctx.bot.kick_target(pvp, 30.0f)) - e.cast(WIND_SHEAR, c->guid); -} - -bool ShouldCapacitorTotem(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(CAPACITOR_TOTEM)) return false; - if (!ctx.bot.is_ready(CAPACITOR_TOTEM)) return false; - return ctx.bot.enemies_within(8.0f) >= 3; -} -void DoCapacitorTotem(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(CAPACITOR_TOTEM); } - -// Off-target Hex via the shared PickOffTargetCC gate (PvE: only on a 2+ -// ATTACKER pull, skipping already-CC'd mobs; PvP: enemy Healer > caster). -// See ApCrowdControl.h - replaced the old nearby_enemies.size()>=2 + has_aura -// gate that fired every GCD on a 40y scan bystander during questing. -bool ShouldHex(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(HEX)) return false; - if (!ctx.bot.is_ready(HEX)) return false; - if (!ctx.bot.in_combat()) return false; - return !PickOffTargetCC(ctx, HEX, ApInPvp(ctx)).IsEmpty(); -} -void DoHex(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - ObjectGuid const t = PickOffTargetCC(ctx, HEX, ApInPvp(ctx)); - if (!t.IsEmpty()) e.cast(HEX, t); -} - -// Purge (370, [M] class talent) - strip a Magic buff off the current -// enemy when the group is not in need of healing. -bool ShouldPurge(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(PURGE)) return false; - if (ctx.bot.victim().IsEmpty()) return false; - if (!GroupTopped(ctx)) return false; - return ctx.bot.target_dispellable(Playerbot::DispelType::Magic); -} -void DoPurge(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(PURGE, ctx.bot.victim()); -} - -// ---- Shield maintenance ---- -bool ShouldEarthShield(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(EARTH_SHIELD)) return false; - GroupMemberSummary const* tank = ctx.group.tank(); - if (!tank || !tank->online) return false; - AuraEntry const* a = ctx.bot.find_aura(EARTH_SHIELD, tank->guid); - return !a || a->remaining.count() <= 30000; -} -void DoEarthShield(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* tank = ctx.group.tank()) - e.cast(EARTH_SHIELD, tank->guid); -} - -// ---- Major CDs ---- -bool ShouldAscendance(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(ASCENDANCE_RESTO)) return false; - if (!ctx.bot.is_ready(ASCENDANCE_RESTO)) return false; - return WoundedFriendCount(ctx, 60) >= 3; -} -void DoAscendance(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(ASCENDANCE_RESTO); } - -bool ShouldHealingTideTotem(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(HEALING_TIDE_TOTEM)) return false; - if (!ctx.bot.is_ready(HEALING_TIDE_TOTEM)) return false; - return WoundedFriendCount(ctx, 60) >= 3; -} -void DoHealingTideTotem(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(HEALING_TIDE_TOTEM); } - -bool ShouldSpiritLinkTotem(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(SPIRIT_LINK_TOTEM)) return false; - if (!ctx.bot.is_ready(SPIRIT_LINK_TOTEM)) return false; - return WoundedFriendCount(ctx, 30) >= 2; -} -void DoSpiritLinkTotem(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(SPIRIT_LINK_TOTEM); } - -bool KnowsHealingStreamTotem(ApPredicateContext const& ctx) -{ - return ctx.bot.knows_spell(HEALING_STREAM_TOTEM) - || ctx.bot.knows_spell(HEALING_STREAM_TALENT) - || ctx.bot.knows_spell(HEALING_STREAM_TALENT2); -} -bool ShouldHealingStreamTotem(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!KnowsHealingStreamTotem(ctx)) return false; - if (!ctx.bot.is_ready(HEALING_STREAM_TOTEM)) return false; - return !ctx.bot.has_aura(HEALING_STREAM_TOTEM); -} -void DoHealingStreamTotem(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(HEALING_STREAM_TOTEM); } - -// ---- AoE / spike heal ---- -// Healing Rain (73920) is replaced by Surging Totem (444995) in the Totemic -// hero builds (both curated Restoration builds). Two-branch so bots with -// and without the hero tree both drop their ground heal. -uint32 PickGroundHeal(ApPredicateContext const& ctx) -{ - if (ctx.bot.knows_spell(SURGING_TOTEM)) return SURGING_TOTEM; - if (ctx.bot.knows_spell(HEALING_RAIN)) return HEALING_RAIN; - return 0; -} -bool ShouldHealingRain(ApPredicateContext const& ctx) -{ - const uint32 sid = PickGroundHeal(ctx); - if (!sid || !ctx.bot.is_ready(sid)) return false; - return WoundedFriendCount(ctx, 85) >= 3; -} -void DoHealingRain(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - const uint32 sid = PickGroundHeal(ctx); - if (!sid) return; - float bx, by, bz; - ctx.bot.position(bx, by, bz); - e.cast_at(sid, bx, by, bz); -} - -bool ShouldChainHeal(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(CHAIN_HEAL)) return false; - return WoundedFriendCount(ctx, 75) >= 2; -} -void DoChainHeal(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(CHAIN_HEAL, LowestFriendOrSelf(ctx).guid); -} - -// Nature's Swiftness (378081, [R][M]) - next Nature heal instant and free. -// Pop it right before the emergency direct heal so the 2s Healing Wave -// lands immediately on a target at or below 35%. -bool ShouldNaturesSwiftness(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(NATURES_SWIFTNESS)) return false; - if (!ctx.bot.is_ready(NATURES_SWIFTNESS)) return false; - if (ctx.bot.has_aura(NATURES_SWIFTNESS)) return false; - if (!ctx.bot.knows_spell(HEALING_WAVE) && !ctx.bot.knows_spell(HEALING_SURGE)) return false; - return LowestFriendOrSelf(ctx).hp_pct <= 35; -} -void DoNaturesSwiftness(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(NATURES_SWIFTNESS); } - -// Emergency direct heal. Healing Wave (77472) overrides Healing Surge -// (8004) for Restoration in 12.1, so the spec normally has only the wave; -// Healing Surge remains the pre-L10 / fallback id. -uint32 PickDirectHeal(ApPredicateContext const& ctx) -{ - if (ctx.bot.knows_spell(HEALING_WAVE)) return HEALING_WAVE; - if (ctx.bot.knows_spell(HEALING_SURGE)) return HEALING_SURGE; - return 0; -} -bool ShouldHealingSurge(ApPredicateContext const& ctx) -{ - if (!PickDirectHeal(ctx)) return false; - return LowestFriendOrSelf(ctx).hp_pct <= 50; -} -void DoHealingSurge(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (const uint32 sid = PickDirectHeal(ctx)) e.cast(sid, LowestFriendOrSelf(ctx).guid); -} - -// Unleash Life (73685, [R][M]) - instant heal that also amplifies the next -// Riptide / Chain Heal / Healing Wave. Fire it on cooldown ahead of the -// Riptide rung whenever someone actually needs the follow-up. -bool ShouldUnleashLife(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(UNLEASH_LIFE)) return false; - if (!ctx.bot.is_ready(UNLEASH_LIFE)) return false; - if (ctx.bot.has_aura(UNLEASH_LIFE)) return false; - return LowestFriendOrSelf(ctx).hp_pct <= 80; -} -void DoUnleashLife(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(UNLEASH_LIFE, LowestFriendOrSelf(ctx).guid); -} - -bool ShouldRiptide(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(RIPTIDE)) return false; - if (!ctx.bot.is_ready(RIPTIDE)) return false; - HealTarget t = LowestFriendOrSelf(ctx); - if (t.hp_pct >= 95) return false; - AuraEntry const* a = ctx.bot.find_aura(RIPTIDE, t.guid); - return !a || a->remaining.count() <= 3000; -} -void DoRiptide(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(RIPTIDE, LowestFriendOrSelf(ctx).guid); -} - -bool ShouldHealingWave(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(HEALING_WAVE)) return false; - if (LowestFriendOrSelf(ctx).hp_pct > 90) return false; - if (ctx.bot.is_moving() && !ctx.bot.can_cast_while_moving(HEALING_WAVE)) return false; - return true; -} -void DoHealingWave(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(HEALING_WAVE, LowestFriendOrSelf(ctx).guid); -} - -// ---- Offensive filler when group is topped (Mastery proc + Ancestral Awakening) ---- -bool ShouldFlameShockFiller(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!GroupTopped(ctx)) return false; - if (!ctx.bot.knows_spell(FLAME_SHOCK)) return false; - if (ctx.bot.victim().IsEmpty()) return false; - // The 12.1 castable is 470411; the DoT may still be tracked under the - // legacy 188389 row, so accept either before re-applying. - AuraEntry const* a = ctx.bot.find_aura(FLAME_SHOCK, ctx.bot.victim()); - if (!a) a = ctx.bot.find_aura(FLAME_SHOCK_DOT_LEGACY, ctx.bot.victim()); - return !a || a->remaining.count() <= 4000; -} -void DoFlameShock(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(FLAME_SHOCK, ctx.bot.victim()); -} - -bool ShouldLavaBurstFiller(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!GroupTopped(ctx)) return false; - if (!ctx.bot.knows_spell(LAVA_BURST)) return false; - if (!ctx.bot.is_ready(LAVA_BURST)) return false; - if (ctx.bot.victim().IsEmpty()) return false; - // Restoration has no Lava Surge proc in 12.1: Lava Burst is a 2s hard - // cast, so only start it while stationary. - return !ctx.bot.is_moving() || ctx.bot.can_cast_while_moving(LAVA_BURST); -} -void DoLavaBurst(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(LAVA_BURST, ctx.bot.victim()); -} - -// Chain Lightning (188443, [R][M] class talent) - AoE DPS filler once the -// group is topped and 3+ enemies are stacked. -bool ShouldChainLightningFiller(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!GroupTopped(ctx)) return false; - if (!ctx.bot.knows_spell(CHAIN_LIGHTNING)) return false; - if (ctx.bot.victim().IsEmpty()) return false; - if (ctx.bot.is_moving() && !ctx.bot.can_cast_while_moving(CHAIN_LIGHTNING)) return false; - return ctx.aoe_preference || ctx.bot.enemies_within(20.0f) >= 3; -} -void DoChainLightning(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(CHAIN_LIGHTNING, ctx.bot.victim()); -} - -bool ShouldLightningBoltFiller(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!GroupTopped(ctx)) return false; - if (!ctx.bot.knows_spell(LIGHTNING_BOLT)) return false; - return !ctx.bot.victim().IsEmpty(); -} -void DoLightningBolt(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(LIGHTNING_BOLT, ctx.bot.victim()); -} - -bool AlwaysAlive(ApPredicateContext const& ctx) { return ctx.bot.is_alive(); } -void DoNothing(ApPredicateContext const&, BotIntentEmitter&) {} - -// Cast-swap shim - Resto Shaman slow heals. Healing Wave 2.5s, -// Healing Surge 1.5s, Chain Heal 2.5s. See ApHealHelpers.h. -bool ShouldCancelHealForSwap(ApPredicateContext const& ctx) -{ - return ShouldCancelHealForSwapImpl(ctx, - { HEALING_WAVE, HEALING_SURGE, CHAIN_HEAL }); -} - -// Rule ORDER (12.1 Restoration): cancel-for-swap -> OOC rez (Ancestral -// Vision for 2+ dead, else Ancestral Spirit) -> Bloodlust -> tank Earth -// Shield -> self buffs (Skyfury, Water Shield, Earthliving / Tidecaller's -// imbues) -> Astral Shift -> Spiritwalker's Grace -> interrupt / CC -> -// Earth Elemental / Tremor / Poison Cleansing -> raid CDs (Ascendance, -// Spirit Link, Healing Tide) -> dispel (Purify / Cleanse) -> Nature's -// Swiftness + emergency direct heal (<=50%) -> Unleash Life -> Riptide -> -// Healing Stream -> Healing Wave (filler) -> Healing Rain / Surging Totem -// (group spike) -> Chain Heal (multi-spike) -> DPS filler when topped -// (Flame Shock, Lava Burst, Chain Lightning, Lightning Bolt) -> Idle. -ApRule const kRules[] = { - { ShouldCancelHealForSwap, DoCancelHealForSwap, "Cancel heal - swap to lower target" }, - { ShouldAncestralVision, DoAncestralVision, "Ancestral Vision (2+ dead OOC)" }, - { ShouldAncestralSpirit, DoAncestralSpirit, "Ancestral Spirit (rez OOC)" }, - { ShouldBloodlust, DoBloodlust, "Bloodlust/Heroism (boss)" }, - { ShouldEarthShield, DoEarthShield, "Earth Shield (tank buff)" }, - { ShouldSkyfury, DoSkyfury, "Skyfury (group buff)" }, - { ShouldWaterShield, DoWaterShield, "Water Shield (self-buff)" }, - { ShouldEarthlivingWeapon, DoEarthlivingWeapon, "Earthliving Weapon (imbue)" }, - { ShouldTidecallersGuard, DoTidecallersGuard, "Tidecaller's Guard (imbue)" }, - { ShouldAstralShift, DoAstralShift, "Astral Shift (<=50%)" }, - { ShouldSpiritwalkerGrace, DoSpiritwalkerGrace, "Spiritwalker's Grace" }, - { ShouldWindShear, DoWindShear, "Wind Shear (interrupt)" }, - { ShouldCapacitorTotem, DoCapacitorTotem, "Capacitor Totem (3+ AoE)" }, - { ShouldHex, DoHex, "Hex (off-target CC)" }, - { ShouldPurge, DoPurge, "Purge (Magic, group topped)" }, - { ShouldEarthElemental, DoEarthElemental, "Earth Elemental (panic)" }, - { ShouldTremorTotem, DoTremorTotem, "Tremor Totem (anti-fear)" }, - { ShouldPoisonCleansingTotem,DoPoisonCleansingTotem,"Poison Cleansing Totem" }, - { ShouldAscendance, DoAscendance, "Ascendance (3+ wounded)" }, - { ShouldSpiritLinkTotem, DoSpiritLinkTotem, "Spirit Link Totem (emergency)" }, - { ShouldHealingTideTotem, DoHealingTideTotem, "Healing Tide Totem (panic)" }, - { ShouldPurifySpirit, DoPurifySpirit, "Purify Spirit (dispel)" }, - { ShouldCleanseSpirit, DoCleanseSpirit, "Cleanse Spirit (curse, fallback)" }, - { ShouldNaturesSwiftness, DoNaturesSwiftness, "Nature's Swiftness (<=35%)" }, - { ShouldHealingSurge, DoHealingSurge, "Healing Wave/Surge (<=50%)" }, - { ShouldUnleashLife, DoUnleashLife, "Unleash Life (<=80%)" }, - { ShouldRiptide, DoRiptide, "Riptide (HoT spam priority)" }, - { ShouldHealingStreamTotem, DoHealingStreamTotem, "Healing Stream Totem" }, - { ShouldHealingWave, DoHealingWave, "Healing Wave (filler)" }, - { ShouldHealingRain, DoHealingRain, "Healing Rain/Surging (3+ 85%)"}, - { ShouldChainHeal, DoChainHeal, "Chain Heal (2+ at 75%)" }, - { ShouldFlameShockFiller, DoFlameShock, "Flame Shock (DPS filler)" }, - { ShouldLavaBurstFiller, DoLavaBurst, "Lava Burst (DPS filler)" }, - { ShouldChainLightningFiller,DoChainLightning, "Chain Lightning (3+ filler)" }, - { ShouldLightningBoltFiller,DoLightningBolt, "Lightning Bolt (DPS filler)" }, - { AlwaysAlive, DoNothing, "Idle" }, -}; - -} // anonymous - -void RegisterApl_Shaman_Restoration() -{ - constexpr uint32 SPEC_SHAMAN_RESTORATION = 264; - RegisterRotation(CLASS_SHAMAN, SPEC_SHAMAN_RESTORATION, ApRotation{kRules}); -} - -} // namespace Playerbot::Combat diff --git a/src/modules/PlayerbotV2/Combat/Apl/Apl_Warlock_Affliction.cpp b/src/modules/PlayerbotV2/Combat/Apl/Apl_Warlock_Affliction.cpp deleted file mode 100644 index f824091a52..0000000000 --- a/src/modules/PlayerbotV2/Combat/Apl/Apl_Warlock_Affliction.cpp +++ /dev/null @@ -1,472 +0,0 @@ -// Affliction Warlock - WoW 12.1.0.69587 rotation. Caster DPS, mana + -// soul shards. Multi-DoT spread + Unstable Affliction shard-spend cycle. -// -// Multi-DoT model: the bot maintains Agony / Corruption (Wither when the -// Hellcaller passive is known) on the primary target, then expands both to -// every visible add via the snapshot's `enemy_without_my_aura` helper. -// Unstable Affliction is the 12.1 shard SPENDER (1 shard, 8s, stacking -// overlaps) and stays on the primary target. The expansion rules sit -// between the primary refresh rules and the spend/filler rules so a fresh -// add is dotted before any Soul Shard is spent. -// -// Talent overrides (SpellEffect aura 332, OVERRIDE_ACTIONBAR_SPELLS): TC -// redirects a cast of the BASE id to the override while the passive is -// known, so the rules always emit the base id and gate/label on the talent: -// 388667 Drain Soul (passive [R][M]) 686 Shadow Bolt -> 198590 Drain Soul -// 445465 Wither (Hellcaller passive) 172 Corruption -> 445468 Wither -// -// ---- Validated IDs (SpellName.csv, WoW 12.1.0.69587) -------------------- -// 686 Shadow Bolt L1 filler (redirected to Drain Soul) -// 172 Corruption L2 baseline DoT (cast id) -// 146739 Corruption periodic aura applied by 172 -// 445465 Wither Hellcaller passive (gate only) -// 445474 Wither periodic aura applied by 445468 -// 980 Agony spec talent [R][M], shard generator -// 1259790 Unstable Affliction spec talent [R][M], 1-shard spender -// 48181 Haunt spec talent [R][M], 15s CD debuff -// 1257052 Dark Harvest spec talent [R][M], 60s CD burst+heal -// 27243 Seed of Corruption spec talent [R][M], AoE shard spend -// 205180 Summon Darkglare spec talent [R][M], 2min CD -// 388667 Drain Soul spec passive [R][M] (gate only) -// 234153 Drain Life L9 emergency self-heal channel -// 6789 Mortal Coil class talent [R][M], horror + heal -// 5484 Howl of Terror class talent, AoE fear, 40s CD -// 108416 Dark Pact class talent [R][M], absorb shield -// 231811 Soulstone modern combat-rez (preferred) -// 20707 Soulstone L14 baseline fallback id -// 104773 Unending Resolve L4 baseline, 40% DR, 3min CD -// -// ---- Pet abilities (cast through pet_cast) ------------------------------ -// 19647 Spell Lock Felhunter interrupt/silence -// 89766 Axe Toss Felguard stun (not Aff default but -// supported when player swapped pet) -// 17012 Devour Magic Felhunter dispel (cleanses bot's -// harmful Magic auras) -// -// ---- Skipped spells (and why) ------------------------------------------- -// - Malefic Rapture (324536), Phantom Singularity (205179), Vile Taint -// (278350), Soul Rot (236235), Dark Soul: Misery (113860): removed from -// the Affliction 12.1 tree (ids still exist but are not learnable). -// - Drain Soul 198590 / Wither 445468: never emitted directly - TC -// redirects the base cast (see override note above). -// - Demonic Circle (268358 -> 48018/48020), Demonic Gateway (111771), -// Soulburn (385899), Burning Rush (111400): positioning / utility the -// fixed-tick rotation cannot use sensibly. -// - Banish (710), Fear (5782), Curse of Tongues (1714) / Exhaustion -// (334275), Blight of Tongues (1271802): situational CC / debuffs. -// - Grimoire of Sacrifice (108503): not in the curated builds; pet kept. -// - Summon Imp / Felhunter (688 / 691): pet maintenance lives in -// State_Idle (ooc pet-summon rule), not in the combat APL. - -#include "../ApRegistry.h" -#include "../ApRotation.h" -#include "Bot/BotIntentEmitter.h" -#include "Bot/BotSnapshotView.h" -#include "Group/GroupSnapshot.h" -#include "SharedDefines.h" - -namespace Playerbot::Combat { - -namespace { - -// ---- Spell IDs (WoW 12.1.0.69587, validated against SpellName.csv) ---- -constexpr uint32 SHADOW_BOLT = 686; // base filler; 388667 redirects to Drain Soul -constexpr uint32 CORRUPTION = 172; // base cast; 445465 redirects to Wither -constexpr uint32 CORRUPTION_DOT = 146739; // periodic aura applied by 172 -constexpr uint32 WITHER_TALENT = 445465; // Hellcaller passive (gate only) -constexpr uint32 WITHER_DOT = 445474; // periodic aura applied by 445468 -constexpr uint32 AGONY = 980; -constexpr uint32 UNSTABLE_AFFLICTION = 1259790; // 1-shard spender, stacking -constexpr uint32 HAUNT = 48181; -constexpr uint32 DARK_HARVEST = 1257052; // 60s CD burst + self-heal -constexpr uint32 DRAIN_SOUL_TALENT = 388667; // passive: Shadow Bolt cast becomes Drain Soul -constexpr uint32 SEED_OF_CORRUPTION = 27243; -constexpr uint32 SUMMON_DARKGLARE = 205180; -constexpr uint32 DRAIN_LIFE = 234153; -constexpr uint32 MORTAL_COIL = 6789; -constexpr uint32 HOWL_OF_TERROR = 5484; -constexpr uint32 DARK_PACT = 108416; -constexpr uint32 SOULSTONE_MODERN = 231811; // modern combat-rez -constexpr uint32 SOULSTONE_LEGACY = 20707; // legacy fallback -constexpr uint32 UNENDING_RESOLVE = 104773; - -// ---- Pet abilities (cast through PetCastSpellIntent) ---- -constexpr uint32 PET_SPELL_LOCK = 19647; // Felhunter -constexpr uint32 PET_AXE_TOSS = 89766; // Felguard -constexpr uint32 PET_DEVOUR_MAGIC = 17012; // Felhunter dispel - -// ---- Helpers ---- -bool HasLiveTarget(ApPredicateContext const& ctx) -{ - return !ctx.bot.victim().IsEmpty(); -} - -// Refresh threshold for DoTs: 30% of base duration is the standard pandemic -// window in modern WoW. Using 4s here covers the maintained Aff DoTs (Agony -// 18s, Corruption / Wither ~14s) without burning mana on early refreshes. -bool MissingDot(ApPredicateContext const& ctx, uint32 dot) -{ - AuraEntry const* a = ctx.bot.find_aura(dot, ctx.bot.victim()); - return !a || a->remaining.count() <= 4000; -} - -// The Corruption cast (172) is redirected to Wither (445468) by TC while the -// Hellcaller passive is known, and the periodic aura on the target differs -// (146739 vs 445474). Resolve the aura id the bot's build actually applies. -uint32 CorruptionDotId(ApPredicateContext const& ctx) -{ - return ctx.bot.knows_spell(WITHER_TALENT) ? WITHER_DOT : CORRUPTION_DOT; -} - -bool MissingCorruption(ApPredicateContext const& ctx) -{ - return MissingDot(ctx, CorruptionDotId(ctx)); -} - -// Resolve which Soulstone variant the bot actually knows. Modern (231811) -// is preferred; older learnsets still resolve only 20707. -uint32 KnownSoulstone(ApPredicateContext const& ctx) -{ - if (ctx.bot.knows_spell(SOULSTONE_MODERN)) return SOULSTONE_MODERN; - if (ctx.bot.knows_spell(SOULSTONE_LEGACY)) return SOULSTONE_LEGACY; - return 0; -} - -// Boss-tier target for major-CD timing. Avoids blowing Darkglare on trash. -bool BossLikeTargetEngaged(ApPredicateContext const& ctx) -{ - constexpr int32 kBossHpThreshold = 5'000'000; - NearbyUnit const* t = ctx.bot.victim_info(); - if (t && t->max_hp >= kBossHpThreshold) return true; - for (auto const& a : ctx.bot.raw().combat.attackers) - if (a.max_hp >= kBossHpThreshold) return true; - return false; -} - -// Pet interrupt - Felhunter's Spell Lock (24s CD, no school lockout in 12.0). -// We only fire when the bot has a pet summoned and the caster is targeting -// our victim or a nearby threat. Pet abilities cast via PetCastSpellIntent, -// NOT bot-side cast(); the API resolves the pet and issues the cast through -// pet->CastSpell. Emitting both Spell Lock + Axe Toss means whichever pet is -// out lands the matching one - the executor returns Locked on the mismatch. -bool ShouldPetSpellLock(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.has_pet()) return false; - const bool pvp = ctx.pvp.in_battleground || ctx.pvp.in_arena; - if (pvp) return ctx.bot.kick_target(true, 40.0f) != nullptr; - auto const* c = ctx.bot.interruptible_caster(); - return c && c->guid == ctx.bot.victim(); -} -void DoPetSpellLock(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - const bool pvp = ctx.pvp.in_battleground || ctx.pvp.in_arena; - if (auto const* c = ctx.bot.kick_target(pvp, 40.0f)) - { - e.pet_cast(PET_SPELL_LOCK, c->guid); - e.pet_cast(PET_AXE_TOSS, c->guid); - } -} - -// Felhunter Devour Magic - pet dispel. The bot's pet eats one Magic aura -// off the bot, healing the pet for ~10% of its max HP. Fire when the bot -// carries a harmful Magic aura. Cheap to attempt: the call no-ops if the -// summoned pet isn't a Felhunter. -bool ShouldPetDevourMagic(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.has_pet()) return false; - return ctx.bot.self_dispellable(DispelType::Magic); -} -void DoPetDevourMagic(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.pet_cast(PET_DEVOUR_MAGIC, ctx.bot.guid()); -} - -// ---- Predicates ---- -bool ShouldUnendingResolve(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(UNENDING_RESOLVE)) return false; - if (!ctx.bot.is_ready(UNENDING_RESOLVE)) return false; - return ctx.bot.hp_pct() <= 30; -} -void DoUnendingResolve(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(UNENDING_RESOLVE); } - -bool ShouldDarkPact(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(DARK_PACT)) return false; - if (!ctx.bot.is_ready(DARK_PACT)) return false; - // Burns 20% of current HP for an absorb shield. Only fire when we have - // headroom AND we're being beaten on. Not on full HP (waste) and not - // sub-30% (the 20% sacrifice would take us into Mortal Coil territory). - if (ctx.bot.hp_pct() < 30 || ctx.bot.hp_pct() > 75) return false; - return ctx.bot.attackers_count() >= 1; -} -void DoDarkPact(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(DARK_PACT); } - -bool ShouldDrainLifeEmergency(ApPredicateContext const& ctx) -{ - // Emergency self-heal channel - only when we're critically low AND no - // instant defensive is up. The 5s channel pins the bot in place so we - // gate harder than the baseline rule (<=50%). - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(DRAIN_LIFE)) return false; - // is_ready folds in cast-in-progress: re-emitting mid-channel would - // cancel and restart the 5s drain every tick. - if (!ctx.bot.is_ready(DRAIN_LIFE)) return false; - if (ctx.bot.hp_pct() > 50) return false; - if (ctx.bot.knows_spell(UNENDING_RESOLVE) && ctx.bot.is_ready(UNENDING_RESOLVE)) return false; - if (ctx.bot.knows_spell(MORTAL_COIL) && ctx.bot.is_ready(MORTAL_COIL)) return false; - if (ctx.bot.knows_spell(DARK_PACT) && ctx.bot.is_ready(DARK_PACT)) return false; - return true; -} -void DoDrainLifeEmergency(ApPredicateContext const& ctx, BotIntentEmitter& e) { e.cast(DRAIN_LIFE, ctx.bot.victim()); } - -bool ShouldMortalCoil(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(MORTAL_COIL)) return false; - if (!ctx.bot.is_ready(MORTAL_COIL)) return false; - if (ctx.bot.victim().IsEmpty()) return false; - // Use as emergency self-heal when low. Fear is incidental. - return ctx.bot.hp_pct() <= 40; -} -void DoMortalCoil(ApPredicateContext const& ctx, BotIntentEmitter& e) { e.cast(MORTAL_COIL, ctx.bot.victim()); } - -// Howl of Terror - 10y AoE fear, 40s CD. Multi-target panic CC: when we're -// surrounded AND taking damage, fear the pack so we can reposition. Gated -// on HP < 70% to avoid wasting the CD opening on a single pack of trash. -bool ShouldHowlOfTerror(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(HOWL_OF_TERROR)) return false; - if (!ctx.bot.is_ready(HOWL_OF_TERROR)) return false; - return ctx.bot.enemies_within(10.0f) >= 2 && ctx.bot.hp_pct() <= 70; -} -void DoHowlOfTerror(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(HOWL_OF_TERROR); } - -bool ShouldSoulstone(ApPredicateContext const& ctx) -{ - if (KnownSoulstone(ctx) == 0) return false; - uint32 sid = KnownSoulstone(ctx); - if (!ctx.bot.is_ready(sid)) return false; - return ctx.group.dead_member(ctx.bot.map_id()) != nullptr; -} -void DoSoulstone(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - uint32 sid = KnownSoulstone(ctx); - if (sid == 0) return; - if (auto const* m = ctx.group.dead_member(ctx.bot.map_id())) - e.cast(sid, m->guid); -} - -bool ShouldSummonDarkglare(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(SUMMON_DARKGLARE)) return false; - if (!ctx.bot.is_ready(SUMMON_DARKGLARE)) return false; - // 2min CD - only blow on a boss with all DoTs ramped (Darkglare buffs - // Agony / Corruption / UA damage while active; firing without DoTs up - // wastes the cooldown). - if (!BossLikeTargetEngaged(ctx)) return false; - if (MissingDot(ctx, AGONY) || MissingCorruption(ctx)) return false; - return ctx.bot.has_aura(UNSTABLE_AFFLICTION, ctx.bot.victim()); -} -void DoSummonDarkglare(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(SUMMON_DARKGLARE, ctx.bot.victim()); -} - -// Dark Harvest - 60s CD, self-centred (range 0): consumes the life force of -// every target carrying our periodic effects for 3s of Shadowflame damage -// and heals for a share of it. Fire once Agony + Corruption are ramped on -// the victim so the burst has DoTs to feed on; spreads reward more targets -// but a single ramped target is already worth the 60s. -bool ShouldDarkHarvest(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(DARK_HARVEST)) return false; - if (!ctx.bot.is_ready(DARK_HARVEST)) return false; - return !MissingDot(ctx, AGONY) && !MissingCorruption(ctx); -} -void DoDarkHarvest(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(DARK_HARVEST); } - -// Haunt - 15s CD, 1.5s cast: +damage-taken debuff on the target and, with -// the curated Shadow of Nathreza / Improved Haunt passives, periodic + -// splash damage of its own. Cheap enough to run on cooldown; only wait for -// Agony + Corruption so the amplified window lands on ticking DoTs. -bool ShouldHaunt(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(HAUNT)) return false; - if (!ctx.bot.is_ready(HAUNT)) return false; - if (ctx.bot.is_moving() && !ctx.bot.can_cast_while_moving(HAUNT)) return false; - return !MissingDot(ctx, AGONY) && !MissingCorruption(ctx); -} -void DoHaunt(ApPredicateContext const& ctx, BotIntentEmitter& e) { e.cast(HAUNT, ctx.bot.victim()); } - -// Unstable Affliction - the 12.1 shard SPENDER: 1 shard, 1.5s cast, 8s DoT; -// multiple casts overlap and every stack raises its damage. Dump shards on -// the primary target once Agony + Corruption are ramped (Seed of Corruption -// sits above this rule and claims the shard first when 3+ are clustered). -bool ShouldUnstableAffliction(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(UNSTABLE_AFFLICTION)) return false; - if (!ctx.bot.is_ready(UNSTABLE_AFFLICTION)) return false; - if (ctx.bot.power(POWER_SOUL_SHARDS) < 1) return false; - if (ctx.bot.is_moving() && !ctx.bot.can_cast_while_moving(UNSTABLE_AFFLICTION)) return false; - return !MissingDot(ctx, AGONY) && !MissingCorruption(ctx); -} -void DoUnstableAffliction(ApPredicateContext const& ctx, BotIntentEmitter& e) { e.cast(UNSTABLE_AFFLICTION, ctx.bot.victim()); } - -bool ShouldAgonyPrimary(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(AGONY)) return false; - return MissingDot(ctx, AGONY); -} -void DoAgonyPrimary(ApPredicateContext const& ctx, BotIntentEmitter& e) { e.cast(AGONY, ctx.bot.victim()); } - -// Corruption / Wither primary: emit the base Corruption id - TC redirects it -// to Wither while the Hellcaller passive is known - and refresh off the -// aura the build actually applies. -bool ShouldCorruptionPrimary(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(CORRUPTION)) return false; - return MissingCorruption(ctx); -} -void DoCorruptionPrimary(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(CORRUPTION, ctx.bot.victim()); -} - -// Multi-dot expansion: spread Agony + Corruption to off-target adds. Skips -// the primary victim (handled by the primary refresh rules above) and any -// add already carrying our own DoT. Returns nullptr when nothing to do - -// which means the spec falls through to spend/filler rules. Range capped at -// 40yd to match the cast range of both DoTs. -NearbyUnit const* OffDotExpansionTarget(ApPredicateContext const& ctx, uint32 dot) -{ - return ctx.bot.enemy_without_my_aura(dot, 40.0f); -} - -bool ShouldAgonyExpand(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(AGONY)) return false; - return OffDotExpansionTarget(ctx, AGONY) != nullptr; -} -void DoAgonyExpand(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* t = OffDotExpansionTarget(ctx, AGONY)) - e.cast(AGONY, t->guid); -} - -bool ShouldCorruptionExpand(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(CORRUPTION)) return false; - return OffDotExpansionTarget(ctx, CorruptionDotId(ctx)) != nullptr; -} -void DoCorruptionExpand(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* t = OffDotExpansionTarget(ctx, CorruptionDotId(ctx))) - e.cast(CORRUPTION, t->guid); -} - -// Filler. With the Drain Soul passive (388667) known, TC redirects the -// Shadow Bolt emit to Drain Soul (198590, a channel) - same emit, separate -// rule so /whyidle labels it truthfully. Both are hard-casts: hold while -// moving, and is_ready keeps a running channel from being restarted. -bool ShouldDrainSoul(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(DRAIN_SOUL_TALENT)) return false; - if (!ctx.bot.knows_spell(SHADOW_BOLT)) return false; - if (!ctx.bot.is_ready(SHADOW_BOLT)) return false; - if (ctx.bot.is_moving() && !ctx.bot.can_cast_while_moving(SHADOW_BOLT)) return false; - return true; -} -void DoDrainSoul(ApPredicateContext const& ctx, BotIntentEmitter& e) { e.cast(SHADOW_BOLT, ctx.bot.victim()); } - -bool ShouldShadowBolt(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (ctx.bot.knows_spell(DRAIN_SOUL_TALENT)) return false; // Drain Soul rule owns the filler slot - if (!ctx.bot.knows_spell(SHADOW_BOLT)) return false; - if (!ctx.bot.is_ready(SHADOW_BOLT)) return false; - if (ctx.bot.is_moving() && !ctx.bot.can_cast_while_moving(SHADOW_BOLT)) return false; - return true; -} -void DoShadowBolt(ApPredicateContext const& ctx, BotIntentEmitter& e) { e.cast(SHADOW_BOLT, ctx.bot.victim()); } - -bool ShouldSeedOfCorruption(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(SEED_OF_CORRUPTION)) return false; - if (!ctx.bot.is_ready(SEED_OF_CORRUPTION)) return false; - if (ctx.bot.power(POWER_SOUL_SHARDS) < 1) return false; - if (ctx.bot.is_moving() && !ctx.bot.can_cast_while_moving(SEED_OF_CORRUPTION)) return false; - // Seed costs a shard (2s cast) and explodes into Corruption / Wither on - // everything nearby; worth it only when 3+ enemies cluster. - return ctx.aoe_preference || ctx.bot.enemies_within(20.0f) >= 3; -} -void DoSeedOfCorruption(ApPredicateContext const& ctx, BotIntentEmitter& e) { e.cast(SEED_OF_CORRUPTION, ctx.bot.victim()); } - -bool AlwaysAlive(ApPredicateContext const& ctx) { return ctx.bot.is_alive(); } -void DoNothing(ApPredicateContext const&, BotIntentEmitter&) {} - -// ---- Rule table ---- -// Order (per task spec): -// 1. Unending Resolve - panic <=30% -// 2. Drain Life - emergency self-heal <=50% when nothing else up -// 3. Mortal Coil - heal + horror CC -// 4. Howl of Terror - multi-target panic fear -// 5. Felhunter Devour Magic - pet dispel on self (Magic auras) -// 6. Felhunter Spell Lock - pet interrupt -// 7. Dark Pact - absorb shield (30-75% HP) -// 8. Group utility - Soulstone rez -// 9. Major offensive CDs - Summon Darkglare (boss, all DoTs), Dark -// Harvest (DoTs ramped) -// 10. Single-target debuff CD - Haunt (DoTs ramped) -// 11. Primary DoT maintenance - Agony, Corruption / Wither -// 12. Off-target DoT expansion - Agony + Corruption / Wither to adds -// 13. AoE shard spend - Seed of Corruption (3+ clustered) -// 14. Single-target shard spend - Unstable Affliction (1+ shard) -// 15. Filler - Drain Soul (talent redirect) else Shadow Bolt -ApRule const kRules[] = { - { ShouldUnendingResolve, DoUnendingResolve, "Unending Resolve (<=30%)" }, - { ShouldDrainLifeEmergency, DoDrainLifeEmergency, "Drain Life (emergency)" }, - { ShouldMortalCoil, DoMortalCoil, "Mortal Coil (heal+horror)" }, - { ShouldHowlOfTerror, DoHowlOfTerror, "Howl of Terror (AoE fear)" }, - { ShouldPetDevourMagic, DoPetDevourMagic, "Felhunter Devour Magic" }, - { ShouldPetSpellLock, DoPetSpellLock, "Felhunter Spell Lock" }, - { ShouldDarkPact, DoDarkPact, "Dark Pact (absorb 30-75%)" }, - { ShouldSoulstone, DoSoulstone, "Soulstone (battle rez)" }, - { ShouldSummonDarkglare, DoSummonDarkglare, "Summon Darkglare (boss+dots)" }, - { ShouldDarkHarvest, DoDarkHarvest, "Dark Harvest (dots ramped)" }, - { ShouldHaunt, DoHaunt, "Haunt (dots ramped)" }, - { ShouldAgonyPrimary, DoAgonyPrimary, "Agony primary (refresh)" }, - { ShouldCorruptionPrimary, DoCorruptionPrimary, "Corruption/Wither primary" }, - { ShouldAgonyExpand, DoAgonyExpand, "Agony off-target spread" }, - { ShouldCorruptionExpand, DoCorruptionExpand, "Corruption/Wither spread" }, - { ShouldSeedOfCorruption, DoSeedOfCorruption, "Seed of Corruption (3+ AoE)" }, - { ShouldUnstableAffliction, DoUnstableAffliction, "Unstable Affliction (spend)" }, - { ShouldDrainSoul, DoDrainSoul, "Drain Soul (filler)" }, - { ShouldShadowBolt, DoShadowBolt, "Shadow Bolt (filler)" }, - { AlwaysAlive, DoNothing, "Idle" }, -}; - -} // anonymous - -void RegisterApl_Warlock_Affliction() -{ - constexpr uint32 SPEC_WARLOCK_AFFLICTION = 265; - RegisterRotation(CLASS_WARLOCK, SPEC_WARLOCK_AFFLICTION, ApRotation{kRules}); -} - -} // namespace Playerbot::Combat diff --git a/src/modules/PlayerbotV2/Combat/Apl/Apl_Warlock_Demonology.cpp b/src/modules/PlayerbotV2/Combat/Apl/Apl_Warlock_Demonology.cpp deleted file mode 100644 index a5456932c0..0000000000 --- a/src/modules/PlayerbotV2/Combat/Apl/Apl_Warlock_Demonology.cpp +++ /dev/null @@ -1,395 +0,0 @@ -// Demonology Warlock - WoW 12.1.0.69587 rotation. Pet-driven caster: Hand -// of Gul'dan summons Wild Imps, Demonbolt spends Demonic Core procs, Call -// Dreadstalkers (which in 12.1 also brings the Vilefiend) runs on cooldown. -// Major cooldowns: Summon Demonic Tyrant (after the stalkers are out), -// Grimoire: Imp Lord / Fel Ravager, Summon Doomguard, Power Siphon. -// -// ---- Validated IDs (SpellName.csv, WoW 12.1.0.69587) -------------------- -// 686 Shadow Bolt L1 filler shard generator -// 264178 Demonbolt granted by Demoniac 426115 [R][M] -// 105174 Hand of Gul'dan granted by talent 1250273 [R][M] -// 104316 Call Dreadstalkers spec talent [R][M], 2 shards, 20s CD -// 265187 Summon Demonic Tyrant spec talent [R][M], 60s CD -// 1276452 Grimoire: Imp Lord spec talent [R][M], 1 shard, 2min CD -// 1276467 Grimoire: Fel Ravager choice-node alternative (same node) -// 1276672 Summon Doomguard spec talent (not curated), 2min CD -// 196277 Implosion spec talent [M], detonate Wild Imps -// 264130 Power Siphon spec talent [R], imps -> Demonic Core -// 264173 Demonic Core proc aura (read-only) -// 30283 Shadowfury class talent [M], AoE 3s stun -// 234153 Drain Life L9 emergency self-heal channel -// 6789 Mortal Coil class talent [R][M], horror + heal -// 5484 Howl of Terror class talent, AoE fear, 40s CD -// 108416 Dark Pact class talent [R][M], absorb shield -// 231811 Soulstone modern combat-rez (preferred) -// 20707 Soulstone L14 baseline fallback id -// 104773 Unending Resolve L4 baseline, 40% DR, 3min CD -// -// ---- Pet abilities (cast through pet_cast) ------------------------------ -// 89766 Axe Toss Felguard stun / interrupt -// 19647 Spell Lock Felhunter interrupt/silence -// 17012 Devour Magic Felhunter dispel -// -// ---- Skipped spells (and why) ------------------------------------------- -// - Grimoire: Felguard (111898), Nether Portal (267217), Bilescourge -// Bombers (267211), Demonic Strength (267171), Soul Strike (264057): -// removed from the Demonology 12.1 tree (ids exist, not learnable). -// - Summon Vilefiend (264119): the 12.1 talent 1251778 is a passive that -// makes Call Dreadstalkers summon the Vilefiend - nothing to cast. -// - Doom (603): 12.1 Doom 460551 is a passive applied by Demonbolt. -// - Fel Firebolt / Felstorm (89751): Wild Imp / Felguard PET abilities, -// handled by the pet bot logic server-side, never cast by the warlock. -// - Summon Felguard (30146) / Imp (688): pet maintenance lives in -// State_Idle (ooc pet-summon rule), not in the combat APL. -// - Banish (710), Fear (5782), Curse of Tongues (1714 [R]) / Exhaustion -// (334275): situational CC / debuffs. -// - Demonic Circle (268358), Demonic Gateway (111771), Soulburn (385899), -// Burning Rush (111400): positioning / utility. - -#include "../ApRegistry.h" -#include "../ApRotation.h" -#include "Bot/BotIntentEmitter.h" -#include "Bot/BotSnapshotView.h" -#include "Group/GroupSnapshot.h" -#include "SharedDefines.h" - -namespace Playerbot::Combat { - -namespace { - -// ---- Spell IDs (WoW 12.1.0.69587, validated against SpellName.csv) ---- -constexpr uint32 SHADOW_BOLT = 686; -constexpr uint32 DEMONBOLT = 264178; // granted by Demoniac 426115 -constexpr uint32 HAND_OF_GULDAN = 105174; // granted by talent 1250273 -constexpr uint32 CALL_DREADSTALKERS = 104316; -constexpr uint32 SUMMON_DEMONIC_TYRANT= 265187; -constexpr uint32 GRIMOIRE_IMP_LORD = 1276452; // [R][M] choice node -constexpr uint32 GRIMOIRE_FEL_RAVAGER = 1276467; // alternative on the same node -constexpr uint32 SUMMON_DOOMGUARD = 1276672; // spec talent, 1 shard, 2min CD -constexpr uint32 IMPLOSION = 196277; -constexpr uint32 POWER_SIPHON = 264130; -constexpr uint32 SHADOWFURY = 30283; -constexpr uint32 DEMONIC_CORE = 264173; // proc aura (read-only) -constexpr uint32 DRAIN_LIFE = 234153; -constexpr uint32 MORTAL_COIL = 6789; -constexpr uint32 HOWL_OF_TERROR = 5484; -constexpr uint32 DARK_PACT = 108416; -constexpr uint32 SOULSTONE_MODERN = 231811; -constexpr uint32 SOULSTONE_LEGACY = 20707; -constexpr uint32 UNENDING_RESOLVE = 104773; - -// Pet abilities (cast through PetCastSpellIntent). -constexpr uint32 PET_SPELL_LOCK = 19647; // Felhunter -constexpr uint32 PET_AXE_TOSS = 89766; // Felguard (Demo default) -constexpr uint32 PET_DEVOUR_MAGIC = 17012; // Felhunter dispel - -// ---- Helpers ---- -bool HasLiveTarget(ApPredicateContext const& ctx) -{ - return !ctx.bot.victim().IsEmpty(); -} - -// Modern Soulstone preferred over legacy id. -uint32 KnownSoulstone(ApPredicateContext const& ctx) -{ - if (ctx.bot.knows_spell(SOULSTONE_MODERN)) return SOULSTONE_MODERN; - if (ctx.bot.knows_spell(SOULSTONE_LEGACY)) return SOULSTONE_LEGACY; - return 0; -} - -// Demo defaults to Felguard, so Axe Toss (4s stun) is the primary "interrupt" -// - no silence, but the stun stops a cast cold. Spell Lock falls back when -// the player swapped to Felhunter. Emit both; only the matching pet's -// ability succeeds, the other returns Locked harmlessly. -bool ShouldPetInterrupt(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.has_pet()) return false; - const bool pvp = ctx.pvp.in_battleground || ctx.pvp.in_arena; - if (pvp) return ctx.bot.kick_target(true, 40.0f) != nullptr; - auto const* c = ctx.bot.interruptible_caster(); - return c && c->guid == ctx.bot.victim(); -} -void DoPetInterrupt(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - const bool pvp = ctx.pvp.in_battleground || ctx.pvp.in_arena; - auto const* c = ctx.bot.kick_target(pvp, 40.0f); - if (!c) return; - e.pet_cast(PET_AXE_TOSS, c->guid); - e.pet_cast(PET_SPELL_LOCK, c->guid); -} - -// Felhunter Devour Magic - fires only if the pet is a Felhunter and the bot -// is carrying a harmful Magic aura. Mismatched-pet calls no-op server-side. -bool ShouldPetDevourMagic(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.has_pet()) return false; - return ctx.bot.self_dispellable(DispelType::Magic); -} -void DoPetDevourMagic(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.pet_cast(PET_DEVOUR_MAGIC, ctx.bot.guid()); -} - -// ---- Survival ---- -bool ShouldUnendingResolve(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(UNENDING_RESOLVE)) return false; - if (!ctx.bot.is_ready(UNENDING_RESOLVE)) return false; - return ctx.bot.hp_pct() <= 30; -} -void DoUnendingResolve(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(UNENDING_RESOLVE); } - -bool ShouldMortalCoil(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(MORTAL_COIL)) return false; - if (!ctx.bot.is_ready(MORTAL_COIL)) return false; - if (ctx.bot.victim().IsEmpty()) return false; - return ctx.bot.hp_pct() <= 40; -} -void DoMortalCoil(ApPredicateContext const& ctx, BotIntentEmitter& e) { e.cast(MORTAL_COIL, ctx.bot.victim()); } - -bool ShouldDarkPact(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(DARK_PACT)) return false; - if (!ctx.bot.is_ready(DARK_PACT)) return false; - if (ctx.bot.hp_pct() < 30 || ctx.bot.hp_pct() > 75) return false; - return ctx.bot.attackers_count() >= 1; -} -void DoDarkPact(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(DARK_PACT); } - -bool ShouldDrainLifeEmergency(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(DRAIN_LIFE)) return false; - if (!ctx.bot.is_ready(DRAIN_LIFE)) return false; // don't restart a running channel - if (ctx.bot.hp_pct() > 50) return false; - if (ctx.bot.knows_spell(UNENDING_RESOLVE) && ctx.bot.is_ready(UNENDING_RESOLVE)) return false; - if (ctx.bot.knows_spell(MORTAL_COIL) && ctx.bot.is_ready(MORTAL_COIL)) return false; - if (ctx.bot.knows_spell(DARK_PACT) && ctx.bot.is_ready(DARK_PACT)) return false; - return true; -} -void DoDrainLifeEmergency(ApPredicateContext const& ctx, BotIntentEmitter& e) { e.cast(DRAIN_LIFE, ctx.bot.victim()); } - -bool ShouldHowlOfTerror(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(HOWL_OF_TERROR)) return false; - if (!ctx.bot.is_ready(HOWL_OF_TERROR)) return false; - return ctx.bot.enemies_within(10.0f) >= 2 && ctx.bot.hp_pct() <= 70; -} -void DoHowlOfTerror(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(HOWL_OF_TERROR); } - -// ---- Group utility ---- -bool ShouldSoulstone(ApPredicateContext const& ctx) -{ - uint32 sid = KnownSoulstone(ctx); - if (sid == 0) return false; - if (!ctx.bot.is_ready(sid)) return false; - return ctx.group.dead_member_priority(ctx.bot.map_id()) != nullptr; -} -void DoSoulstone(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - uint32 sid = KnownSoulstone(ctx); - if (sid == 0) return; - if (auto const* m = ctx.group.dead_member_priority(ctx.bot.map_id())) - e.cast(sid, m->guid); -} - -// ---- CC ---- -bool ShouldShadowfury(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(SHADOWFURY)) return false; - if (!ctx.bot.is_ready(SHADOWFURY)) return false; - // 3+ adds clustered around us - emergency stun. - return ctx.bot.enemies_within(8.0f) >= 3 && ctx.bot.hp_pct() <= 70; -} -void DoShadowfury(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* v = ctx.bot.victim_info()) - e.cast_at(SHADOWFURY, v->x, v->y, v->z); - else - e.cast(SHADOWFURY); -} - -// ---- Major offensive cooldowns ---- -// Call Dreadstalkers - 2 shards, 20s CD; in 12.1 also summons the Vilefiend -// (passive 1251778 [R][M]). Runs on cooldown ahead of the Tyrant so the -// stalkers are out for the empowerment window. -bool ShouldCallDreadstalkers(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(CALL_DREADSTALKERS)) return false; - if (!ctx.bot.is_ready(CALL_DREADSTALKERS)) return false; - if (ctx.bot.is_moving() && !ctx.bot.can_cast_while_moving(CALL_DREADSTALKERS)) return false; - return ctx.bot.power(POWER_SOUL_SHARDS) >= 2; -} -void DoCallDreadstalkers(ApPredicateContext const& ctx, BotIntentEmitter& e) { e.cast(CALL_DREADSTALKERS, ctx.bot.victim()); } - -// Summon Demonic Tyrant - 60s CD; damage scales with every Wild Imp and -// Dreadstalker active. Hold it while Call Dreadstalkers is still off -// cooldown (nothing to empower yet); the Dreadstalkers rule above fires -// first, then the Tyrant follows on the next tick. -bool ShouldDemonicTyrant(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(SUMMON_DEMONIC_TYRANT)) return false; - if (!ctx.bot.is_ready(SUMMON_DEMONIC_TYRANT)) return false; - if (ctx.bot.is_moving() && !ctx.bot.can_cast_while_moving(SUMMON_DEMONIC_TYRANT)) return false; - if (ctx.bot.knows_spell(CALL_DREADSTALKERS) && ctx.bot.cd_remaining(CALL_DREADSTALKERS).count() <= 0) - return false; - return true; -} -void DoDemonicTyrant(ApPredicateContext const& ctx, BotIntentEmitter& e) { e.cast(SUMMON_DEMONIC_TYRANT, ctx.bot.victim()); } - -// Grimoire: Imp Lord [R][M] / Grimoire: Fel Ravager - choice node, 20s -// guardian, 1 shard, 2min CD. Both are pure damage (Imp Lord also strips -// one harmful effect from the bot on summon), so fire whichever the build -// owns off cooldown with a shard in hand. -uint32 ReadyGrimoire(ApPredicateContext const& ctx) -{ - for (uint32 sid : { GRIMOIRE_IMP_LORD, GRIMOIRE_FEL_RAVAGER }) - if (ctx.bot.knows_spell(sid) && ctx.bot.is_ready(sid)) - return sid; - return 0; -} -bool ShouldGrimoire(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (ctx.bot.power(POWER_SOUL_SHARDS) < 1) return false; - return ReadyGrimoire(ctx) != 0; -} -void DoGrimoire(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (uint32 sid = ReadyGrimoire(ctx)) - e.cast(sid, ctx.bot.victim()); -} - -// Summon Doomguard - spec talent (not in the curated builds, knows_spell -// gated): 12s guardian, 1 shard, 2min CD shortened by Demonic Core use. -bool ShouldSummonDoomguard(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(SUMMON_DOOMGUARD)) return false; - if (!ctx.bot.is_ready(SUMMON_DOOMGUARD)) return false; - return ctx.bot.power(POWER_SOUL_SHARDS) >= 1; -} -void DoSummonDoomguard(ApPredicateContext const& ctx, BotIntentEmitter& e) { e.cast(SUMMON_DOOMGUARD, ctx.bot.victim()); } - -// ---- AoE Implosion ---- -// When 3+ Wild Imps are out and 3+ enemies clustered, detonate them. -// Tracked indirectly: imps sit out for ~12s after Hand of Gul'dan. We can't -// count imp-pets in the snapshot, so we use a proxy - fire when in AoE -// situation (3+ enemies in 8yd). -bool ShouldImplosion(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(IMPLOSION)) return false; - if (!ctx.bot.is_ready(IMPLOSION)) return false; - return ctx.aoe_preference || ctx.bot.enemies_within(8.0f) >= 3; -} -void DoImplosion(ApPredicateContext const& ctx, BotIntentEmitter& e) { e.cast(IMPLOSION, ctx.bot.victim()); } - -// ---- Shard generators / spenders ---- -bool ShouldHandOfGuldan(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(HAND_OF_GULDAN)) return false; - if (!ctx.bot.is_ready(HAND_OF_GULDAN)) return false; - if (ctx.bot.is_moving() && !ctx.bot.can_cast_while_moving(HAND_OF_GULDAN)) return false; - // Spend at 3+ shards for max imp count (3 imps per cast at 3 shards). - return ctx.bot.power(POWER_SOUL_SHARDS) >= 3; -} -void DoHandOfGuldan(ApPredicateContext const& ctx, BotIntentEmitter& e) { e.cast(HAND_OF_GULDAN, ctx.bot.victim()); } - -bool ShouldPowerSiphon(ApPredicateContext const& ctx) -{ - // Sacrifices up to 2 imps to gain 2 stacks of Demonic Core. Ideally - // fired before a damage burst window; a 2nd-tier readiness check - - // skip when we already have Demonic Core stacks ready. - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(POWER_SIPHON)) return false; - if (!ctx.bot.is_ready(POWER_SIPHON)) return false; - if (ctx.bot.aura_stacks(DEMONIC_CORE) >= 2) return false; - return ctx.bot.in_combat(); -} -void DoPowerSiphon(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(POWER_SIPHON); } - -bool ShouldDemonbolt(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(DEMONBOLT)) return false; - if (!ctx.bot.is_ready(DEMONBOLT)) return false; - // Spend Demonic Core procs - instant cast, 2-shard generator on Demo - // (and with the Doom passive 460551 it also plants Doom on the target). - return ctx.bot.has_aura(DEMONIC_CORE); -} -void DoDemonbolt(ApPredicateContext const& ctx, BotIntentEmitter& e) { e.cast(DEMONBOLT, ctx.bot.victim()); } - -bool ShouldShadowBolt(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(SHADOW_BOLT)) return false; - if (!ctx.bot.is_ready(SHADOW_BOLT)) return false; - if (ctx.bot.is_moving() && !ctx.bot.can_cast_while_moving(SHADOW_BOLT)) return false; - return true; -} -void DoShadowBolt(ApPredicateContext const& ctx, BotIntentEmitter& e) { e.cast(SHADOW_BOLT, ctx.bot.victim()); } - -bool AlwaysAlive(ApPredicateContext const& ctx) { return ctx.bot.is_alive(); } -void DoNothing(ApPredicateContext const&, BotIntentEmitter&) {} - -// ---- Rule table ---- -// Order (per task spec): -// 1. Unending Resolve - panic <=30% -// 2. Drain Life - emergency self-heal <=50% when nothing else up -// 3. Howl of Terror - multi-target panic fear -// 4. Felhunter Devour Magic - pet dispel -// 5. Pet interrupt - Axe Toss / Spell Lock -// 6. Mortal Coil - heal + horror -// 7. Dark Pact - absorb shield (30-75%) -// 8. Group utility - Soulstone rez -// 9. Emergency CC - Shadowfury (3+ surround) -// 10. Major offensive CDs - Call Dreadstalkers -> Demonic Tyrant (stalkers -// out) -> Grimoire: Imp Lord / Fel Ravager -> Summon Doomguard -// 11. AoE - Implosion (3+ clustered) -// 12. Demonbolt - Demonic Core spending -// 13. Power Siphon - generate cores when none -// 14. Hand of Gul'dan - 3+ shards -// 15. Filler - Shadow Bolt -ApRule const kRules[] = { - { ShouldUnendingResolve, DoUnendingResolve, "Unending Resolve (<=30%)" }, - { ShouldDrainLifeEmergency, DoDrainLifeEmergency, "Drain Life (emergency)" }, - { ShouldHowlOfTerror, DoHowlOfTerror, "Howl of Terror (AoE fear)" }, - { ShouldPetDevourMagic, DoPetDevourMagic, "Felhunter Devour Magic" }, - { ShouldPetInterrupt, DoPetInterrupt, "Pet interrupt (Axe Toss/Lock)" }, - { ShouldMortalCoil, DoMortalCoil, "Mortal Coil (heal+horror)" }, - { ShouldDarkPact, DoDarkPact, "Dark Pact (absorb 30-75%)" }, - { ShouldSoulstone, DoSoulstone, "Soulstone (battle rez)" }, - { ShouldShadowfury, DoShadowfury, "Shadowfury (3+ surround stun)" }, - { ShouldCallDreadstalkers, DoCallDreadstalkers, "Call Dreadstalkers" }, - { ShouldDemonicTyrant, DoDemonicTyrant, "Summon Demonic Tyrant" }, - { ShouldGrimoire, DoGrimoire, "Grimoire: Imp Lord/Ravager" }, - { ShouldSummonDoomguard, DoSummonDoomguard, "Summon Doomguard" }, - { ShouldImplosion, DoImplosion, "Implosion (3+ AoE)" }, - { ShouldDemonbolt, DoDemonbolt, "Demonbolt (Demonic Core proc)" }, - { ShouldPowerSiphon, DoPowerSiphon, "Power Siphon (build cores)" }, - { ShouldHandOfGuldan, DoHandOfGuldan, "Hand of Gul'dan (imps)" }, - { ShouldShadowBolt, DoShadowBolt, "Shadow Bolt (filler)" }, - { AlwaysAlive, DoNothing, "Idle" }, -}; - -} // anonymous - -void RegisterApl_Warlock_Demonology() -{ - constexpr uint32 SPEC_WARLOCK_DEMONOLOGY = 266; - RegisterRotation(CLASS_WARLOCK, SPEC_WARLOCK_DEMONOLOGY, ApRotation{kRules}); -} - -} // namespace Playerbot::Combat diff --git a/src/modules/PlayerbotV2/Combat/Apl/Apl_Warlock_Destruction.cpp b/src/modules/PlayerbotV2/Combat/Apl/Apl_Warlock_Destruction.cpp deleted file mode 100644 index 8936c853af..0000000000 --- a/src/modules/PlayerbotV2/Combat/Apl/Apl_Warlock_Destruction.cpp +++ /dev/null @@ -1,517 +0,0 @@ -// Destruction Warlock - WoW 12.1.0.69587 rotation. Direct-damage caster -// with Soul Shard fragments + Chaos Bolt spend. Cleave via Havoc on a -// secondary target. Major cooldowns: Summon Infernal, Malevolence -// (Hellcaller), Cataclysm, Channel Demonfire, Soul Fire. -// -// Talent override (SpellEffect aura 332, OVERRIDE_ACTIONBAR_SPELLS): TC -// redirects a cast of the BASE id to the override while the passive is -// known, so the Immolate rule always emits 348 and checks the aura the -// build actually applies: -// 445465 Wither (Hellcaller passive [R][M]) 348 Immolate -> 445468 Wither -// -// ---- Validated IDs (SpellName.csv, WoW 12.1.0.69587) -------------------- -// 29722 Incinerate spec spell L10 (overrides Shadow Bolt) -// 348 Immolate spec spell (overrides Corruption) -// 157736 Immolate periodic aura applied by 348 -// 445465 Wither Hellcaller passive (gate only) -// 445474 Wither periodic aura applied by 445468 -// 17962 Conflagrate spec talent [R][M], Backdraft proc -// 117828 Backdraft proc aura (talent 196406 [R][M]) -// 116858 Chaos Bolt spec talent [R][M], 2-shard spender -// 5740 Rain of Fire spec talent [R], ground-targeted -// 1214467 Rain of Fire choice alternative [M], cast on target -// 1122 Summon Infernal spec talent [R][M], 2min CD -// 442726 Malevolence Hellcaller active (granted by 430014) -// 80240 Havoc spec talent, cleave debuff -// 17877 Shadowburn spec talent [R][M], execute -// 152108 Cataclysm spec talent [M], AoE + Immolate spread -// 196447 Channel Demonfire spec talent, needs Immolate / Wither -// 6353 Soul Fire spec talent [R], shard generator -// 196586 Dimensional Rift class baseline (artifact), charges -// 30283 Shadowfury class talent [R], AoE 3s stun -// 6789 Mortal Coil class talent [R][M], horror + heal -// 5484 Howl of Terror class talent, AoE fear, 40s CD -// 108416 Dark Pact class talent [R][M], absorb shield -// 234153 Drain Life L9 emergency self-heal channel -// 231811 Soulstone modern combat-rez (preferred) -// 20707 Soulstone L14 baseline fallback id -// 104773 Unending Resolve L4 baseline, 40% DR, 3min CD -// -// ---- Pet abilities (cast through pet_cast) ------------------------------ -// 19647 Spell Lock Felhunter interrupt/silence -// 89766 Axe Toss Felguard stun -// 17012 Devour Magic Felhunter dispel -// -// ---- Skipped spells (and why) ------------------------------------------- -// - Immolate 193541: a passive in 12.1, not the castable (348 is). -// - Wither 445468: never emitted directly - TC redirects the Immolate -// cast (see override note above). -// - Banish (710 [R]), Fear (5782), Curse of Tongues (1714) / Exhaustion -// (334275), Blight of Tongues (1271802 [R][M]): situational CC / -// debuffs, not a fixed-tick rotation slot. -// - Demonic Circle (268358), Demonic Gateway (111771), Soulburn (385899), -// Burning Rush (111400): positioning / utility. -// - Grimoire of Sacrifice (108503): not in the curated builds; pet kept. -// - Summon Imp (688): pet maintenance lives in State_Idle. - -#include "../ApRegistry.h" -#include "../ApRotation.h" -#include "Bot/BotIntentEmitter.h" -#include "Bot/BotSnapshotView.h" -#include "Group/GroupSnapshot.h" -#include "SharedDefines.h" - -namespace Playerbot::Combat { - -namespace { - -// ---- Spell IDs (WoW 12.1.0.69587, validated against SpellName.csv) ---- -constexpr uint32 INCINERATE = 29722; -constexpr uint32 IMMOLATE = 348; // base cast; 445465 redirects to Wither -constexpr uint32 IMMOLATE_DOT = 157736; // periodic aura applied by 348 -constexpr uint32 WITHER_TALENT = 445465; // Hellcaller passive (gate only) -constexpr uint32 WITHER_DOT = 445474; // periodic aura applied by 445468 -constexpr uint32 CONFLAGRATE = 17962; -constexpr uint32 CHAOS_BOLT = 116858; -constexpr uint32 RAIN_OF_FIRE = 5740; // [R] ground-targeted variant -constexpr uint32 RAIN_OF_FIRE_TGT = 1214467; // [M] choice: cast on the target -constexpr uint32 SUMMON_INFERNAL = 1122; -constexpr uint32 MALEVOLENCE = 442726; // Hellcaller active, granted by 430014 -constexpr uint32 HAVOC = 80240; -constexpr uint32 SHADOWBURN = 17877; -constexpr uint32 CATACLYSM = 152108; -constexpr uint32 CHANNEL_DEMONFIRE = 196447; -constexpr uint32 SOUL_FIRE = 6353; -constexpr uint32 DIMENSIONAL_RIFT = 196586; -constexpr uint32 SHADOWFURY = 30283; -constexpr uint32 MORTAL_COIL = 6789; -constexpr uint32 HOWL_OF_TERROR = 5484; -constexpr uint32 DARK_PACT = 108416; -constexpr uint32 DRAIN_LIFE = 234153; -constexpr uint32 SOULSTONE_MODERN = 231811; -constexpr uint32 SOULSTONE_LEGACY = 20707; -constexpr uint32 UNENDING_RESOLVE = 104773; -constexpr uint32 BACKDRAFT = 117828; // proc - buffs Incin/CB -constexpr uint32 PET_SPELL_LOCK = 19647; // Felhunter interrupt -constexpr uint32 PET_AXE_TOSS = 89766; // Felguard stun -constexpr uint32 PET_DEVOUR_MAGIC = 17012; // Felhunter dispel - -bool HasLiveTarget(ApPredicateContext const& ctx) -{ - return ctx.bot.in_combat() && !ctx.bot.victim().IsEmpty(); -} - -bool TargetExecuteRange(ApPredicateContext const& ctx) -{ - NearbyUnit const* t = ctx.bot.victim_info(); - if (!t || t->max_hp <= 0 || t->hp <= 0) return false; - return (t->hp * 100) / t->max_hp <= 20; -} - -bool BossLikeTargetEngaged(ApPredicateContext const& ctx) -{ - constexpr int32 kBossHpThreshold = 5'000'000; - NearbyUnit const* t = ctx.bot.victim_info(); - if (t && t->max_hp >= kBossHpThreshold) return true; - for (auto const& a : ctx.bot.raw().combat.attackers) - if (a.max_hp >= kBossHpThreshold) return true; - return false; -} - -// Modern Soulstone preferred over legacy id. -uint32 KnownSoulstone(ApPredicateContext const& ctx) -{ - if (ctx.bot.knows_spell(SOULSTONE_MODERN)) return SOULSTONE_MODERN; - if (ctx.bot.knows_spell(SOULSTONE_LEGACY)) return SOULSTONE_LEGACY; - return 0; -} - -// The Immolate cast (348) is redirected to Wither (445468) by TC while the -// Hellcaller passive is known, and the periodic aura on the target differs -// (157736 vs 445474). Resolve the aura id the bot's build actually applies. -uint32 ImmolateDotId(ApPredicateContext const& ctx) -{ - return ctx.bot.knows_spell(WITHER_TALENT) ? WITHER_DOT : IMMOLATE_DOT; -} - -// The bot's Immolate / Wither DoT on the victim (nullptr when absent). -AuraEntry const* VictimImmolate(ApPredicateContext const& ctx) -{ - if (AuraEntry const* a = ctx.bot.find_aura(ImmolateDotId(ctx), ctx.bot.victim())) return a; - return ctx.bot.find_aura(IMMOLATE, ctx.bot.victim()); -} - -bool VictimHasImmolate(ApPredicateContext const& ctx) -{ - return VictimImmolate(ctx) != nullptr; -} - -// Pet interrupt - emit both Spell Lock (Felhunter) and Axe Toss (Felguard); -// only the matching pet's ability succeeds. -bool ShouldPetInterrupt(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.has_pet()) return false; - const bool pvp = ctx.pvp.in_battleground || ctx.pvp.in_arena; - if (pvp) return ctx.bot.kick_target(true, 40.0f) != nullptr; - auto const* c = ctx.bot.interruptible_caster(); - return c && c->guid == ctx.bot.victim(); -} -void DoPetInterrupt(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - const bool pvp = ctx.pvp.in_battleground || ctx.pvp.in_arena; - if (auto const* c = ctx.bot.kick_target(pvp, 40.0f)) - { - e.pet_cast(PET_SPELL_LOCK, c->guid); - e.pet_cast(PET_AXE_TOSS, c->guid); - } -} - -// Felhunter Devour Magic - pet dispel on self for harmful Magic auras. -bool ShouldPetDevourMagic(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.has_pet()) return false; - return ctx.bot.self_dispellable(DispelType::Magic); -} -void DoPetDevourMagic(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.pet_cast(PET_DEVOUR_MAGIC, ctx.bot.guid()); -} - -// ---- Survival ---- -bool ShouldUnendingResolve(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(UNENDING_RESOLVE)) return false; - if (!ctx.bot.is_ready(UNENDING_RESOLVE)) return false; - return ctx.bot.hp_pct() <= 30; -} -void DoUnendingResolve(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(UNENDING_RESOLVE); } - -bool ShouldMortalCoil(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(MORTAL_COIL)) return false; - if (!ctx.bot.is_ready(MORTAL_COIL)) return false; - if (ctx.bot.victim().IsEmpty()) return false; - return ctx.bot.hp_pct() <= 40; -} -void DoMortalCoil(ApPredicateContext const& ctx, BotIntentEmitter& e) { e.cast(MORTAL_COIL, ctx.bot.victim()); } - -bool ShouldDarkPact(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(DARK_PACT)) return false; - if (!ctx.bot.is_ready(DARK_PACT)) return false; - if (ctx.bot.hp_pct() < 30 || ctx.bot.hp_pct() > 75) return false; - return ctx.bot.attackers_count() >= 1; -} -void DoDarkPact(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(DARK_PACT); } - -bool ShouldDrainLifeEmergency(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(DRAIN_LIFE)) return false; - if (!ctx.bot.is_ready(DRAIN_LIFE)) return false; // don't restart a running channel - if (ctx.bot.hp_pct() > 50) return false; - if (ctx.bot.knows_spell(UNENDING_RESOLVE) && ctx.bot.is_ready(UNENDING_RESOLVE)) return false; - if (ctx.bot.knows_spell(MORTAL_COIL) && ctx.bot.is_ready(MORTAL_COIL)) return false; - if (ctx.bot.knows_spell(DARK_PACT) && ctx.bot.is_ready(DARK_PACT)) return false; - return true; -} -void DoDrainLifeEmergency(ApPredicateContext const& ctx, BotIntentEmitter& e) { e.cast(DRAIN_LIFE, ctx.bot.victim()); } - -bool ShouldHowlOfTerror(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(HOWL_OF_TERROR)) return false; - if (!ctx.bot.is_ready(HOWL_OF_TERROR)) return false; - return ctx.bot.enemies_within(10.0f) >= 2 && ctx.bot.hp_pct() <= 70; -} -void DoHowlOfTerror(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(HOWL_OF_TERROR); } - -// ---- Group utility ---- -bool ShouldSoulstone(ApPredicateContext const& ctx) -{ - uint32 sid = KnownSoulstone(ctx); - if (sid == 0) return false; - if (!ctx.bot.is_ready(sid)) return false; - return ctx.group.dead_member(ctx.bot.map_id()) != nullptr; -} -void DoSoulstone(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - uint32 sid = KnownSoulstone(ctx); - if (sid == 0) return; - if (auto const* m = ctx.group.dead_member(ctx.bot.map_id())) - e.cast(sid, m->guid); -} - -// ---- CC ---- -bool ShouldShadowfury(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(SHADOWFURY)) return false; - if (!ctx.bot.is_ready(SHADOWFURY)) return false; - return ctx.bot.enemies_within(8.0f) >= 3 && ctx.bot.hp_pct() <= 70; -} -void DoShadowfury(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* v = ctx.bot.victim_info()) - e.cast_at(SHADOWFURY, v->x, v->y, v->z); - else - e.cast(SHADOWFURY); -} - -// ---- Major offensive cooldowns ---- -bool ShouldSummonInfernal(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(SUMMON_INFERNAL)) return false; - if (!ctx.bot.is_ready(SUMMON_INFERNAL)) return false; - return BossLikeTargetEngaged(ctx) || ctx.bot.enemies_within(10.0f) >= 3; -} -void DoSummonInfernal(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* v = ctx.bot.victim_info()) - e.cast_at(SUMMON_INFERNAL, v->x, v->y, v->z); - else - e.cast(SUMMON_INFERNAL); -} - -// Malevolence - Hellcaller burst (granted by passive 430014 [R][M]): for -// its duration every enemy suffering our Wither takes Shadowflame damage -// and gains Wither stacks. Worthless without Wither ticking, so require -// the DoT on the victim; otherwise run it on cooldown. -bool ShouldMalevolence(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(MALEVOLENCE)) return false; - if (!ctx.bot.is_ready(MALEVOLENCE)) return false; - return VictimHasImmolate(ctx); -} -void DoMalevolence(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(MALEVOLENCE); } - -bool ShouldCataclysm(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(CATACLYSM)) return false; - if (!ctx.bot.is_ready(CATACLYSM)) return false; - if (ctx.bot.is_moving() && !ctx.bot.can_cast_while_moving(CATACLYSM)) return false; - // 2s cast AoE that also applies Immolate / Wither to every hit. Worth a - // 30s CD when 2+ targets in range, or always on boss for the refresh. - return ctx.bot.enemies_within(8.0f) >= 2 || BossLikeTargetEngaged(ctx); -} -void DoCataclysm(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* v = ctx.bot.victim_info()) - e.cast_at(CATACLYSM, v->x, v->y, v->z); - else - e.cast(CATACLYSM); -} - -// Dimensional Rift - talent on a charge system; opens a portal that fires -// free damage at the target. Fire any time we're in combat with a live -// target (charges deplete naturally). -bool ShouldDimensionalRift(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(DIMENSIONAL_RIFT)) return false; - return ctx.bot.is_ready(DIMENSIONAL_RIFT); -} -void DoDimensionalRift(ApPredicateContext const& ctx, BotIntentEmitter& e) { e.cast(DIMENSIONAL_RIFT, ctx.bot.victim()); } - -// ---- Havoc cleave ---- -// Havoc copies Chaos Bolt / Incinerate damage to a secondary target. Apply -// when an OFF-target is alive within 30y so the cleave actually lands. -bool ShouldHavoc(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(HAVOC)) return false; - if (!ctx.bot.is_ready(HAVOC)) return false; - // Find an off-target enemy in range that doesn't already have Havoc. - return ctx.bot.enemy_without_my_aura(HAVOC, 30.0f) != nullptr; -} -void DoHavoc(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* t = ctx.bot.enemy_without_my_aura(HAVOC, 30.0f)) - e.cast(HAVOC, t->guid); -} - -// ---- DoT maintenance ---- -// Emit the base Immolate id - TC redirects it to Wither while the -// Hellcaller passive is known - and refresh off the aura the build applies. -bool ShouldImmolate(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(IMMOLATE)) return false; - if (!ctx.bot.is_ready(IMMOLATE)) return false; - if (ctx.bot.is_moving() && !ctx.bot.can_cast_while_moving(IMMOLATE)) return false; - // Refresh aware: pandemic 4.5s window for an 18s base DoT. - AuraEntry const* a = VictimImmolate(ctx); - return !a || a->remaining.count() <= 4500; -} -void DoImmolate(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(IMMOLATE, ctx.bot.victim()); -} - -// ---- Channel Demonfire (channel; only worth it with Immolate up) ---- -bool ShouldChannelDemonfire(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(CHANNEL_DEMONFIRE)) return false; - if (!ctx.bot.is_ready(CHANNEL_DEMONFIRE)) return false; - // Channel only worth firing with Immolate up on at least the victim. - return VictimHasImmolate(ctx); -} -void DoChannelDemonfire(ApPredicateContext const& ctx, BotIntentEmitter& e) { e.cast(CHANNEL_DEMONFIRE, ctx.bot.victim()); } - -// ---- Soul Fire - 45s CD shard generator (3s cast, applies Immolate) ---- -bool ShouldSoulFire(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(SOUL_FIRE)) return false; - if (!ctx.bot.is_ready(SOUL_FIRE)) return false; - if (ctx.bot.is_moving() && !ctx.bot.can_cast_while_moving(SOUL_FIRE)) return false; - return true; -} -void DoSoulFire(ApPredicateContext const& ctx, BotIntentEmitter& e) { e.cast(SOUL_FIRE, ctx.bot.victim()); } - -// Conflagrate fires Backdraft proc that speeds the next Incinerate/Chaos -// Bolt. Off-CD on victim - but skip when we already have a Backdraft stack -// so we don't waste the next charge. -bool ShouldConflagrate(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(CONFLAGRATE)) return false; - if (!ctx.bot.is_ready(CONFLAGRATE)) return false; - // Skip if we already carry an unspent Backdraft proc - let the buff be - // consumed first by Incinerate / Chaos Bolt. - if (ctx.bot.has_aura(BACKDRAFT)) return false; - return true; -} -void DoConflagrate(ApPredicateContext const& ctx, BotIntentEmitter& e) { e.cast(CONFLAGRATE, ctx.bot.victim()); } - -bool ShouldShadowburn(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(SHADOWBURN)) return false; - if (!ctx.bot.is_ready(SHADOWBURN)) return false; - return TargetExecuteRange(ctx); -} -void DoShadowburn(ApPredicateContext const& ctx, BotIntentEmitter& e) { e.cast(SHADOWBURN, ctx.bot.victim()); } - -// ---- AoE shard spend ---- -// Rain of Fire is a choice node: 5740 [R] is ground-targeted, 1214467 [M] -// lands on the current target. Resolve whichever the build owns. -uint32 KnownRainOfFire(ApPredicateContext const& ctx) -{ - if (ctx.bot.knows_spell(RAIN_OF_FIRE_TGT)) return RAIN_OF_FIRE_TGT; - if (ctx.bot.knows_spell(RAIN_OF_FIRE)) return RAIN_OF_FIRE; - return 0; -} -bool ShouldRainOfFire(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - uint32 sid = KnownRainOfFire(ctx); - if (sid == 0) return false; - if (!ctx.bot.is_ready(sid)) return false; - if (ctx.bot.power(POWER_SOUL_SHARDS) < 3) return false; - return ctx.aoe_preference || ctx.bot.enemies_within(20.0f) >= 3; -} -void DoRainOfFire(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - uint32 sid = KnownRainOfFire(ctx); - if (sid == 0) return; - if (sid == RAIN_OF_FIRE_TGT) - e.cast(sid, ctx.bot.victim()); - else if (auto const* v = ctx.bot.victim_info()) - e.cast_at(sid, v->x, v->y, v->z); - else - e.cast(sid); -} - -// ---- Single-target shard spend ---- -bool ShouldChaosBolt(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(CHAOS_BOLT)) return false; - if (!ctx.bot.is_ready(CHAOS_BOLT)) return false; - if (ctx.bot.is_moving() && !ctx.bot.can_cast_while_moving(CHAOS_BOLT)) return false; - return ctx.bot.power(POWER_SOUL_SHARDS) >= 2; -} -void DoChaosBolt(ApPredicateContext const& ctx, BotIntentEmitter& e) { e.cast(CHAOS_BOLT, ctx.bot.victim()); } - -bool ShouldIncinerate(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(INCINERATE)) return false; - if (!ctx.bot.is_ready(INCINERATE)) return false; - if (ctx.bot.is_moving() && !ctx.bot.can_cast_while_moving(INCINERATE)) return false; - return true; -} -void DoIncinerate(ApPredicateContext const& ctx, BotIntentEmitter& e) { e.cast(INCINERATE, ctx.bot.victim()); } - -bool AlwaysAlive(ApPredicateContext const& ctx) { return ctx.bot.is_alive(); } -void DoNothing(ApPredicateContext const&, BotIntentEmitter&) {} - -// ---- Rule table ---- -// Order (per task spec): -// 1. Unending Resolve - panic <=30% -// 2. Drain Life - emergency self-heal <=50% when nothing else up -// 3. Howl of Terror - multi-target panic fear -// 4. Felhunter Devour Magic - pet dispel on self -// 5. Pet interrupt - Spell Lock / Axe Toss -// 6. Mortal Coil - heal + horror -// 7. Dark Pact - absorb shield 30-75% HP -// 8. Soulstone (battle rez) -// 9. Shadowfury (3+ surround stun) -// 10. Summon Infernal (boss / 3+ AoE) -// 11. Malevolence (Hellcaller burst, Wither up) -// 12. Cataclysm (AoE + Immolate / Wither spread) -// 13. Havoc (cleave secondary) -// 14. Immolate / Wither (DoT maintenance - primary) -// 15. Channel Demonfire (Immolate / Wither up) -// 16. Dimensional Rift (charges) -// 17. Shadowburn (execute) -// 18. Rain of Fire (3+ AoE shard spend, either variant) -// 19. Chaos Bolt (2+ shard ST spend) -// 20. Conflagrate (apply Backdraft if absent) -// 21. Soul Fire (shard generator) -// 22. Incinerate (filler) -ApRule const kRules[] = { - { ShouldUnendingResolve, DoUnendingResolve, "Unending Resolve (<=30%)" }, - { ShouldDrainLifeEmergency, DoDrainLifeEmergency, "Drain Life (emergency)" }, - { ShouldHowlOfTerror, DoHowlOfTerror, "Howl of Terror (AoE fear)" }, - { ShouldPetDevourMagic, DoPetDevourMagic, "Felhunter Devour Magic" }, - { ShouldPetInterrupt, DoPetInterrupt, "Pet interrupt (Lock/Axe Toss)" }, - { ShouldMortalCoil, DoMortalCoil, "Mortal Coil (heal+horror)" }, - { ShouldDarkPact, DoDarkPact, "Dark Pact (absorb 30-75%)" }, - { ShouldSoulstone, DoSoulstone, "Soulstone (battle rez)" }, - { ShouldShadowfury, DoShadowfury, "Shadowfury (3+ surround stun)" }, - { ShouldSummonInfernal, DoSummonInfernal, "Summon Infernal" }, - { ShouldMalevolence, DoMalevolence, "Malevolence (Wither burst)" }, - { ShouldCataclysm, DoCataclysm, "Cataclysm (AoE + Immolate)" }, - { ShouldHavoc, DoHavoc, "Havoc (cleave secondary)" }, - { ShouldImmolate, DoImmolate, "Immolate/Wither (refresh)" }, - { ShouldChannelDemonfire, DoChannelDemonfire, "Channel Demonfire" }, - { ShouldDimensionalRift, DoDimensionalRift, "Dimensional Rift (charges)" }, - { ShouldShadowburn, DoShadowburn, "Shadowburn (<=20%)" }, - { ShouldRainOfFire, DoRainOfFire, "Rain of Fire (3+ AoE)" }, - { ShouldChaosBolt, DoChaosBolt, "Chaos Bolt (2-shard spend)" }, - { ShouldConflagrate, DoConflagrate, "Conflagrate (apply Backdraft)" }, - { ShouldSoulFire, DoSoulFire, "Soul Fire (shard generator)" }, - { ShouldIncinerate, DoIncinerate, "Incinerate (filler)" }, - { AlwaysAlive, DoNothing, "Idle" }, -}; - -} // anonymous - -void RegisterApl_Warlock_Destruction() -{ - constexpr uint32 SPEC_WARLOCK_DESTRUCTION = 267; - RegisterRotation(CLASS_WARLOCK, SPEC_WARLOCK_DESTRUCTION, ApRotation{kRules}); -} - -} // namespace Playerbot::Combat diff --git a/src/modules/PlayerbotV2/Combat/Apl/Apl_Warrior_Arms.cpp b/src/modules/PlayerbotV2/Combat/Apl/Apl_Warrior_Arms.cpp deleted file mode 100644 index 0f449b61d4..0000000000 --- a/src/modules/PlayerbotV2/Combat/Apl/Apl_Warrior_Arms.cpp +++ /dev/null @@ -1,586 +0,0 @@ -// Arms Warrior - WoW 12.1.0.69587 (Midnight) enterprise rotation. Two-handed -// melee with Rage resource, Mortal Strike single-target focus, Cleave / -// Sweeping Strikes for AoE, Colossus Smash damage window followed by -// Demolish (Colossus hero tree), Avatar burst. Execute under 20% (35% with -// Massacre, any HP on a Sudden Death proc). Rend bleed for Deep Wounds upkeep. -// -// Survival ladder: Die by the Sword (parry chance + 30% DR) -> Defensive -// Stance (<=30% HP, swapped back to Battle Stance once recovered) -> Spell -// Reflection (magic absorb) -> Victory Rush / Impending Victory (heal). -// Group utility: Battle Shout (group buff), Rallying Cry (group HP buff), -// Berserker Rage / Berserker Shout (anti-fear), Intervene (peel + damage -// redirect). CC: Pummel interrupt, Storm Bolt (talent stun), Hamstring slow, -// Piercing Howl AoE snare (PvP), Intimidating Shout fear, Shockwave AoE stun. -// -// Rule order (panic-first ladder, then offensive ladder): -// 1) Anti-CC immunity - Berserker Rage / Berserker Shout (fear/sap/incap break) -// 2) Spec defensive - Die by the Sword (<=35% HP), Defensive Stance (<=30%) -// 3) Interrupt - Pummel, Storm Bolt fallback -// 4) Magic absorb - Spell Reflection (enemy casting) -// 5) Slow / CC - Shockwave, Intimidating Shout, Piercing Howl, Hamstring -// 6) Group utility - Battle Stance, Battle Shout, Rallying Cry, Intervene -// 7) Self heals / shields - Ignore Pain / Victory Rush / Impending Victory -// 8) Major CDs - Avatar, Sweeping Strikes, Bladestorm, Colossus Smash, -// Demolish -// 9) Rotation - Execute, Mortal Strike, Overpower, Rend, Cleave, -// Wrecking Throw, Slam -// 10) Auto-attack - engage fallback -// -// Validated spell IDs (WoW 12.1.0.69587): -// 12294 Mortal Strike | 7384 Overpower | 163201 Execute (Arms variant) -// 1464 Slam | 227847 Bladestorm | 845 Cleave (talent) -// 167105 Colossus Smash | 260708 Sweeping Strikes| 107574 Avatar -// 772 Rend | 436358 Demolish | 384110 Wrecking Throw -// 46968 Shockwave | 107570 Storm Bolt | 12323 Piercing Howl -// 1715 Hamstring | 5246 Intimidating Shout| 18499 Berserker Rage -// 384100 Berserker Shout | 386164 Battle Stance | 386208 Defensive Stance -// 118038 Die by the Sword| 1277297 Ignore Pain | 34428 Victory Rush -// 202168 Impending Victory| 6552 Pummel | 23920 Spell Reflection -// 6673 Battle Shout | 97462 Rallying Cry | 3411 Intervene -// Aura-only: 388539 Rend bleed | 208086 Colossus Smash debuff | 52437 Sudden Death -// Passive gates: 281001 Massacre -// -// Skipped spells (and why): -// 260643 Skullsplitter - removed from the Arms tree in 12.1 -// 384318 Thunderous Roar - removed from the Arms tree in 12.1 -// 262161 Warbreaker - removed in 12.1 (209577 is the Legion artifact spell) -// 209577 Warbreaker (artifact)- unlearnable artifact ability, not a 12.1 talent -// 1244088 Interpose / 3411 Intervene-target-location, 6544 Heroic Leap -// - ground-target positioning the bot does not do -// 376079 Champion's Spear - not in the curated Arms builds (gated anyway if added) -// 228920 Ravager - Arms tree option not in the curated builds -// 1229376 Single-Button Assistant - client convenience macro, not a rotation ability -// 262115 Deep Wounds debuff - MS proc bleed (NOT cast directly; tracked via Rend instead) -// 100 Charge - handled in baseline rotation -// 1680 Whirlwind (baseline) - covered by Cleave (spec talent) for Arms AoE - -#include "../ApRegistry.h" -#include "../ApRotation.h" -#include "Bot/BotIntentEmitter.h" -#include "Bot/BotSnapshotView.h" -#include "Group/GroupSnapshot.h" -#include "SharedDefines.h" - -namespace Playerbot::Combat { - -namespace { - -// ---- Spell IDs (WoW 12.1.0.69587, validated against SpellName.csv) ---- -constexpr uint32 MORTAL_STRIKE = 12294; -constexpr uint32 OVERPOWER = 7384; -constexpr uint32 EXECUTE = 163201; // Arms-flagged Execute (Massacre-aware) -constexpr uint32 SLAM = 1464; -constexpr uint32 BLADESTORM = 227847; // Arms Bladestorm (channel) -constexpr uint32 CLEAVE = 845; // talent AoE -constexpr uint32 COLOSSUS_SMASH = 167105; -constexpr uint32 SWEEPING_STRIKES = 260708; -constexpr uint32 AVATAR = 107574; -constexpr uint32 DEMOLISH = 436358; // Colossus hero tree - 2s channel burst -constexpr uint32 WRECKING_THROW = 384110; // talent - 25y armor-ignoring throw -constexpr uint32 REND = 772; // talent bleed (12.1 cast id) -constexpr uint32 SHOCKWAVE = 46968; // AoE stun -constexpr uint32 STORM_BOLT = 107570; // talent stun (interrupt fallback) -constexpr uint32 HAMSTRING = 1715; -constexpr uint32 PIERCING_HOWL = 12323; // talent AoE snare (PvP peel) -constexpr uint32 INTIMIDATING_SHOUT = 5246; -constexpr uint32 BERSERKER_RAGE = 18499; // anti-fear / sap / incap immunity -constexpr uint32 BERSERKER_SHOUT = 384100; // talent - overrides Berserker Rage -constexpr uint32 BATTLE_STANCE = 386164; // talent - default DPS stance -constexpr uint32 DEFENSIVE_STANCE = 386208; // talent - DR stance (panic swap) -constexpr uint32 DIE_BY_THE_SWORD = 118038; // 100% parry + 30% DR, 8s -constexpr uint32 IGNORE_PAIN = 1277297; // Arms spec-tree talent - absorb shield -constexpr uint32 VICTORY_RUSH = 34428; -constexpr uint32 IMPENDING_VICTORY = 202168; // talent replacement -constexpr uint32 PUMMEL = 6552; -constexpr uint32 SPELL_REFLECTION = 23920; -constexpr uint32 BATTLE_SHOUT = 6673; -constexpr uint32 RALLYING_CRY = 97462; -constexpr uint32 INTERVENE = 3411; -// Aura / passive ids (never cast; predicates only). -constexpr uint32 REND_BLEED_AURA = 388539; // Rend DoT on the target (772 applies it) -constexpr uint32 COLOSSUS_SMASH_DEBUFF = 208086; // damage-taken window on the target -constexpr uint32 SUDDEN_DEATH_AURA = 52437; // proc: Execute usable at any HP -constexpr uint32 MASSACRE = 281001; // passive: Execute usable below 35% - -constexpr uint8 POWER_RAGE_IDX = 1; - -bool HasLiveTarget(ApPredicateContext const& ctx) -{ - return ctx.bot.in_combat() && !ctx.bot.victim().IsEmpty(); -} - -// Execute window: 20% baseline, 35% with the Massacre passive, any HP while -// a Sudden Death proc is up (both are [R] in the curated Arms build). -bool TargetExecuteRange(ApPredicateContext const& ctx) -{ - NearbyUnit const* t = ctx.bot.victim_info(); - if (!t || t->max_hp <= 0 || t->hp <= 0) return false; - if (ctx.bot.has_aura(SUDDEN_DEATH_AURA)) return true; - const int32 threshold = ctx.bot.knows_spell(MASSACRE) ? 35 : 20; - return (t->hp * 100) / t->max_hp <= threshold; -} - -bool BossLikeTargetEngaged(ApPredicateContext const& ctx) -{ - constexpr int32 kBossHpThreshold = 5'000'000; - NearbyUnit const* t = ctx.bot.victim_info(); - if (t && t->max_hp >= kBossHpThreshold) return true; - for (auto const& a : ctx.bot.raw().combat.attackers) - if (a.max_hp >= kBossHpThreshold) return true; - return false; -} - -int32 Rage(ApPredicateContext const& ctx) { return ctx.bot.power(POWER_RAGE_IDX); } - -// Berserker Shout (talent) overrides Berserker Rage in the spellbook, so -// resolve which of the two the bot actually owns (same two-branch idiom as -// Victory Rush / Impending Victory). -uint32 BerserkerRageId(ApPredicateContext const& ctx) -{ - return ctx.bot.knows_spell(BERSERKER_SHOUT) ? BERSERKER_SHOUT : BERSERKER_RAGE; -} - -// ---- Anti-CC immunity (highest panic priority) ---- -bool ShouldBerserkerRage(ApPredicateContext const& ctx) -{ - const uint32 id = BerserkerRageId(ctx); - if (!ctx.bot.knows_spell(id)) return false; - if (!ctx.bot.is_ready(id)) return false; - // Berserker Rage clears (and grants 6s immunity to) Fear / Sap / - // Incapacitate / Disorient effects. MECHANIC_FEAR=5, - // MECHANIC_DISORIENTED=2, MECHANIC_HORROR=24, MECHANIC_SAPPED=30. - return ctx.bot.has_mechanic(5) || ctx.bot.has_mechanic(2) || - ctx.bot.has_mechanic(24) || ctx.bot.has_mechanic(30); -} -void DoBerserkerRage(ApPredicateContext const& ctx, BotIntentEmitter& e) { e.cast(BerserkerRageId(ctx)); } - -// ---- Survival ---- -bool ShouldDieByTheSword(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(DIE_BY_THE_SWORD)) return false; - if (!ctx.bot.is_ready(DIE_BY_THE_SWORD)) return false; - return ctx.bot.hp_pct() <= 35; -} -void DoDieByTheSword(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(DIE_BY_THE_SWORD); } - -// Defensive Stance: flat DR toggle. Swap in at <=30% HP; ShouldBattleStance -// swaps back once HP recovers (>=70%) or combat ends. The 3s stance -// category cooldown prevents ping-pong. -bool ShouldDefensiveStance(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(DEFENSIVE_STANCE)) return false; - if (!ctx.bot.is_ready(DEFENSIVE_STANCE)) return false; - if (ctx.bot.has_aura(DEFENSIVE_STANCE)) return false; - return ctx.bot.hp_pct() <= 30; -} -void DoDefensiveStance(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(DEFENSIVE_STANCE); } - -bool ShouldIgnorePain(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(IGNORE_PAIN)) return false; - if (Rage(ctx) < 40) return false; - if (ctx.bot.has_aura(IGNORE_PAIN)) return false; - return ctx.bot.hp_pct() <= 60; -} -void DoIgnorePain(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(IGNORE_PAIN); } - -bool ShouldImpendingVictory(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(IMPENDING_VICTORY)) return false; - if (!ctx.bot.is_ready(IMPENDING_VICTORY)) return false; - return ctx.bot.hp_pct() <= 70; -} -void DoImpendingVictory(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(IMPENDING_VICTORY, ctx.bot.victim()); -} - -bool ShouldVictoryRush(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (ctx.bot.knows_spell(IMPENDING_VICTORY)) return false; - if (!ctx.bot.knows_spell(VICTORY_RUSH)) return false; - return ctx.bot.hp_pct() <= 80; -} -void DoVictoryRush(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(VICTORY_RUSH, ctx.bot.victim()); -} - -bool ShouldSpellReflection(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(SPELL_REFLECTION)) return false; - if (!ctx.bot.is_ready(SPELL_REFLECTION)) return false; - return ctx.bot.interruptible_caster() != nullptr; -} -void DoSpellReflection(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(SPELL_REFLECTION); } - -// ---- Maintenance ---- -// Battle Stance is the Arms default. Re-enter it when no stance is up, or -// when Defensive Stance was taken as a panic swap and HP has recovered. -bool ShouldBattleStance(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(BATTLE_STANCE)) return false; - if (!ctx.bot.is_ready(BATTLE_STANCE)) return false; - if (ctx.bot.has_aura(BATTLE_STANCE)) return false; - if (!ctx.bot.has_aura(DEFENSIVE_STANCE)) return true; - return !ctx.bot.in_combat() || ctx.bot.hp_pct() >= 70; -} -void DoBattleStance(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(BATTLE_STANCE); } - -bool ShouldBattleShout(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(BATTLE_SHOUT)) return false; - return !ctx.bot.has_aura(BATTLE_SHOUT); -} -void DoBattleShout(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(BATTLE_SHOUT); } - -// ---- Group utility ---- -bool ShouldRallyingCry(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(RALLYING_CRY)) return false; - if (!ctx.bot.is_ready(RALLYING_CRY)) return false; - auto const* low = ctx.group.lowest_hp_on_map(ctx.bot.map_id(), Role::Unknown, ctx.bot.raw().position.x, ctx.bot.raw().position.y, ctx.bot.raw().position.z, 45.0f); - if (low && low->online && low->hp > 0) - return (low->hp * 100) / low->max_hp <= 35; - return false; -} -void DoRallyingCry(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(RALLYING_CRY); } - -bool ShouldIntervene(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(INTERVENE)) return false; - if (!ctx.bot.is_ready(INTERVENE)) return false; - auto const* low = ctx.group.lowest_hp_on_map(ctx.bot.map_id(), Role::Unknown, ctx.bot.raw().position.x, ctx.bot.raw().position.y, ctx.bot.raw().position.z, 45.0f); - if (!low || !low->online || low->hp <= 0) return false; - if (low->guid == ctx.bot.raw().guid) return false; - return (low->hp * 100) / low->max_hp <= 30; -} -void DoIntervene(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* low = ctx.group.lowest_hp_on_map(ctx.bot.map_id(), Role::Unknown, ctx.bot.raw().position.x, ctx.bot.raw().position.y, ctx.bot.raw().position.z, 45.0f)) - e.cast(INTERVENE, low->guid); -} - -// ---- Interrupt / CC ---- -bool ShouldPummel(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(PUMMEL)) return false; - if (!ctx.bot.is_ready(PUMMEL)) return false; - const bool pvp = ctx.pvp.in_battleground || ctx.pvp.in_arena; - return ctx.bot.kick_target(pvp, 5.0f) != nullptr; -} -void DoPummel(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - const bool pvp = ctx.pvp.in_battleground || ctx.pvp.in_arena; - if (auto const* c = ctx.bot.kick_target(pvp, 5.0f)) - e.cast(PUMMEL, c->guid); -} - -bool ShouldStormBolt(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(STORM_BOLT)) return false; - if (!ctx.bot.is_ready(STORM_BOLT)) return false; - if (ctx.bot.is_ready(PUMMEL)) return false; - return ctx.bot.interruptible_caster() != nullptr; -} -void DoStormBolt(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* c = ctx.bot.interruptible_caster()) - e.cast(STORM_BOLT, c->guid); -} - -bool ShouldShockwave(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(SHOCKWAVE)) return false; - if (!ctx.bot.is_ready(SHOCKWAVE)) return false; - return ctx.aoe_preference || ctx.bot.enemies_within(10.0f) >= 3; -} -void DoShockwave(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(SHOCKWAVE); } - -bool ShouldIntimidatingShout(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(INTIMIDATING_SHOUT)) return false; - if (!ctx.bot.is_ready(INTIMIDATING_SHOUT)) return false; - return ctx.bot.enemies_within(8.0f) >= 2 && ctx.bot.hp_pct() <= 50; -} -void DoIntimidatingShout(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(INTIMIDATING_SHOUT); } - -// Piercing Howl: 8s AoE snare on a 90s CD. PvP-only - in PvE a mass snare -// on melee-range mobs is a wasted GCD, in BGs it peels a whole pack off a -// carrier / kites a chase. -bool ShouldPiercingHowl(ApPredicateContext const& ctx) -{ - if (!ctx.pvp.in_battleground && !ctx.pvp.in_arena) return false; - if (!ctx.bot.knows_spell(PIERCING_HOWL)) return false; - if (!ctx.bot.is_ready(PIERCING_HOWL)) return false; - return ctx.bot.enemies_within(10.0f) >= 2; -} -void DoPiercingHowl(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(PIERCING_HOWL); } - -// Hamstring fires either on the bot's current victim OR - in BGs where we -// have a friendly flag carrier - on an enemy meleeing the carrier (the FC -// peel pattern). The carrier-peel branch is evaluated first because slowing -// the FC's attacker is higher leverage than slowing whatever the bot is on. -NearbyUnit const* PickHamstringTarget(ApPredicateContext const& ctx) -{ - if (ctx.pvp.in_battleground && !ctx.pvp.friendly_flag_carrier.IsEmpty()) - { - if (NearbyUnit const* peel = ctx.bot.enemy_near_friendly_carrier(8.0f)) - { - if (!ctx.bot.has_aura(HAMSTRING, peel->guid)) return peel; - } - } - return ctx.bot.victim_info(); -} - -bool ShouldHamstring(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(HAMSTRING)) return false; - if (!ctx.bot.is_ready(HAMSTRING)) return false; - if (Rage(ctx) < 30) return false; - NearbyUnit const* t = PickHamstringTarget(ctx); - if (!t || t->hp <= 0) return false; - if (ctx.bot.has_aura(HAMSTRING, t->guid)) return false; - // Original gate: only fire when not in AoE territory (saves Rage for - // Whirlwind / Sweeping Strikes). FC-peel ignores that - peeling for the - // carrier is worth the Rage trade. - const bool fc_peel = ctx.pvp.in_battleground && - !ctx.pvp.friendly_flag_carrier.IsEmpty() && - t != ctx.bot.victim_info(); - return fc_peel || ctx.bot.enemies_within(8.0f) == 0; -} -void DoHamstring(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (NearbyUnit const* t = PickHamstringTarget(ctx)) - e.cast(HAMSTRING, t->guid); -} - -// ---- Major offensive cooldowns ---- -bool ShouldAvatar(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(AVATAR)) return false; - if (!ctx.bot.is_ready(AVATAR)) return false; - return BossLikeTargetEngaged(ctx) || ctx.bot.enemies_within(10.0f) >= 3; -} -void DoAvatar(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(AVATAR); } - -// Colossus Smash is an 8y ground AoE in 12.1 (no target needed); fire on -// cooldown when we are in melee so the debuff lands on the victim. -bool ShouldColossusSmash(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(COLOSSUS_SMASH)) return false; - if (!ctx.bot.is_ready(COLOSSUS_SMASH)) return false; - return ctx.bot.enemies_within(8.0f) >= 1; -} -void DoColossusSmash(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(COLOSSUS_SMASH); } - -// Demolish (Colossus hero tree): 2s channel, biggest single hit. Prefer to -// land it inside the Colossus Smash window; the CS rule sits above this one -// so when CS is ready it fires first and Demolish follows the next tick. -// Do not hold it forever - if CS is on cooldown, fire anyway. -bool ShouldDemolish(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(DEMOLISH)) return false; - if (!ctx.bot.is_ready(DEMOLISH)) return false; - if (ctx.bot.enemies_within(5.0f) == 0) return false; - if (ctx.bot.has_aura(COLOSSUS_SMASH_DEBUFF, ctx.bot.victim())) return true; - return !ctx.bot.knows_spell(COLOSSUS_SMASH) || !ctx.bot.is_ready(COLOSSUS_SMASH); -} -void DoDemolish(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(DEMOLISH, ctx.bot.victim()); -} - -bool ShouldBladestormAoe(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(BLADESTORM)) return false; - if (!ctx.bot.is_ready(BLADESTORM)) return false; - return ctx.aoe_preference || ctx.bot.enemies_within(8.0f) >= 3; -} -void DoBladestorm(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(BLADESTORM); } - -bool ShouldSweepingStrikes(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(SWEEPING_STRIKES)) return false; - if (!ctx.bot.is_ready(SWEEPING_STRIKES)) return false; - if (ctx.bot.has_aura(SWEEPING_STRIKES)) return false; - return ctx.aoe_preference || ctx.bot.enemies_within(8.0f) >= 2; -} -void DoSweepingStrikes(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(SWEEPING_STRIKES); } - -// ---- Damage ---- -bool ShouldExecute(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(EXECUTE)) return false; - if (!ctx.bot.is_ready(EXECUTE)) return false; - if (Rage(ctx) < 20) return false; - return TargetExecuteRange(ctx); -} -void DoExecute(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(EXECUTE, ctx.bot.victim()); -} - -bool ShouldMortalStrike(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(MORTAL_STRIKE)) return false; - return ctx.bot.is_ready(MORTAL_STRIKE); -} -void DoMortalStrike(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(MORTAL_STRIKE, ctx.bot.victim()); -} - -bool ShouldOverpower(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(OVERPOWER)) return false; - return ctx.bot.is_ready(OVERPOWER); -} -void DoOverpower(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(OVERPOWER, ctx.bot.victim()); -} - -bool ShouldRend(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(REND)) return false; - if (!ctx.bot.is_ready(REND)) return false; - // Track Rend itself, NOT Deep Wounds. Deep Wounds (262115) is the - // MS-proc bleed that re-applies every ~5s, so it almost never - // expires - gating Rend on DW caused Rend to drop ~30-40% of its - // intended uptime. In 12.1 the cast is 772 but the bleed it applies is - // still aura 388539; track that at the 30% pandemic window (~4.5s of a - // 15s bleed). - AuraEntry const* a = ctx.bot.find_aura(REND_BLEED_AURA, ctx.bot.victim()); - return !a || a->remaining.count() <= 4500; -} -void DoRend(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(REND, ctx.bot.victim()); -} - -// Wrecking Throw: 25y, 45s CD, ignores armor and shreds absorbs. Low in the -// ladder so it only fills a GCD nothing better wants (also our only ranged -// hit while closing on a target). -bool ShouldWreckingThrow(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(WRECKING_THROW)) return false; - return ctx.bot.is_ready(WRECKING_THROW); -} -void DoWreckingThrow(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(WRECKING_THROW, ctx.bot.victim()); -} - -bool ShouldCleave(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(CLEAVE)) return false; - if (!ctx.bot.is_ready(CLEAVE)) return false; - if (Rage(ctx) < 20) return false; - return ctx.aoe_preference || ctx.bot.enemies_within(8.0f) >= 3; -} -void DoCleave(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(CLEAVE); } - -bool ShouldSlam(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(SLAM)) return false; - return Rage(ctx) >= 20; -} -void DoSlam(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(SLAM, ctx.bot.victim()); -} - -bool AlwaysInCombat(ApPredicateContext const& ctx) { return ctx.bot.in_combat(); } -void DoAutoAttack(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - ObjectGuid t = ctx.bot.victim(); - if (t.IsEmpty()) t = ctx.bot.current_target(); - // Retaliate fallback (2026-06-17): in combat with no victim/target the bot - // looped "Engage auto attack" as a no-op while taking damage (the CombatLoop - // wedge cluster). Engage whatever is meleeing us (attackers are adjacent and - // reachable), else the nearest visible enemy, so combat actually resolves. - // Strictly additive: only runs when no target was already selected. - if (t.IsEmpty()) - for (auto const& u : ctx.bot.attackers()) - if (u.hp > 0) { t = u.guid; break; } - if (t.IsEmpty()) - for (auto const& u : ctx.bot.nearby_enemies()) - if (u.hp > 0 && u.in_los) { t = u.guid; break; } - if (!t.IsEmpty()) e.start_attack(t); -} - -// Rule table - order is meaningful. See the file header comment for the -// canonical ladder; the comments below restate each tier for quick scanning. -ApRule const kRules[] = { - // 1) Anti-CC immunity (must clear fear/sap before anything else can fire) - { ShouldBerserkerRage, DoBerserkerRage, "Berserker Rage (anti-fear)" }, - // 2) Spec defensive ladder - { ShouldDieByTheSword, DoDieByTheSword, "Die by the Sword (<=35%)" }, - { ShouldDefensiveStance, DoDefensiveStance, "Defensive Stance (<=30%)" }, - // 3) Interrupts - { ShouldPummel, DoPummel, "Pummel (interrupt)" }, - { ShouldStormBolt, DoStormBolt, "Storm Bolt (interrupt fb)" }, - // 4) Magic absorb - { ShouldSpellReflection, DoSpellReflection, "Spell Reflection" }, - // 5) Slow / CC - { ShouldShockwave, DoShockwave, "Shockwave (3+ AoE stun)" }, - { ShouldIntimidatingShout, DoIntimidatingShout, "Intimidating Shout (panic)" }, - { ShouldPiercingHowl, DoPiercingHowl, "Piercing Howl (PvP snare)" }, - { ShouldHamstring, DoHamstring, "Hamstring (slow)" }, - // 6) Maintenance / group utility - { ShouldBattleStance, DoBattleStance, "Battle Stance" }, - { ShouldBattleShout, DoBattleShout, "Battle Shout (group buff)" }, - { ShouldRallyingCry, DoRallyingCry, "Rallying Cry" }, - { ShouldIntervene, DoIntervene, "Intervene" }, - // 7) Self-heal / shield (cheap, GCD-locked, fire before CDs) - { ShouldIgnorePain, DoIgnorePain, "Ignore Pain" }, - { ShouldVictoryRush, DoVictoryRush, "Victory Rush" }, - { ShouldImpendingVictory, DoImpendingVictory, "Impending Victory" }, - // 8) Major offensive cooldowns (boss / multi-target gated) - { ShouldAvatar, DoAvatar, "Avatar" }, - { ShouldSweepingStrikes, DoSweepingStrikes, "Sweeping Strikes (2+)" }, - { ShouldBladestormAoe, DoBladestorm, "Bladestorm (3+ AoE)" }, - { ShouldColossusSmash, DoColossusSmash, "Colossus Smash" }, - { ShouldDemolish, DoDemolish, "Demolish (CS window)" }, - // 9) Rotation (signature MS-window first, then proc spends, then fillers) - { ShouldExecute, DoExecute, "Execute (window)" }, - { ShouldMortalStrike, DoMortalStrike, "Mortal Strike (signature)" }, - { ShouldOverpower, DoOverpower, "Overpower (proc)" }, - { ShouldRend, DoRend, "Rend (refresh bleed)" }, - { ShouldCleave, DoCleave, "Cleave (3+ AoE)" }, - { ShouldWreckingThrow, DoWreckingThrow, "Wrecking Throw" }, - { ShouldSlam, DoSlam, "Slam (rage spender)" }, - // 10) Auto-attack fallback - { AlwaysInCombat, DoAutoAttack, "Engage auto attack" }, -}; - -} // anonymous - -void RegisterApl_Warrior_Arms() -{ - constexpr uint32 SPEC_WARRIOR_ARMS = 71; - RegisterRotation(CLASS_WARRIOR, SPEC_WARRIOR_ARMS, ApRotation{kRules}); -} - -} // namespace Playerbot::Combat diff --git a/src/modules/PlayerbotV2/Combat/Apl/Apl_Warrior_Fury.cpp b/src/modules/PlayerbotV2/Combat/Apl/Apl_Warrior_Fury.cpp deleted file mode 100644 index 4e72685d1e..0000000000 --- a/src/modules/PlayerbotV2/Combat/Apl/Apl_Warrior_Fury.cpp +++ /dev/null @@ -1,513 +0,0 @@ -// Fury Warrior - WoW 12.1.0.69587 (Midnight) enterprise rotation. Dual-wield -// berserker with Enrage uptime via Bloodthirst / Rampage cycle, Raging Blow -// proc spending, Whirlwind cleave (Improved Whirlwind / Meat Cleaver auras -// for AoE), Recklessness + Avatar burst, Odyn's Fury / Bladestorm AoE bursts, -// Execute under 20% (35% with Massacre, any HP on a Sudden Death proc). -// -// Survival: Enraged Regen, Defensive Stance (<=30% HP, swapped back to -// Berserker Stance once recovered), Rallying Cry (group HP buff), Spell -// Reflection, Berserker Rage / Berserker Shout anti-fear, Impending Victory / -// Victory Rush. Group utility: Battle Shout, Intervene (peel), Storm Bolt -// stun. CC: Pummel interrupt, Storm Bolt fallback, Intimidating Shout fear, -// Piercing Howl AoE snare (PvP), Hamstring slow. -// -// Rule order (panic-first ladder, then offensive ladder): -// 1) Anti-CC immunity - Berserker Rage / Berserker Shout (fear/sap/incap break) -// 2) Spec defensives - Enraged Regen (<=35%), Defensive Stance (<=30%) -// 3) Interrupts - Pummel, Storm Bolt fallback -// 4) Magic absorb - Spell Reflection (enemy casting) -// 5) Slow / CC - Intimidating Shout, Piercing Howl, Hamstring -// 6) Group utility - Berserker Stance, Battle Shout, Rallying Cry, Intervene -// 7) Self heals - Victory Rush / Impending Victory -// 8) Major CDs - Recklessness, Avatar, Odyn's Fury, Bladestorm -// 9) Rotation - Rampage (Enrage), Execute (window), Bloodthirst, -// Raging Blow, Whirlwind -// 10) Auto-attack - engage fallback -// -// Validated spell IDs (WoW 12.1.0.69587): -// 23881 Bloodthirst | 85288 Raging Blow | 184367 Rampage -// 5308 Execute (Fury) | 190411 Whirlwind | 385059 Odyn's Fury -// 1719 Recklessness | 107574 Avatar | 227847 Bladestorm -// 184364 Enraged Regen | 386196 Berserker Stance| 386208 Defensive Stance -// 6552 Pummel | 107570 Storm Bolt | 5246 Intimidating Shout -// 12323 Piercing Howl | 1715 Hamstring | 18499 Berserker Rage -// 384100 Berserker Shout | 23920 Spell Reflection| 97462 Rallying Cry -// 202168 Impending Vict. | 34428 Victory Rush | 6673 Battle Shout -// 3411 Intervene -// Aura-only: 184361 Enrage | 52437 Sudden Death -// Passive gates: 206315 Massacre (Fury) -// -// Skipped spells (and why): -// 335096 Bloodbath - hero talent removed in 12.1 (113344 is an old -// bleed sub-spell, not castable) -// 315720 Onslaught - removed from the Fury tree in 12.1 -// 228920 Ravager - Arms / Protection tree only in 12.1 -// 118038 Die by the Sword - Arms tree only in 12.1 -// 190456 Ignore Pain - Protection tree only in 12.1 -// 184362 Enrage (BaseLevel=1) - Enrage talent grant aura, not the buff itself -// (real buff = 184361, applied by Bloodthirst/Rampage). -// 6343 Thunder Clap, 384110 Wrecking Throw, 46968 Shockwave -// - M+/optional picks not in the curated Fury raid build -// 6544 Heroic Leap, 1244088 Interpose -// - ground-target positioning the bot does not do -// 1229376 Single-Button Assistant - client convenience macro, not a rotation ability -// 100 Charge - handled in baseline rotation - -#include "../ApRegistry.h" -#include "../ApRotation.h" -#include "Bot/BotIntentEmitter.h" -#include "Bot/BotSnapshotView.h" -#include "Group/GroupSnapshot.h" -#include "SharedDefines.h" - -namespace Playerbot::Combat { - -namespace { - -// ---- Spell IDs (WoW 12.1.0.69587, validated against SpellName.csv) ---- -constexpr uint32 BLOODTHIRST = 23881; -constexpr uint32 RAGING_BLOW = 85288; -constexpr uint32 RAMPAGE = 184367; -constexpr uint32 EXECUTE_FURY = 5308; -constexpr uint32 WHIRLWIND = 190411; -constexpr uint32 ODYNS_FURY = 385059; // talent CD -constexpr uint32 RECKLESSNESS = 1719; -constexpr uint32 AVATAR = 107574; -constexpr uint32 BLADESTORM_FURY = 227847; // shared talent Bladestorm (12.1 id) -// Enrage damage buff aura applied by Bloodthirst (crit) or Rampage. Used to -// gate Rampage refresh - IMPORTANT: 184361 is the damage buff itself, NOT -// 184362 (which is the BaseLevel=1 talent grant aura - same name, different -// effect). Previous code used 184362 which never matched. -constexpr uint32 ENRAGE_AURA = 184361; -constexpr uint32 PUMMEL = 6552; -constexpr uint32 STORM_BOLT = 107570; -constexpr uint32 INTIMIDATING_SHOUT = 5246; -constexpr uint32 PIERCING_HOWL = 12323; // talent AoE snare (PvP peel) -constexpr uint32 HAMSTRING = 1715; -constexpr uint32 BERSERKER_RAGE = 18499; -constexpr uint32 BERSERKER_SHOUT = 384100; // talent - overrides Berserker Rage -constexpr uint32 BERSERKER_STANCE = 386196; // talent - default Fury stance -constexpr uint32 DEFENSIVE_STANCE = 386208; // talent - DR stance (panic swap) -constexpr uint32 ENRAGED_REGEN = 184364; -constexpr uint32 RALLYING_CRY = 97462; -constexpr uint32 SPELL_REFLECTION = 23920; -constexpr uint32 IMPENDING_VICTORY = 202168; -constexpr uint32 VICTORY_RUSH = 34428; -constexpr uint32 BATTLE_SHOUT = 6673; -constexpr uint32 INTERVENE = 3411; -// Aura / passive ids (never cast; predicates only). -constexpr uint32 SUDDEN_DEATH_AURA = 52437; // proc: Execute usable at any HP -constexpr uint32 MASSACRE = 206315; // Fury passive: Execute below 35% - -constexpr uint8 POWER_RAGE_IDX = 1; - -bool HasLiveTarget(ApPredicateContext const& ctx) -{ - return ctx.bot.in_combat() && !ctx.bot.victim().IsEmpty(); -} - -// Execute window: 20% baseline, 35% with the Massacre passive, any HP while -// a Sudden Death proc is up (both are [R] in the curated Fury build). -bool TargetExecuteRange(ApPredicateContext const& ctx) -{ - NearbyUnit const* t = ctx.bot.victim_info(); - if (!t || t->max_hp <= 0 || t->hp <= 0) return false; - if (ctx.bot.has_aura(SUDDEN_DEATH_AURA)) return true; - const int32 threshold = ctx.bot.knows_spell(MASSACRE) ? 35 : 20; - return (t->hp * 100) / t->max_hp <= threshold; -} - -bool BossLikeTargetEngaged(ApPredicateContext const& ctx) -{ - constexpr int32 kBossHpThreshold = 5'000'000; - NearbyUnit const* t = ctx.bot.victim_info(); - if (t && t->max_hp >= kBossHpThreshold) return true; - for (auto const& a : ctx.bot.raw().combat.attackers) - if (a.max_hp >= kBossHpThreshold) return true; - return false; -} - -int32 Rage(ApPredicateContext const& ctx) { return ctx.bot.power(POWER_RAGE_IDX); } - -bool HasEnrage(ApPredicateContext const& ctx) { return ctx.bot.has_aura(ENRAGE_AURA); } - -// Berserker Shout (talent) overrides Berserker Rage in the spellbook, so -// resolve which of the two the bot actually owns (same two-branch idiom as -// Victory Rush / Impending Victory). -uint32 BerserkerRageId(ApPredicateContext const& ctx) -{ - return ctx.bot.knows_spell(BERSERKER_SHOUT) ? BERSERKER_SHOUT : BERSERKER_RAGE; -} - -// ---- Anti-CC immunity (highest panic priority) ---- -bool ShouldBerserkerRage(ApPredicateContext const& ctx) -{ - const uint32 id = BerserkerRageId(ctx); - if (!ctx.bot.knows_spell(id)) return false; - if (!ctx.bot.is_ready(id)) return false; - // Berserker Rage clears (and grants 6s immunity to) Fear / Sap / - // Incapacitate / Disorient effects. MECHANIC_FEAR=5, - // MECHANIC_DISORIENTED=2, MECHANIC_HORROR=24, MECHANIC_SAPPED=30. - return ctx.bot.has_mechanic(5) || ctx.bot.has_mechanic(2) || - ctx.bot.has_mechanic(24) || ctx.bot.has_mechanic(30); -} -void DoBerserkerRage(ApPredicateContext const& ctx, BotIntentEmitter& e) { e.cast(BerserkerRageId(ctx)); } - -// ---- Survival ---- -bool ShouldEnragedRegen(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(ENRAGED_REGEN)) return false; - if (!ctx.bot.is_ready(ENRAGED_REGEN)) return false; - return ctx.bot.hp_pct() <= 35; -} -void DoEnragedRegen(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(ENRAGED_REGEN); } - -// Defensive Stance: Fury's only flat DR in 12.1 (Die by the Sword is Arms-only -// now). Swap in at <=30% HP; ShouldBerserkerStance swaps back once HP has -// recovered (>=70%) or combat ends. The 3s stance category cooldown prevents -// ping-pong. -bool ShouldDefensiveStance(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(DEFENSIVE_STANCE)) return false; - if (!ctx.bot.is_ready(DEFENSIVE_STANCE)) return false; - if (ctx.bot.has_aura(DEFENSIVE_STANCE)) return false; - return ctx.bot.hp_pct() <= 30; -} -void DoDefensiveStance(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(DEFENSIVE_STANCE); } - -bool ShouldRallyingCry(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(RALLYING_CRY)) return false; - if (!ctx.bot.is_ready(RALLYING_CRY)) return false; - auto const* low = ctx.group.lowest_hp_on_map(ctx.bot.map_id(), Role::Unknown, ctx.bot.raw().position.x, ctx.bot.raw().position.y, ctx.bot.raw().position.z, 45.0f); - if (low && low->online && low->hp > 0) - return (low->hp * 100) / low->max_hp <= 35; - return ctx.bot.hp_pct() <= 50; -} -void DoRallyingCry(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(RALLYING_CRY); } - -bool ShouldImpendingVictory(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(IMPENDING_VICTORY)) return false; - if (!ctx.bot.is_ready(IMPENDING_VICTORY)) return false; - return ctx.bot.hp_pct() <= 70; -} -void DoImpendingVictory(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(IMPENDING_VICTORY, ctx.bot.victim()); -} - -bool ShouldVictoryRush(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (ctx.bot.knows_spell(IMPENDING_VICTORY)) return false; - if (!ctx.bot.knows_spell(VICTORY_RUSH)) return false; - return ctx.bot.hp_pct() <= 80; -} -void DoVictoryRush(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(VICTORY_RUSH, ctx.bot.victim()); -} - -bool ShouldSpellReflection(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(SPELL_REFLECTION)) return false; - if (!ctx.bot.is_ready(SPELL_REFLECTION)) return false; - return ctx.bot.interruptible_caster() != nullptr; -} -void DoSpellReflection(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(SPELL_REFLECTION); } - -// ---- Maintenance ---- -// Berserker Stance is the Fury default. Re-enter it when no stance is up, or -// when Defensive Stance was taken as a panic swap and HP has recovered. -bool ShouldBerserkerStance(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(BERSERKER_STANCE)) return false; - if (!ctx.bot.is_ready(BERSERKER_STANCE)) return false; - if (ctx.bot.has_aura(BERSERKER_STANCE)) return false; - if (!ctx.bot.has_aura(DEFENSIVE_STANCE)) return true; - return !ctx.bot.in_combat() || ctx.bot.hp_pct() >= 70; -} -void DoBerserkerStance(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(BERSERKER_STANCE); } - -bool ShouldBattleShout(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(BATTLE_SHOUT)) return false; - return !ctx.bot.has_aura(BATTLE_SHOUT); -} -void DoBattleShout(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(BATTLE_SHOUT); } - -// ---- Group utility ---- -bool ShouldIntervene(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(INTERVENE)) return false; - if (!ctx.bot.is_ready(INTERVENE)) return false; - auto const* low = ctx.group.lowest_hp_on_map(ctx.bot.map_id(), Role::Unknown, ctx.bot.raw().position.x, ctx.bot.raw().position.y, ctx.bot.raw().position.z, 45.0f); - if (!low || !low->online || low->hp <= 0) return false; - if (low->guid == ctx.bot.raw().guid) return false; - return (low->hp * 100) / low->max_hp <= 30; -} -void DoIntervene(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* low = ctx.group.lowest_hp_on_map(ctx.bot.map_id(), Role::Unknown, ctx.bot.raw().position.x, ctx.bot.raw().position.y, ctx.bot.raw().position.z, 45.0f)) - e.cast(INTERVENE, low->guid); -} - -// ---- Interrupt / CC ---- -bool ShouldPummel(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(PUMMEL)) return false; - if (!ctx.bot.is_ready(PUMMEL)) return false; - const bool pvp = ctx.pvp.in_battleground || ctx.pvp.in_arena; - return ctx.bot.kick_target(pvp, 5.0f) != nullptr; -} -void DoPummel(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - const bool pvp = ctx.pvp.in_battleground || ctx.pvp.in_arena; - if (auto const* c = ctx.bot.kick_target(pvp, 5.0f)) - e.cast(PUMMEL, c->guid); -} - -bool ShouldStormBolt(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(STORM_BOLT)) return false; - if (!ctx.bot.is_ready(STORM_BOLT)) return false; - if (ctx.bot.is_ready(PUMMEL)) return false; - return ctx.bot.interruptible_caster() != nullptr; -} -void DoStormBolt(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* c = ctx.bot.interruptible_caster()) - e.cast(STORM_BOLT, c->guid); -} - -bool ShouldIntimidatingShout(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(INTIMIDATING_SHOUT)) return false; - if (!ctx.bot.is_ready(INTIMIDATING_SHOUT)) return false; - return ctx.bot.enemies_within(8.0f) >= 2 && ctx.bot.hp_pct() <= 50; -} -void DoIntimidatingShout(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(INTIMIDATING_SHOUT); } - -// Piercing Howl: 8s AoE snare on a 90s CD. PvP-only - in PvE a mass snare -// on melee-range mobs is a wasted GCD, in BGs it peels a whole pack off a -// carrier / kites a chase. -bool ShouldPiercingHowl(ApPredicateContext const& ctx) -{ - if (!ctx.pvp.in_battleground && !ctx.pvp.in_arena) return false; - if (!ctx.bot.knows_spell(PIERCING_HOWL)) return false; - if (!ctx.bot.is_ready(PIERCING_HOWL)) return false; - return ctx.bot.enemies_within(10.0f) >= 2; -} -void DoPiercingHowl(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(PIERCING_HOWL); } - -// FC peel: in a BG with a friendly carrier, prefer slowing an enemy on the -// carrier over slowing our own victim. See Apl_Warrior_Arms.cpp for the -// rationale (same pattern; kept duplicated rather than shared so each spec -// can tune its Rage gates independently). -NearbyUnit const* PickHamstringTarget(ApPredicateContext const& ctx) -{ - if (ctx.pvp.in_battleground && !ctx.pvp.friendly_flag_carrier.IsEmpty()) - { - if (NearbyUnit const* peel = ctx.bot.enemy_near_friendly_carrier(8.0f)) - { - if (!ctx.bot.has_aura(HAMSTRING, peel->guid)) return peel; - } - } - return ctx.bot.victim_info(); -} - -bool ShouldHamstring(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(HAMSTRING)) return false; - if (!ctx.bot.is_ready(HAMSTRING)) return false; - if (Rage(ctx) < 30) return false; - NearbyUnit const* t = PickHamstringTarget(ctx); - if (!t || t->hp <= 0) return false; - if (ctx.bot.has_aura(HAMSTRING, t->guid)) return false; - const bool fc_peel = ctx.pvp.in_battleground && - !ctx.pvp.friendly_flag_carrier.IsEmpty() && - t != ctx.bot.victim_info(); - return fc_peel || ctx.bot.enemies_within(8.0f) == 0; -} -void DoHamstring(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (NearbyUnit const* t = PickHamstringTarget(ctx)) - e.cast(HAMSTRING, t->guid); -} - -// ---- Major offensive cooldowns ---- -bool ShouldRecklessness(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(RECKLESSNESS)) return false; - if (!ctx.bot.is_ready(RECKLESSNESS)) return false; - return BossLikeTargetEngaged(ctx) || ctx.bot.enemies_within(10.0f) >= 3; -} -void DoRecklessness(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(RECKLESSNESS); } - -bool ShouldAvatar(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(AVATAR)) return false; - if (!ctx.bot.is_ready(AVATAR)) return false; - return BossLikeTargetEngaged(ctx) || ctx.bot.enemies_within(10.0f) >= 3; -} -void DoAvatar(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(AVATAR); } - -bool ShouldOdynsFury(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(ODYNS_FURY)) return false; - if (!ctx.bot.is_ready(ODYNS_FURY)) return false; - return true; -} -void DoOdynsFury(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(ODYNS_FURY); } - -bool ShouldBladestormAoe(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(BLADESTORM_FURY)) return false; - if (!ctx.bot.is_ready(BLADESTORM_FURY)) return false; - return ctx.aoe_preference || ctx.bot.enemies_within(8.0f) >= 3; -} -void DoBladestorm(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(BLADESTORM_FURY); } - -// ---- Damage ---- -// Rampage: 80-rage spender that applies / refreshes Enrage. We pool to 100 -// before spending unless Enrage is about to drop (<=1.5s) - refreshing it -// is worth more than the extra Rampage damage from pooling further. -bool ShouldRampage(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(RAMPAGE)) return false; - if (!ctx.bot.is_ready(RAMPAGE)) return false; - if (Rage(ctx) < 80) return false; - AuraEntry const* a = ctx.bot.find_aura(ENRAGE_AURA); - return !a || a->remaining.count() <= 1500 || Rage(ctx) >= 100; -} -void DoRampage(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(RAMPAGE, ctx.bot.victim()); -} - -bool ShouldExecute(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(EXECUTE_FURY)) return false; - if (!ctx.bot.is_ready(EXECUTE_FURY)) return false; - return TargetExecuteRange(ctx); -} -void DoExecute(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(EXECUTE_FURY, ctx.bot.victim()); -} - -bool ShouldBloodthirst(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(BLOODTHIRST)) return false; - return ctx.bot.is_ready(BLOODTHIRST); -} -void DoBloodthirst(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(BLOODTHIRST, ctx.bot.victim()); -} - -bool ShouldRagingBlow(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(RAGING_BLOW)) return false; - return ctx.bot.is_ready(RAGING_BLOW); -} -void DoRagingBlow(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(RAGING_BLOW, ctx.bot.victim()); -} - -// Whirlwind: AoE swing AND single-target buff (next abilities cleave). With -// Meat Cleaver talent the single-target buff is a meaningful DPS gain even -// vs one target, but it's a Rage cost - only spend when AoE is happening -// or we've got Rage flooding to dump. -bool ShouldWhirlwind(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(WHIRLWIND)) return false; - return ctx.bot.enemies_within(8.0f) >= 2 || Rage(ctx) >= 30; -} -void DoWhirlwind(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(WHIRLWIND); } - -bool AlwaysInCombat(ApPredicateContext const& ctx) { return ctx.bot.in_combat(); } -void DoAutoAttack(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - ObjectGuid t = ctx.bot.victim(); - if (t.IsEmpty()) t = ctx.bot.current_target(); - // Retaliate fallback (2026-06-17): in combat with no victim/target the bot - // looped "Engage auto attack" as a no-op while taking damage (the CombatLoop - // wedge cluster). Engage whatever is meleeing us (attackers are adjacent and - // reachable), else the nearest visible enemy, so combat actually resolves. - // Strictly additive: only runs when no target was already selected. - if (t.IsEmpty()) - for (auto const& u : ctx.bot.attackers()) - if (u.hp > 0) { t = u.guid; break; } - if (t.IsEmpty()) - for (auto const& u : ctx.bot.nearby_enemies()) - if (u.hp > 0 && u.in_los) { t = u.guid; break; } - if (!t.IsEmpty()) e.start_attack(t); -} - -// Rule table - order is meaningful. See the file header comment for the -// canonical ladder; the comments below restate each tier for quick scanning. -ApRule const kRules[] = { - // 1) Anti-CC immunity - { ShouldBerserkerRage, DoBerserkerRage, "Berserker Rage (anti-fear)" }, - // 2) Spec defensive ladder - { ShouldEnragedRegen, DoEnragedRegen, "Enraged Regen (<=35%)" }, - { ShouldDefensiveStance, DoDefensiveStance, "Defensive Stance (<=30%)" }, - // 3) Interrupts - { ShouldPummel, DoPummel, "Pummel (interrupt)" }, - { ShouldStormBolt, DoStormBolt, "Storm Bolt (interrupt fb)" }, - // 4) Magic absorb - { ShouldSpellReflection, DoSpellReflection, "Spell Reflection" }, - // 5) Slow / CC - { ShouldIntimidatingShout, DoIntimidatingShout, "Intimidating Shout (panic)" }, - { ShouldPiercingHowl, DoPiercingHowl, "Piercing Howl (PvP snare)" }, - { ShouldHamstring, DoHamstring, "Hamstring (slow)" }, - // 6) Maintenance / group utility - { ShouldBerserkerStance, DoBerserkerStance, "Berserker Stance" }, - { ShouldBattleShout, DoBattleShout, "Battle Shout (group buff)" }, - { ShouldRallyingCry, DoRallyingCry, "Rallying Cry" }, - { ShouldIntervene, DoIntervene, "Intervene" }, - // 7) Self-heal (cheap, GCD-locked, fire before CDs) - { ShouldVictoryRush, DoVictoryRush, "Victory Rush" }, - { ShouldImpendingVictory, DoImpendingVictory, "Impending Victory" }, - // 8) Major offensive cooldowns - { ShouldRecklessness, DoRecklessness, "Recklessness" }, - { ShouldAvatar, DoAvatar, "Avatar" }, - { ShouldOdynsFury, DoOdynsFury, "Odyn's Fury" }, - { ShouldBladestormAoe, DoBladestorm, "Bladestorm (3+ AoE)" }, - // 9) Rotation - Rampage (Enrage maintenance) -> Execute window -> Bloodthirst - // -> Raging Blow -> Whirlwind (filler/AoE) - { ShouldRampage, DoRampage, "Rampage (Enrage)" }, - { ShouldExecute, DoExecute, "Execute (window)" }, - { ShouldBloodthirst, DoBloodthirst, "Bloodthirst" }, - { ShouldRagingBlow, DoRagingBlow, "Raging Blow" }, - { ShouldWhirlwind, DoWhirlwind, "Whirlwind (filler/AoE)" }, - // 10) Auto-attack fallback - { AlwaysInCombat, DoAutoAttack, "Engage auto attack" }, -}; - -} // anonymous - -void RegisterApl_Warrior_Fury() -{ - constexpr uint32 SPEC_WARRIOR_FURY = 72; - RegisterRotation(CLASS_WARRIOR, SPEC_WARRIOR_FURY, ApRotation{kRules}); -} - -} // namespace Playerbot::Combat diff --git a/src/modules/PlayerbotV2/Combat/Apl/Apl_Warrior_Protection.cpp b/src/modules/PlayerbotV2/Combat/Apl/Apl_Warrior_Protection.cpp deleted file mode 100644 index bb39f0a122..0000000000 --- a/src/modules/PlayerbotV2/Combat/Apl/Apl_Warrior_Protection.cpp +++ /dev/null @@ -1,653 +0,0 @@ -// Protection Warrior - WoW 12.1.0.69587 (Midnight) enterprise rotation. -// Shield-and-board tank with Shield Block active mitigation, Ignore Pain rage -// absorb, and the Shield Slam / Thunder Clap / Revenge rotation with Demolish -// (Colossus hero tree) as the burst hit. Survival ladder: Shield Wall (40% DR; -// Last Stand is a passive rider on it in 12.1) -> Spell Reflection (magic -// absorb) -> Victory Rush / Impending Victory (heal). Defensive Stance kept -// up as the tank's default stance. Group utility: Battle Shout, Rallying Cry, -// Intervene (peel), Demoralizing Shout (damage debuff). CC: Pummel, Storm -// Bolt, Shockwave AoE stun, Intimidating Shout fear, Piercing Howl snare -// (PvP). Ranged engage: Heroic Throw (pull), Wrecking Throw, Shield Charge -// (gap close), Champion's Spear (talent ground AoE). -// -// Rule order (tank panic-first ladder, then threat/mitigation, then offense): -// 1) Anti-CC immunity - Berserker Rage / Berserker Shout (fear/sap/incap break) -// 2) Panic CDs - Shield Wall (<=35%, pre-emptive on pile-on) -// 3) Interrupts - Pummel, Storm Bolt fallback -// 4) Magic absorb - Spell Reflection -// 5) Threat / peel - Taunt (mob on healer), Challenging / Disrupting Shout (4+), -// Intervene (peel ally) -// 6) Active mitigation - Shield Block (rage), Ignore Pain (rage absorb), -// Demoralizing Shout (incoming reduction) -// 7) Self heals - Victory Rush / Impending Victory -// 8) Slow / CC - Shockwave, Intimidating Shout, Piercing Howl -// 9) Group utility - Defensive Stance, Battle Shout, Rallying Cry -// 10) Major CDs - Avatar, Ravager, Champion's Spear, Shield Charge, Demolish -// 11) Rotation - Execute (window), Shield Slam, Thunder Clap, -// Revenge, Wrecking Throw, Heroic Throw, Devastate -// 12) Auto-attack - engage fallback -// -// Validated spell IDs (WoW 12.1.0.69587): -// 23922 Shield Slam | 6343 Thunder Clap | 6572 Revenge -// 20243 Devastate | 163201 Execute (Prot) | 2565 Shield Block (CASTABLE) -// 190456 Ignore Pain | 871 Shield Wall | 386208 Defensive Stance -// 107574 Avatar | 385952 Shield Charge | 228920 Ravager -// 436358 Demolish | 384110 Wrecking Throw | 376079 Champion's Spear -// 1160 Demoralizing Shout | 46968 Shockwave | 107570 Storm Bolt -// 5246 Intimidating Shout | 12323 Piercing Howl | 18499 Berserker Rage -// 384100 Berserker Shout | 23920 Spell Reflection| 6552 Pummel -// 355 Taunt | 1161 Challenging Shout| 386071 Disrupting Shout -// 3411 Intervene | 6673 Battle Shout | 97462 Rallying Cry -// 202168 Impending Victory | 34428 Victory Rush | 57755 Heroic Throw -// Aura-only: 52437 Sudden Death -// Passive gates: 236279 Devastator | 281001 Massacre -// -// Skipped spells (and why): -// 12975 Last Stand (cast) - no longer castable; 12.1 Last Stand (1243659) is -// a passive that rides on Shield Wall (max HP + heal) -// 392966 Spell Block - removed from the Protection tree in 12.1 -// 198304 Intercept - removed in 12.1 (Intervene 3411 remains) -// 386164 Battle Stance - DPS stance; the tank stays in Defensive Stance -// 6544 Heroic Leap - ground-target positioning the bot does not do -// 231847 Shield Block (passive) - Prot SPEC-grant aura adding rage on block; -// distinct from the castable 2565 we use here -// 5301 Revenge! - passive proc that makes Revenge free / -// instant; we use the base Revenge cast (6572) -// 137048 Protection Warrior - spec aura container (passive) -// 1229376 Single-Button Assistant - client convenience macro, not a rotation ability -// 100 Charge - handled in baseline rotation - -#include "../ApRegistry.h" -#include "../ApRotation.h" -#include "Bot/BotIntentEmitter.h" -#include "Bot/BotSnapshotView.h" -#include "Group/GroupSnapshot.h" -#include "SharedDefines.h" - -namespace Playerbot::Combat { - -namespace { - -// ---- Spell IDs (WoW 12.1.0.69587, validated against SpellName.csv) ---- -constexpr uint32 SHIELD_SLAM = 23922; -constexpr uint32 THUNDER_CLAP = 6343; -constexpr uint32 REVENGE = 6572; -constexpr uint32 DEVASTATE = 20243; // replaced by the Devastator passive when taken -constexpr uint32 EXECUTE_PROT = 163201; -// Castable Shield Block (the active mitigation we manage). Distinct from the -// Prot spec passive Shield Block (231847) which is auto-granted and only adds -// rage gain on block - it doesn't replace the castable. -constexpr uint32 SHIELD_BLOCK = 2565; -constexpr uint32 IGNORE_PAIN = 190456; -constexpr uint32 SHIELD_WALL = 871; // Last Stand (1243659) is a passive rider on this in 12.1 -constexpr uint32 DEFENSIVE_STANCE = 386208; // talent - tank default stance -// Avatar uses the shared 107574 id. The previous value 401150 was bogus - -// no row in SpellName.csv 12.0 - so the rule never fired. -constexpr uint32 AVATAR = 107574; -constexpr uint32 SHIELD_CHARGE = 385952; // talent - gap close + dmg + Shield Block -constexpr uint32 RAVAGER = 228920; // talent ground AoE -constexpr uint32 DEMOLISH = 436358; // Colossus hero tree - 2s channel burst -constexpr uint32 WRECKING_THROW = 384110; // talent - 25y armor-ignoring throw -constexpr uint32 DEMORALIZING_SHOUT = 1160; // damage-dealt debuff -constexpr uint32 SHOCKWAVE = 46968; -constexpr uint32 STORM_BOLT = 107570; -constexpr uint32 INTIMIDATING_SHOUT = 5246; -constexpr uint32 PIERCING_HOWL = 12323; // talent AoE snare (PvP peel) -constexpr uint32 BERSERKER_RAGE = 18499; -constexpr uint32 BERSERKER_SHOUT = 384100; // talent - overrides Berserker Rage -constexpr uint32 SPELL_REFLECTION = 23920; -constexpr uint32 PUMMEL = 6552; -constexpr uint32 TAUNT = 355; -constexpr uint32 CHALLENGING_SHOUT = 1161; -constexpr uint32 DISRUPTING_SHOUT = 386071; // talent - overrides Challenging Shout (+AoE interrupt) -constexpr uint32 INTERVENE = 3411; -constexpr uint32 HEROIC_THROW = 57755; // ranged pull (~30y) -constexpr uint32 CHAMPIONS_SPEAR = 376079; // talent ground AoE root -constexpr uint32 BATTLE_SHOUT = 6673; -constexpr uint32 RALLYING_CRY = 97462; -constexpr uint32 IMPENDING_VICTORY = 202168; -constexpr uint32 VICTORY_RUSH = 34428; -// Aura / passive ids (never cast; predicates only). -constexpr uint32 SUDDEN_DEATH_AURA = 52437; // proc: Execute usable at any HP -constexpr uint32 MASSACRE = 281001; // passive: Execute usable below 35% -constexpr uint32 DEVASTATOR = 236279; // passive: auto-attacks replace Devastate - -constexpr uint8 POWER_RAGE_IDX = 1; - -bool HasLiveTarget(ApPredicateContext const& ctx) -{ - return ctx.bot.in_combat() && !ctx.bot.victim().IsEmpty(); -} - -// Execute window: 20% baseline, 35% with the Massacre passive, any HP while -// a Sudden Death proc is up (Sudden Death is [R] in the curated Prot build). -bool TargetExecuteRange(ApPredicateContext const& ctx) -{ - NearbyUnit const* t = ctx.bot.victim_info(); - if (!t || t->max_hp <= 0 || t->hp <= 0) return false; - if (ctx.bot.has_aura(SUDDEN_DEATH_AURA)) return true; - const int32 threshold = ctx.bot.knows_spell(MASSACRE) ? 35 : 20; - return (t->hp * 100) / t->max_hp <= threshold; -} - -bool BossLikeTargetEngaged(ApPredicateContext const& ctx) -{ - constexpr int32 kBossHpThreshold = 5'000'000; - NearbyUnit const* t = ctx.bot.victim_info(); - if (t && t->max_hp >= kBossHpThreshold) return true; - for (auto const& a : ctx.bot.raw().combat.attackers) - if (a.max_hp >= kBossHpThreshold) return true; - return false; -} - -int32 Rage(ApPredicateContext const& ctx) { return ctx.bot.power(POWER_RAGE_IDX); } - -// Berserker Shout (talent) overrides Berserker Rage in the spellbook, so -// resolve which of the two the bot actually owns (same two-branch idiom as -// Victory Rush / Impending Victory). -uint32 BerserkerRageId(ApPredicateContext const& ctx) -{ - return ctx.bot.knows_spell(BERSERKER_SHOUT) ? BERSERKER_SHOUT : BERSERKER_RAGE; -} - -// ---- Anti-CC immunity ---- -bool ShouldBerserkerRage(ApPredicateContext const& ctx) -{ - const uint32 id = BerserkerRageId(ctx); - if (!ctx.bot.knows_spell(id)) return false; - if (!ctx.bot.is_ready(id)) return false; - // MECHANIC_FEAR=5, MECHANIC_DISORIENTED=2, MECHANIC_HORROR=24, - // MECHANIC_SAPPED=30. 6s immunity window. - return ctx.bot.has_mechanic(5) || ctx.bot.has_mechanic(2) || - ctx.bot.has_mechanic(24) || ctx.bot.has_mechanic(30); -} -void DoBerserkerRage(ApPredicateContext const& ctx, BotIntentEmitter& e) { e.cast(BerserkerRageId(ctx)); } - -// ---- Panic CDs ---- -// PRE-EMPTIVE-ON-PILE-ON (2026-06-27). A large simultaneous melee pile-on -// (e.g. the Deadmines harbor deck: ~24 Defias Pirates LEAP-CLEAVE on aggro, -// taking the L30 tank 87%->dead in ~15s) blows past a purely-reactive HP gate -// before the cooldown can land. So: pop Shield Wall the instant a heavy pile -// engages while HP is still high, with a hard <=20% floor that can never be -// withheld into a death. Keyed on fightable_attackers_count() (stalker-free) -// so the untargetable 49521 Lightning Stalker flood can't trivially trip it -// every tick. K=4 attackers; the HP co-gate keeps it from burning on trivial -// pulls. In 12.1 Last Stand is no longer a separate button - the passive -// (1243659) adds its max-HP boost + heal to every Shield Wall - so Shield Wall -// is the single major DR and carries both the pre-emptive and reactive gates. -constexpr size_t kPileOnAttackers = 4; - -bool ShouldShieldWall(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(SHIELD_WALL)) return false; - if (!ctx.bot.is_ready(SHIELD_WALL)) return false; - // Unconditional death-floor: never withhold Shield Wall into a death. - if (ctx.bot.hp_pct() <= 20) return true; - // Pre-emptive (2026-06-27): fire when a HEAVY pile engages while HP is still - // high so the 40% DR covers the burst window instead of reacting at 35% (one - // heal-tick from death vs the ~930 HP/s harbor pull). Key on enemies_within - // (NOT only fightable_attackers_count): at the Deadmines harbor the killing - // ring is untargetable 49521 stalkers so fightable reads ~0-2, while the real - // leap-cleave Defias register as raw nearby hostiles. The high threshold (6) - // + in_combat gate keep it off trivial pulls. - if ((ctx.bot.enemies_within(10.0f) >= 6 || - ctx.bot.fightable_attackers_count() >= kPileOnAttackers) && - ctx.bot.hp_pct() <= 80) - return true; - // Reactive panic raised 25 -> 35 so it lands before a fast burst kills. - return ctx.bot.hp_pct() <= 35; -} -void DoShieldWall(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(SHIELD_WALL); } - -// ---- Magic absorb ---- -bool ShouldSpellReflection(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(SPELL_REFLECTION)) return false; - if (!ctx.bot.is_ready(SPELL_REFLECTION)) return false; - return ctx.bot.interruptible_caster() != nullptr; -} -void DoSpellReflection(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(SPELL_REFLECTION); } - -// ---- Threat / peel ---- -bool ShouldTaunt(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(TAUNT)) return false; - if (!ctx.bot.is_ready(TAUNT)) return false; - return ctx.bot.untaunted_enemy() != nullptr; -} -void DoTaunt(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* t = ctx.bot.untaunted_enemy()) - e.cast(TAUNT, t->guid); -} - -// Disrupting Shout (talent) overrides Challenging Shout in the spellbook and -// adds an AoE interrupt on top of the AoE taunt. Resolve which one is owned. -uint32 ChallengingShoutId(ApPredicateContext const& ctx) -{ - return ctx.bot.knows_spell(DISRUPTING_SHOUT) ? DISRUPTING_SHOUT : CHALLENGING_SHOUT; -} - -bool ShouldChallengingShout(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - const uint32 id = ChallengingShoutId(ctx); - if (!ctx.bot.knows_spell(id)) return false; - if (!ctx.bot.is_ready(id)) return false; - int n = 0; - for (auto const& u : ctx.bot.raw().combat.nearby_enemies) - if (u.hp > 0) ++n; - return n >= 4; -} -void DoChallengingShout(ApPredicateContext const& ctx, BotIntentEmitter& e) { e.cast(ChallengingShoutId(ctx)); } - -// ---- Active mitigation ---- -bool ShouldShieldBlock(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(SHIELD_BLOCK)) return false; - if (!ctx.bot.is_ready(SHIELD_BLOCK)) return false; - // Rage gate lowered 30 -> 20 (2026-06-27): on a fresh big pull the tank - // enters combat rage-starved, so the old >=30 gate locked active mitigation - // out for the first several seconds - exactly the burst window. Always- - // valuable cooldown, so a slightly earlier fire is strictly better. - if (Rage(ctx) < 20) return false; - return !ctx.bot.has_aura(SHIELD_BLOCK); -} -void DoShieldBlock(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(SHIELD_BLOCK); } - -bool ShouldIgnorePain(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(IGNORE_PAIN)) return false; - if (!ctx.bot.is_ready(IGNORE_PAIN)) return false; - if (ctx.bot.has_aura(IGNORE_PAIN)) return false; - // Under a heavy pile-on, accept the absorb at >=20 rage so it is usable in - // the rage-starved opening seconds (otherwise the >=40 gate whiffs the - // burst window); for normal pulls keep the standard >=40 gate. - const int32 rage = Rage(ctx); - // enemies_within co-signal (2026-06-27): at the stalker-dominated harbor the - // pile-on fightable count reads ~0-2 (untargetable 49521 flood), so the - // rage-starve relief branch never fired and Ignore Pain whiffed the burst. - // Count raw nearby hostiles too so the >=20-rage early-absorb path triggers. - if (ctx.bot.fightable_attackers_count() >= kPileOnAttackers || - ctx.bot.enemies_within(10.0f) >= 6) - { - if (rage < 20) return false; - } - else if (rage < 40) - return false; - return ctx.bot.hp_pct() < 90; -} -void DoIgnorePain(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(IGNORE_PAIN); } - -bool ShouldDemoralizingShout(ApPredicateContext const& ctx) -{ - if (!ctx.bot.in_combat()) return false; - if (!ctx.bot.knows_spell(DEMORALIZING_SHOUT)) return false; - if (!ctx.bot.is_ready(DEMORALIZING_SHOUT)) return false; - return ctx.bot.attackers_count() >= 1; -} -void DoDemoralizingShout(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(DEMORALIZING_SHOUT); } - -// ---- Self heal ---- -bool ShouldImpendingVictory(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(IMPENDING_VICTORY)) return false; - if (!ctx.bot.is_ready(IMPENDING_VICTORY)) return false; - return ctx.bot.hp_pct() <= 70; -} -void DoImpendingVictory(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(IMPENDING_VICTORY, ctx.bot.victim()); -} - -bool ShouldVictoryRush(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (ctx.bot.knows_spell(IMPENDING_VICTORY)) return false; - if (!ctx.bot.knows_spell(VICTORY_RUSH)) return false; - return ctx.bot.hp_pct() <= 80; -} -void DoVictoryRush(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(VICTORY_RUSH, ctx.bot.victim()); -} - -// ---- Interrupt / CC ---- -bool ShouldPummel(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(PUMMEL)) return false; - if (!ctx.bot.is_ready(PUMMEL)) return false; - const bool pvp = ctx.pvp.in_battleground || ctx.pvp.in_arena; - return ctx.bot.kick_target(pvp, 5.0f) != nullptr; -} -void DoPummel(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - const bool pvp = ctx.pvp.in_battleground || ctx.pvp.in_arena; - if (auto const* c = ctx.bot.kick_target(pvp, 5.0f)) - e.cast(PUMMEL, c->guid); -} - -bool ShouldStormBolt(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(STORM_BOLT)) return false; - if (!ctx.bot.is_ready(STORM_BOLT)) return false; - if (ctx.bot.is_ready(PUMMEL)) return false; - return ctx.bot.interruptible_caster() != nullptr; -} -void DoStormBolt(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* c = ctx.bot.interruptible_caster()) - e.cast(STORM_BOLT, c->guid); -} - -bool ShouldShockwave(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(SHOCKWAVE)) return false; - if (!ctx.bot.is_ready(SHOCKWAVE)) return false; - return ctx.aoe_preference || ctx.bot.enemies_within(10.0f) >= 3; -} -void DoShockwave(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(SHOCKWAVE); } - -bool ShouldIntimidatingShout(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(INTIMIDATING_SHOUT)) return false; - if (!ctx.bot.is_ready(INTIMIDATING_SHOUT)) return false; - return ctx.bot.enemies_within(8.0f) >= 2 && ctx.bot.hp_pct() <= 50; -} -void DoIntimidatingShout(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(INTIMIDATING_SHOUT); } - -// Piercing Howl: 8s AoE snare on a 90s CD. PvP-only - in PvE a tank wants -// mobs ON it, in BGs it peels a whole pack off a carrier / kites a chase. -bool ShouldPiercingHowl(ApPredicateContext const& ctx) -{ - if (!ctx.pvp.in_battleground && !ctx.pvp.in_arena) return false; - if (!ctx.bot.knows_spell(PIERCING_HOWL)) return false; - if (!ctx.bot.is_ready(PIERCING_HOWL)) return false; - return ctx.bot.enemies_within(10.0f) >= 2; -} -void DoPiercingHowl(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(PIERCING_HOWL); } - -// ---- Maintenance / group utility ---- -// Defensive Stance is the tank default (flat DR). Keep it up; no stance -// dance into Battle Stance for damage - survivability first for a bot tank. -bool ShouldDefensiveStance(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(DEFENSIVE_STANCE)) return false; - if (!ctx.bot.is_ready(DEFENSIVE_STANCE)) return false; - return !ctx.bot.has_aura(DEFENSIVE_STANCE); -} -void DoDefensiveStance(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(DEFENSIVE_STANCE); } - -bool ShouldBattleShout(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(BATTLE_SHOUT)) return false; - return !ctx.bot.has_aura(BATTLE_SHOUT); -} -void DoBattleShout(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(BATTLE_SHOUT); } - -bool ShouldRallyingCry(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(RALLYING_CRY)) return false; - if (!ctx.bot.is_ready(RALLYING_CRY)) return false; - auto const* low = ctx.group.lowest_hp_on_map(ctx.bot.map_id(), Role::Unknown, ctx.bot.raw().position.x, ctx.bot.raw().position.y, ctx.bot.raw().position.z, 45.0f); - if (low && low->online && low->hp > 0) - return (low->hp * 100) / low->max_hp <= 35; - return false; -} -void DoRallyingCry(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(RALLYING_CRY); } - -bool ShouldIntervene(ApPredicateContext const& ctx) -{ - if (!ctx.bot.knows_spell(INTERVENE)) return false; - if (!ctx.bot.is_ready(INTERVENE)) return false; - auto const* low = ctx.group.lowest_hp_on_map(ctx.bot.map_id(), Role::Unknown, ctx.bot.raw().position.x, ctx.bot.raw().position.y, ctx.bot.raw().position.z, 45.0f); - if (!low || !low->online || low->hp <= 0) return false; - if (low->guid == ctx.bot.raw().guid) return false; - return (low->hp * 100) / low->max_hp <= 30; -} -void DoIntervene(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* low = ctx.group.lowest_hp_on_map(ctx.bot.map_id(), Role::Unknown, ctx.bot.raw().position.x, ctx.bot.raw().position.y, ctx.bot.raw().position.z, 45.0f)) - e.cast(INTERVENE, low->guid); -} - -// ---- Major offensive cooldowns ---- -bool ShouldAvatar(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(AVATAR)) return false; - if (!ctx.bot.is_ready(AVATAR)) return false; - return BossLikeTargetEngaged(ctx) || ctx.bot.attackers_count() >= 3; -} -void DoAvatar(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(AVATAR); } - -bool ShouldRavager(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(RAVAGER)) return false; - if (!ctx.bot.is_ready(RAVAGER)) return false; - return ctx.bot.enemies_within(10.0f) >= 2 || BossLikeTargetEngaged(ctx); -} -void DoRavager(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* v = ctx.bot.victim_info()) - e.cast_at(RAVAGER, v->x, v->y, v->z); - else - e.cast(RAVAGER, ctx.bot.victim()); -} - -bool ShouldChampionsSpear(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(CHAMPIONS_SPEAR)) return false; - if (!ctx.bot.is_ready(CHAMPIONS_SPEAR)) return false; - return BossLikeTargetEngaged(ctx) || ctx.bot.enemies_within(8.0f) >= 2; -} -void DoChampionsSpear(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - if (auto const* v = ctx.bot.victim_info()) - e.cast_at(CHAMPIONS_SPEAR, v->x, v->y, v->z); - else - e.cast(CHAMPIONS_SPEAR, ctx.bot.victim()); -} - -// Shield Charge: gap close AND a big hit + Shield Block + 20 Rage in 12.1, so -// it is worth pressing on cooldown once engaged, not only when out of melee. -bool ShouldShieldCharge(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(SHIELD_CHARGE)) return false; - return ctx.bot.is_ready(SHIELD_CHARGE); -} -void DoShieldCharge(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(SHIELD_CHARGE, ctx.bot.victim()); -} - -// Demolish (Colossus hero tree): 2s channel, the tank's biggest hit and a -// 5y AoE around the target. Fire when in melee and off cooldown. -bool ShouldDemolish(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(DEMOLISH)) return false; - if (!ctx.bot.is_ready(DEMOLISH)) return false; - return ctx.bot.enemies_within(5.0f) >= 1; -} -void DoDemolish(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(DEMOLISH, ctx.bot.victim()); -} - -// ---- Damage / threat ---- -// Wrecking Throw: 25y, 45s CD, ignores armor and shreds absorbs. Sits below -// the core rotation so it only fills a GCD nothing better wants, but above -// Heroic Throw so it is the preferred ranged hit while closing. -bool ShouldWreckingThrow(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(WRECKING_THROW)) return false; - return ctx.bot.is_ready(WRECKING_THROW); -} -void DoWreckingThrow(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(WRECKING_THROW, ctx.bot.victim()); -} - -// Heroic Throw: ranged pull (~30y). Fires only when we're out of melee -// range - otherwise Shield Slam / Devastate is strictly higher DPS. -// Cheap CD (6s) so it's also a free off-GCD threat top-up in many cases, -// but we keep the out-of-melee gate so it doesn't usurp the actual -// rotation. -bool ShouldHeroicThrow(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(HEROIC_THROW)) return false; - if (!ctx.bot.is_ready(HEROIC_THROW)) return false; - return ctx.bot.enemies_within(5.0f) == 0; -} -void DoHeroicThrow(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(HEROIC_THROW, ctx.bot.victim()); -} - -bool ShouldShieldSlam(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(SHIELD_SLAM)) return false; - return ctx.bot.is_ready(SHIELD_SLAM); -} -void DoShieldSlam(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(SHIELD_SLAM, ctx.bot.victim()); -} - -bool ShouldThunderClap(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(THUNDER_CLAP)) return false; - return ctx.bot.is_ready(THUNDER_CLAP); -} -void DoThunderClap(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(THUNDER_CLAP); } - -bool ShouldExecute(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(EXECUTE_PROT)) return false; - if (!ctx.bot.is_ready(EXECUTE_PROT)) return false; - return TargetExecuteRange(ctx); -} -void DoExecute(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(EXECUTE_PROT, ctx.bot.victim()); -} - -bool ShouldRevenge(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (!ctx.bot.knows_spell(REVENGE)) return false; - return ctx.bot.is_ready(REVENGE); -} -void DoRevenge(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(REVENGE, ctx.bot.victim()); -} - -// Devastate filler. The Devastator passive ([R] in the curated build) folds -// Devastate into auto-attacks and removes the button, so skip when known. -bool ShouldDevastate(ApPredicateContext const& ctx) -{ - if (!HasLiveTarget(ctx)) return false; - if (ctx.bot.knows_spell(DEVASTATOR)) return false; - return ctx.bot.knows_spell(DEVASTATE); -} -void DoDevastate(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - e.cast(DEVASTATE, ctx.bot.victim()); -} - -bool AlwaysInCombat(ApPredicateContext const& ctx) { return ctx.bot.in_combat(); } -void DoAutoAttack(ApPredicateContext const& ctx, BotIntentEmitter& e) -{ - ObjectGuid t = ctx.bot.victim(); - if (t.IsEmpty()) t = ctx.bot.current_target(); - // Retaliate fallback (2026-06-17): in combat with no victim/target the bot - // looped "Engage auto attack" as a no-op while taking damage (the CombatLoop - // wedge cluster). Engage whatever is meleeing us (attackers are adjacent and - // reachable), else the nearest visible enemy, so combat actually resolves. - // Strictly additive: only runs when no target was already selected. - if (t.IsEmpty()) - for (auto const& u : ctx.bot.attackers()) - if (u.hp > 0) { t = u.guid; break; } - if (t.IsEmpty()) - for (auto const& u : ctx.bot.nearby_enemies()) - if (u.hp > 0 && u.in_los) { t = u.guid; break; } - if (!t.IsEmpty()) e.start_attack(t); -} - -// Rule table - order is meaningful. See file header for the canonical -// tank ladder; comments below restate each tier for quick scanning. -ApRule const kRules[] = { - // 1) Anti-CC immunity - { ShouldBerserkerRage, DoBerserkerRage, "Berserker Rage (anti-fear)" }, - // 2) Panic CDs (Last Stand rides on Shield Wall as a passive in 12.1) - { ShouldShieldWall, DoShieldWall, "Shield Wall (<=35%/pile)" }, - // 3) Interrupts - { ShouldPummel, DoPummel, "Pummel (interrupt)" }, - { ShouldStormBolt, DoStormBolt, "Storm Bolt (interrupt fb)" }, - // 4) Magic absorb - { ShouldSpellReflection, DoSpellReflection, "Spell Reflection" }, - // 5) Threat / peel - { ShouldTaunt, DoTaunt, "Taunt (threat-grab)" }, - { ShouldChallengingShout, DoChallengingShout, "Challenging Shout (4+)" }, - { ShouldIntervene, DoIntervene, "Intervene (peel low ally)" }, - // 6) Active mitigation - { ShouldShieldBlock, DoShieldBlock, "Shield Block (mitigate)" }, - { ShouldIgnorePain, DoIgnorePain, "Ignore Pain (rage)" }, - { ShouldDemoralizingShout, DoDemoralizingShout, "Demoralizing Shout" }, - // 7) Self heals - { ShouldVictoryRush, DoVictoryRush, "Victory Rush" }, - { ShouldImpendingVictory, DoImpendingVictory, "Impending Victory" }, - // 8) Slow / CC - { ShouldShockwave, DoShockwave, "Shockwave (3+ AoE stun)" }, - { ShouldIntimidatingShout, DoIntimidatingShout, "Intimidating Shout (panic)" }, - { ShouldPiercingHowl, DoPiercingHowl, "Piercing Howl (PvP snare)" }, - // 9) Group utility / stance - { ShouldDefensiveStance, DoDefensiveStance, "Defensive Stance" }, - { ShouldBattleShout, DoBattleShout, "Battle Shout (group buff)" }, - { ShouldRallyingCry, DoRallyingCry, "Rallying Cry" }, - // 10) Major offensive cooldowns - { ShouldAvatar, DoAvatar, "Avatar" }, - { ShouldRavager, DoRavager, "Ravager" }, - { ShouldChampionsSpear, DoChampionsSpear, "Champion's Spear" }, - { ShouldShieldCharge, DoShieldCharge, "Shield Charge" }, - { ShouldDemolish, DoDemolish, "Demolish (burst)" }, - // 11) Rotation - Execute window -> Shield Slam (signature) -> Thunder Clap (AoE/rage) - // -> Revenge (proc) -> Wrecking Throw -> Heroic Throw (ranged) -> Devastate - { ShouldExecute, DoExecute, "Execute (window)" }, - { ShouldShieldSlam, DoShieldSlam, "Shield Slam" }, - { ShouldThunderClap, DoThunderClap, "Thunder Clap" }, - { ShouldRevenge, DoRevenge, "Revenge (proc)" }, - { ShouldWreckingThrow, DoWreckingThrow, "Wrecking Throw" }, - { ShouldHeroicThrow, DoHeroicThrow, "Heroic Throw (ranged)" }, - { ShouldDevastate, DoDevastate, "Devastate (filler)" }, - // 12) Auto-attack fallback - { AlwaysInCombat, DoAutoAttack, "Engage auto attack" }, -}; - -} // anonymous - -void RegisterApl_Warrior_Protection() -{ - constexpr uint32 SPEC_WARRIOR_PROTECTION = 73; - RegisterRotation(CLASS_WARRIOR, SPEC_WARRIOR_PROTECTION, ApRotation{kRules}); -} - -} // namespace Playerbot::Combat diff --git a/src/modules/PlayerbotV2/Commands/cs_playerbot_v2.cpp b/src/modules/PlayerbotV2/Commands/cs_playerbot_v2.cpp index 5d84321901..e2cefcdc61 100644 --- a/src/modules/PlayerbotV2/Commands/cs_playerbot_v2.cpp +++ b/src/modules/PlayerbotV2/Commands/cs_playerbot_v2.cpp @@ -606,22 +606,24 @@ public: }; // One-step companions for the player at the keyboard: `.bot add warrior tank` creates the bot, binds it to the // caller's character, levels it to them, teaches its spells, sets role/talents/gear, brings it over and groups it. + // Every player: the commands for the caller's own bots (each one only ever touches bots owned by the caller's account). + // GM only: world, bgstress, bgsoak and itemstats, which look at other players or the whole server. static ChatCommandTable botTable = { - { "about", HandleBotAbout, rbac::RBAC_PERM_COMMAND_GM, Console::Yes }, + { "about", HandleBotAbout, rbac::RBAC_PERM_JOIN_NORMAL_BG, Console::Yes }, { "addon", HandleBotAddonHello, rbac::RBAC_PERM_JOIN_NORMAL_BG, Console::No }, - { "add", HandleBotAdd, rbac::RBAC_PERM_COMMAND_GM, Console::No }, - { "call", HandleBotCall, rbac::RBAC_PERM_COMMAND_GM, Console::No }, + { "add", HandleBotAdd, 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|`). { "summon", HandleBotSummon, rbac::RBAC_PERM_JOIN_NORMAL_BG, Console::No }, - { "dismiss", HandleBotDismiss, rbac::RBAC_PERM_COMMAND_GM, Console::No }, - { "regear", HandleBotRegear, rbac::RBAC_PERM_COMMAND_GM, Console::No }, - { "gear", HandleBotGear, rbac::RBAC_PERM_COMMAND_GM, Console::No }, + { "dismiss", HandleBotDismiss, rbac::RBAC_PERM_JOIN_NORMAL_BG, Console::No }, + { "regear", HandleBotRegear, rbac::RBAC_PERM_JOIN_NORMAL_BG, Console::No }, + { "gear", HandleBotGear, rbac::RBAC_PERM_JOIN_NORMAL_BG, Console::No }, { "itemstats", HandleBotItemStats, rbac::RBAC_PERM_COMMAND_GM, Console::No }, - { "save", HandleBotSave, rbac::RBAC_PERM_COMMAND_GM, Console::No }, - { "unsave", HandleBotUnsave, rbac::RBAC_PERM_COMMAND_GM, Console::No }, - { "delete", HandleBotDelete, rbac::RBAC_PERM_COMMAND_GM, Console::No }, - { "list", HandleBotList, rbac::RBAC_PERM_COMMAND_GM, Console::No }, + { "save", HandleBotSave, rbac::RBAC_PERM_JOIN_NORMAL_BG, Console::No }, + { "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 }, { "world", HandleBotWorld, rbac::RBAC_PERM_COMMAND_GM, Console::Yes }, { "bgstress", HandleBotBgStress, rbac::RBAC_PERM_COMMAND_GM, Console::Yes }, { "bgsoak", HandleBotBgSoak, rbac::RBAC_PERM_COMMAND_GM, Console::Yes }, @@ -839,7 +841,7 @@ public: Player const* me = sess->GetPlayer(); Group const* group = me ? me->GetGroup() : nullptr; for (Playerbot::BotId id : CompanionsMatching(sess, "all")) - if (Playerbot::Services::Owners().GetOwner(id).saved || + if (Playerbot::Services::Owners().SavedBy(id, me ? me->GetGUID().GetCounter() : 0) || (group && group->IsMember(ObjectGuid::Create(id)))) out.push_back(id); return out; @@ -870,12 +872,26 @@ public: std::vector ids; if (roster && groupOnly) { + // The companions in the group (one logged out is logged in again: a raid member that is offline is a missing one) and the + // companions already online that are not in it yet: they are put in the group and brought, as `.bot call` does. Saved + // companions that are offline and not grouped stay where they are (the 2-person-party case above). Group const* grp = me->GetGroup(); + uint32 grouped = 0, offlineGrouped = 0, outside = 0; for (Playerbot::BotId id : CompanionsMatching(sess, "all")) - if (grp && grp->IsMember(ObjectGuid::Create(id)) && ObjectAccessor::FindConnectedPlayer(ObjectGuid::Create(id))) - ids.push_back(id); + { + ObjectGuid const guid = ObjectGuid::Create(id); + bool const online = ObjectAccessor::FindConnectedPlayer(guid) != nullptr; + bool const inGroup = grp && grp->IsMember(guid); + if (!inGroup && !online) + continue; + ids.push_back(id); + if (inGroup) { ++grouped; offlineGrouped += online ? 0u : 1u; } + else ++outside; + } + TC_LOG_INFO("playerbot.v2", "[summon] {} .bot summon all on map {}: {} companions in the group ({} logged out), {} online outside the group", + me->GetName(), me->GetMapId(), grouped, offlineGrouped, outside); if (ids.empty()) - { handler->SendSysMessage("None of your bots are in your group. `.bot summon ` brings one, `.bot call all` brings back your saved raid."); return Refuse(handler); } + { handler->SendSysMessage("None of your bots are in your group or online. `.bot summon ` brings one, `.bot call all` brings back your saved raid."); return Refuse(handler); } } else ids = roster ? SavedCompanions(sess) : CompanionsMatching(sess, who); @@ -885,14 +901,14 @@ public: { std::vector savedOnly; for (Playerbot::BotId id : CompanionsMatching(sess, "all")) - if (Playerbot::Services::Owners().GetOwner(id).saved) + if (Playerbot::Services::Owners().SavedBy(id, me->GetGUID().GetCounter())) savedOnly.push_back(id); if (!savedOnly.empty()) { Group* grp = me->GetGroup(); uint32 removed = 0; for (Playerbot::BotId id : ids) - if (!Playerbot::Services::Owners().GetOwner(id).saved) + if (!Playerbot::Services::Owners().SavedBy(id, me->GetGUID().GetCounter())) { ObjectGuid const guid = ObjectGuid::Create(id); if (grp && grp->IsMember(guid)) @@ -958,7 +974,7 @@ public: while (!who.empty() && (who.front() == ' ' || who.front() == '\t')) who.erase(who.begin()); bool const init = Playerbot::Services::Initialized(); // `saved` = the saved roster (`.bot save`) plus the grouped bots, logged in if need be: the addon's "Call saved" button. - // `.bot call all` is the same but needs GM rights, which normal players do not have. + // `.bot call all` is the same. if (init && ToLowerAscii(who) == "saved") { CallCompanions(handler, "all", /*groupOnly*/ false); @@ -1149,7 +1165,7 @@ public: ++with_group; // A group with none of the owner's bots in it saves nothing and must not wipe the roster. for (Playerbot::BotId id : CompanionsMatching(sess, "all")) - if (with_group && Playerbot::Services::Owners().GetOwner(id).saved && !(grp && grp->IsMember(ObjectGuid::Create(id)))) + if (with_group && Playerbot::Services::Owners().SavedBy(id, me->GetGUID().GetCounter()) && !(grp && grp->IsMember(ObjectGuid::Create(id)))) { Playerbot::Services::Owners().SetSaved(id, false); TC_LOG_INFO("playerbot.v2", "[roster_save] {} was saved earlier and is not in the group: unsaved", CompanionName(id)); @@ -1167,7 +1183,7 @@ public: if (!ObjectAccessor::FindConnectedPlayer(guid) || !group || !group->IsMember(guid)) continue; } - Playerbot::Services::Owners().SetSaved(id, true); + Playerbot::Services::Owners().SetSaved(id, true, me->GetGUID().GetCounter()); // Its role is stored with it (a bot nobody ever gave a role would be re-read from its talents at the next call). if (Player* online = ObjectAccessor::FindConnectedPlayer(ObjectGuid::Create(id))) { @@ -1215,7 +1231,7 @@ public: return false; uint32 removed = 0; for (Playerbot::BotId id : CompanionsMatching(sess, who)) - if (Playerbot::Services::Owners().GetOwner(id).saved) + if (Playerbot::Services::Owners().SavedBy(id, sess->GetPlayer() ? sess->GetPlayer()->GetGUID().GetCounter() : 0)) { Playerbot::Services::Owners().SetSaved(id, false); ++removed; @@ -1300,7 +1316,7 @@ public: continue; handler->PSendSysMessage("%s: level %u %s, %s%s", info->Name.c_str(), uint32(info->Level), ClassName(info->Class), ObjectAccessor::FindConnectedPlayer(guid) ? "online" : "offline", - Playerbot::Services::Owners().GetOwner(id).saved ? ", saved" : ""); + Playerbot::Services::Owners().SavedBy(id, handler->GetSession() && handler->GetSession()->GetPlayer() ? handler->GetSession()->GetPlayer()->GetGUID().GetCounter() : 0) ? ", saved" : ""); } return true; } diff --git a/src/modules/PlayerbotV2/Diagnostics/ScenarioDefs.h b/src/modules/PlayerbotV2/Diagnostics/ScenarioDefs.h index 3c0ddddcea..f4c7a56d83 100644 --- a/src/modules/PlayerbotV2/Diagnostics/ScenarioDefs.h +++ b/src/modules/PlayerbotV2/Diagnostics/ScenarioDefs.h @@ -67,6 +67,8 @@ struct ScenarioDef // A fight with no boss death to wait for (Majordomo Executus yields when his eight adds are dead): the goal is reached when this many // creatures of these two entries have died on the map. 0 = the goal boss's death. std::uint32_t goal_adds_a = 0, goal_adds_b = 0, goal_adds_needed = 0; + // An add that must not die before the goal boss (Garr's Firesworn): each one that does is reported when the boss is dead. 0 = not checked. + std::uint32_t spare_entry = 0; bool order_attack = false; std::uint32_t order_delay_ms = 0; // A whole-dungeon clear to the last boss: long, so `runall` with no filter leaves it out (`runall full` or `run ` starts it). @@ -204,13 +206,16 @@ struct RaidBossRow float lair_x = 0.f, lair_y = 0.f, lair_z = 0.f, lair_o = 0.f; // a boss a script summons (no creature row): where; see ScenarioDef::lair_x float arrive_min_yards = 0.f; // see ScenarioDef::arrive_min_yards std::uint32_t goal_adds_a = 0, goal_adds_b = 0, goal_adds_needed = 0; // see ScenarioDef::goal_adds_needed + std::uint32_t spare_entry = 0; // see ScenarioDef::spare_entry }; // In the order of the raid. Each starts at the boss's room with the encounter pre-spawned (the earlier bosses alive too). inline constexpr RaidBossRow kMcBosses[] = { - { "mc_garr", "Molten Core: 40 level 60 raiders to Garr", 12057, "Garr", 15, 12099 }, // 12099 Firesworn + { "mc_garr", "Molten Core: 40 level 60 raiders to Garr", 12057, "Garr", 15, 12099, 0, 0, + 0.f, 0.f, 0.f, 0.f, 0.f, 0, 0, 0, 12099 }, // 12099 Firesworn: kept alive at staging, and none may die before Garr { "mc_lucifron", "Molten Core: 40 level 60 raiders to Lucifron", 12118, "Lucifron", 15, 12119, 0, 1 }, // Flamewaker Protector; Lucifron's Curse must be removed { "mc_magmadar", "Molten Core: 40 level 60 raiders to Magmadar", 11982, "Magmadar", 15, 0, 1 }, // Frenzy must be tranquilized + { "mc_shazzrah", "Molten Core: 40 level 60 raiders to Shazzrah", 12264, "Shazzrah", 15, 0, 0, 1 }, // Shazzrah's Curse must be removed; the Gate drops him on a random raider { "mc_gehennas", "Molten Core: 40 level 60 raiders to Gehennas", 12259, "Gehennas", 15, 11661, 0, 1 }, // Flamewaker; Gehennas' Curse must be removed { "mc_sulfuron", "Molten Core: 40 level 60 raiders to Sulfuron Harbinger", 12098, "Sulfuron Harbinger", 15, 11662 }, // Flamewaker Priests: Dark Mending is interrupted, Inspire purged, Shadow Word: Pain kept off { "mc_golemagg", "Molten Core: 40 level 60 raiders to Golemagg the Incinerator", 11988, "Golemagg the Incinerator", 15, 11672 }, // Core Ragers: the off tank holds them away from Golemagg; Magma Splash stacks on the main tank @@ -257,6 +262,7 @@ inline ScenarioDef MakeRaidScenario(RaidBossRow const& r, RaidEntrance const& e, d.arrive_near_entry = r.boss_entry; d.keep_entry = r.keep_entry; d.goal_adds_a = r.goal_adds_a; d.goal_adds_b = r.goal_adds_b; d.goal_adds_needed = r.goal_adds_needed; + d.spare_entry = r.spare_entry; d.lair_x = r.lair_x; d.lair_y = r.lair_y; d.lair_z = r.lair_z; d.lair_o = r.lair_o; d.arrive_min_yards = r.arrive_min_yards; d.order_attack = true; @@ -300,6 +306,21 @@ inline ScenarioDef MakeOnyScenario() return MakeRaidScenario(kOny, kOnyEntrance, RaidSquad(kOnyRaid, sizeof(kOnyRaid) / sizeof(kOnyRaid[0]))); } +// The same fight judged on the dodge. onyxia_full passes on the kill however many die, which let a live fight lose 38 of 40 (25 to Deep Breath, 11 to +// Heated Ground, three waves) with the boss alive and say nothing. Here the fourth death fails the run and the sixth ends it: the raid +// stands off the line of the waypoint she hovers at before the cast, and out of the Heated Ground the pass leaves. Read the run's [raid_breath] +// lines (the corridor opens on the cast), [raid_death] (spell, position) and [raid_hazard] (Heated Ground exits). +inline ScenarioDef MakeOnyDodgeScenario() +{ + ScenarioDef d = MakeOnyScenario(); + d.name = "onyxia_dodge"; + d.summary = "Onyxia's Lair: the whole fight with three deaths allowed, so a Deep Breath or Heated Ground that kills the raid fails the run"; + d.limits.kill_is_pass = false; + d.limits.tolerated_deaths = 3; + d.limits.max_deaths = 6; + return d; +} + // ---- Blackwing Lair, Razorgore the Untamed: the orb fight, 40 level 60 raiders ---- // Phase 1: nobody attacks Razorgore while a Black Dragon Egg stands (he dying early kills the raid). A DPS bot walks to the Orb of Domination // (GO 177808) and uses it, which engages and possesses Razorgore; the controller sends him egg to egg (Destroy Egg), Mind Exhaustion hands the @@ -399,6 +420,7 @@ inline std::vector const& ScenarioCatalogue() for (RaidBossRow const& r : kMcBosses) v.push_back(MakeMcScenario(r)); v.push_back(MakeOnyScenario()); + v.push_back(MakeOnyDodgeScenario()); v.push_back(MakeBwlRazorgoreScenario()); // The names are built once and kept: ScenarioDef carries char const*. static std::deque s_parity_names; diff --git a/src/modules/PlayerbotV2/Diagnostics/ScenarioRunner.cpp b/src/modules/PlayerbotV2/Diagnostics/ScenarioRunner.cpp index bb7d681010..c4d8178226 100644 --- a/src/modules/PlayerbotV2/Diagnostics/ScenarioRunner.cpp +++ b/src/modules/PlayerbotV2/Diagnostics/ScenarioRunner.cpp @@ -23,12 +23,16 @@ #include "GroupMgr.h" #include "Log.h" #include "InstanceLockMgr.h" +#include "MMapManager.h" +#include "PhasingHandler.h" +#include "DetourNavMeshQuery.h" #include "Item.h" #include "ItemTemplate.h" #include "DB2Stores.h" #include "Map.h" #include "MapManager.h" #include "MotionMaster.h" +#include "MoveSpline.h" #include "ObjectMgr.h" #include "ObjectAccessor.h" #include "PathGenerator.h" @@ -109,6 +113,7 @@ struct Run std::uint32_t run_ms = 0; // time since the run began (what the failure timestamps count) bool goal_reached = false; std::uint32_t adds_killed = 0; // ScenarioDef::goal_adds_needed + std::uint32_t spared_killed = 0; // ScenarioDef::spare_entry: dead before the goal boss std::string stage_status; // Raids: the goal boss's first spawn, the spot the squad is moved to, and whether the main tank has been ordered on it. bool boss_spawn_known = false; @@ -721,9 +726,12 @@ void LogLanding(Run& run) if (!p || !p->IsInWorld()) continue; BotAI* ai = ::Playerbot::Services::Registry().ai(m.id); - TC_LOG_INFO("playerbot.v2", "[scenario] {} landing round {} {}: {:.0f} y from the landing spot, moving {}, hold {}, rule {}", run.def->name, + // What drives the walk: the movement generator, and the spline's end point when one is running. + auto const& dest = p->movespline->FinalDestination(); + TC_LOG_INFO("playerbot.v2", "[scenario] {} landing round {} {}: {:.0f} y from the landing spot, moving {}, hold {}, rule {}, generator {}, spline {} to {:.0f},{:.0f}", run.def->name, run.landing_rounds, p->GetName(), std::hypot(p->GetPositionX() - run.arrive_x, p->GetPositionY() - run.arrive_y), - p->isMoving() ? 1 : 0, ai && ai->holding_position(now) ? 1 : 0, ai && ai->last_rule_fired() ? ai->last_rule_fired() : "-"); + p->isMoving() ? 1 : 0, ai && ai->holding_position(now) ? 1 : 0, ai && ai->last_rule_fired() ? ai->last_rule_fired() : "-", + uint32(p->GetMotionMaster()->GetCurrentMovementGeneratorType()), p->movespline->Finalized() ? "done" : "running", dest.x, dest.y); } } @@ -784,8 +792,9 @@ void LogEngagements(Run& run, Player* viewer) bool InMagmaContact(Map* map, PhaseShift const& ps, float x, float y, float z) { LiquidData ld; - ZLiquidStatus const st = map->GetLiquidStatus(ps, x, y, z, map_liquidHeaderTypeFlags::Magma | map_liquidHeaderTypeFlags::Slime, &ld); - return (st & MAP_LIQUID_STATUS_IN_CONTACT) != 0; + ZLiquidStatus const st = map->GetLiquidStatus(ps, x, y, z, map_liquidHeaderTypeFlags::AllLiquids, &ld); + return (st & MAP_LIQUID_STATUS_IN_CONTACT) != 0 && + (ld.type_flags.HasFlag(map_liquidHeaderTypeFlags::Magma) || ld.type_flags.HasFlag(map_liquidHeaderTypeFlags::Slime)); } bool PickArrival(Run& run, Player* leader) @@ -1112,6 +1121,47 @@ void SamplePull(Run& run) // What the squad stands in at the pull: health and buffs per role, so a scenario that fails can be told from a raid that is under-prepared // (MC Ragnaros 2026-10-13: healers died to 2000 damage with ~2000 health at the hit). One line per role. +// Every raider's footing at the order: how many stand on the navmesh, and the ones that do not (position, nearest-poly probe). A bot with no +// polygon under it cannot path anywhere (mc_lucifron: srcpoly=0, void ahead, 55-70 y from its target for the whole fight), +// which reads as a rule that never acts. 2 = a polygon within 5 y vertically, 1 = one only far above or below, 0 = no tile or no mesh, -1 = probe fault. +void LogRaiderFooting(Run const& run) +{ + std::uint32_t total = 0, on_mesh = 0; + for (Member const& m : run.members) + { + Player* p = Find(m.id); + if (!p || !p->IsAlive()) + continue; + ++total; + int probe = 0; + if (Map* map = p->GetMap()) + { + uint32 const terrain_map = PhasingHandler::GetTerrainMapId(p->GetPhaseShift(), p->GetMapId(), map->GetTerrain(), p->GetPositionX(), p->GetPositionY()); + if (dtNavMeshQuery const* q = MMAP::MMapManager::instance()->GetNavMeshQuery(terrain_map, p->GetMapId(), p->GetInstanceId())) + { + dtQueryFilter f; + f.setIncludeFlags(0xFFFF); + float ext[3] = { 3.0f, 5.0f, 3.0f }; + float pt[3] = { p->GetPositionY(), p->GetPositionZ(), p->GetPositionX() }; // TC -> Detour (y, z, x) + int r = ::Playerbot::BotMovement::SehSafeNearestPolyProbe(q, pt, ext, &f); + if (r != 0) + probe = r > 0 ? 2 : -1; + else + { + float ext2[3] = { 3.0f, 200.0f, 3.0f }; + probe = ::Playerbot::BotMovement::SehSafeNearestPolyProbe(q, pt, ext2, &f); + } + } + } + if (probe == 2) + ++on_mesh; + else + TC_LOG_INFO("playerbot.v2", "[scenario] {} footing: {} stands at {:.1f},{:.1f},{:.1f} with no navmesh polygon under it (probe {})", run.def->name, + p->GetName(), p->GetPositionX(), p->GetPositionY(), p->GetPositionZ(), probe); + } + TC_LOG_INFO("playerbot.v2", "[scenario] {} footing: {} of {} raiders stand on the navmesh", run.def->name, on_mesh, total); +} + void LogPullState(Run const& run) { // Power Word: Fortitude / Prayer of Fortitude, Mark of the Wild / Gift of the Wild, Arcane Intellect / Brilliance, Blessings and Greater Blessings. @@ -1175,6 +1225,7 @@ bool IssueAttack(Run& run) return false; } LogPullState(run); + LogRaiderFooting(run); // How many of the boss's entry stand within 400 y, and where: a leftover from an earlier run (Ragnaros summoned twice, a lair summon that // was never cleared) would explain tanks that read 16-20 y from "the boss" at the order and a fight that starts on the wrong one. { @@ -1207,7 +1258,9 @@ bool IssueAttack(Run& run) TC_LOG_INFO("playerbot.v2", "[scenario] {} ordered {} onto {} ({}) at {} s, {:.0f} y away (start_attack result {})", run.def->name, tank->GetName(), boss->GetName(), run.def->goal_entry, run.run_ms / 1000u, tank->GetDistance(boss), int(res)); // A target the server refuses (immune to players, not interactible) is a fault in the setup, not a fight that happens to be quiet. - if (res == ::Playerbot::Result::InvalidTarget) + // Not when the boss is already fighting the raid: a boss script (Bot/Raid/RaidFightScript.h) owns the pull and had the DPS on it before + // this order, and Attack on a mob the bot already fights is refused as an invalid target. + if (res == ::Playerbot::Result::InvalidTarget && !boss->IsInCombat()) run.monitor->NoteSetupFailure(run.run_ms, "", fmt::format("{} refused the attack order on {} ({}): the boss is not attackable (immune to players or not interactible)", tank->GetName(), boss->GetName(), run.def->goal_entry)); return true; @@ -1401,6 +1454,11 @@ void Finish(Run& run, bool timed_out, std::string const& note = {}) run.monitor->NoteSupportMissing(run.run_ms, fmt::format("{} curse(s) removed, at least {} expected: the boss's curse was never cleansed ([raid_dispel])", decurse, def.limits.min_decurses)); } + if (def.spare_entry) + run.monitor->NoteInfo(fmt::format("spared adds: {} killed before {}", run.spared_killed, def.goal_name)); + if (run.goal_reached && run.spared_killed) + run.monitor->NoteSupportMissing(run.run_ms, fmt::format("{} add(s) of entry {} died before {}: the raid was to leave them alive until he fell ([raid_fight])", + run.spared_killed, def.spare_entry, def.goal_name)); } bool const pass = run.monitor->passed(run.goal_reached); @@ -1904,7 +1962,14 @@ static void TickRun(Run& run, std::uint32_t diff_ms) } for (Member const& m : run.members) if (Player* p = Find(m.id)) + { + // A walk or follow still running from the staging is cancelled with the landing, as a taxi flight is: mc_garr and mc_geddon + // had the healers walking 7 y/s from the landing spot under the Hold, rule idle:owner_holding, + // and pulled the boss before the order. + p->GetMotionMaster()->Clear(); + p->StopMoving(); ::Playerbot::BotMovement::SafeTeleport(p, run.def->map, run.arrive_x, run.arrive_y, run.arrive_z, run.arrive_o, 0); + } run.arrive_sent = true; // Hold from the moment of the landing, not from "in place": the 40 raiders arrive over seconds, and until the Hold // began they walked toward Garr and into his adds (MC Garr 2026-10-10: the first Firesworn engagements came with the @@ -2159,6 +2224,8 @@ void NoteCreatureKilled(std::uint32_t map, std::uint32_t entry, bool tapped) } if (!any_alive) continue; + if (r->def->spare_entry && entry == r->def->spare_entry && !r->goal_reached) + ++r->spared_killed; if (entry == r->def->goal_entry) r->goal_reached = true; else if (r->def->goal_adds_needed && (entry == r->def->goal_adds_a || entry == r->def->goal_adds_b) && ++r->adds_killed >= r->def->goal_adds_needed) diff --git a/src/modules/PlayerbotV2/Fleet/BotPopulationManager.cpp b/src/modules/PlayerbotV2/Fleet/BotPopulationManager.cpp index 98340f1473..95b7c8bce1 100644 --- a/src/modules/PlayerbotV2/Fleet/BotPopulationManager.cpp +++ b/src/modules/PlayerbotV2/Fleet/BotPopulationManager.cpp @@ -512,6 +512,7 @@ void BotPopulationManager::OnWorldTick(uint32 now_ms) // `.bot add` companions waiting for their first in-world tick. const uint32 slow_pipelines_ms = getMSTimeDiff(t_pipelines_start, getMSTime()); { SLOW_CALL("DrainCompanionSetups"); DrainCompanionSetups(); } + DrainBringChecks(); WarnOversizedInstanceGroups(now_ms); // `.bot delete` companions waiting to leave the world. DrainCompanionDeletes(); @@ -1611,9 +1612,19 @@ void BotPopulationManager::FinishCompanionSetup(Player* bot, Player* owner, uint if (joinFailure.empty()) { float x, y, z; - owner->GetNearPoint(bot, x, y, z, slot_offset.distance, owner->GetOrientation() + slot_offset.angle_radians); - Fleet::PrepareInstanceEntry(bot, owner->GetMapId()); - ::Playerbot::BotMovement::SafeTeleport(bot, owner->GetMapId(), x, y, z, owner->GetOrientation(), 0); + // The owner is the searcher: the ground height is read on the OWNER's map. With the bot as searcher a bot standing on another + // continent had the owner's x,y looked up on its own map and landed 350 y under the owner (a new character in Coldridge). + owner->GetNearPoint(nullptr, x, y, z, slot_offset.distance, owner->GetOrientation() + slot_offset.angle_radians); + TransferAbortReason const door = Fleet::PrepareInstanceEntry(bot, owner->GetMapId()); + if (door != TRANSFER_ABORT_NONE) + { + // The door refuses it (the instance holds its most players, another raid's save...): it stays outside, alive, and the + // rejoin rule asks again; the owner is told why instead of finding a bot missing. + TC_LOG_INFO("playerbot.v2", "[summon] {} stays outside map {}: {}", bot->GetName(), owner->GetMapId(), Fleet::TransferAbortName(door)); + ChatHandler(owner->GetSession()).PSendSysMessage("%s cannot enter yet: %s.", bot->GetName().c_str(), Fleet::TransferAbortName(door)); + } + else + ::Playerbot::BotMovement::SafeTeleport(bot, owner->GetMapId(), x, y, z, owner->GetOrientation(), 0); // A level 10+ hunter's pet, once ever. Mid map change it is not in the world yet: CompanionUpkeep grants it then. GrantCompanionStarterPet(id, bot); @@ -1634,6 +1645,121 @@ void BotPopulationManager::FinishCompanionSetup(Player* bot, Player* owner, uint uint32(bot->GetLevel()), joinFailure.c_str()); } +// The one way an owner's order brings a companion to them ("come", "summon", `.bot summon `, the add-on's Come button), in +// the open world or inside an instance, wherever the bot is: a bot dead on another map is revived as a summon does, one outside +// the group is put in it first (the door checks look at the group's instance), the door is checked and every refusal is logged and +// returned in words, so no bot goes missing without a reason. Empty string = it is on its way. +std::string BotPopulationManager::BringToOwner(Player* owner, Player* bot, char const* why) +{ + auto refuse = [&](std::string reason) + { + TC_LOG_INFO("playerbot.v2", "[summon] {} not brought to {} ({}): {}", bot->GetName(), owner->GetName(), why, reason); + return reason; + }; + if (!owner || !bot || !owner->IsInWorld() || !bot->IsInWorld()) + return refuse("not in the world"); + if (!bot->IsAlive()) + { + if (bot->GetMapId() == owner->GetMapId()) + return refuse("dead where you are: it waits for a rez"); + TC_LOG_INFO("playerbot.v2", "[summon] {} dead on map {}: revived to join {}", bot->GetName(), bot->GetMapId(), owner->GetName()); + bot->ResurrectPlayer(1.0f); + bot->SpawnCorpseBones(); + } + if (bot->IsInCombat()) + { + // Fighting in the owner's own fight it stays; fighting somewhere the owner is not (the pack behind a closed door, another room) + // it leaves the fight and comes, so the owner is never left alone while the bots fight without him. The mobs lose it as a target. + if (bot->GetMapId() == owner->GetMapId() && owner->IsInCombat()) + return refuse("in combat with you"); + TC_LOG_INFO("playerbot.v2", "[summon] {} leaves its fight (map {}) to come to {}", bot->GetName(), bot->GetMapId(), owner->GetName()); + bot->AttackStop(); + bot->CombatStopWithPets(true); + } + if (bot->IsBeingTeleported()) + return refuse("already on its way"); + Map const* ownerMap = owner->GetMap(); + if (ownerMap && ownerMap->IsBattlegroundOrArena()) + return refuse("you are in a battleground"); + + bool const alreadyGrouped = owner->GetGroup() && bot->GetGroup() == owner->GetGroup(); + std::string capFull; + if (!alreadyGrouped && CompanionSpawnFull(owner, bot->GetGUID().GetCounter(), capFull)) + return refuse(capFull); + if (!alreadyGrouped) + if (std::string const joinFailure = JoinOwnerGroup(owner, bot); !joinFailure.empty()) + return refuse(joinFailure); + + // "Come" from a bot that is already close walks: a teleport of a few yards shows to the owner as the bot shooting across the screen. Far away, + // on another map or instance, or at another height (a bot under the map, 353 y below the owner) it is teleported as before. "Summon" always is. + if (why && std::strncmp(why, "come", 4) == 0 && bot->GetMapId() == owner->GetMapId() && bot->GetInstanceId() == owner->GetInstanceId() && + bot->GetDistance(owner) <= 60.0f && std::fabs(bot->GetPositionZ() - owner->GetPositionZ()) <= 15.0f) + { + TC_LOG_INFO("playerbot.v2", "[summon] {} is {:.0f}y from {} ({}): walks, no teleport", bot->GetName(), bot->GetDistance(owner), owner->GetName(), why); + return {}; + } + FormationOffset offset{ 5.0f, 0.0f }; + if (BotAI const* ai = Services::Registry().ai(bot->GetGUID().GetCounter())) + offset = ComputeFormationOffset(ai->formation_type(), ai->formation_slot(), ai->follow_distance() > 0.f ? ai->follow_distance() : 5.0f); + float x, y, z; + owner->GetNearPoint(nullptr, x, y, z, offset.distance, owner->GetOrientation() + offset.angle_radians); + TransferAbortReason const door = Fleet::PrepareInstanceEntry(bot, owner->GetMapId()); + if (door != TRANSFER_ABORT_NONE) + return refuse(Fleet::TransferAbortName(door)); + // The door puts a bot in the instance its group names for the map. A group formed while the owner already stood inside (a new raid, + // a re-formed one) names none, so the first bot in would open a second copy of the instance and arrive where the owner is not. + if (Group* group = owner->GetGroup(); group && ownerMap && ownerMap->IsDungeon() && bot->GetMapId() != owner->GetMapId()) + { + uint32 const named = group->GetRecentInstanceId(owner->GetMapId()); + if (named != ownerMap->GetInstanceId()) + { + TC_LOG_INFO("playerbot.v2", "[summon] group instance of map {} was {}, set to {}'s instance {}", owner->GetMapId(), named, + owner->GetName(), ownerMap->GetInstanceId()); + group->SetRecentInstance(owner->GetMapId(), group->GetRecentInstanceOwner(owner->GetMapId()), ownerMap->GetInstanceId()); + } + } + if (!::Playerbot::BotMovement::SafeTeleport(bot, owner->GetMapId(), x, y, z, owner->GetOrientation(), 0)) + return refuse("the teleport was refused"); + pending_brings_.push_back(PendingBring{ bot->GetGUID().GetCounter(), owner->GetGUID(), getMSTime() }); + return {}; +} + +void BotPopulationManager::DrainBringChecks() +{ + if (pending_brings_.empty()) + return; + constexpr uint32 kSettleMs = 2000u, kGiveUpMs = 6000u; + constexpr float kBesideYards = 25.0f; + for (auto it = pending_brings_.begin(); it != pending_brings_.end();) + { + uint32 const age = getMSTimeDiff(it->queued_ms, getMSTime()); + if (age < kSettleMs) { ++it; continue; } + Player* bot = ObjectAccessor::FindConnectedPlayer(ObjectGuid::Create(it->bot_low)); + Player* owner = ObjectAccessor::FindConnectedPlayer(it->owner); + if (!bot || !owner || !bot->IsInWorld() || !owner->IsInWorld()) + { + TC_LOG_INFO("playerbot.v2", "[summon] bot {} not verified beside its owner: one of them left the world", it->bot_low); + it = pending_brings_.erase(it); + continue; + } + bool const sameMap = bot->GetMapId() == owner->GetMapId() && bot->GetInstanceId() == owner->GetInstanceId(); + float const dist = sameMap ? bot->GetDistance(owner) : -1.0f; + if (sameMap && dist <= kBesideYards) + { + TC_LOG_INFO("playerbot.v2", "[summon] {} is beside {}: {:.0f}y on map {} instance {}", bot->GetName(), owner->GetName(), dist, + owner->GetMapId(), owner->GetInstanceId()); + it = pending_brings_.erase(it); + continue; + } + if (age < kGiveUpMs) { ++it; continue; } + TC_LOG_INFO("playerbot.v2", "[summon] {} did NOT arrive beside {}: bot on map {} instance {} at ({:.0f},{:.0f},{:.0f}), owner on map {} instance {} at ({:.0f},{:.0f},{:.0f}), {}", + bot->GetName(), owner->GetName(), bot->GetMapId(), bot->GetInstanceId(), bot->GetPositionX(), bot->GetPositionY(), + bot->GetPositionZ(), owner->GetMapId(), owner->GetInstanceId(), owner->GetPositionX(), owner->GetPositionY(), + owner->GetPositionZ(), sameMap ? fmt::format("{:.0f}y apart", dist) : std::string("not the same map or instance")); + it = pending_brings_.erase(it); + } +} + bool BotPopulationManager::RegearNow(Player* p) { if (!p || !p->IsInWorld()) return false; @@ -3043,7 +3169,7 @@ bool BotPopulationManager::LoginExisting(uint64 char_guid_low, bool alliance) return false; } -uint64 BotPopulationManager::SpawnNew(uint8 level, bool alliance, uint8 race_hint) +uint64 BotPopulationManager::SpawnNew(uint8 level, bool alliance, uint8 race_hint, bool own_budget) { uint32& budget = alliance ? spawn_budget_alli_ : spawn_budget_horde_; if (!budget) return 0; @@ -3060,7 +3186,7 @@ uint64 BotPopulationManager::SpawnNew(uint8 level, bool alliance, uint8 race_hin // or characters are explicitly deleted. auto& cfg = Services::Config(); const uint32 total_target = cfg.population_total_target(); - if (total_target > 0) + if (total_target > 0 && !own_budget) { // Owner-bound companions (`.bot add`) are marked bots too, but they // ride on top of TotalTarget (see PopulateActual) and never return @@ -3335,11 +3461,31 @@ uint64 BotPopulationManager::SpawnAmbientBot(uint8 level, bool alliance, uint8 r uint32& budget = alliance ? spawn_budget_alli_ : spawn_budget_horde_; uint32 const saved = budget; budget = 1; - uint64 const guid = SpawnNew(level, alliance, race); + uint64 const guid = SpawnNew(level, alliance, race, /*own_budget*/ true); budget = saved; return guid; } +bool BotPopulationManager::RetireVariableBot(uint64 guid_low, uint32 account, std::string const& name) +{ + ObjectGuid const guid = ObjectGuid::Create(guid_low); + // Never a bot that is in the world, a player's companion or in a group, whatever the row said. + if (ObjectAccessor::FindConnectedPlayer(guid) || Services::Owners().GetOwner(guid_low).account_id != 0) + return false; + if (Services::Registry().has(guid_low)) + { + Services::Scheduler().unregister_bot(guid_low); + Services::Snapshots().remove(guid_low); + Services::Registry().unregister_bot(guid_low); + } + BotNamePool::Release(name); + Services::Lifecycle().unmark_as_bot(guid_low); + forget_pipeline_caches(guid_low); + Player::DeleteFromDB(guid, account, /*updateRealmChars*/ true, /*deleteFinally*/ true); + Services::Accounts().note_character_removed(account); + return true; +} + bool BotPopulationManager::GraduateSkyborne(Player* bot) { return pipeline_ && pipeline_->Graduate(bot); diff --git a/src/modules/PlayerbotV2/Fleet/BotPopulationManager.h b/src/modules/PlayerbotV2/Fleet/BotPopulationManager.h index 958eeb5465..72b7a7466a 100644 --- a/src/modules/PlayerbotV2/Fleet/BotPopulationManager.h +++ b/src/modules/PlayerbotV2/Fleet/BotPopulationManager.h @@ -18,6 +18,7 @@ #include "AsyncCallbackProcessor.h" // QueryCallbackProcessor member (async DB reads) #include "DatabaseEnvFwd.h" // QueryCallbackProcessor / QueryResult aliases #include "WorldLoadFacts.h" +#include "ObjectGuid.h" #include "BotQueueFiller.h" #include #include @@ -150,6 +151,9 @@ public: // talents and gear, bring it to the owner and put it in the owner's group (made a raid when full). Dropped if the // bot does not log in within a minute or the owner is offline by then. World thread only. void QueueCompanionSetup(BotId bot, uint64 owner_guid_low, uint8 role); + // Brings an owned companion to its owner at once, in the open world or inside an instance (see the definition). Empty = on its way, + // else why not (also logged as [summon]). World thread. + std::string BringToOwner(Player* owner, Player* bot, char const* why); // Resolves and pins a companion's role: `requested` (the owner's word) if not Role::Unknown, else the role stored with // the companion (OwnerRegistry::DeclaredRole, migration 0024), else the one its talents say. Sets the BotAI role @@ -185,6 +189,16 @@ public: }; std::unordered_map pending_companions_; void DrainCompanionSetups(); + // A bot BringToOwner sent is only "brought" once it stands beside the owner in the owner's instance: checked 2 s after the teleport, + // and for up to 6 s, with both positions and instance ids in the log when it does not. + struct PendingBring + { + uint64 bot_low = 0; + ObjectGuid owner; + uint32 queued_ms = 0; + }; + std::vector pending_brings_; + void DrainBringChecks(); void FinishCompanionSetup(Player* bot, Player* owner, uint8 role); std::unordered_map pending_deletes_; // bot -> queued at (getMSTime) void DrainCompanionDeletes(); @@ -254,6 +268,9 @@ public: // TotalTarget-based pool cap (the world spawner enforces its own). Returns the guid counter, 0 on failure. // `race` (0 = the weighted roll) fixes the race: Classic 1.60 Skyborne residents of Zephras Isle. uint64 SpawnAmbientBot(uint8 level, bool alliance, uint8 race = 0); + // Deletes one temporary world bot (the variable pool, PoolBudget.h) with the server's own character delete. The caller has + // checked the row; this checks the live state again (online, owned, in a group) and refuses a bot that is in use. + bool RetireVariableBot(uint64 guid_low, uint32 account, std::string const& name); // Classic 1.60: places a Skyborne bot that outgrew Zephras Isle in a vanilla leveling town (BotSetupPipeline::Graduate). bool GraduateSkyborne(Player* bot); // True when ambient (non-companion) bots are wanted at all: the shaper (TotalTarget > 0) or the world spawner @@ -451,7 +468,8 @@ private: // JIT spawn one new bot at the given (level, faction). Returns the new // character's GUID counter, or 0 on failure. Decrements the faction's // per-cycle spawn budget on success. - uint64 SpawnNew(uint8 level, bool alliance, uint8 race_hint = 0); + // `own_budget`: the world spawner enforces its own pool budgets, so the shaper's 1.10x-of-TotalTarget spawn cap does not apply. + uint64 SpawnNew(uint8 level, bool alliance, uint8 race_hint = 0, bool own_budget = false); // Login an offline bot character. Decrements the faction's per-cycle // login budget on success. Returns true on success. diff --git a/src/modules/PlayerbotV2/Fleet/BotSetupPipeline.cpp b/src/modules/PlayerbotV2/Fleet/BotSetupPipeline.cpp index 9ea16c63a0..19e145923d 100644 --- a/src/modules/PlayerbotV2/Fleet/BotSetupPipeline.cpp +++ b/src/modules/PlayerbotV2/Fleet/BotSetupPipeline.cpp @@ -625,6 +625,9 @@ bool BotSetupPipeline::DoLearnProfessions(Player* bot) // granted here even though bandages still exist as items. Apprentice // ranks: Cooking 2550, Fishing 7732. grant_skill(/*Cooking*/ 185, 2550); + // Basic Campfire comes with Cooking; the campfire show (idle:campfire) needs it, and a bot that got the skill by SetSkill alone may not have it. + if (!bot->HasSpell(818) && sSpellMgr->GetSpellInfo(818, DIFFICULTY_NONE)) + bot->LearnSpell(818, /*dependent=*/false); grant_skill(/*Fishing*/ 356, 7732); // Classic 1.60: vanilla has First Aid (removed only in BfA) and no diff --git a/src/modules/PlayerbotV2/Fleet/CityLayer.h b/src/modules/PlayerbotV2/Fleet/CityLayer.h new file mode 100644 index 0000000000..f5ddf2e687 --- /dev/null +++ b/src/modules/PlayerbotV2/Fleet/CityLayer.h @@ -0,0 +1,74 @@ +// Two small decisions for bots in a capital, kept free of game types so they can be unit tested. +// +// A capital is built in layers (Stormwind: the city floor at z 94 to 100, other walkable layers under it at z 75 and z 59, joined to +// the city only by a few steep faces). A bot that ends up on a lower layer cannot reach the places the town rules send it to. +// * AcrossDrop: a move that asks for the bot's own level (the rule passed the bot's z, as the chunked walks and the wanderers do) +// whose destination has its ground far below. The ground probe would put the goal on the lower layer and the path would take the +// bot down the face. That is not a place the rule meant. +// * NoPathRun: how many times in a row of minutes the path calls from one spot failed with no route. A bot whose every path fails +// is as cut off as one the stranded watch finds by its own probe (a pocket with void all round it). +#pragma once + +#include +#include +#include + +namespace Playerbot::V2::Fleet +{ + +constexpr float kSameLevelYards = 3.0f; // a destination hint this close to the bot's own z is a request for the same level +constexpr float kCityDropYards = 20.0f; // ground this far under such a hint is across a drop (Stormwind: 23 and 38 y) + +inline bool AcrossDrop(float bot_z, float hint_z, float ground_z) +{ + return std::fabs(hint_z - bot_z) < kSameLevelYards && hint_z - ground_z > kCityDropYards; +} + +constexpr float kCliffDropYards = 15.0f; // a path segment falling this far over no more ground than it falls is a face, not a ramp + +// Is a path segment a cliff face? Detour joins the layers of a capital over steep faces that a bot cannot walk; a ramp or a stair falls +// slower than it runs. `run` is the ground covered, `drop` how far the segment falls (positive = down). +inline bool IsCliffSegment(float run, float drop) +{ + return drop >= kCliffDropYards && run <= drop; +} + +// Does a path (points with x, y, z) cross a cliff face, going down or up? Detour joins layers over steep faces that a bot cannot walk. +template +inline bool PathHasCliff(Points const& pts) +{ + for (std::size_t i = 1; i < pts.size(); ++i) + { + float const run = std::hypot(pts[i].x - pts[i - 1].x, pts[i].y - pts[i - 1].y); + float const dz = pts[i].z - pts[i - 1].z; + if (IsCliffSegment(run, -dz) || IsCliffSegment(run, dz)) + return true; + } + return false; +} + +constexpr std::uint32_t kNoPathWindowMs = 180000u; // failures are counted per window of three minutes +constexpr std::uint32_t kNoPathStorm = 30u; // this many in one window (a bot in a pocket fails once a second) + +struct NoPathRun +{ + std::uint32_t n = 0; + std::uint32_t since_ms = 0; // when the current window opened; 0 = none yet +}; + +inline void NoteNoPath(NoPathRun& r, std::uint32_t now_ms) +{ + if (r.since_ms == 0 || std::uint32_t(now_ms - r.since_ms) > kNoPathWindowMs) + { + r.n = 0; + r.since_ms = now_ms ? now_ms : 1u; + } + ++r.n; +} + +inline bool NoPathStorm(NoPathRun const& r, std::uint32_t now_ms) +{ + return r.since_ms != 0 && std::uint32_t(now_ms - r.since_ms) <= kNoPathWindowMs && r.n >= kNoPathStorm; +} + +} // namespace Playerbot::V2::Fleet diff --git a/src/modules/PlayerbotV2/Fleet/LevelWindow.h b/src/modules/PlayerbotV2/Fleet/LevelWindow.h new file mode 100644 index 0000000000..1ab4ebd36c --- /dev/null +++ b/src/modules/PlayerbotV2/Fleet/LevelWindow.h @@ -0,0 +1,29 @@ +#pragma once +// Level window of the bots a world anchor (a player) is given: the zone's own questing range, kept within a few levels of the +// player (close enough to invite as a group), so the zone he stands in is busy with his level. Pure, tested in tests/game/ClassicLevelWindow.cpp. +#include + +namespace Playerbot::V2::Fleet { + +struct LevelWindow { int lo = 1; int hi = 1; }; + +// zone_known: the zone has a level range (zlo..zhi); a capital has none and gets the wide spread min_level..max_level. +inline LevelWindow AnchorLevelWindow(int anchor_level, bool zone_known, int zlo, int zhi, int min_level, int max_level, int spread = 4, int zone_spread = 1) +{ + if (!zone_known) + return { min_level, std::max(min_level, max_level) }; + int const zone_lo = std::max(1, zlo - zone_spread), zone_hi = std::min(max_level, zhi + zone_spread); + int lo = std::max(1, anchor_level - spread), hi = std::min(max_level, anchor_level + spread); + // The zone's range leaning toward the player's level. If he is far outside it (a level 1 sent to a level 30 zone): the nearest part + // of the zone's range, so the bots still suit the place. + lo = std::max(lo, zone_lo); + hi = std::min(hi, zone_hi); + if (lo > hi) + { + lo = std::min(std::max(anchor_level, zone_lo), zone_hi); + hi = lo; + } + return { lo, hi }; +} + +} // namespace Playerbot::V2::Fleet diff --git a/src/modules/PlayerbotV2/Fleet/OwnerRegistry.cpp b/src/modules/PlayerbotV2/Fleet/OwnerRegistry.cpp index 38d4a84ced..d021bf0937 100644 --- a/src/modules/PlayerbotV2/Fleet/OwnerRegistry.cpp +++ b/src/modules/PlayerbotV2/Fleet/OwnerRegistry.cpp @@ -14,7 +14,7 @@ auto& Db() { return CharacterDatabase; } size_t OwnerRegistry::LoadFromDb() { auto result = Db().Query( - "SELECT character_guid_low, owner_account_id, owner_player_guid, companion_saved, starter_pet_granted, gear_varied, companion_role, companion_subgroup, companion_spec, companion_order " + "SELECT character_guid_low, owner_account_id, owner_player_guid, companion_saved, starter_pet_granted, gear_varied, companion_role, companion_subgroup, companion_spec, companion_order, companion_saved_by " "FROM playerbot_v2_character " "WHERE owner_account_id != 0 OR companion_role != 0"); auto gear_modes = Db().Query("SELECT owner_account_id, gear_mode FROM playerbot_v2_owner_gear"); @@ -42,6 +42,7 @@ size_t OwnerRegistry::LoadFromDb() b.account_id = f[1].GetUInt32(); b.player_guid = f[2].GetUInt64(); b.saved = f[3].GetUInt8() != 0; + b.saved_by = f[10].GetUInt64(); if (b.account_id != 0) owners_[bot] = b; if (f[4].GetUInt8() != 0) @@ -159,6 +160,7 @@ uint64 OwnerRegistry::OwnerCharacter(BotId bot) const void OwnerRegistry::SetOwner(BotId bot, uint32 account_id, uint64 player_guid) { + uint64 saved_by = 0; bool saved = false; // a bot stays on the roster only while the same account owns it { std::unique_lock lk(mtx_); @@ -172,7 +174,8 @@ void OwnerRegistry::SetOwner(BotId bot, uint32 account_id, uint64 player_guid) { auto it = owners_.find(bot); saved = it != owners_.end() && it->second.account_id == account_id && it->second.saved; - owners_[bot] = OwnerBinding{account_id, player_guid, saved}; + saved_by = saved ? it->second.saved_by : 0; + owners_[bot] = OwnerBinding{account_id, player_guid, saved, saved_by}; } } // Persist. UPDATE only — the bot row must already exist (it's @@ -182,12 +185,19 @@ void OwnerRegistry::SetOwner(BotId bot, uint32 account_id, uint64 player_guid) // bot — next mutation will succeed. Db().DirectPExecute( "UPDATE playerbot_v2_character " - "SET owner_account_id = {}, owner_player_guid = {}, companion_saved = {} " + "SET owner_account_id = {}, owner_player_guid = {}, companion_saved = {}, companion_saved_by = {} " "WHERE character_guid_low = {}", - account_id, player_guid, saved ? 1 : 0, bot); + account_id, player_guid, saved ? 1 : 0, saved_by, bot); } -void OwnerRegistry::SetSaved(BotId bot, bool saved) +bool OwnerRegistry::SavedBy(BotId bot, uint64 character) const +{ + std::shared_lock lk(mtx_); + auto it = owners_.find(bot); + return it != owners_.end() && it->second.saved && (it->second.saved_by == 0 || it->second.saved_by == character); +} + +void OwnerRegistry::SetSaved(BotId bot, bool saved, uint64 by) { { std::unique_lock lk(mtx_); @@ -195,9 +205,10 @@ void OwnerRegistry::SetSaved(BotId bot, bool saved) if (it == owners_.end()) return; it->second.saved = saved; + it->second.saved_by = saved ? by : 0; } - Db().DirectPExecute("UPDATE playerbot_v2_character SET companion_saved = {} WHERE character_guid_low = {}", - saved ? 1 : 0, bot); + Db().DirectPExecute("UPDATE playerbot_v2_character SET companion_saved = {}, companion_saved_by = {} WHERE character_guid_low = {}", + saved ? 1 : 0, saved ? by : 0, bot); } bool OwnerRegistry::StarterPetGranted(BotId bot) const diff --git a/src/modules/PlayerbotV2/Fleet/OwnerRegistry.h b/src/modules/PlayerbotV2/Fleet/OwnerRegistry.h index 418fa6a150..45d8c41490 100644 --- a/src/modules/PlayerbotV2/Fleet/OwnerRegistry.h +++ b/src/modules/PlayerbotV2/Fleet/OwnerRegistry.h @@ -36,6 +36,8 @@ struct OwnerBinding uint64 player_guid = 0; // On the owner's saved companion roster (`.bot save`): `.bot call all` brings back only these. Migration 0018. bool saved = false; + // The character whose roster it is on (0 = any character on the account, a roster saved before migration 0030). Migration 0030. + uint64 saved_by = 0; }; class OwnerRegistry @@ -64,7 +66,9 @@ public: bool IsOwner(BotId bot, uint32 sender_account, uint64 sender_guid) const; // Puts the bot on (or takes it off) its owner's saved roster. Writes immediately to the DB. No-op for an unowned bot. - void SetSaved(BotId bot, bool saved); + // The roster is per character: only the character `by` sees the bot as saved. + void SetSaved(BotId bot, bool saved, uint64 by = 0); + bool SavedBy(BotId bot, uint64 character) const; // A hunter companion's starter pet (the Taming the Beast pet it never quests for) is granted once per bot, ever: // after that a pet the owner abandons stays abandoned and the owner's own Tame Beast is free. Migration 0020. diff --git a/src/modules/PlayerbotV2/Fleet/PoolBalance.h b/src/modules/PlayerbotV2/Fleet/PoolBalance.h index 8109591969..f80bc1f759 100644 --- a/src/modules/PlayerbotV2/Fleet/PoolBalance.h +++ b/src/modules/PlayerbotV2/Fleet/PoolBalance.h @@ -1,7 +1,8 @@ // PoolBalance - which character the roster seeder creates next so the pool of sleeping residents is balanced between the factions // in every level bracket (playtest, 2026-10-11: the pool was ~94% Alliance, so no Horde was around when he quested and the Horde // battleground queues starved). The seeder used to flip a coin per bot; now it creates whichever (faction, bracket) is furthest -// below the target ratio. Pure: no game types, tested in tests/game/ClassicPoolBalance.cpp. +// below the target ratio. The roster is balanced at every level, 1-9 included, and each level bracket has a cap of its own, +// so a faction one player has used for hours cannot pull the roster toward it and the 60s cannot crowd out the low brackets. Pure: no game types, tested in tests/game/ClassicPoolBalance.cpp. #pragma once @@ -13,15 +14,21 @@ namespace Playerbot::V2::Fleet { -constexpr std::size_t kPoolBrackets = 5; // 10-19, 20-29, 30-39, 40-49, 50-60 +constexpr std::size_t kPoolBrackets = 6; // 1-9, 10-19, 20-29, 30-39, 40-49, 50-60 inline std::size_t PoolBracketOf(std::uint32_t level) { - return std::clamp(level / 10u, 1u, kPoolBrackets) - 1u; + return std::clamp(level / 10u, 0u, kPoolBrackets - 1u); } -inline std::uint32_t PoolBracketLo(std::size_t b) { return std::uint32_t(b + 1) * 10u; } -inline std::uint32_t PoolBracketHi(std::size_t b) { return b + 1 == kPoolBrackets ? 60u : std::uint32_t(b + 1) * 10u + 9u; } +inline std::uint32_t PoolBracketLo(std::size_t b) { return b == 0 ? 1u : std::uint32_t(b) * 10u; } +inline std::uint32_t PoolBracketHi(std::size_t b) { return b + 1 == kPoolBrackets ? 60u : std::uint32_t(b) * 10u + 9u; } + +// The cap of one level bracket: the standing roster split evenly over the brackets (rounded up). +inline std::uint32_t PoolBracketCap(std::uint32_t pool_max) +{ + return (pool_max + std::uint32_t(kPoolBrackets) - 1u) / std::uint32_t(kPoolBrackets); +} struct PoolCounts { @@ -36,12 +43,28 @@ struct SeedChoice std::int64_t deficit = 0; // characters this (faction, bracket) lacks to reach the ratio; <= 0 = nothing is lacking }; -// horde_pct: share of the pool that should be Horde, 5..95. For Horde H' = A * p / (1 - p) is the count that would put a bracket at the -// ratio, so it lacks H' - H; likewise for Alliance. The pick is random in proportion to the shortfalls (roll in [0,1)), so every bracket -// that lacks characters gets some at once, in step with how much it lacks: always taking the single largest shortfall filled one bracket -// first and left the low brackets without Horde for the first hundred creations. deficit in the result is the chosen entry's shortfall; -// when nothing lacks, it is the largest (<= 0) and the caller falls back to its own choice. -inline SeedChoice PickSeed(PoolCounts const& c, std::uint32_t horde_pct, double roll) +// How many characters one faction may hold in a bracket: its share of the bracket cap (horde_pct 5..95). +inline std::int64_t PoolTarget(std::uint32_t bracket_cap, std::uint32_t horde_pct, bool alliance) +{ + double const p = std::clamp(horde_pct, 5u, 95u) / 100.0; + return std::int64_t(std::ceil(double(bracket_cap) * (alliance ? 1.0 - p : p))); +} + +// Does the standing roster have room for one more character of this faction at this level? A full (faction, bracket) sends the creation +// to the temporary pool, so the roster stays balanced however much one faction is played. +inline bool PoolHasRoom(PoolCounts const& c, std::uint32_t level, bool alliance, std::uint32_t bracket_cap, std::uint32_t horde_pct) +{ + std::size_t const b = PoolBracketOf(level); + return std::int64_t((alliance ? c.alliance : c.horde)[b]) < PoolTarget(bracket_cap, horde_pct, alliance); +} + +// bracket_cap > 0: every (faction, bracket) has a target of its share of the cap, and the shortfall is target - count, so the short side +// of the short bracket is filled first and a full one is never grown. bracket_cap == 0: the old rule, the ratio between the factions. +// The pick is random in proportion to the shortfalls (roll in [0,1)), so every bracket that lacks characters gets some at once, in step +// with how much it lacks: always taking the single largest shortfall filled one bracket first and left the low brackets without Horde +// for the first hundred creations. deficit in the result is the chosen entry's shortfall; when nothing lacks, it is the largest (<= 0) +// and the caller creates nothing (cap) or falls back to its own choice (ratio). +inline SeedChoice PickSeed(PoolCounts const& c, std::uint32_t horde_pct, double roll, std::uint32_t bracket_cap = 0) { double const p = std::clamp(horde_pct, 5u, 95u) / 100.0; struct Entry { bool alliance; std::size_t bracket; std::int64_t deficit; }; @@ -50,6 +73,12 @@ inline SeedChoice PickSeed(PoolCounts const& c, std::uint32_t horde_pct, double Entry largest{ false, 0, std::numeric_limits::min() }; for (std::size_t b = 0; b < kPoolBrackets; ++b) { + if (bracket_cap) + { + e[b * 2] = { false, b, PoolTarget(bracket_cap, horde_pct, false) - std::int64_t(c.horde[b]) }; + e[b * 2 + 1] = { true, b, PoolTarget(bracket_cap, horde_pct, true) - std::int64_t(c.alliance[b]) }; + continue; + } e[b * 2] = { false, b, std::int64_t(std::ceil(double(c.alliance[b]) * p / (1.0 - p))) - std::int64_t(c.horde[b]) }; e[b * 2 + 1] = { true, b, std::int64_t(std::ceil(double(c.horde[b]) * (1.0 - p) / p)) - std::int64_t(c.alliance[b]) }; } diff --git a/src/modules/PlayerbotV2/Fleet/PoolBudget.h b/src/modules/PlayerbotV2/Fleet/PoolBudget.h new file mode 100644 index 0000000000..29081c8762 --- /dev/null +++ b/src/modules/PlayerbotV2/Fleet/PoolBudget.h @@ -0,0 +1,70 @@ +// PoolBudget - the two budgets of ambient characters and the rule for retiring the temporary ones. +// +// core the standing roster (PoolMax): level 10+ residents that sleep in the characters table and stay for good; +// variable temporary residents (VariableMax): created around a real player where the core has nobody fitting - the island's +// level 1-9 Skyborne for a new character, a low-level town for a new player - and deleted again once they have been +// offline for VariableTtl with nobody needing them. +// +// the core was full (5506/3000, mostly level 60), so every creation was refused and a new character on +// Zephras Isle met 12 bots. A full core must not keep the world empty around a new player, and the extra bots must not pile up. +// Pure: no game types, tested in tests/game/ClassicPoolBudget.cpp. + +#pragma once + +#include + +namespace Playerbot::V2::Fleet { + +struct PoolBudget +{ + std::int64_t core = 0; // standing roster rows + std::int64_t core_max = 0; + std::int64_t variable = 0; // temporary rows (and the island residents created before the variable pool existed) + std::int64_t variable_max = 0; +}; + +enum class PoolSlot : std::uint8_t { None, Core, Variable }; + +// Where one more character may be created. The island's residents are always temporary (they only matter while someone is on the +// island); anyone else goes to the core while it has room and to the variable pool when it does not. +constexpr PoolSlot ChoosePoolSlot(PoolBudget const& b, bool isle_resident) +{ + if (!isle_resident && b.core < b.core_max) + return PoolSlot::Core; + return b.variable < b.variable_max ? PoolSlot::Variable : PoolSlot::None; +} + +// With a level census the standing roster takes a creation when its (faction, level bracket) is below its share of the bracket cap, whatever +// the roster total is (a roster that grew past core_max earlier would otherwise send every missing low-level bot to the temporary pool). +constexpr PoolBudget BalancedBudget(PoolBudget b, bool bracket_has_room) +{ + b.core_max = bracket_has_room ? b.core + 1 : 0; + return b; +} + +constexpr void PoolCountCreated(PoolBudget& b, PoolSlot slot) +{ + if (slot == PoolSlot::Core) + ++b.core; + else if (slot == PoolSlot::Variable) + ++b.variable; +} + +// May a temporary character be deleted now? Only when it is flagged temporary, nobody is using it (offline, no owner, no group, no +// queue tag) and it has been offline for the whole TTL. A core, owned, saved, grouped or online character is never retired. +struct RetireFacts +{ + bool variable = false; + bool online = false; + bool owned = false; // a player's companion + bool grouped = false; + bool queue_tagged = false; // a battleground/queue JIT bot (its own hygiene handles those) + std::int64_t offline_seconds = 0; +}; + +constexpr bool CanRetire(RetireFacts const& f, std::int64_t ttl_seconds) +{ + return f.variable && !f.online && !f.owned && !f.grouped && !f.queue_tagged && f.offline_seconds >= ttl_seconds; +} + +} // namespace Playerbot::V2::Fleet diff --git a/src/modules/PlayerbotV2/Fleet/WorldBotSpawner.cpp b/src/modules/PlayerbotV2/Fleet/WorldBotSpawner.cpp index 6b20baf207..f8b68fc2f7 100644 --- a/src/modules/PlayerbotV2/Fleet/WorldBotSpawner.cpp +++ b/src/modules/PlayerbotV2/Fleet/WorldBotSpawner.cpp @@ -1,6 +1,11 @@ // WorldBotSpawner - see the header for the model. World thread only. +#include "Fleet/LevelWindow.h" +#include "Api/PlayerbotAPI.h" +#include "Bot/QuestDoable.h" +#include "Bot/Gear/WorldGearStart.h" #include "Fleet/WorldLeash.h" +#include "Fleet/CityLayer.h" #include "WorldBotSpawner.h" #include "Bot/TownLife.h" #include "WakeSelect.h" @@ -8,6 +13,8 @@ #include "DayRhythm.h" #include "SoakAnchors.h" #include "../Travel/TownNpcIndex.h" +#include "../Travel/ReachMemory.h" +#include "../Travel/UnifiedTravelGraph.h" #include "UnitDefines.h" #include "TownGatherSource.h" #include "WorldFactionMix.h" @@ -263,7 +270,8 @@ void WorldBotSpawner::LoadConfig() c.area_cap_town = uint32(std::clamp(sConfigMgr->GetIntDefault("Playerbot.World.AreaCapTown", 40, true), 0, 500)); c.area_radius = std::clamp(sConfigMgr->GetFloatDefault("Playerbot.World.AreaRadius", 45.0f, true), 15.0f, 200.0f); c.pool_horde_pct = std::clamp(uint32(sConfigMgr->GetIntDefault("Playerbot.World.PoolHordePct", 50, true)), 5, 95); - c.skyborne_seed_pct = std::min(100, uint32(sConfigMgr->GetIntDefault("Playerbot.World.SkyborneSeedPct", 5, true))); + c.variable_max = uint32(std::clamp(sConfigMgr->GetIntDefault("Playerbot.World.VariableMax", 2000, true), 0, 20000)); + c.variable_ttl_h = uint32(std::clamp(sConfigMgr->GetIntDefault("Playerbot.World.VariableTtlHours", 24, true), 1, 24 * 90)); cfg_ = c; } @@ -271,7 +279,7 @@ WorldLoadFacts WorldBotSpawner::Load() const { WorldLoadFacts f; f.awake = ambient_online_; - int64 const pool = pool_count_ < 0 ? 0 : pool_count_; + int64 const pool = pool_count_ < 0 ? 0 : pool_count_ + variable_count_; // temporary residents are rows too f.sleeping = pool > int64(all_online_) ? uint32(pool - int64(all_online_)) : 0u; f.rss_mb = uint32(ProcessRssKb() / 1024u); f.cpu_pct = cpu_pct_; @@ -295,21 +303,35 @@ std::string WorldBotSpawner::Report() const n_no_match_, n_pool_full_, n_spawn_failed_, n_login_failed_, n_logged_in_, n_created_, n_placed_, n_despawned_, n_abandoned_, last_tick_cost_ms_, avg, max_tick_cost_ms_, rss / 1024, baseline_rss_kb_ / 1024, per_bot_mb); + { + // The standing roster by level bracket (1-9 / 10s / 20s / 30s / 40s / 50-60), Alliance/Horde, as of the last census plus creations since. + std::string pool; + for (std::size_t b = 0; b < kPoolBrackets; ++b) + pool += Trinity::StringFormat(" {}/{}", pool_counts_.alliance[b], pool_counts_.horde[b]); + line += Trinity::StringFormat(" | pool A/H per bracket{} cap {}", pool, PoolBracketCap(cfg_.pool_max)); + } + line += Trinity::StringFormat(" | place calls={} none={} rejected no_ground={} water={} no_nav={} lava={} no_path={} area_full={}", + n_place_calls_, n_place_none_, n_place_reject_[0], n_place_reject_[1], n_place_reject_[2], n_place_reject_[3], n_place_reject_[4], n_place_reject_[5]); line += Trinity::StringFormat(" | split world={} (cap {}) tied_up={} (group/BG/instance) owned={} (companions) soak_anchors={} evicted_for_room={} | walked_in={} walked_out={} leaving={}", ambient_online_, cfg_.max_bots, tied_online_, owned_online_, soak_anchors_, n_evicted_, n_arrived_walking_, n_left_walking_, leaving_.size()); { auto& tl = ::Playerbot::V2::TownLife::Counters(); - line += Trinity::StringFormat(" | town_life inn_ticks={} mailbox_ticks={} duels={} campfires={} lfg_calls={} idle_strikes town={} field={}", - tl.inn_ticks.load(std::memory_order_relaxed), tl.mailbox_ticks.load(std::memory_order_relaxed), tl.duels.load(std::memory_order_relaxed), + line += Trinity::StringFormat(" | town_life inn_ticks={} inn_walk={} inn_none={} inn_stuck={} mailbox_ticks={} duels={} campfires={} lfg_calls={} idle_strikes town={} field={}", + tl.inn_ticks.load(std::memory_order_relaxed), tl.inn_walk.load(std::memory_order_relaxed), tl.inn_none.load(std::memory_order_relaxed), tl.inn_stuck.load(std::memory_order_relaxed), tl.mailbox_ticks.load(std::memory_order_relaxed), tl.duels.load(std::memory_order_relaxed), tl.campfires.load(std::memory_order_relaxed), tl.lfg_calls.load(std::memory_order_relaxed), tl.idle_town.load(std::memory_order_relaxed), tl.idle_field.load(std::memory_order_relaxed)); } auto const tiers = Services::Scheduler().tier_counts(); // Persistent residents: the pool is the roster, a bot logged out stays where it stood. sleeping = pool bots offline. - int64 const pool = pool_count_ < 0 ? 0 : pool_count_; + int64 const pool = pool_count_ < 0 ? 0 : pool_count_ + variable_count_; // temporary residents are rows too int64 const sleeping = pool > int64(all_online_) ? pool - int64(all_online_) : 0; double const awake_ram_mb = all_online_ ? double(rss) / 1024.0 / double(all_online_) : 0.0; line += Trinity::StringFormat(" | roster pool={} awake={} sleeping={} seeding={} seeded_total={} woken_total={} wake_dry={} wake_radius={:.0f} | cost proc_cpu_pct={:.1f} cpu_pct_per_awake_bot={:.3f} ram_mb_per_awake_bot_incl_base={:.2f} ram_mb_per_sleeping_bot=0 (offline: a row in the characters table)", pool, all_online_, sleeping, seeding_.size(), n_seeded_, n_woken_, n_wake_dry_, cfg_.wake_radius, cpu_pct_, all_online_ ? cpu_pct_ / double(all_online_) : 0.0, awake_ram_mb); + { + auto& rm = ::Playerbot::V2::Travel::ReachMemory::Instance(); + line += Trinity::StringFormat(" | reach_memory cells={} noted={} skipped={}", rm.size(), rm.noted(), rm.skips()); + } + line += Trinity::StringFormat(" | variable pool={}/{} created={} retired={}", variable_count_, cfg_.variable_max, n_created_variable_, n_retired_); line += Trinity::StringFormat(" | tiers combat={} active={} cruise={} idle={} parked={}", tiers[0], tiers[1], tiers[2], tiers[3], tiers[4]); return line; } @@ -434,6 +456,9 @@ static bool CompletePathTo(Player* from, float x, float y, float z) // stranded on that alone. So an incomplete path is followed: the next call starts where the last one ended, and the goal is reached when // some call completes. A real pocket (the Great Forge pit) ends at the same point every time, so the chain stops advancing and it is // refused. At most `hops` calls; `used` gets the number made (the caller's probe budget). +// A path that goes down a cliff face is not one a bot can walk: Detour joins the layers of Stormwind over steep faces, so a bot on a +// platform above the city "reaches" the city by a drop it cannot make (Dutchess, 36 minutes on the wall at z 101). The check is +// Fleet::PathHasCliff (CityLayer.h); no function of the same name may be declared in this file, or the call below binds to it. static bool ReachableChain(Player* from, float x, float y, float z, uint32 hops, uint32& used) { float sx = from->GetPositionX(), sy = from->GetPositionY(), sz = from->GetPositionZ(); @@ -446,11 +471,11 @@ static bool ReachableChain(Player* from, float x, float y, float z, uint32 hops, if (t & (PATHFIND_NOT_USING_PATH | PATHFIND_SHORTCUT)) return true; if ((t & PATHFIND_NORMAL) && !(t & (PATHFIND_NOPATH | PATHFIND_INCOMPLETE | PATHFIND_FARFROMPOLY))) - return true; + return !PathHasCliff(pg.GetPath()); if (!(t & PATHFIND_INCOMPLETE) || (t & PATHFIND_NOPATH)) return false; Movement::PointsArray const& pts = pg.GetPath(); - if (pts.size() < 2) + if (pts.size() < 2 || PathHasCliff(pts)) return false; G3D::Vector3 const& end = pts.back(); if (std::hypot(end.x - sx, end.y - sy) < 3.0f) @@ -530,6 +555,7 @@ void WorldBotSpawner::StepOffStack(Player* bot) bool WorldBotSpawner::PlaceNear(Player* bot, Player* anchor) { + ++n_place_calls_; Map* map = anchor->GetMap(); if (!map) return false; @@ -568,6 +594,10 @@ bool WorldBotSpawner::PlaceNear(Player* bot, Player* anchor) { if (h.mapId != anchor->GetMapId()) return; if (in_town && h.zoneId != anchor->GetZoneId()) return; // a city's crowd stays in the city, not in the hubs of the countryside around it + // Outside a city a bot stands at a hub to take its quests. A hub where this bot can take none (the chain starts are done, the quests are + // above its level or another class's) only parks it at the quest giver with nothing to do, and a valley's one hub then holds the whole crowd + // (Coldridge camp, 2026-10-18): the bot gets a ring spot among the mobs instead, where it grinds. + if (!in_town && !::Playerbot::HubHasDoableQuest(bot, h)) return; float const d = Dist2D(h.location.GetPositionX(), h.location.GetPositionY(), ax, ay); if (d >= min_d && d <= cfg_.activity_radius * 0.9f) { @@ -587,7 +617,17 @@ bool WorldBotSpawner::PlaceNear(Player* bot, Player* anchor) if (uint64(id) == bot->GetGUID().GetCounter()) return; Player* o = ObjectAccessor::FindConnectedPlayer(ObjectGuid::Create(id)); if (o && o->IsInWorld() && o->GetMapId() == anchor->GetMapId() && owner_.IsAmbientBot(id, o)) - crowd.push_back({ uint64(id), o->GetPositionX(), o->GetPositionY(), area_cap }); + { + // A bot just sent here walks in from out of sight: count it at the spot it is walking to. By its position on the way every + // bot looked like room at the same hub, they all arrived together and the crowd pass sent the extras off again (every 10 s). + float cx = o->GetPositionX(), cy = o->GetPositionY(); + if (auto const it = place_dest_.find(uint64(id)); it != place_dest_.end()) + { + if (int32(it->second.until_ms - getMSTime()) > 0) { cx = it->second.x; cy = it->second.y; } + else place_dest_.erase(it); + } + crowd.push_back({ uint64(id), cx, cy, area_cap }); + } }); auto crowd_at = [&](Spot const& h) { @@ -602,7 +642,9 @@ bool WorldBotSpawner::PlaceNear(Player* bot, Player* anchor) // Capital: 60% a quest-giver hub near the player (the busy spots), 25% a spot on a tight ring, 15% any hub of the // city, so the crowd is around him and not in the far districts. Elsewhere: any hub of the zone. uint32 const roll = urand(0, 99); - bool const use_hub = !hubs.empty() && (!in_town || (roll < 60 && !near_hubs.empty()) || roll >= 85); + // The first eight tries stand at a hub; when every hub near the player is full (a starter valley has one or two) the last four + // take a ring spot, instead of the whole pass failing with area_full. + bool const use_hub = !hubs.empty() && attempt < 8 && (!in_town || (roll < 60 && !near_hubs.empty()) || roll >= 85); if (use_hub) { std::vector const& base = (in_town && roll < 60 && !near_hubs.empty()) ? near_hubs : hubs; @@ -652,23 +694,41 @@ bool WorldBotSpawner::PlaceNear(Player* bot, Player* anchor) } float const z = map->GetHeight(anchor->GetPhaseShift(), x, y, anchor->GetPositionZ() + 20.0f, true, 60.0f); if (z <= INVALID_HEIGHT) + { + ++n_place_reject_[0]; continue; + } // The ground height of a canal or pond is its floor: never put a bot on a spot that has water over it (even ankle-deep: the check is at the floor, not at head height). if (map->GetLiquidStatus(anchor->GetPhaseShift(), x, y, z + 0.05f, {}) & (LIQUID_MAP_IN_WATER | LIQUID_MAP_UNDER_WATER)) + { + ++n_place_reject_[1]; continue; + } // The height probe finds ANY surface within 60 y below the player: the floor of a lava pit (Ironforge's Great Forge), a roof, // a lower level. Stand only where a walkable navmesh polygon is, so the bot can path from its spot to anywhere. Position nav; if (!::Playerbot::BotMovement::NearestNavPoint(anchor, x, y, z, 4.0f, 5.0f, nav)) + { + ++n_place_reject_[2]; continue; + } // Walkable is not yet "a place to live": never lava or slime, and in a town a spot the player can walk to. The Great Forge's // pit floor is ground to the probe and to the mesh but joins nothing; a bot put there stands in it for good. if (InMagma(map, anchor->GetPhaseShift(), nav.GetPositionX(), nav.GetPositionY(), nav.GetPositionZ() + 0.05f)) + { + ++n_place_reject_[3]; continue; + } if (in_town && !CompletePathTo(anchor, nav.GetPositionX(), nav.GetPositionY(), nav.GetPositionZ())) + { + ++n_place_reject_[4]; continue; + } if (!::Playerbot::V2::Fleet::RoomFor(crowd, nav.GetPositionX(), nav.GetPositionY(), cfg_.area_radius, area_cap)) - continue; // the area is full: another spot + { + ++n_place_reject_[5]; // the area is full: another spot + continue; + } bx = nav.GetPositionX(); by = nav.GetPositionY(); bz = nav.GetPositionZ(); last_place_dist_ = dist; have = true; @@ -676,7 +736,19 @@ bool WorldBotSpawner::PlaceNear(Player* bot, Player* anchor) hidden = !anchor->IsWithinLOS(bx, by, bz + 1.5f); } if (!have) + { + ++n_place_none_; + // Nothing was ever placed and the navmesh refused the spots: the world's mmaps are not there (a repack ships only the dungeon ones; + // setup\build-bot-pathfinding.bat builds the rest). Say so once a minute, so the empty world has a reason in the log. + static uint32 s_nonav_warn_ms = 0; + if (n_placed_ == 0 && n_place_reject_[2] > 0 && getMSTimeDiff(s_nonav_warn_ms, getMSTime()) >= 60000u) + { + s_nonav_warn_ms = getMSTime(); + TC_LOG_ERROR("playerbot.v2", "[world] WARNING: no navmesh found around the player on map {} ({} spots refused, no bot placed so far). World bots cannot be placed " + "without the world mmaps: run setup\\build-bot-pathfinding.bat (or copy the mmaps folder) and restart.", anchor->GetMapId(), n_place_reject_[2]); + } return false; + } float const o = frand(0.0f, 2.0f * float(M_PI)); // A spot the player can see: the bot does not pop into view there. It appears out of his sight, 110-160 y away, and walks in. @@ -707,6 +779,9 @@ bool WorldBotSpawner::PlaceNear(Player* bot, Player* anchor) bool const moved = bot->GetMapId() == anchor->GetMapId() ? ::Playerbot::BotMovement::SafeNearTeleport(bot, sx, sy, sz, o) : ::Playerbot::BotMovement::SafeTeleport(bot, anchor->GetMapId(), sx, sy, sz, o, /*options*/ 0); + last_place_x_ = sx; last_place_y_ = sy; last_place_z_ = sz; + if (moved) + place_dest_[bot->GetGUID().GetCounter()] = PlaceDest{ bx, by, getMSTime() + 90000u }; if (moved && arrive_on_foot) if (BotAI* ai = Services::Registry().ai(bot->GetGUID().GetCounter())) { @@ -716,6 +791,47 @@ bool WorldBotSpawner::PlaceNear(Player* bot, Player* anchor) return moved; } +void WorldBotSpawner::LoadGearResetPending() +{ + if (gear_reset_loaded_ || gear_reset_inflight_) + return; + gear_reset_inflight_ = true; + queries_.AddCallback(CharacterDatabase.AsyncQuery("SELECT character_guid_low FROM playerbot_v2_character WHERE world_gear_pending = 1") + .WithCallback([this](QueryResult res) + { + if (res) + do { gear_reset_pending_.insert(res->Fetch()[0].GetUInt64()); } while (res->NextRow()); + gear_reset_loaded_ = true; + gear_reset_inflight_ = false; + if (!gear_reset_pending_.empty()) + TC_LOG_INFO("playerbot.v2", "[world] {} world bots under level 10 will be set back to their starter outfit on login", gear_reset_pending_.size()); + })); +} + +// A world bot made before this change wears a generated full set at level 1-9. It is stripped once to the outfit its character was created with, and the +// row is marked so it never happens again; one that has reached level 10 since keeps what it wears (only the mark is cleared). +void WorldBotSpawner::ResetStarterGearOnce(Player* bot) +{ + uint64 const guid_low = bot->GetGUID().GetCounter(); + if (!gear_reset_pending_.contains(guid_low) || gear_reset_tried_.contains(guid_low)) + return; + // Armor cannot be put on while casting or fighting (result 40, "can't do that right now"): try again on a later tick. + if (bot->IsInCombat() || bot->HasUnitState(UNIT_STATE_CASTING) || bot->IsNonMeleeSpellCast(false)) + return; + gear_reset_tried_.insert(guid_low); // not marked, or already tried since the server started (a piece that cannot be worn is not retried every tick) + bool complete = true; + if (bot->GetLevel() < ::Playerbot::Gear::kWorldGearMinLevel) + { + uint32 const removed = ::Playerbot::API(bot).reset_to_starter_gear(complete); + TC_LOG_INFO("playerbot.v2", "[world] {} (L{}) starter outfit {}: {} equipped items replaced or removed", bot->GetName(), uint32(bot->GetLevel()), + complete ? "on" : "NOT complete, kept for the next login", removed); + } + if (!complete) + return; // the mark stays: the next login tries again, and the old pieces were only taken off where a starter piece went on + gear_reset_pending_.erase(guid_low); + CharacterDatabase.PExecute("UPDATE playerbot_v2_character SET world_gear_pending = 0 WHERE character_guid_low = {}", guid_low); +} + void WorldBotSpawner::DrivePending(uint32 now_ms, std::vector const&) { for (auto it = pending_.begin(); it != pending_.end();) @@ -724,6 +840,9 @@ void WorldBotSpawner::DrivePending(uint32 now_ms, std::vector const&) Pending& pd = it->second; ObjectGuid const g = ObjectGuid::Create(guid_low); Player* bot = ObjectAccessor::FindConnectedPlayer(g); + // Once the pending list is read, a bot that is up and set up is looked at for the one-time outfit reset before anything else moves it. + if (gear_reset_loaded_ && bot && bot->IsInWorld() && !bot->IsBeingTeleported() && owner_.SetupDone(guid_low)) + ResetStarterGearOnce(bot); bool drop = getMSTimeDiff(pd.queued_ms, now_ms) >= kPendingTimeoutMs; if (pd.global) @@ -770,9 +889,11 @@ void WorldBotSpawner::DrivePending(uint32 now_ms, std::vector const&) } if (!bot->IsInCombat() && bot->IsAlive() && PlaceNear(bot, anchor)) { - TC_LOG_INFO("playerbot.v2", "[world] placed {} ({}) L{} zone {} at ({:.0f},{:.0f},{:.0f}), {:.0f} y from anchor, after {} ms", - bot->GetName(), guid_low, bot->GetLevel(), bot->GetZoneId(), bot->GetPositionX(), bot->GetPositionY(), - bot->GetPositionZ(), last_place_dist_, getMSTimeDiff(pd.queued_ms, now_ms)); + // The teleport lands after this call, so the bot's own position and zone are still where it logged in: the line names the + // destination (and the anchor's zone), and "was" is the position it came from. + TC_LOG_INFO("playerbot.v2", "[world] placed {} ({}) L{} to ({:.0f},{:.0f},{:.0f}) in zone {}, {:.0f} y from anchor, after {} ms | was zone {} ({:.0f},{:.0f},{:.0f}) map {}", + bot->GetName(), guid_low, bot->GetLevel(), last_place_x_, last_place_y_, last_place_z_, anchor->GetZoneId(), last_place_dist_, + getMSTimeDiff(pd.queued_ms, now_ms), bot->GetZoneId(), bot->GetPositionX(), bot->GetPositionY(), bot->GetPositionZ(), bot->GetMapId()); placed_[guid_low] = Placed{ now_ms }; ++n_placed_; // A town (capital: no zone level range): most bots stay there and do town things, so it looks busy. @@ -1030,19 +1151,14 @@ void WorldBotSpawner::WindowFor(Anchor const& a, uint8& lo, uint8& hi) const hi = w.hi; return; } - if (!::Playerbot::V2::World::VanillaZoneLevelRange(a.zone, lo, hi)) - { - // Capitals and other towns: a town is full of every level, so spread over the whole range. - lo = uint8(cfg_.min_level); - hi = uint8(cfg_.max_level); - } - else - { - lo = uint8(std::max(1, int(lo) - 2)); - hi = uint8(std::min(60, int(hi) + 2)); - } - lo = uint8(std::clamp(lo, cfg_.min_level, cfg_.max_level)); - hi = uint8(std::clamp(hi, lo, cfg_.max_level)); + // The player's own level inside the zone's range (a level 1 in Northshire meets level 1-3 bots, not level 10 ones), whatever the + // zone; MinLevel keeps the wide spread of a capital and the world-wide filler up, it no longer lifts a starter zone's bots. + uint8 zlo = 0, zhi = 0; + bool const zone_known = ::Playerbot::V2::World::VanillaZoneLevelRange(a.zone, zlo, zhi); + ::Playerbot::V2::Fleet::LevelWindow const w = ::Playerbot::V2::Fleet::AnchorLevelWindow( + int(a.level), zone_known, int(zlo), int(zhi), int(cfg_.min_level), int(cfg_.max_level)); + lo = uint8(w.lo); + hi = uint8(w.hi); } void WorldBotSpawner::DriveSpawn(uint32 now_ms, std::vector const& anchors) @@ -1088,6 +1204,8 @@ void WorldBotSpawner::DriveSpawn(uint32 now_ms, std::vector const& ancho } } + // Random order, not oldest-seen first: the oldest rows are the same ones every pass, and when they are all of the other faction + // (or never match the slots) the pass matched nothing and the anchor's zone stayed empty (Duskwood 0/8 each pass in a soak run). // Level range that suits the anchor's zone; capitals and the like have none, so spread around the player. uint8 lo = 0, hi = 0; WindowFor(a, lo, hi); @@ -1106,7 +1224,7 @@ void WorldBotSpawner::DriveSpawn(uint32 now_ms, std::vector const& ancho "SELECT pv.character_guid_low, c.level, c.race, c.map, c.position_x, c.position_y, c.position_z FROM playerbot_v2_character pv " "JOIN characters c ON c.guid = pv.character_guid_low " "WHERE c.level BETWEEN {} AND {} AND c.online = 0 AND pv.distribution_level > 0 {}" - "ORDER BY pv.last_seen_at ASC LIMIT {}", + "ORDER BY RAND() LIMIT {}", uint32(lo), uint32(hi), SkyborneRaceClause(Skyborne::IsOnIsle(a.map)), std::max(want * 20u, 100u)).c_str()) .WithCallback([this, a, slots, slot_levels](QueryResult res) { @@ -1184,7 +1302,7 @@ void WorldBotSpawner::DriveCrowd(uint32 now_ms, std::vector const& ancho void WorldBotSpawner::DriveStranded(uint32 now_ms, std::vector const& anchors) { constexpr uint32 kPassMs = 2000u; - constexpr uint32 kProbesPerPass = 3u; // path probes (the costly ones) per pass; lava checks are cheap + constexpr uint32 kProbesPerPass = 12u; // path probes (the costly ones) per pass; lava checks are cheap. Three a pass checked a bot once in two minutes or worse once 40 bots needed the full chain constexpr float kTownPathRange = 200.0f; // a town's player this close gives the reference for "a way out" if (last_stranded_ms_ && getMSTimeDiff(last_stranded_ms_, now_ms) < kPassMs) return; @@ -1233,6 +1351,37 @@ void WorldBotSpawner::DriveStranded(uint32 now_ms, std::vector const& an path_out = ReachableChain(p, near_a->x, near_a->y, near_a->z, 4u, used); probes += std::max(1u, used); } + else if (!magma && in_town) + { + // Nobody close by: the town's own meeting places are the reference. A bot on a lower layer under the city (a bot at z 75 and 59 + // below the Trade District's z 97, same x/y) reaches none of them. It must reach at least one of the three nearest. + std::vector<::Playerbot::V2::Fleet::GatherSpot> spots = + ::Playerbot::V2::Fleet::TownGatherSpots(p->GetMapId(), px, py, 150.0f, p->GetTeam() == ALLIANCE); + if (spots.empty()) // a far corner of the city (Dutchess, the wall at the north-west): no meeting place within 150 y, so look wider + spots = ::Playerbot::V2::Fleet::TownGatherSpots(p->GetMapId(), px, py, 600.0f, p->GetTeam() == ALLIANCE); + std::sort(spots.begin(), spots.end(), [&](auto const& a, auto const& b) + { return Dist2D(a.x, a.y, px, py) < Dist2D(b.x, b.y, px, py); }); + if (spots.size() > 3u) + spots.resize(3u); + if (!spots.empty()) + { + if (probes >= kProbesPerPass) + return; + path_out = false; + for (auto const& g : spots) + { + uint32 used = 0; + bool const ok = ReachableChain(p, g.x, g.y, g.z, 4u, used); + probes += std::max(1u, used); + if (ok) { path_out = true; break; } + } + } + } + // Every path call from this spot has been failing for minutes (a pocket with void all round it: Hellice, 3720 NoPath in an hour, + // pacing a few yards so the idle watch never saw her stand still): as cut off as a bot whose probe finds no way out. + bool const storm = !magma && path_out && ::Playerbot::BotMovement::NoPathStorm(p); + if (storm) + path_out = false; if (!StrandedUpdate(st, magma, path_out, px, py, pz, now_ms)) return; @@ -1240,12 +1389,13 @@ void WorldBotSpawner::DriveStranded(uint32 now_ms, std::vector const& an if (!ap || !ap->IsInWorld() || !PlaceNear(p, ap)) return; placed_[uint64(id)] = Placed{ now_ms }; + ::Playerbot::BotMovement::ClearNoPath(p); ++n_stranded_moved_; // How it got there, so the cause can be read from the log: the rule that last moved it, and the spot the previous check found it // on (a bot that walked in shows a previous spot nearby; one that was put there or woke there shows none or a far one). char const* last_rule = entry.ai && entry.ai->last_rule_fired() ? entry.ai->last_rule_fired() : "-"; TC_LOG_INFO("playerbot.v2", "[world] {} ({}) was {} at ({:.0f},{:.0f},{:.0f}) in zone {}, placed again next to {} | last_rule={} previous_check=({:.0f},{:.0f},{:.0f})", - p->GetName(), uint64(id), magma ? "standing in lava" : "on ground with no way out", px, py, pz, p->GetZoneId(), ap->GetName(), + p->GetName(), uint64(id), magma ? "standing in lava" : storm ? "on ground where every path call fails" : "on ground with no way out", px, py, pz, p->GetZoneId(), ap->GetName(), last_rule, prev_x, prev_y, prev_z); }); // Forget bots that are gone. @@ -1300,13 +1450,13 @@ void WorldBotSpawner::DriveStuckLedger(uint32 now_ms) float const ground = p->GetMap()->GetHeight(p->GetPhaseShift(), px, py, pz + 3.0f, true, 20.0f); TC_LOG_INFO("playerbot.v2", "[stuck_ledger] {} ({}) zone {} at ({:.1f},{:.1f},{:.1f}) strikes={} on_mesh={} {} ground_z={:.1f} rooted={} stunned={} held_state={} " - "falling={} swimming={} move_gen={} run_speed={:.1f} target=({:.0f},{:.0f},{:.0f}) {} last_rule={}", + "falling={} swimming={} move_gen={} run_speed={:.1f} nopath_storm={} target=({:.0f},{:.0f},{:.0f}) {} last_rule={}", p->GetName(), uint64(id), p->GetZoneId(), px, py, pz, w.strikes, on_mesh ? "yes" : "NO", on_mesh ? "" : (wide ? std::format("(walkable ground {:.0f} y away)", std::hypot(wide_mesh.GetPositionX() - px, wide_mesh.GetPositionY() - py)) : std::string("(none within 40 y)")), ground > INVALID_HEIGHT ? ground : -999.f, p->HasUnitMovementFlag(MOVEMENTFLAG_ROOT) ? 1 : 0, p->HasUnitState(UNIT_STATE_STUNNED) ? 1 : 0, p->HasUnitState(UNIT_STATE_ROOT | UNIT_STATE_CONFUSED | UNIT_STATE_FLEEING | UNIT_STATE_CONTROLLED) ? 1 : 0, p->IsFalling() ? 1 : 0, p->IsInWater() ? 1 : 0, uint32(p->GetMotionMaster()->GetCurrentMovementGeneratorType()), - p->GetSpeed(MOVE_RUN), w.tx, w.ty, w.tz, reach, + p->GetSpeed(MOVE_RUN), ::Playerbot::BotMovement::NoPathStorm(p) ? 1 : 0, w.tx, w.ty, w.tz, reach, entry.ai->last_rule_fired() ? entry.ai->last_rule_fired() : "-"); if (!on_mesh && wide) { @@ -1320,6 +1470,66 @@ void WorldBotSpawner::DriveStuckLedger(uint32 now_ms) it = ObjectAccessor::FindConnectedPlayer(ObjectGuid::Create(it->first)) ? std::next(it) : ledger_ms_.erase(it); } +// The variable pool (PoolBudget.h): temporary residents were created around a player; once one has been offline for VariableTtlHours, +// with no owner, group or queue tag and not flagged anything but temporary, the server's own character delete removes it. The core +// roster, a player's companions, saved or grouped bots and anything online are never selected, in the query and again live. +// One small batch per pass (the query runs off the world thread; only the few deletes run on it), logged with its cost. +void WorldBotSpawner::DriveRetire(uint32 now_ms) +{ + constexpr uint32 kRetirePassMs = 10u * 60u * 1000u; + constexpr uint32 kRetirePerPass = 25u; + if (variable_sweep_inflight_ || pool_count_ < 0 || query_inflight_) + return; + if (variable_sweep_ms_ && getMSTimeDiff(variable_sweep_ms_, now_ms) < kRetirePassMs) + return; + variable_sweep_ms_ = now_ms ? now_ms : 1u; + variable_sweep_inflight_ = true; + uint32 const ttl_h = cfg_.variable_ttl_h; + queries_.AddCallback(CharacterDatabase.AsyncQuery(Trinity::StringFormat( + "SELECT pv.character_guid_low, c.account, c.name, c.online, " + "(pv.owner_account_id <> 0 OR pv.owner_player_guid <> 0), " + "EXISTS (SELECT 1 FROM `group_member` gm WHERE gm.memberGuid = c.guid), " + "(pv.jit_for_queue IS NOT NULL AND pv.jit_for_queue <> ''), " + "GREATEST(UNIX_TIMESTAMP() - c.logout_time, UNIX_TIMESTAMP() - UNIX_TIMESTAMP(pv.spawned_at)) " + "FROM playerbot_v2_character pv JOIN characters c ON c.guid = pv.character_guid_low " + "WHERE pv.variable_pool = 1 AND c.online = 0 AND pv.spawned_at < (NOW() - INTERVAL {} HOUR) " + "AND c.logout_time < (UNIX_TIMESTAMP() - {}) ORDER BY c.logout_time LIMIT {}", + ttl_h, uint64(ttl_h) * 3600u, kRetirePerPass).c_str()) + .WithCallback([this, ttl_h](QueryResult res) + { + variable_sweep_inflight_ = false; + if (!res) + return; + uint32 const t0 = getMSTime(); + uint32 retired = 0; + do + { + Field* f = res->Fetch(); + uint64 const guid = f[0].GetUInt64(); + RetireFacts facts; + facts.variable = true; // the query selects flagged rows only + facts.online = f[3].GetUInt8() != 0 || pending_.contains(guid) || seeding_.contains(guid) || placed_.contains(guid); + facts.owned = f[4].GetInt64() != 0; + facts.grouped = f[5].GetInt64() != 0; + facts.queue_tagged = f[6].GetInt64() != 0; + facts.offline_seconds = f[7].GetInt64(); + if (!CanRetire(facts, int64(ttl_h) * 3600)) + continue; + if (owner_.RetireVariableBot(guid, f[1].GetUInt32(), f[2].GetString())) + { + ++retired; + --variable_count_; + } + } while (res->NextRow()); + if (retired) + { + n_retired_ += retired; + TC_LOG_INFO("playerbot.v2", "[world] variable pool: {} temporary resident(s) deleted after {} h unused in {} ms (now {}/{}, {} deleted, {} created since start)", + retired, ttl_h, getMSTimeDiff(t0, getMSTime()), variable_count_, cfg_.variable_max, n_retired_, n_created_variable_); + } + })); +} + void WorldBotSpawner::DriveGraduation(uint32 now_ms) { // Every few seconds, at most two bots per pass: a bot reaching level 10 on the isle is moved the way a new level-10 bot is @@ -1383,7 +1593,12 @@ void WorldBotSpawner::DriveSeed(uint32 now_ms) ++it; } - if (!cfg_.seed_roster || pool_count_ < 0 || rss_capped_ || pool_count_ >= int64(cfg_.pool_max)) + if (!cfg_.seed_roster || pool_count_ < 0 || rss_capped_) + return; + // The seeder only builds the standing roster (core). Temporary residents are created on demand around a player (FinishSpawn). + // Once the census is read, what the roster lacks is decided per (faction, level bracket) against the bracket cap, not by the total: a + // roster that grew past PoolMax in the old days (brackets 10+ over their cap) would otherwise never get its short level 1-9 bracket. + if (!pool_counts_ms_ && pool_count_ >= int64(cfg_.pool_max)) return; if (seeding_.size() >= cfg_.seed_in_flight || ambient_online_ + pending_.size() + seeding_.size() >= cfg_.max_bots) return; @@ -1391,24 +1606,18 @@ void WorldBotSpawner::DriveSeed(uint32 now_ms) // The census decides which faction and level bracket the roster lacks most; until it is read the seeder waits. if (!pool_counts_ms_) return; - SeedChoice const want = PickSeed(pool_counts_, cfg_.pool_horde_pct, double(urand(0, 999999)) / 1000000.0); - bool const alliance = want.deficit > 0 ? want.alliance : urand(0, 99) >= cfg_.pool_horde_pct; - // A small share of the seeds are Skyborne residents of Zephras Isle: level 1-9, asleep on the island (their pipeline leaves - // them at the start), so a player who arrives there finds the island lived in. The rest are the usual leveling-town bots. - bool const isle = urand(0, 99) < cfg_.skyborne_seed_pct; - uint8 level; - if (isle) - level = uint8(urand(Skyborne::kIsleLevelLo, Skyborne::kIsleLevelHi)); - else if (want.deficit > 0) - level = uint8(urand(std::max(cfg_.min_level, PoolBracketLo(want.bracket)), std::max(cfg_.min_level, std::min(cfg_.max_level, PoolBracketHi(want.bracket))))); - else - level = uint8(urand(cfg_.min_level, cfg_.max_level)); - if (uint64 const guid = owner_.SpawnAmbientBot(level, alliance, isle ? Skyborne::RaceForTeam(alliance) : uint8(0))) + // Every (faction, level bracket) has a target of its own, 1-9 included; the roster is filled where it lacks most and never past a + // bracket's cap, so the factions stay level and the 60s cannot crowd out the low levels. + SeedChoice const want = PickSeed(pool_counts_, cfg_.pool_horde_pct, double(urand(0, 999999)) / 1000000.0, PoolBracketCap(cfg_.pool_max)); + if (want.deficit <= 0) + return; // every (faction, bracket) is at its target + bool const alliance = want.alliance; + uint8 const level = uint8(urand(PoolBracketLo(want.bracket), std::min(cfg_.max_level, PoolBracketHi(want.bracket)))); + if (uint64 const guid = owner_.SpawnAmbientBot(level, alliance, uint8(0))) { seeding_[guid] = Seeding{ now_ms ? now_ms : 1u, 0 }; ++pool_count_; - if (!isle) - PoolAdd(pool_counts_, alliance, level); + PoolAdd(pool_counts_, alliance, level); } else ++n_spawn_failed_; @@ -1511,7 +1720,7 @@ void WorldBotSpawner::DriveGlobalSpawn(uint32 now_ms, std::vector const& "SELECT pv.character_guid_low, c.level, c.race, c.map, c.position_x, c.position_y, c.position_z FROM playerbot_v2_character pv " "JOIN characters c ON c.guid = pv.character_guid_low " "WHERE c.level BETWEEN {} AND {} AND c.online = 0 AND pv.distribution_level > 0 {}" - "ORDER BY pv.last_seen_at ASC LIMIT {}", + "ORDER BY RAND() LIMIT {}", cfg_.min_level, cfg_.max_level, SkyborneRaceClause(false), std::max(want * 40u, 200u)).c_str()) .WithCallback([this, g, slots, slot_levels](QueryResult res) { @@ -1525,17 +1734,18 @@ void WorldBotSpawner::FinishSpawn(Anchor const& a, std::vector const& slot { struct Row { uint64 guid; bool alliance; bool used; bool in_hub; }; std::vector rows; + uint32 skipped_pending = 0, skipped_owned = 0, skipped_online = 0; // rows the fetch brought but this pass cannot use if (res) { do { Field* f = res->Fetch(); uint64 const guid = f[0].GetUInt64(); - if (pending_.contains(guid)) continue; + if (pending_.contains(guid)) { ++skipped_pending; continue; } // A player's companion (owner-bound, e.g. dismissed with `.bot dismiss`) is never an ambient pool bot: logging it // back in would bring it back following its owner. - if (Services::Owners().GetOwner(guid).account_id != 0) continue; - if (ObjectAccessor::FindConnectedPlayer(ObjectGuid::Create(guid))) continue; + if (Services::Owners().GetOwner(guid).account_id != 0) { ++skipped_owned; continue; } + if (ObjectAccessor::FindConnectedPlayer(ObjectGuid::Create(guid))) { ++skipped_online; continue; } // World-wide filler: only pool bots that were saved inside a quest hub / town. Memory grows with the number of // distinct places that have a Player in them (grids, mmap tiles), so the filler is kept on shared hubs. // Hub rows are preferred; rows saved elsewhere are the fallback (stage B, 2026-10-07: a hub-only filter left @@ -1578,19 +1788,37 @@ void WorldBotSpawner::FinishSpawn(Anchor const& a, std::vector const& slot // No pool bot of that faction at that level: create one (bounded by PoolMax). ++n_no_match_; - if (pool_count_ >= int64(cfg_.pool_max)) + // Around a Zephras anchor every new resident is Skyborne (the other races cannot leave their start for the isle's quests). + // The island's residents are always temporary; anyone else goes to the core roster while it has room and, when it is full, + // to the variable pool - so a new character meets bots of its own level whatever the core is made of (PoolBudget.h). + uint8 const race = !global && Skyborne::IsOnIsle(a.map) ? Skyborne::RaceForTeam(alliance) : uint8(0); + PoolBudget budget{ pool_count_, int64(cfg_.pool_max), variable_count_, int64(cfg_.variable_max) }; + // A (faction, level bracket) that is already at its share of the cap goes to the temporary pool, so the standing roster stays + // balanced however much one faction is played (the census is read only with the seeder on; without it there is no cap). + bool const core_full_here = pool_counts_ms_ && !PoolHasRoom(pool_counts_, slot_levels[i], alliance, PoolBracketCap(cfg_.pool_max), cfg_.pool_horde_pct); + // With a census the bracket cap decides whether the standing roster takes it (the roster total can be over PoolMax from before). + if (pool_counts_ms_ && race == 0) + budget = BalancedBudget(budget, !core_full_here); + PoolSlot const slot = ChoosePoolSlot(budget, race != 0 || core_full_here); + if (slot == PoolSlot::None) { ++n_pool_full_; continue; } - // Around a Zephras anchor every new resident is Skyborne (the other races cannot leave their start for the isle's quests). - uint8 const race = !global && Skyborne::IsOnIsle(a.map) ? Skyborne::RaceForTeam(alliance) : uint8(0); if (uint64 const guid = owner_.SpawnAmbientBot(slot_levels[i], alliance, race)) { pending_[guid] = Pending{ a.guid, now, global }; - ++pool_count_; ++n_created_; - PoolAdd(pool_counts_, alliance, slot_levels[i]); + PoolCountCreated(budget, slot); + pool_count_ = budget.core; + variable_count_ = budget.variable; + if (slot == PoolSlot::Variable) + { + CharacterDatabase.PExecute("UPDATE playerbot_v2_character SET variable_pool = 1 WHERE character_guid_low = {}", guid); + ++n_created_variable_; + } + else + PoolAdd(pool_counts_, alliance, slot_levels[i]); } else ++n_spawn_failed_; @@ -1601,10 +1829,13 @@ void WorldBotSpawner::FinishSpawn(Anchor const& a, std::vector const& slot { last_why_ms_ = now; TC_LOG_INFO("playerbot.v2", - "[world] spawn pass around anchor (zone {}, L{}): wanted {} slot(s), {} offline pool row(s) fetched; " - "totals no_match={} pool_full={} (pool {}/{}) spawn_failed={} login_failed={}", - a.zone, uint32(a.level), slots.size(), rows.size(), n_no_match_, n_pool_full_, pool_count_, - cfg_.pool_max, n_spawn_failed_, n_login_failed_); + "[world] spawn pass around anchor (zone {}, L{}): wanted {} slot(s) ({} Alliance), {} offline pool row(s) usable ({} Alliance) " + "of those fetched (skipped: {} pending, {} companions, {} already online); " + "totals no_match={} pool_full={} (core {}/{}, variable {}/{}) spawn_failed={} login_failed={}", + a.zone, uint32(a.level), slots.size(), uint32(std::count(slots.begin(), slots.end(), true)), rows.size(), + uint32(std::count_if(rows.begin(), rows.end(), [](Row const& r) { return r.alliance; })), + skipped_pending, skipped_owned, skipped_online, n_no_match_, n_pool_full_, pool_count_, + cfg_.pool_max, variable_count_, cfg_.variable_max, n_spawn_failed_, n_login_failed_); } } @@ -1639,6 +1870,7 @@ void WorldBotSpawner::OnWorldTick(uint32 now_ms) } queries_.ProcessReadyCallbacks(); + LoadGearResetPending(); if (query_inflight_ && getMSTimeDiff(query_started_ms_, now_ms) >= kQueryTimeoutMs) query_inflight_ = false; // a QueryCallback always fires; this only guards a lost one @@ -1669,11 +1901,22 @@ void WorldBotSpawner::OnWorldTick(uint32 now_ms) { pool_count_inflight_ = true; queries_.AddCallback(CharacterDatabase.AsyncQuery( - "SELECT COUNT(*) FROM playerbot_v2_character WHERE distribution_level > 0 " - "AND (jit_for_queue IS NULL OR jit_for_queue = '')") + Trinity::StringFormat( + "SELECT COUNT(*), CAST(COALESCE(SUM(pv.variable_pool = 1), 0) AS UNSIGNED), " + "CAST(COALESCE(SUM(pv.variable_pool = 0 AND c.race IN ({}, {}) AND c.level < {}), 0) AS UNSIGNED) " + "FROM playerbot_v2_character pv JOIN characters c ON c.guid = pv.character_guid_low " + "WHERE pv.distribution_level > 0 AND (pv.jit_for_queue IS NULL OR pv.jit_for_queue = '')", + uint32(Skyborne::kRaceAlliance), uint32(Skyborne::kRaceHorde), uint32(Skyborne::kGraduationLevel)).c_str()) .WithCallback([this](QueryResult res) { - pool_count_ = res ? int64((*res)[0].GetUInt64()) : 0; + // The core roster (PoolMax) is the standing level 10+ residents. Temporary residents (flagged) and the island + // residents created before the flag existed are counted against VariableMax, so a core full of level 60 bots can + // never keep a new character's surroundings empty. + int64 const total = res ? int64((*res)[0].GetUInt64()) : 0; + int64 const flagged = res ? int64((*res)[1].GetUInt64()) : 0; + int64 const legacy_isle = res ? int64((*res)[2].GetUInt64()) : 0; + variable_count_ = flagged + legacy_isle; + pool_count_ = std::max(0, total - variable_count_); pool_count_inflight_ = false; })); } @@ -1685,7 +1928,7 @@ void WorldBotSpawner::OnWorldTick(uint32 now_ms) pool_counts_inflight_ = true; queries_.AddCallback(CharacterDatabase.AsyncQuery( "SELECT c.race, c.level, COUNT(*) FROM playerbot_v2_character pv JOIN characters c ON c.guid = pv.character_guid_low " - "WHERE pv.distribution_level > 0 AND (pv.jit_for_queue IS NULL OR pv.jit_for_queue = '') AND c.level >= 10 " + "WHERE pv.distribution_level > 0 AND (pv.jit_for_queue IS NULL OR pv.jit_for_queue = '') AND (pv.variable_pool IS NULL OR pv.variable_pool = 0) " "GROUP BY c.race, c.level") .WithCallback([this, now_ms](QueryResult res) { @@ -1701,9 +1944,9 @@ void WorldBotSpawner::OnWorldTick(uint32 now_ms) pool_counts_inflight_ = false; uint32 a = 0, h = 0; for (std::size_t b = 0; b < kPoolBrackets; ++b) { a += counts.alliance[b]; h += counts.horde[b]; } - TC_LOG_INFO("playerbot.v2", "[world] roster census: Alliance {} Horde {} (target Horde {}%); per bracket A/H: {}/{} {}/{} {}/{} {}/{} {}/{}", - a, h, cfg_.pool_horde_pct, counts.alliance[0], counts.horde[0], counts.alliance[1], counts.horde[1], counts.alliance[2], - counts.horde[2], counts.alliance[3], counts.horde[3], counts.alliance[4], counts.horde[4]); + TC_LOG_INFO("playerbot.v2", "[world] roster census: Alliance {} Horde {} (target Horde {}%, cap {} per bracket); per bracket 1-9/10s/20s/30s/40s/50-60 A/H: {}/{} {}/{} {}/{} {}/{} {}/{} {}/{}", + a, h, cfg_.pool_horde_pct, PoolBracketCap(cfg_.pool_max), counts.alliance[0], counts.horde[0], counts.alliance[1], counts.horde[1], + counts.alliance[2], counts.horde[2], counts.alliance[3], counts.horde[3], counts.alliance[4], counts.horde[4], counts.alliance[5], counts.horde[5]); })); } @@ -1764,6 +2007,7 @@ void WorldBotSpawner::OnWorldTick(uint32 now_ms) DriveDespawn(now_ms, keep_anchors); DriveSpawn(now_ms, anchors); DriveSeed(now_ms); + DriveRetire(now_ms); DriveGraduation(now_ms); DriveStranded(now_ms, anchors); DriveStuckLedger(now_ms); diff --git a/src/modules/PlayerbotV2/Fleet/WorldBotSpawner.h b/src/modules/PlayerbotV2/Fleet/WorldBotSpawner.h index 80d082ebbc..62d83da510 100644 --- a/src/modules/PlayerbotV2/Fleet/WorldBotSpawner.h +++ b/src/modules/PlayerbotV2/Fleet/WorldBotSpawner.h @@ -31,6 +31,7 @@ #include "WorldLoadFacts.h" #include "WorldFactionMix.h" #include "PoolBalance.h" +#include "PoolBudget.h" class Player; @@ -94,7 +95,8 @@ private: uint32 area_cap_town = 40; // the same in a capital float area_radius = 45.0f; uint32 pool_horde_pct = 50; // share of the roster that should be Horde, in every level bracket (PoolBalance.h) - uint32 skyborne_seed_pct = 5; // share of the roster seeds that are level 1-9 Skyborne residents of Zephras Isle (Classic 1.60) + uint32 variable_max = 2000; // temporary residents allowed to exist next to the core roster (PoolBudget.h); 0 = none + uint32 variable_ttl_h = 24; // hours a temporary resident stays offline before it is deleted }; struct Anchor @@ -132,6 +134,7 @@ private: // Roster seeding: creates residents (level spread, both factions) one by one, lets the setup pipeline gear them and send them // to a zone hub for their level, then logs them out so they sleep there. No player needed; stops at PoolMax. void DriveSeed(uint32 now_ms); // log in the pool bots that sleep around this anchor, no placement + void DriveRetire(uint32 now_ms); // deletes temporary residents that nobody has needed for VariableTtlHours void FinishSpawn(Anchor const& a, std::vector const& slots, std::vector const& slot_levels, QueryResult res, bool global = false); void DriveGlobalSpawn(uint32 now_ms, std::vector const& anchors); @@ -159,6 +162,14 @@ private: struct Ghost { Anchor a; uint32 until_ms; }; // where a player was before an instance / far jump: keeps its bots for a grace std::vector ghosts_; std::unordered_map prev_anchor_; + struct PlaceDest { float x = 0.0f, y = 0.0f; uint32 until_ms = 0; }; + std::unordered_map place_dest_; // where a bot sent by PlaceNear is walking to, for a while: the crowd count uses it, not its position on the way + // World bots under level 10 made before they stopped being given a generated set (migration 0031): each is stripped to its starter outfit once, on login. + std::unordered_set gear_reset_pending_, gear_reset_tried_; + bool gear_reset_loaded_ = false, gear_reset_inflight_ = false; + void LoadGearResetPending(); + void ResetStarterGearOnce(Player* bot); + float last_place_x_ = 0.0f, last_place_y_ = 0.0f, last_place_z_ = 0.0f; // where the last PlaceNear sent the bot (it lands later) float last_place_dist_ = 0.0f; // ring distance chosen by the last PlaceNear (the teleport lands later) BotPopulationManager& owner_; Config cfg_; @@ -179,7 +190,12 @@ private: QueryCallbackProcessor queries_; bool query_inflight_ = false; uint32 query_started_ms_ = 0; - int64 pool_count_ = -1; // ambient characters in the DB (-1 = not loaded yet) + int64 pool_count_ = -1; // ambient characters in the DB, island residents not counted (-1 = not loaded yet) + int64 variable_count_ = 0; // temporary residents in the DB, plus the island residents created before the flag existed + uint32 variable_sweep_ms_ = 0; // when temporary residents were last retired + bool variable_sweep_inflight_ = false; + uint32 n_created_variable_ = 0; // temporary residents created since start + uint32 n_retired_ = 0; // temporary residents deleted since start bool pool_count_inflight_ = false; PoolCounts pool_counts_; // the roster by faction and level bracket (levels 10+) bool pool_counts_inflight_ = false; @@ -193,6 +209,11 @@ private: uint64 n_placed_ = 0; uint64 n_despawned_ = 0; uint64 n_abandoned_ = 0; + // Why PlaceNear's candidate spots were refused (index: 0 no ground, 1 water, 2 no navmesh point, 3 lava, 4 no complete path, 5 area full) and + // how many calls found none at all; reported in the [world] line so a placement that never succeeds names its cause. + uint64 n_place_reject_[6] = {}; + uint64 n_place_none_ = 0; + uint64 n_place_calls_ = 0; struct Seeding { uint32 started_ms = 0; uint32 setup_done_ms = 0; }; std::unordered_map seeding_; uint32 last_grad_ms_ = 0; diff --git a/src/modules/PlayerbotV2/PlayerbotV2.cpp b/src/modules/PlayerbotV2/PlayerbotV2.cpp index d31e56d66c..784e6e5b8f 100644 --- a/src/modules/PlayerbotV2/PlayerbotV2.cpp +++ b/src/modules/PlayerbotV2/PlayerbotV2.cpp @@ -48,6 +48,7 @@ #include "Bot/BotCommandParser.h" #include "Bot/BotChatReactor.h" #include "Bot/GroupOrderText.h" +#include "Util.h" #include "Bot/AddonHint.h" #include "Bot/BotTextMgr.h" #include "Chat.h" @@ -2806,8 +2807,11 @@ void Module::OnLevelUp(Player* p, uint8 new_level) uint32 const quest_spells = api.learn_class_quest_spells_free(); uint32 const spells = api.learn_trainer_spells_free(); uint32 const weapon_skills = api.learn_weapon_skills_free(); - TC_LOG_INFO("playerbot.v2", "[levelup] {} reached L{} (class {} zone {}): +{} trainer spells, +{} class quest spells, +{} weapon skills", - p->GetName(), uint32(new_level), uint32(p->GetClass()), p->GetZoneId(), spells, quest_spells, weapon_skills); + // Riding (vanilla: apprentice and the race's mount at 40, journeyman and the swift mount at 60). The call does nothing below 40 and + // when the skill and mount are already there, so a level past 40 (or a jump over it) is safe to hand to it. + uint32 const riding = new_level >= 40 ? api.learn_riding_free() : 0; + TC_LOG_INFO("playerbot.v2", "[levelup] {} reached L{} (class {} zone {}): +{} trainer spells, +{} class quest spells, +{} weapon skills, +{} riding", + p->GetName(), uint32(new_level), uint32(p->GetClass()), p->GetZoneId(), spells, quest_spells, weapon_skills, riding); } namespace { @@ -3171,15 +3175,13 @@ void Module::OnSpiritReleased(Player* p) if (!initialized_ || !p || !p->GetSession() || p->GetSession()->IsBot()) return; Group* group = p->GetGroup(); if (!group) return; - uint32 const account = p->GetSession()->GetAccountId(); uint32 released = 0, considered = 0; for (GroupReference const& itr : group->GetMembers()) { Player* member = itr.GetSource(); if (!member || member == p) continue; BotId const mid = member->GetGUID().GetCounter(); - if (!Services::Registry().has(mid) || - !Services::Owners().IsOwner(mid, account, p->GetGUID().GetCounter())) + if (!Services::Registry().has(mid) || !BotCommandParser::ControlsForGroupOrder(p, member)) continue; if (member->IsAlive() || member->GetMapId() != p->GetMapId()) continue; ++considered; @@ -3228,7 +3230,7 @@ void Module::RouteGroupOrder(Player* sender, Group* group, std::string order) if (!m || m == sender || !m->IsAlive()) return false; BotId const mid = m->GetGUID().GetCounter(); - return Services::Registry().has(mid) && Services::Owners().IsOwner(mid, account, sender->GetGUID().GetCounter()) && + return Services::Registry().has(mid) && BotCommandParser::ControlsForGroupOrder(sender, m) && BotCommandParser::BotRole(m) == Role::Tank; }; std::string main_tank_skipped; @@ -3271,7 +3273,7 @@ void Module::RouteGroupOrder(Player* sender, Group* group, std::string order) Player* m = itr.GetSource(); if (!m || m == sender || !m->IsAlive()) continue; BotId const mid = m->GetGUID().GetCounter(); - if (!Services::Registry().has(mid) || !Services::Owners().IsOwner(mid, account, sender->GetGUID().GetCounter()) || + if (!Services::Registry().has(mid) || !BotCommandParser::ControlsForGroupOrder(sender, m) || BotCommandParser::BotRole(m) != Role::Tank) continue; float const d = sel ? m->GetDistance(sel) : m->GetDistance(sender); @@ -3287,12 +3289,12 @@ void Module::RouteGroupOrder(Player* sender, Group* group, std::string order) Player* member = itr.GetSource(); if (!member || member == sender) continue; BotId const mid = member->GetGUID().GetCounter(); - // Quest words also reach an unowned bot in the group (a world bot the player invited): it shares and accepts - // quests like a companion; every other order stays with the bots the sender owns. + // Every order reaches the bots the sender owns and the world bots he leads (invited into his group, no owner): they + // obey the group leader exactly like a companion. Quest words also reach an unowned bot of any other member. bool const quest_word = order == "share" || order == "accept" || order == "accept all" || order == "quests" || order == "quest list"; if (!Services::Registry().has(mid) || - !(Services::Owners().IsOwner(mid, account, sender->GetGUID().GetCounter()) || + !(BotCommandParser::ControlsForGroupOrder(sender, member) || (quest_word && Services::Owners().GetOwner(mid).account_id == 0))) continue; if (order == "pull back") @@ -3347,7 +3349,7 @@ void Module::RouteGroupOrder(Player* sender, Group* group, std::string order) Player* m = itr.GetSource(); if (!m || m == sender) continue; BotId const mid = m->GetGUID().GetCounter(); - if (!Services::Registry().has(mid) || !Services::Owners().IsOwner(mid, account, sender->GetGUID().GetCounter()) || + if (!Services::Registry().has(mid) || !BotCommandParser::ControlsForGroupOrder(sender, m) || BotCommandParser::BotRole(m) != Role::Tank) continue; ++owned_tanks; @@ -3392,7 +3394,7 @@ void Module::OnGroupPingPoint(Player* sender, Group* group, Position const& poin Player* m = itr.GetSource(); if (!m || m == sender || !m->IsAlive() || m->GetMapId() != sender->GetMapId()) continue; BotId const mid = m->GetGUID().GetCounter(); - if (!Services::Registry().has(mid) || !Services::Owners().IsOwner(mid, account, sender->GetGUID().GetCounter())) continue; + if (!Services::Registry().has(mid) || !BotCommandParser::ControlsForGroupOrder(sender, m)) continue; if (BotAI* ai = Services::Registry().ai(mid)) { ai->set_rally_point(sender->GetMapId(), point.GetPositionX(), point.GetPositionY(), point.GetPositionZ()); @@ -3461,13 +3463,35 @@ void Module::OnPartyChat(Player* sender, Group* group, std::string const& msg) if (msg.front() != ';') { // A bare group order ("follow", "stay", ...) in party or raid chat goes to every bot of the sender's in the - // group. Other chatter stays ignored. + // group. A line that starts with the name of a bot in the group, or with "all", is that bot's (every bot's) + // order without the ';' ("Lentha use altar", "all use altar"). Other chatter stays ignored. if (auto const order = ClassifyGroupOrder(msg, Services::Config().behavior_owner_commands())) RouteGroupOrder(sender, group, *order); + else if (auto const addressed = AddressedGroupOrder(msg, [group](std::string_view name) { return GroupHasBotNamed(group, name); })) + DispatchSquadLine(sender, group, *addressed, false); return; } const std::string body = msg.substr(1); if (body.empty()) return; + DispatchSquadLine(sender, group, body, true); +} + +bool Module::GroupHasBotNamed(Group const* group, std::string_view name) +{ + if (!group || name.empty()) return false; + for (GroupReference const& itr : group->GetMembers()) + { + Player const* member = itr.GetSource(); + if (!member) continue; + if (!Services::Registry().has(member->GetGUID().GetCounter())) continue; + if (StringEqualI(member->GetName(), name)) return true; + } + return false; +} + +void Module::DispatchSquadLine(Player* sender, Group* group, std::string const& body, bool answer_unknown) +{ + if (!sender || !group || body.empty()) return; // Walk the group for the sender's first owned bot. We need a // primary bot to attach the reply whisper to; if the owner has // none in the group, route to the first owned-on-realm fallback. @@ -3511,7 +3535,7 @@ void Module::OnPartyChat(Player* sender, Group* group, std::string const& msg) if (!primary) primary = any_group_bot; if (!primary) return; - if (!BotCommandParser::Dispatch(sender, primary, body, "party;")) + if (!BotCommandParser::Dispatch(sender, primary, body, "party;") && answer_unknown) { // A ";" line is meant as an order: an unknown or refused one answers instead of vanishing. (A plain whisper falls // through to the social reactor and a bare party word is chatter, so only this explicit route replies.) diff --git a/src/modules/PlayerbotV2/PlayerbotV2.h b/src/modules/PlayerbotV2/PlayerbotV2.h index bbb8f78c5f..2b3af6f975 100644 --- a/src/modules/PlayerbotV2/PlayerbotV2.h +++ b/src/modules/PlayerbotV2/PlayerbotV2.h @@ -73,6 +73,11 @@ public: // The ForeverBots add-on greeted the server (self-whisper or the silent `.bot addon` command): no download hint for this player. void NoteAddonHello(Player* p); void RouteGroupOrder(Player* sender, Group* group, std::string order); + // A squad line (";tank: attack", or the bare "Lentha use altar" / "all use altar") through the whisper parser, with the + // sender's first bot in the group as the messenger. answer_unknown: an unrecognised order whispers back instead of + // vanishing (the ';' form only; a bare line could be chatter). + void DispatchSquadLine(Player* sender, Group* group, std::string const& body, bool answer_unknown); + static bool GroupHasBotNamed(Group const* group, std::string_view name); // Phase C.3: route guild chat messages to BotChatReactor::ReactGuild. void OnGuildChat(Player* sender, uint64 guild_id, std::string const& msg); diff --git a/src/modules/PlayerbotV2/Travel/ReachMemory.h b/src/modules/PlayerbotV2/Travel/ReachMemory.h new file mode 100644 index 0000000000..a3b6cade2e --- /dev/null +++ b/src/modules/PlayerbotV2/Travel/ReachMemory.h @@ -0,0 +1,161 @@ +// ReachMemory - what the path checks have already learned about "from around here, that goal cannot be walked to". A failed path (no path, +// a goal off the mesh, a partial route that stops short or loops) is remembered per pair of cells (50 y around the start, 25 y around the +// goal) for every bot, so a second bot standing in the same place does not pay the same Detour call and goal selection can skip a goal +// before committing to it. +// A complete path forgets the pair. Pure: no game types, tested in tests/game/ClassicReachMemory.cpp. + +#pragma once + +#include +#include +#include +#include +#include +#include + +namespace Playerbot::V2::Travel { + +class ReachMemory +{ +public: + static constexpr float kFromCellYds = 50.0f; + static constexpr float kToCellYds = 25.0f; + static constexpr std::uint32_t kTtlMs = 10u * 60u * 1000u; // geometry does not change; a data fix arrives with a restart + static constexpr std::uint32_t kMinFails = 2; // one failure can be a bot standing in a bad spot + static constexpr std::size_t kCap = 4096; // cells remembered; the oldest go first + + void NoteFail(std::uint32_t map, float fx, float fy, float tx, float ty, std::uint32_t now_ms) + { + std::lock_guard lk(mx_); + Entry& e = cells_[KeyOf(map, fx, fy, tx, ty)]; + if (e.last_ms && Expired(e, now_ms)) + e.fails = 0; + ++e.fails; + e.last_ms = now_ms ? now_ms : 1u; + ++noted_; + if (cells_.size() > kCap) + Prune(now_ms); + } + + void NoteOk(std::uint32_t map, float fx, float fy, float tx, float ty) + { + std::lock_guard lk(mx_); + if (!cells_.empty()) + cells_.erase(KeyOf(map, fx, fy, tx, ty)); + } + + bool KnownUnreachable(std::uint32_t map, float fx, float fy, float tx, float ty, std::uint32_t now_ms) + { + std::lock_guard lk(mx_); + auto it = cells_.find(KeyOf(map, fx, fy, tx, ty)); + bool const hit = it != cells_.end() && it->second.fails >= kMinFails && !Expired(it->second, now_ms); + if (hit) + ++skips_; + return hit; + } + + std::size_t size() const { std::lock_guard lk(mx_); return cells_.size(); } + std::uint64_t noted() const { std::lock_guard lk(mx_); return noted_; } + std::uint64_t skips() const { std::lock_guard lk(mx_); return skips_; } + + static ReachMemory& Instance() + { + static ReachMemory inst; + return inst; + } + +private: + struct Key + { + std::uint16_t map; + std::int16_t fx, fy, tx, ty; + bool operator==(Key const& o) const { return map == o.map && fx == o.fx && fy == o.fy && tx == o.tx && ty == o.ty; } + }; + struct KeyHash + { + std::size_t operator()(Key const& k) const + { + std::uint64_t h = k.map; + h = h * 1000003u + std::uint16_t(k.fx); + h = h * 1000003u + std::uint16_t(k.fy); + h = h * 1000003u + std::uint16_t(k.tx); + h = h * 1000003u + std::uint16_t(k.ty); + return std::size_t(h ^ (h >> 29)); + } + }; + struct Entry { std::uint32_t last_ms = 0; std::uint32_t fails = 0; }; + + static std::int16_t Cell(float v, float size) { return std::int16_t(std::clamp(std::floor(v / size), -32000.0f, 32000.0f)); } + static Key KeyOf(std::uint32_t map, float fx, float fy, float tx, float ty) + { + return Key{ std::uint16_t(map), Cell(fx, kFromCellYds), Cell(fy, kFromCellYds), Cell(tx, kToCellYds), Cell(ty, kToCellYds) }; + } + static bool Expired(Entry const& e, std::uint32_t now_ms) { return std::uint32_t(now_ms - e.last_ms) >= kTtlMs; } + + // Over the cap: the expired cells go first, then the oldest quarter. + void Prune(std::uint32_t now_ms) + { + for (auto it = cells_.begin(); it != cells_.end();) + it = Expired(it->second, now_ms) ? cells_.erase(it) : std::next(it); + if (cells_.size() <= kCap) + return; + std::vector ages; + ages.reserve(cells_.size()); + for (auto const& [k, e] : cells_) + ages.push_back(std::uint32_t(now_ms - e.last_ms)); + std::size_t const drop = ages.size() / 4; + std::nth_element(ages.begin(), ages.begin() + std::ptrdiff_t(drop), ages.end(), std::greater<>()); + std::uint32_t const cut = ages[drop]; + for (auto it = cells_.begin(); it != cells_.end();) + it = std::uint32_t(now_ms - it->second.last_ms) >= cut ? cells_.erase(it) : std::next(it); + } + + mutable std::mutex mx_; + std::unordered_map cells_; + std::uint64_t noted_ = 0; + std::uint64_t skips_ = 0; +}; + +// QuestGoalMemory - the same idea for a quest objective: when bots keep giving up on the walk to one quest's goal (the tracker drops the goal +// after it made no progress), the other bots stop starting that quest for a while instead of each paying the same 90 s wedge +//. Per quest, not per place: the objective is one point. +class QuestGoalMemory +{ +public: + static constexpr std::uint32_t kTtlMs = 30u * 60u * 1000u; + static constexpr std::uint32_t kMinDrops = 2; // one bot can be stuck for its own reasons (a pack on the path, its own gear) + + void NoteDropped(std::uint32_t quest_id, std::uint32_t now_ms) + { + if (quest_id == 0) + return; + std::lock_guard lk(mx_); + Entry& e = quests_[quest_id]; + if (e.drops == 0 || std::uint32_t(now_ms - e.last_ms) >= kTtlMs) + e.drops = 0; + ++e.drops; + e.last_ms = now_ms; + } + + bool KnownUnreachable(std::uint32_t quest_id, std::uint32_t now_ms) const + { + if (quest_id == 0) + return false; + std::lock_guard lk(mx_); + auto const it = quests_.find(quest_id); + return it != quests_.end() && it->second.drops >= kMinDrops && std::uint32_t(now_ms - it->second.last_ms) < kTtlMs; + } + + static QuestGoalMemory& Instance() + { + static QuestGoalMemory inst; + return inst; + } + +private: + struct Entry { std::uint32_t last_ms = 0; std::uint32_t drops = 0; }; + mutable std::mutex mx_; + std::unordered_map quests_; +}; + +} // namespace Playerbot::V2::Travel diff --git a/src/modules/PlayerbotV2/Travel/UnifiedTravelGraph.cpp b/src/modules/PlayerbotV2/Travel/UnifiedTravelGraph.cpp index 3387b6c530..db6f92ec35 100644 --- a/src/modules/PlayerbotV2/Travel/UnifiedTravelGraph.cpp +++ b/src/modules/PlayerbotV2/Travel/UnifiedTravelGraph.cpp @@ -22,8 +22,11 @@ #include "PathGenerator.h" #include "Player.h" #include "UnitDefines.h" +#include "Travel/WalkLinkTable.h" #include +#include +#include #include #include #include @@ -77,6 +80,12 @@ constexpr float kMaxWalkEdgeYds = 600.0f; // but never to the ground / bottom stop (dz 90+); comfortably above any real // ramp's rise across a 600y edge. constexpr float kMaxWalkEdgeDz = 18.0f; +// The Classic 1.60 maps (ids from 2000) are mountain islands with tiers up to 350 y apart in height; a distance-and-height rule cannot say +// whether two places on them are joined by ground. Their walk edges come only from the checked link table (WalkLinkTable.h), never from the +// 600 y / 18 y rule or from a Bridge node: an unchecked edge sent bots to a hub they could not reach (Zephras Isle: "partial +// routes toward (3289,1758,824)" and a 91 s wedge at the starter hub), where no edge sends them to the places they can. +constexpr uint32 kForeverMapFrom = 2000; +constexpr float kLinkCandidateYds = 1600.0f; // the farthest two pieces are tried for a link by the offline check (tools/walk_link_check) inline float Dist2D(float ax, float ay, float bx, float by) { @@ -153,6 +162,27 @@ void UnifiedTravelGraph::Initialize() counts.dungeon_entries, counts.capitals, counts.quest_hubs, counts.bridges, counts.elevator_stops, total_edges, _nodes_by_map.size()); + LogForeverMaps(); +} + +// What the bots know of the Classic 1.60 maps (ids from 2000): the quest hubs on them (zone, level band, team, quests) and every dock or +// portal that starts or ends on one, so a missing exit or a hub with the wrong level band shows in the log (tools: Fleet/SkyborneIsle.h). +void UnifiedTravelGraph::LogForeverMaps() const +{ + Services::Hubs().ForEach([&](QuestHub const& h) + { + if (h.mapId < kForeverMapFrom) return; + TC_LOG_INFO("playerbot.v2", "[forever_maps] hub {} map {} zone {} at ({:.0f},{:.0f},{:.0f}) r {:.0f} L{}-{} team mask {} {} quest(s) '{}'", + h.hubId, h.mapId, h.zoneId, h.location.GetPositionX(), h.location.GetPositionY(), h.location.GetPositionZ(), h.radius, + h.minLevel, h.maxLevel, h.factionMask, uint32(h.questIds.size()), h.name); + }); + for (auto const& a : Services::Portals().Anchors()) + if (a.source_map >= kForeverMapFrom || a.dest_map >= kForeverMapFrom) + TC_LOG_INFO("playerbot.v2", "[forever_maps] {} {} map {} ({:.0f},{:.0f},{:.0f}) -> map {} ({:.0f},{:.0f})", + a.kind == PortalAnchor::Kind::Portal ? "portal" : "dock", a.go_entry, a.source_map, a.x, a.y, a.z, a.dest_map, a.dest_x, a.dest_y); + for (auto const& [map_id, ids] : _nodes_by_map) + if (map_id >= kForeverMapFrom) + TC_LOG_INFO("playerbot.v2", "[forever_maps] map {}: {} graph node(s)", map_id, uint32(ids.size())); } NodeId UnifiedTravelGraph::AppendNode(GraphNode node) @@ -882,6 +912,8 @@ void UnifiedTravelGraph::BuildWalkEdges() uint32 added = 0; for (auto const& [map_id, ids] : _nodes_by_map) { + if (map_id >= kForeverMapFrom) + continue; // checked links only (see kForeverMapFrom) for (size_t i = 0; i < ids.size(); ++i) { for (size_t j = i + 1; j < ids.size(); ++j) @@ -919,6 +951,169 @@ void UnifiedTravelGraph::BuildWalkEdges() } TC_LOG_INFO("playerbot.v2", "[UnifiedTravelGraph] BuildWalkEdges: {} edges (cap={}y)", added, uint32(kMaxWalkEdgeYds)); + AddCheckedWalkLinks(); + LogWalkGaps(); +} + +// The fixed links of Travel/WalkLinkTable.h: walk edges between pieces that the 600 y / 18 y rule leaves apart, each one checked offline +// against the real mmaps. An end that names no node (the node data changed since the check) is skipped and counted. +void UnifiedTravelGraph::AddCheckedWalkLinks() +{ + struct P { float x, y, z; }; + uint32 added = 0, unmatched = 0; + for (WalkLink const& l : kWalkLinks) + { + auto const map_it = _nodes_by_map.find(l.map); + if (map_it == _nodes_by_map.end()) + { + ++unmatched; + continue; + } + std::vector

pts; + pts.reserve(map_it->second.size()); + for (NodeId id : map_it->second) + pts.push_back(P{ _nodes[id].x, _nodes[id].y, _nodes[id].z }); + long const ia = MatchWalkLinkEnd(pts, l.ax, l.ay, l.az); + long const ib = MatchWalkLinkEnd(pts, l.bx, l.by, l.bz); + if (ia < 0 || ib < 0 || ia == ib) + { + ++unmatched; + continue; + } + NodeId const a = map_it->second[size_t(ia)], b = map_it->second[size_t(ib)]; + bool have = false; + for (GraphEdge const& e : _adj[a]) + if (e.kind == EdgeKind::Walk && e.to == b) { have = true; break; } + if (have) + continue; + float const cost = l.length / kWalkSpeedYds; + GraphEdge eab{}; + eab.to = b; eab.kind = EdgeKind::Walk; eab.cost = cost; + AddEdge(a, eab); + GraphEdge eba{}; + eba.to = a; eba.kind = EdgeKind::Walk; eba.cost = cost; + AddEdge(b, eba); + added += 2; + } + TC_LOG_INFO("playerbot.v2", "[UnifiedTravelGraph] WalkLinks: {} edges from {} checked links, {} with an end that names no node", + added, uint32(std::size(kWalkLinks)), unmatched); +} + +// Names the places where the walk edges of one landmass break into separate pieces, so a "no route" between two hubs on the same map can +// be traced to a missing link: per map, each piece with its node count and box, and the closest pair of nodes between two pieces of the +// same landmass (distance and height gap). Diagnostic only; it changes no edge. +void UnifiedTravelGraph::LogWalkGaps() const +{ + for (auto const& [map_id, ids] : _nodes_by_map) + { + if (ids.size() < 2) + continue; + std::unordered_map index; + for (size_t i = 0; i < ids.size(); ++i) + index[ids[i]] = i; + std::vector parent(ids.size()); + for (size_t i = 0; i < parent.size(); ++i) + parent[i] = i; + auto const find = [&](size_t v) + { + while (parent[v] != v) + v = parent[v] = parent[parent[v]]; + return v; + }; + for (size_t i = 0; i < ids.size(); ++i) + if (ids[i] < _adj.size()) + for (GraphEdge const& e : _adj[ids[i]]) + if (e.kind == EdgeKind::Walk) + if (auto it = index.find(e.to); it != index.end()) + parent[find(i)] = find(it->second); + + struct Piece { size_t n = 0; float x0 = 1e9f, y0 = 1e9f, x1 = -1e9f, y1 = -1e9f; uint32 region = 0; std::string sample; }; + std::unordered_map pieces; + for (size_t i = 0; i < ids.size(); ++i) + { + GraphNode const& n = _nodes[ids[i]]; + Piece& pc = pieces[find(i)]; + if (pc.n++ == 0) + { + pc.region = RegionForPosition(map_id, n.x, n.y); + pc.sample = n.name; + } + pc.x0 = std::min(pc.x0, n.x); pc.x1 = std::max(pc.x1, n.x); + pc.y0 = std::min(pc.y0, n.y); pc.y1 = std::max(pc.y1, n.y); + } + if (pieces.size() < 2) + continue; + TC_LOG_INFO("playerbot.v2", "[walk_gaps] map {}: {} nodes in {} separate walk pieces", map_id, ids.size(), pieces.size()); + + // Candidate links for the offline navmesh check (src/tools/walk_link_check): per pair of pieces the closest pair of real places + // (flight master, quest hub, capital) on the same landmass, up to kLinkCandidateYds apart. One line each, with the heights. + { + // On the Classic 1.60 maps every node is tried (their docks and hubs are all there is); elsewhere only the real places. + bool const forever = map_id >= kForeverMapFrom; + auto const isPlace = [forever](GraphNode const& n) + { return forever || n.kind == NodeKind::FlightMaster || n.kind == NodeKind::QuestHub || n.kind == NodeKind::Capital; }; + struct Cand { size_t i, j; float d; }; + std::map, Cand> best_pair; + for (size_t i = 0; i < ids.size(); ++i) + { + GraphNode const& a = _nodes[ids[i]]; + if (!isPlace(a)) continue; + for (size_t j = i + 1; j < ids.size(); ++j) + { + GraphNode const& b = _nodes[ids[j]]; + size_t const ri = find(i), rj = find(j); + if (ri == rj || !isPlace(b)) continue; + if (RegionForPosition(map_id, a.x, a.y) != RegionForPosition(map_id, b.x, b.y)) continue; + float const d = Dist2D(a.x, a.y, b.x, b.y); + if (d > kLinkCandidateYds) continue; + auto key = std::minmax(ri, rj); + auto it = best_pair.find(key); + if (it == best_pair.end() || d < it->second.d) + best_pair[key] = Cand{ i, j, d }; + } + } + std::vector list; + for (auto const& [k, c] : best_pair) + list.push_back(c); + std::sort(list.begin(), list.end(), [](Cand const& l, Cand const& r) { return l.d < r.d; }); + if (list.size() > 500) + list.resize(500); + for (Cand const& c : list) + { + GraphNode const& a = _nodes[ids[c.i]]; + GraphNode const& b = _nodes[ids[c.j]]; + TC_LOG_INFO("playerbot.v2", "[walk_gap_pair] map={} a={} ax={:.1f} ay={:.1f} az={:.1f} b={} bx={:.1f} by={:.1f} bz={:.1f} d={:.0f}", + map_id, uint32(a.kind), a.x, a.y, a.z, uint32(b.kind), b.x, b.y, b.z, c.d); + } + } + size_t lines = 0; + for (auto const& [root, pc] : pieces) + { + if (++lines > 40) // a map in pieces everywhere (a battleground, a staging zone) would drown the log + break; + // Closest node of another piece on the same landmass, from any node of this one. + float best = 1e18f, best_dz = 0.f; + GraphNode const* from = nullptr; GraphNode const* to = nullptr; + for (size_t i = 0; i < ids.size(); ++i) + { + if (find(i) != root) continue; + GraphNode const& a = _nodes[ids[i]]; + for (size_t j = 0; j < ids.size(); ++j) + { + if (find(j) == root) continue; + GraphNode const& b = _nodes[ids[j]]; + if (RegionForPosition(map_id, b.x, b.y) != pc.region) continue; + float const d = Dist2D(a.x, a.y, b.x, b.y); + if (d < best) { best = d; best_dz = b.z - a.z; from = &a; to = &b; } + } + } + TC_LOG_INFO("playerbot.v2", + "[walk_gaps] piece of {} node(s) x[{:.0f}..{:.0f}] y[{:.0f}..{:.0f}] e.g. '{}'; nearest other piece: {} ({:.0f},{:.0f}) -> '{}' ({:.0f},{:.0f}) {:.0f} y, dz {:.0f}", + pc.n, pc.x0, pc.x1, pc.y0, pc.y1, pc.sample, + from ? from->name : std::string("-"), from ? from->x : 0.f, from ? from->y : 0.f, + to ? to->name : std::string("-"), to ? to->x : 0.f, to ? to->y : 0.f, from ? best : 0.f, best_dz); + } + } } void UnifiedTravelGraph::ConnectIslands() @@ -951,6 +1146,7 @@ void UnifiedTravelGraph::ConnectIslands() if (has_walk[i]) continue; // Find the closest other node on the same map. GraphNode const& src = _nodes[i]; + if (src.map_id >= kForeverMapFrom) continue; // no unchecked bridge on the Classic 1.60 maps (see kForeverMapFrom) auto it = _nodes_by_map.find(src.map_id); if (it == _nodes_by_map.end()) continue; NodeId best = INVALID_NODE_ID; diff --git a/src/modules/PlayerbotV2/Travel/UnifiedTravelGraph.h b/src/modules/PlayerbotV2/Travel/UnifiedTravelGraph.h index d594763a47..7d9b9dee44 100644 --- a/src/modules/PlayerbotV2/Travel/UnifiedTravelGraph.h +++ b/src/modules/PlayerbotV2/Travel/UnifiedTravelGraph.h @@ -277,6 +277,9 @@ private: void BuildTaxiEdges(); // sTaxiPathStore → directed Taxi edges void BuildPortalEdges(); // Portal/Dock edges: cross-map, and same-map transport rides (dock -> dock) void MarkConnectorMaps(); // maps exempt from the transit penalty (same-map ride, nothing else there) + void AddCheckedWalkLinks(); // the fixed, offline-checked links of WalkLinkTable.h + void LogForeverMaps() const; // [forever_maps] hubs and docks on the Classic 1.60 maps + void LogWalkGaps() const; // [walk_gaps] diagnostic after BuildWalkEdges void BuildWalkEdges(); // Same-map intra-cluster walk edges (bounded) void BuildElevatorEdges(); // Bidirectional Elevator edges between stops of the same platform diff --git a/src/modules/PlayerbotV2/Travel/WalkLinkTable.h b/src/modules/PlayerbotV2/Travel/WalkLinkTable.h new file mode 100644 index 0000000000..c8c8516a97 --- /dev/null +++ b/src/modules/PlayerbotV2/Travel/WalkLinkTable.h @@ -0,0 +1,144 @@ +// Walk links between pieces of the travel graph that its own walk edges (600 y, 18 y of height) leave apart. +// +// Every row was found by the offline check tools/walk_link_check on the server's real mmaps: a complete +// Detour path (ground, steep ground and road; no water), no cliff face, and no longer than 4,000 y (the first run used 3 times the straight distance plus 300 y). +// Pairs that came back PARTIAL, CLIFF, LONG or without a polygon are not here. `length` is the checked path length in yards. +// +// To refresh the table: run the worldserver (it writes [walk_gap_pair] lines at startup), run walk_link_check on the log, replace the rows. +// Kept free of game types so the table and the matching can be unit tested. +#pragma once + +#include +#include +#include + +namespace Playerbot::V2::Travel +{ + +struct WalkLink +{ + std::uint32_t map; + float ax, ay, az; + float bx, by, bz; + float length; +}; + +inline constexpr WalkLink kWalkLinks[] = +{ + { 0, -5421.9f, -2930.0f, 347.2f, -5394.1f, -2954.4f, 322.1f, 119.0f }, + { 0, -10457.0f, -3279.2f, 21.4f, -10465.0f, -3317.9f, 40.0f, 104.0f }, + { 0, -10628.9f, 1036.7f, 34.1f, -10508.8f, 1045.2f, 60.7f, 139.0f }, + { 0, 1421.0f, 405.9f, -85.2f, 1277.5f, 320.3f, -60.0f, 491.0f }, + { 0, -4126.4f, -1091.6f, 168.9f, -4074.1f, -1268.0f, 146.2f, 219.0f }, + { 0, -11620.5f, -51.9f, 11.2f, -11313.9f, -202.8f, 75.6f, 613.0f }, + { 0, -0.1f, -859.9f, 58.8f, 382.5f, -983.1f, 110.0f, 415.0f }, + { 0, 1812.0f, 239.0f, 62.0f, 1421.0f, 405.9f, -85.2f, 1384.0f }, + { 0, 1812.0f, 239.0f, 62.0f, 2270.7f, 280.0f, 36.7f, 471.0f }, + { 0, -9465.2f, 50.8f, 57.0f, -9895.0f, 332.4f, 36.6f, 520.0f }, + { 0, 2270.7f, 280.0f, 36.7f, 1767.3f, 418.4f, -57.1f, 1828.0f }, + { 0, -8832.8f, 478.6f, 109.6f, -9328.5f, 271.2f, 68.1f, 820.0f }, + { 0, -0.1f, -859.9f, 58.8f, -16.3f, -321.6f, 131.3f, 683.0f }, + { 0, 1848.3f, 1627.6f, 97.0f, 2326.6f, 1351.7f, 33.5f, 701.0f }, + { 0, -8752.3f, 377.6f, 101.1f, -8874.9f, -186.3f, 82.1f, 1433.0f }, + { 0, -9465.2f, 50.8f, 57.0f, -8874.9f, -186.3f, 82.1f, 676.0f }, + { 0, -11112.2f, -3435.7f, 79.1f, -10465.0f, -3317.9f, 40.0f, 1269.0f }, + { 0, -11112.2f, -3435.7f, 79.1f, -10457.0f, -3279.2f, 21.4f, 1167.0f }, + { 0, 2326.6f, 1351.7f, 33.5f, 2492.1f, 2035.0f, 155.7f, 998.0f }, + { 0, 931.3f, -1430.1f, 64.7f, 382.5f, -983.1f, 110.0f, 938.0f }, + { 0, -711.5f, -515.5f, 26.1f, -16.3f, -321.6f, 131.3f, 748.0f }, + { 0, -10128.7f, 1055.2f, 36.4f, -9895.0f, 332.4f, 36.6f, 943.0f }, + { 0, 1848.3f, 1627.6f, 97.0f, 2492.1f, 2035.0f, 155.7f, 1691.0f }, + { 0, 382.5f, -983.1f, 110.0f, -16.3f, -321.6f, 131.3f, 810.0f }, + { 0, -0.1f, -859.9f, 58.8f, -711.5f, -515.5f, 26.1f, 813.0f }, + { 0, -11620.5f, -51.9f, 11.2f, -12398.4f, 168.0f, 3.1f, 830.0f }, + { 0, -5596.2f, -504.1f, 400.7f, -5372.0f, 315.4f, 394.4f, 892.0f }, + { 0, 2270.7f, 280.0f, 36.7f, 1421.0f, 405.9f, -85.2f, 1527.0f }, + { 0, 283.7f, -2002.8f, 194.7f, 931.3f, -1430.1f, 64.7f, 2439.0f }, + { 0, -9245.8f, -2045.3f, 77.2f, -9467.9f, -1182.3f, 49.4f, 1164.0f }, + { 0, -6634.0f, -2180.1f, 244.1f, -5858.2f, -2641.1f, 309.2f, 1984.0f }, + { 0, -8980.0f, 1041.1f, 101.5f, -9861.1f, 1290.8f, 41.8f, 2766.0f }, + { 0, -10508.8f, 1045.2f, 60.7f, -9895.0f, 332.4f, 36.6f, 1331.0f }, + { 0, 1812.0f, 239.0f, 62.0f, 1751.8f, -730.0f, 60.2f, 1060.0f }, + { 0, -6513.6f, -1183.8f, 309.3f, -6686.6f, -2162.7f, 244.2f, 1731.0f }, + { 0, -5596.2f, -504.1f, 400.7f, -6056.7f, 393.5f, 392.8f, 1416.0f }, + { 0, -7504.0f, -2187.5f, 165.5f, -8364.6f, -2738.4f, 185.5f, 1117.0f }, + { 0, -9009.0f, 845.3f, 105.9f, -9895.0f, 332.4f, 36.6f, 2105.0f }, + { 0, -1240.5f, -2515.1f, 22.2f, -916.3f, -3496.9f, 70.4f, 1147.0f }, + { 0, -3591.8f, -1994.5f, 117.0f, -2650.7f, -2453.3f, 80.2f, 1454.0f }, + { 0, -8380.6f, -2751.9f, 187.1f, -9261.0f, -2172.7f, 64.2f, 1464.0f }, + { 0, -8874.9f, -186.3f, 82.1f, -9942.3f, -147.5f, 25.0f, 1129.0f }, + { 0, 1751.8f, -730.0f, 60.2f, 944.3f, -1431.1f, 64.0f, 1253.0f }, + { 0, 2270.7f, 280.0f, 36.7f, 2326.6f, 1351.7f, 33.5f, 1080.0f }, + { 0, 931.3f, -1430.1f, 64.7f, -33.4f, -927.9f, 54.5f, 1176.0f }, + { 0, 1767.3f, 418.4f, -57.1f, 2326.6f, 1351.7f, 33.5f, 1958.0f }, + { 1, -441.8f, -2596.1f, 96.1f, -474.9f, -2607.7f, 127.9f, 104.0f }, + { 1, -1197.2f, 29.7f, 176.9f, -1246.5f, 74.3f, 128.4f, 149.0f }, + { 1, -6811.4f, 836.7f, 49.8f, -6761.8f, 772.0f, 88.9f, 132.0f }, + { 1, -3825.4f, -4516.6f, 10.4f, -3757.5f, -4462.3f, 65.1f, 413.0f }, + { 1, 139.2f, 1325.8f, 193.5f, 126.2f, 1232.7f, 163.3f, 100.0f }, + { 1, 7458.5f, -2487.2f, 462.3f, 7470.4f, -2123.4f, 492.3f, 397.0f }, + { 1, 10458.5f, 827.9f, 1381.0f, 9822.2f, 952.0f, 1308.9f, 1006.0f }, + { 1, -825.6f, -4920.8f, 19.7f, -629.1f, -4228.1f, 38.2f, 793.0f }, + { 1, -4491.9f, -775.9f, -39.5f, -4915.6f, -1381.2f, -52.6f, 789.0f }, + { 1, 2054.6f, -2400.4f, 87.8f, 1447.9f, -1866.8f, 127.5f, 870.0f }, + { 1, 3374.7f, 997.0f, 5.2f, 3185.5f, 189.4f, 4.8f, 946.0f }, + { 1, -629.1f, -4228.1f, 38.2f, -3.1f, -3637.4f, 27.5f, 2482.0f }, + { 1, 966.6f, 1040.3f, 104.3f, 126.2f, 1232.7f, 163.3f, 2242.0f }, + { 1, -7048.9f, -3780.4f, 10.2f, -6187.2f, -3878.2f, -58.7f, 960.0f }, + { 1, 966.6f, 1040.3f, 104.3f, 139.2f, 1325.8f, 193.5f, 2322.0f }, + { 1, -894.6f, -3773.0f, 11.5f, -3.1f, -3637.4f, 27.5f, 1004.0f }, + { 1, -4491.9f, -775.9f, -39.5f, -4419.9f, 199.3f, 25.1f, 1054.0f }, + { 1, 275.3f, -4704.0f, 11.7f, -629.1f, -4228.1f, 38.2f, 1344.0f }, + { 1, -7048.9f, -3780.4f, 10.2f, -6974.0f, -4845.7f, 8.1f, 1076.0f }, + { 1, 3661.5f, -4390.4f, 113.1f, 2722.0f, -3880.6f, 100.9f, 1103.0f }, + { 2991, 4079.1f, 1852.5f, 977.3f, 3288.7f, 1757.9f, 824.5f, 1008.0f }, + // second run (1,600 y candidates, complete cliff-free paths up to 4,000 y) + { 0, -7491.6f, -2170.4f, 165.4f, -6686.6f, -2162.7f, 244.2f, 3482.0f }, + { 0, -9942.3f, -147.5f, 25.0f, -9467.9f, -1182.3f, 49.4f, 1179.0f }, + { 0, -3745.6f, -801.5f, 11.6f, -3591.8f, -1994.5f, 117.0f, 1647.0f }, + { 0, -11313.9f, -202.8f, 75.6f, -10716.4f, -1250.0f, 29.5f, 1309.0f }, + { 0, -5394.1f, -2954.4f, 322.1f, -5667.5f, -4248.2f, 407.2f, 1837.0f }, + { 0, 520.6f, 1602.9f, 126.5f, 1848.3f, 1627.6f, 97.0f, 2960.0f }, + { 0, -11313.9f, -202.8f, 75.6f, -9942.3f, -147.5f, 25.0f, 3194.0f }, + { 0, -1240.5f, -2515.1f, 22.2f, -2650.7f, -2453.3f, 80.2f, 1479.0f }, + { 0, -1231.2f, -2510.2f, 23.2f, 30.7f, -1585.2f, 193.2f, 2159.0f }, + { 1, -902.0f, -3759.4f, 11.6f, -2011.4f, -3635.4f, 22.6f, 1225.0f }, + { 1, 126.2f, 1232.7f, 163.3f, -658.0f, 426.6f, 187.2f, 1258.0f }, + { 1, -441.8f, -2596.1f, 96.1f, -3.1f, -3637.4f, 27.5f, 1263.0f }, + { 1, -5407.7f, -2414.3f, 90.3f, -4915.6f, -1381.2f, -52.6f, 1946.0f }, + { 1, -3147.4f, -2842.2f, 34.6f, -2382.8f, -1922.7f, 95.9f, 2028.0f }, + { 1, 6205.9f, -1949.6f, 571.3f, 7470.4f, -2123.4f, 492.3f, 1568.0f }, + { 1, 9822.2f, 952.0f, 1308.9f, 10081.5f, 2256.8f, 1343.4f, 1477.0f }, + { 1, -3132.8f, -2880.3f, 34.8f, -2011.4f, -3635.4f, 22.6f, 1991.0f }, + { 1, 2722.0f, -3880.6f, 100.9f, 2310.5f, -2554.7f, 101.9f, 1773.0f }, + { 1, 5068.4f, -337.2f, 367.4f, 4006.0f, -1288.4f, 254.4f, 1813.0f }, + { 2991, 2037.1f, 1529.9f, 648.5f, 3288.7f, 1757.9f, 824.5f, 1422.0f }, + // third run: the Classic 1.60 isle (map 2991), checked on its own mmaps + { 2991, 2262.7f, 917.6f, 675.3f, 1993.6f, 545.6f, 658.7f, 485.0f }, + { 2991, 2037.1f, 1529.9f, 648.5f, 2262.7f, 917.6f, 675.3f, 687.0f }, + { 2991, 2037.1f, 1529.9f, 648.5f, 1993.6f, 545.6f, 658.7f, 1094.0f }, +}; + +// A link end is a graph node's own position, written with one decimal; the node it names is the nearest within this many yards. +inline constexpr float kWalkLinkMatchYards = 1.0f; + +// Index of the point of `pts` (each with x, y, z) nearest to (x, y, z) and within kWalkLinkMatchYards, or -1 when there is none. +template +inline long MatchWalkLinkEnd(Points const& pts, float x, float y, float z) +{ + long best = -1; + float best_d2 = kWalkLinkMatchYards * kWalkLinkMatchYards; + for (std::size_t i = 0; i < pts.size(); ++i) + { + float const dx = pts[i].x - x, dy = pts[i].y - y, dz = pts[i].z - z; + float const d2 = dx * dx + dy * dy + dz * dz; + if (d2 <= best_d2) + { + best_d2 = d2; + best = long(i); + } + } + return best; +} + +} // namespace Playerbot::V2::Travel diff --git a/src/modules/PlayerbotV2/Util/ConfigReader.cpp b/src/modules/PlayerbotV2/Util/ConfigReader.cpp index 76a17d876a..cacbc6dec0 100644 --- a/src/modules/PlayerbotV2/Util/ConfigReader.cpp +++ b/src/modules/PlayerbotV2/Util/ConfigReader.cpp @@ -1,4 +1,5 @@ #include "ConfigReader.h" +#include "../Bot/ThreatLimits.h" #include "Config.h" #include "Log.h" #include @@ -150,7 +151,7 @@ void ConfigReader::apply_from_loaded_config() raid_provide_consumables_ = c.GetBoolDefault("Playerbot.Raid.ProvideConsumables", true, true); consumables_pve_ = c.GetBoolDefault("Playerbot.Consumables.PvE", true, true); consumables_pvp_ = c.GetBoolDefault("Playerbot.Consumables.PvP", false, true); - raid_dps_wait_timeout_ms_ = uint32(std::clamp(int64(c.GetIntDefault("Playerbot.Raid.DpsWaitTimeoutMs", 6000, true)), 1000, 6000)); + raid_dps_wait_timeout_ms_ = uint32(std::clamp(int64(c.GetIntDefault("Playerbot.Raid.DpsWaitTimeoutMs", int(kRaidDpsWaitTimeoutMaxMs), true)), 1000, int64(kRaidDpsWaitTimeoutMaxMs))); threat_hold_open_world_ = c.GetBoolDefault("PlayerbotV2.Threat.HoldInOpenWorld", false, true); threat_max_ratio_ = std::clamp(float(c.GetFloatDefault("PlayerbotV2.Threat.MaxRatio", 0.9f, true)), 0.3f, 1.2f); threat_opening_lead_boss_ = std::max(0.0f, float(c.GetFloatDefault("PlayerbotV2.Threat.OpeningLeadBoss", 900.0f, true))); @@ -185,8 +186,8 @@ void ConfigReader::apply_from_loaded_config() bhv_bot_whisperable_ = c.GetBoolDefault("Playerbot.Behavior.BotWhisperable", true, true); chatter_conversation_ = c.GetBoolDefault("Playerbot.Chatter.Conversation", true, true); bhv_world_bot_say_reply_ = c.GetBoolDefault("Playerbot.Behavior.WorldBotSayReply", true, true); - bhv_instance_group_cap_ = c.GetBoolDefault("Playerbot.Behavior.InstanceGroupCap", false, true); - bhv_open_world_group_cap_ = std::clamp(c.GetIntDefault("Playerbot.Behavior.OpenWorldGroupCap", 5, true), 1, 40); + bhv_instance_group_cap_ = c.GetBoolDefault("Playerbot.Behavior.InstanceGroupCap", true, true); + bhv_open_world_group_cap_ = std::clamp(c.GetIntDefault("Playerbot.Behavior.OpenWorldGroupCap", 40, true), 1, 40); bhv_bg_human_priority_ = c.GetBoolDefault("Playerbot.Behavior.BgHumanPriority", true, true); bhv_tank_markers_ = c.GetBoolDefault("Playerbot.Behavior.TankMarkers", true, true); bhv_mark_cc_ = c.GetBoolDefault("Playerbot.Behavior.MarkCc", true, true); @@ -201,6 +202,8 @@ void ConfigReader::apply_from_loaded_config() bhv_ranged_slow_ = c.GetBoolDefault("Playerbot.Behavior.RangedSlow", true, true); bhv_ike3_commands_ = c.GetBoolDefault("Playerbot.Behavior.Ike3Commands", true, true); bhv_owner_commands_ = c.GetBoolDefault("Playerbot.Behavior.OwnerCommands", true, true); + bhv_passive_leash_yd_ = std::max(0.0f, float(c.GetFloatDefault("Playerbot.Behavior.PassiveLeashYd", 25.0f, true))); + bhv_aggressive_radius_yd_ = std::max(1.0f, float(c.GetFloatDefault("Playerbot.Behavior.AggressiveRadiusYd", 10.0f, true))); bhv_fidget_ = c.GetBoolDefault("Playerbot.Behavior.Fidget", true, true); addon_hint_enabled_ = c.GetBoolDefault("Playerbot.AddonHint.Enable", false, true); addon_hint_delay_sec_ = uint32(std::clamp(c.GetIntDefault("Playerbot.AddonHint.DelaySec", 30, true), 5, 600)); diff --git a/src/modules/PlayerbotV2/Util/ConfigReader.h b/src/modules/PlayerbotV2/Util/ConfigReader.h index ec5c1724d9..f4b8dbed32 100644 --- a/src/modules/PlayerbotV2/Util/ConfigReader.h +++ b/src/modules/PlayerbotV2/Util/ConfigReader.h @@ -352,6 +352,10 @@ public: bool behavior_ranged_slow() const { return bhv_ranged_slow_; } bool behavior_ike3_commands() const { return bhv_ike3_commands_; } bool behavior_owner_commands() const { return bhv_owner_commands_; } + // Yards from the group's leader: a Passive bot defends a mob only within this of the leader (or of the member it is on), and an + // Aggressive one attacks a hostile only within the aggressive radius of the leader. 0 switches the Passive leash off. + float behavior_passive_leash_yd() const { return bhv_passive_leash_yd_; } + float behavior_aggressive_radius_yd() const { return bhv_aggressive_radius_yd_; } bool behavior_fidget() const { return bhv_fidget_; } // Players who log in without the ForeverBots add-on get one line with its download link. bool addon_hint_enabled() const { return addon_hint_enabled_; } @@ -497,7 +501,7 @@ private: bool raid_provide_consumables_ = false; bool consumables_pve_ = true; bool consumables_pvp_ = false; - uint32 raid_dps_wait_timeout_ms_ = 10000; + uint32 raid_dps_wait_timeout_ms_ = 8000; bool threat_hold_open_world_ = false; float threat_max_ratio_ = 0.9f; float threat_opening_lead_boss_ = 900.0f; @@ -530,8 +534,8 @@ private: bool bhv_bot_whisperable_ = true; bool chatter_conversation_ = true; bool bhv_world_bot_say_reply_ = true; - bool bhv_instance_group_cap_ = false; - uint32 bhv_open_world_group_cap_ = 5; + bool bhv_instance_group_cap_ = true; + uint32 bhv_open_world_group_cap_ = 40; bool bhv_bg_human_priority_ = true; bool bhv_tank_markers_ = true; bool bhv_mark_cc_ = true; @@ -546,6 +550,8 @@ private: bool bhv_ranged_slow_ = true; bool bhv_ike3_commands_ = true; bool bhv_owner_commands_ = true; + float bhv_passive_leash_yd_ = 25.0f; + float bhv_aggressive_radius_yd_ = 10.0f; bool bhv_fidget_ = true; bool addon_hint_enabled_ = false; uint32 addon_hint_delay_sec_ = 30; diff --git a/src/modules/PlayerbotV2/WORLD_BOTS.md b/src/modules/PlayerbotV2/WORLD_BOTS.md index 1c9e62c60f..b72c74310c 100644 --- a/src/modules/PlayerbotV2/WORLD_BOTS.md +++ b/src/modules/PlayerbotV2/WORLD_BOTS.md @@ -95,7 +95,7 @@ Raise `SpawnPerTick` for a faster ramp; the setup pipeline drains at most 10 bot Not run on the PC yet. Rules in `Fleet/SkyborneIsle.h` (tested: `ctest -L skyborne`). - The Skyborne races (95 Alliance, 96 Horde) are in the ambient race roll with weight 4 (about 9% of the Alliance and 11% of the Horde bots). At level 10 and up they are placed in a vanilla leveling town like every other bot. - Zephras Isle is an island with no exit in the server data (its portals lead to Valanaar and Rohashi Spires on the same map; the Skyborne portals of Stormwind and Dalaran connect those two cities). So the isle is handled apart: around a real player on the isle the spawner keeps Skyborne bots of level 1-9 (MinLevel does not apply there), the pipeline leaves a level 1-9 Skyborne at its start, they quest with the same-map starter logic of low-level bots, and `WorldBotSpawner::DriveGraduation` moves a bot that reaches level 10 on the isle to a leveling town with `BotSetupPipeline::Graduate` (the placement a new level-10 bot gets). The graduation is the only carried move; it is logged as `[world] skyborne graduate`. -- Seeding (`SeedRoster = 1`) makes `SkyborneSeedPct` (5) of the residents sleeping Skyborne level 1-9 at the isle start, so they wake when a player comes near. +- The island's residents are temporary (the variable pool, `Fleet/PoolBudget.h`): created on demand around a player on the isle, counted against `VariableMax` and not against `PoolMax`, and deleted after `VariableTtlHours` offline. A full core roster no longer keeps the isle empty. The seeder builds the core roster only. - Unverified: whether the quest givers of the isle deal with both Skyborne races in `giver_team_mask`, whether map 2991 is a normal open-world map for the anchor test (not an instance map), mmap coverage of the whole isle (33 mmtiles for 72 map tiles), and customization options for races 95/96 in `BotCharacterFactory`. - Area cap: no more than `AreaCapOutdoors` (14) world bots within `AreaRadius` (45 y) of one another outdoors, `AreaCapTown` (40) in a capital. Placement refuses a full spot, and every 10 s a pass moves up to three extras of an over-full crowd next to the nearest player (`[world] crowd:` line). `Fleet/AreaCap.h`. diff --git a/src/modules/PlayerbotV2/conf/playerbot.conf.dist b/src/modules/PlayerbotV2/conf/playerbot.conf.dist index f6044bbfae..db27444958 100644 --- a/src/modules/PlayerbotV2/conf/playerbot.conf.dist +++ b/src/modules/PlayerbotV2/conf/playerbot.conf.dist @@ -189,7 +189,8 @@ Playerbot.World.FillerHubOnly = 1 # around players waits too. Bots already online stay. -1 = 45% of the machine's RAM (the default), 0 = no limit. # Stage B/C: 12000 on a 31 GB PC that also runs a client. Playerbot.World.RssBudgetMb = -1 -# Bot level limits. +# Bot level limits. MinLevel is the floor of the wide level spread in capitals and of the world-wide filler; bots around a player in +# a zone follow the player's own level (from 1) inside the zone's level range. Playerbot.World.MinLevel = 10 Playerbot.World.MaxLevel = 60 # Percentage of bots of the player's own faction (the rest is the opposing faction). @@ -249,11 +250,13 @@ Playerbot.World.JumpGraceSec = 20 Playerbot.World.AreaCapOutdoors = 14 Playerbot.World.AreaCapTown = 40 Playerbot.World.AreaRadius = 45 -# Classic 1.60 (Skyborne): share of the seeded residents (SeedRoster = 1) that are level 1-9 Skyborne who sleep on Zephras Isle, the -# Skyborne start, so a player who arrives there finds quests being done. Around a player on Zephras the spawner always keeps -# Skyborne bots of level 1-9 (MinLevel does not apply there); a Skyborne bot that reaches level 10 on the island is moved to a -# leveling town of the vanilla world, because the island has no exit. 0 = no seeded islanders. -Playerbot.World.SkyborneSeedPct = 5 +# Temporary residents. PoolMax is the standing (core) roster; VariableMax more characters may exist next to it, created around a real +# player where the core has nobody fitting (a new character on Zephras Isle, a new low-level player) and deleted again, with the +# server's own character delete, once they have been offline VariableTtlHours with no owner, group or queue tag. The island's +# Skyborne residents (level 1-9, MinLevel does not apply there) are always temporary. A Skyborne bot that reaches level 10 on the +# island is moved to a leveling town of the vanilla world. VariableMax = 0: no temporary residents. +Playerbot.World.VariableMax = 2000 +Playerbot.World.VariableTtlHours = 24 #----------------------------------------------------------------------------- # Player interaction @@ -542,19 +545,20 @@ Playerbot.Behavior.DungeonTactics = 1 # question or their name: within 25 yd, 60 s per bot, 8 s global, 1-4 s delay, '[say_reply]' log. Playerbot.Behavior.BotWhisperable = 1 Playerbot.Behavior.WorldBotSayReply = 1 -# InstanceGroupCap OFF by default (an owner may have as many companions out as they like, up to the 40-man raid -# group limit; playtest 2026-10-08). Set 1 to cap: inside an instance `.bot add`, `.bot call` and the addon buttons stop once the owner has +# InstanceGroupCap ON by default. +# Inside an instance `.bot add`, `.bot call` and the addon buttons stop once the owner has # as many companions out as the map holds, or the group (human included) is full (5 dungeon, # 10/20/40 raid, from the map data; fallback 5 / 40). The owner is warned once when a larger -# group enters a smaller instance. Outside an instance the OpenWorldGroupCap below applies. -Playerbot.Behavior.InstanceGroupCap = 0 +# group enters a smaller instance. Outside an instance the OpenWorldGroupCap below applies. Set 0 to turn the cap off. +Playerbot.Behavior.InstanceGroupCap = 1 # OpenWorldGroupCap outside an instance (open world) an owner has at most this many of their own companions out # (`.bot add`, `.bot call`, saved roster, addon buttons, relog). Default 5. More bots only by -# inviting world bots, which are not counted; the group becomes a raid when it needs to. A +# inviting world bots, which are not counted; the group becomes a raid when it needs to. Default 40: no limit +# beyond the raid (a raid is built in the open world); set 5 for a normal party. A # companion above the cap (called inside an instance) is dismissed 10 s after the owner stands # outside: grouped ones are kept first. Needs InstanceGroupCap = 1. Battleground and arena maps # are not capped by this. Range 1-40. -Playerbot.Behavior.OpenWorldGroupCap = 5 +Playerbot.Behavior.OpenWorldGroupCap = 40 # BgHumanPriority a human queueing for a battleground never opens a second instance while a running one can # make room: a bot leaves it for the human, and a bots-only battleground keeps playing to its # normal end after the last human leaves ([bg_queue] log lines). @@ -614,6 +618,14 @@ Playerbot.Behavior.Ike3Commands = 1 # "sell grey", "repair", "summon" (with its combat / instance refusals), "passive" / "aggressive" / # "defensive". Off: none of these new words is parsed (the older verbs keep working). Playerbot.Behavior.OwnerCommands = 1 +# PassiveLeashYd a bot in a group with a player is Passive until told otherwise: it starts nothing and fights only what the +# leader pulled (his target) or what is attacking it or a member, and in the open world only within this +# many yards of the leader or of the member being attacked. It never chases further and goes back to +# follow when the fight is done. 0 = no distance limit. +# AggressiveRadiusYd Aggressive stance: a bot attacks any hostile within this many yards of the leader (not of itself) and +# nothing beyond; in a dungeon or raid only mobs not yet in combat inside this radius. +Playerbot.Behavior.PassiveLeashYd = 25 +Playerbot.Behavior.AggressiveRadiusYd = 10 # Fidget a bot standing idle out of combat (not mounted, nothing hostile near, no group fight) occasionally # fidgets like a person: a jump, a short emote, a dance or a sit, every 20-90 s (random per bot). # Off: bots stand perfectly still. @@ -1070,9 +1082,10 @@ Playerbot.Raid.ProvideConsumables = 1 Playerbot.Consumables.PvE = 1 Playerbot.Consumables.PvP = 0 # Playerbot.Raid.DpsWaitTimeoutMs with DpsWaitForAttack: after the tanks have fought this long without the owner's -# Attack, the DPS go anyway (a forgotten Attack no longer wipes the raid). Same six seconds as a party's Pull; the -# value is limited to 1000-6000 (there is no "never"). Default 6000. -Playerbot.Raid.DpsWaitTimeoutMs = 6000 +# Attack, the DPS go anyway (a forgotten Attack no longer wipes the raid). Eight seconds for a raid, because the tank +# takes a while to run in (a party's Pull keeps six); the value is limited to 1000-8000 (there is no "never"). +# Default 8000. +Playerbot.Raid.DpsWaitTimeoutMs = 8000 PlayerbotV2.Threat.HoldInOpenWorld = 0 PlayerbotV2.Threat.MaxRatio = 0.9 PlayerbotV2.Threat.OpeningLeadBoss = 900