From ff001afd46eaf2e67045ff14b0603194b17eb0c3 Mon Sep 17 00:00:00 2001 From: Mat Date: Sat, 30 May 2026 20:12:54 +0200 Subject: [PATCH] Reset instance ID via existing cmd refresh=raid for alt bots (#2422) ## Pull Request Description Alt bots can now use refresh=raid cmd if cfg is set to 1. `AiPlayerbot.ResetInstanceIdForAltBots = 1` ## Feature Evaluation - Describe the **minimum logic** required to achieve the intended behavior. - Describe the **processing cost** when this logic executes across many bots. ## How to Test the Changes Add alt bot, use .playerbots bot refresh=raid and it should say ok after reseting instance. ## Impact Assessment - Does this change increase per-bot/per-tick processing or risk scaling poorly with thousands of bots? - - [x] No, not at all - - [ ] Minimal impact (**explain below**) - - [ ] Moderate impact (**explain below**) - Does this change modify default bot behavior? - - [ ] No - - [x] Yes (**explain why**) Alt bots will now reset instance ID if cfg is set to 1. - Does this change add new decision branches or increase maintenance complexity? - - [ ] No - - [x] Yes (**explain below**) It will check if cfg is set to 1 to enable alt bots to reset instance id. ## AI Assistance Was AI assistance used while working on this change? - - [x] No - - [ ] Yes (**explain below**) ## Final Checklist - - [x] Stability is not compromised. - - [x] Performance impact is understood, tested, and acceptable. - - [x] Added logic complexity is justified and explained. - - [x] Any new bot dialogue lines are translated. - - [x] Documentation updated if needed (Conf comments, WiKi commands). ## Notes for Reviewers --------- Co-authored-by: Keleborn <22352763+Celandriel@users.noreply.github.com> --- conf/playerbots.conf.dist | 7 +++++++ src/Bot/PlayerbotMgr.cpp | 5 ++++- src/PlayerbotAIConfig.cpp | 1 + src/PlayerbotAIConfig.h | 1 + 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/conf/playerbots.conf.dist b/conf/playerbots.conf.dist index c12049d66..324cdc457 100644 --- a/conf/playerbots.conf.dist +++ b/conf/playerbots.conf.dist @@ -187,6 +187,13 @@ AiPlayerbot.SelfBotLevel = 1 # Default: 0 (non-GM player can use any intialization commands) AiPlayerbot.AutoInitOnly = 0 +# Allow .bot refresh=raid to unbind instances on player-created alt +# bots (non-addclass bots). When 0, refresh=raid is denied on alts +# with "non-addclass bot" error. UnbindInstance is DB-light, no lag +# risk from enabling this. +# Default: 0 +AiPlayerbot.ResetInstanceIdForAltBots = 0 + # The upper limit ratio of bot equipment level for init=auto # Default: 1.0 (same with the player) AiPlayerbot.AutoInitEquipLevelLimitRatio = 1.0 diff --git a/src/Bot/PlayerbotMgr.cpp b/src/Bot/PlayerbotMgr.cpp index d38e7720e..9d9f5688f 100644 --- a/src/Bot/PlayerbotMgr.cpp +++ b/src/Bot/PlayerbotMgr.cpp @@ -732,7 +732,10 @@ std::string const PlayerbotHolder::ProcessBotCommand(std::string const cmd, Obje bool addClassBot = sRandomPlayerbotMgr.IsAddclassBot(guid.GetCounter()); if (!addClassBot) - return "ERROR: You can not use this command on non-addclass bot."; + { + if (!(cmd == "refresh=raid" && sPlayerbotAIConfig.resetInstanceIdForAltBots)) + return "ERROR: You can only use this command on addclass bots."; + } if (!admin) { diff --git a/src/PlayerbotAIConfig.cpp b/src/PlayerbotAIConfig.cpp index c01769eb8..fb036e359 100644 --- a/src/PlayerbotAIConfig.cpp +++ b/src/PlayerbotAIConfig.cpp @@ -593,6 +593,7 @@ bool PlayerbotAIConfig::Initialize() reviveBotWhenSummoned = sConfigMgr->GetOption("AiPlayerbot.ReviveBotWhenSummoned", 1); botRepairWhenSummon = sConfigMgr->GetOption("AiPlayerbot.BotRepairWhenSummon", true); autoInitOnly = sConfigMgr->GetOption("AiPlayerbot.AutoInitOnly", false); + resetInstanceIdForAltBots = sConfigMgr->GetOption("AiPlayerbot.ResetInstanceIdForAltBots", false); autoInitEquipLevelLimitRatio = sConfigMgr->GetOption("AiPlayerbot.AutoInitEquipLevelLimitRatio", 1.0); maxAddedBots = sConfigMgr->GetOption("AiPlayerbot.MaxAddedBots", 40); diff --git a/src/PlayerbotAIConfig.h b/src/PlayerbotAIConfig.h index 9dc1dcba1..1936d1ca7 100644 --- a/src/PlayerbotAIConfig.h +++ b/src/PlayerbotAIConfig.h @@ -406,6 +406,7 @@ public: int reviveBotWhenSummoned; bool botRepairWhenSummon; bool autoInitOnly; + bool resetInstanceIdForAltBots; float autoInitEquipLevelLimitRatio; int32 maxAddedBots; int32 addClassCommand;