From 03d184cbef57198c4fd22bcf6138a61995cb1ba4 Mon Sep 17 00:00:00 2001 From: Mat Date: Fri, 12 Jun 2026 22:11:45 +0200 Subject: [PATCH] Fix bot leader handling (#2462) ## Pull Request Description With the default formation, FollowAction::isUseful resolved the follow target as "group leader" and returned false when the bot itself was leader, so an alt bot left as group leader never moved. Gate on the master first (matching Execute, which already positions relative to master) and fall back to group leader only when no master is set. Fixes [#2443](https://github.com/Noscopezz/mod-playerbots/issues/2443) ## 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 1. Be leader and have alt bot in group 2. Change to Alt 3. Leader and every other bot should follow you and listen to your commands even if you are not leader. give leader command will still work without breaking other Fixes so we have middle groud which should make everyone happy. 4. Play around, it should work every time ## 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**) explained above - Does this change add new decision branches or increase maintenance complexity? - - [x] No - - [ ] Yes (**explain below**) ## 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 --- src/Ai/Base/Actions/FollowActions.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Ai/Base/Actions/FollowActions.cpp b/src/Ai/Base/Actions/FollowActions.cpp index f82b05368..baa6e3e41 100644 --- a/src/Ai/Base/Actions/FollowActions.cpp +++ b/src/Ai/Base/Actions/FollowActions.cpp @@ -259,6 +259,8 @@ bool FollowAction::isUseful() Unit* fTarget = nullptr; if (!target.empty()) fTarget = AI_VALUE(Unit*, target); + else if (botAI->GetMaster()) + fTarget = botAI->GetMaster(); else fTarget = AI_VALUE(Unit*, "group leader");