From b7b67e0fd99bca956fc3d980e1da626fd0c09b03 Mon Sep 17 00:00:00 2001 From: NoxMax <50133316+NoxMax@users.noreply.github.com> Date: Fri, 27 Feb 2026 17:07:42 -0700 Subject: [PATCH] Feat/Fix: Expand follower bot flightmaster distance search and use correct config patterns (#2140) # Pull Request Feat: A common problem I have with follower bots is that if I quickly run up to a flightmaster and select a destination, as I go on my way, the bots can't get on a damn bird and say "Cannot find any flightmaster to talk". Guy was 8 yards away and they're completely blind to him. This is because when you select a destination, at that moment the bot would check `GetNPCIfCanInteractWith` from core, which uses `INTERACTION_DISTANCE`, which is defined as 5.5 yards. So the bot has to have caught up with you to be within 5.5 yards of the flightmaster. This PR expands that distance to use our own `sPlayerbotAIConfig.farDistance`, which is by default set to 20 yards. So just as long as bots have caught up to be within 20 yards from the flightmaster, they will follow you. Fix: While I was doing this, I noticed that the timings for bot flight staggering (introduced in #1281) are defined in TaxiAction and PlayerbotAIConfig. So I removed their definitions from TaxiAction, made proper calls to the configs, and renamed them to similar format that other configs use. --- ## Design Philosophy We prioritize **stability, performance, and predictability** over behavioral realism. Complex player-mimicking logic is intentionally limited due to its negative impact on scalability, maintainability, and long-term robustness. Excessive processing overhead can lead to server hiccups, increased CPU usage, and degraded performance for all participants. Because every action and decision tree is executed **per bot and per trigger**, even small increases in logic complexity can scale poorly and negatively affect both players and world (random) bots. Bots are not expected to behave perfectly, and perfect simulation of human decision-making is not a project goal. Increased behavioral realism often introduces disproportionate cost, reduced predictability, and significantly higher maintenance overhead. Every additional branch of logic increases long-term responsibility. All decision paths must be tested, validated, and maintained continuously as the system evolves. If advanced or AI-intensive behavior is introduced, the **default configuration must remain the lightweight decision model**. More complex behavior should only be available as an **explicit opt-in option**, clearly documented as having a measurable performance cost. Principles: - **Stability before intelligence** A stable system is always preferred over a smarter one. - **Performance is a shared resource** Any increase in bot cost affects all players and all bots. - **Simple logic scales better than smart logic** Predictable behavior under load is more valuable than perfect decisions. - **Complexity must justify itself** If a feature cannot clearly explain its cost, it should not exist. - **Defaults must be cheap** Expensive behavior must always be optional and clearly communicated. - **Bots should look reasonable, not perfect** The goal is believable behavior, not human simulation. Before submitting, confirm that this change aligns with those principles. --- ## Feature Evaluation Please answer the following: - Describe the **minimum logic** required to achieve the intended behavior? - Describe the **cheapest implementation** that produces an acceptable result? - Describe the **runtime cost** when this logic executes across many bots? Changes here use a minimal amount of code to accomplish the objective, including using pre-defined distance values rather than creating new ones. Changes have no effect on processing. --- ## How to Test the Changes For expanding flightmaster search distance: You will be using the `stay` command. A bot commanded to `stay` will still take a flight with you, if it is near a flightmaster. So you can use the command to position the bot exactly where you want it to be 1. Place your follower bot immediately next to the flightmaster 2. Take a flight and the bot should follow. Nothing new here 3. Place the bot about 12 yards away from flightmaster. 4. Take a flight and the bot should follow. Same as before. 5. Repeat again, but this time place the bot 22 yards away. It should not follow you and instead say "Cannot find any flightmaster to talk" 6. The change should work correctly with `InstantFlightPaths = 0` in worldserver.conf, or if it's set to 1/2 and bots can instantly fly. For the config of staggering: 1. Make sure `InstantFlightPaths = 0` in worldserver.conf. 2. Change the timings in playerbots.conf under the `# FLIGHTPATH` section. 3. Changes should be correctly reflected in world. ## Complexity & Impact Does this change add new decision branches? - - [x] No - - [ ] Yes (**explain below**) Does this change increase per-bot or per-tick processing? - - [x] No - - [ ] Yes (**describe and justify impact**) Could this logic scale poorly under load? - - [x] No - - [ ] Yes (**explain why**) --- ## Defaults & Configuration Does this change modify default bot behavior? - - [x] No - - [ ] Yes (**explain why**) Follower bots search a slightly bigger distance for nearby flightmasters. If this introduces more advanced or AI-heavy logic: - - [x] Lightweight mode remains the default - - [x] More complex behavior is optional and thereby configurable --- ## AI Assistance Was AI assistance (e.g. ChatGPT or similar tools) used while working on this change? - - [x] No - - [ ] Yes (**explain below**) If yes, please specify: - AI tool or model used (e.g. ChatGPT, GPT-4, Claude, etc.) - Purpose of usage (e.g. brainstorming, refactoring, documentation, code generation) - Which parts of the change were influenced or generated - Whether the result was manually reviewed and adapted AI assistance is allowed, but all submitted code must be fully understood, reviewed, and owned by the contributor. Any AI-influenced changes must be verified against existing CORE and PB logic. We expect contributors to be honest about what they do and do not understand. --- ## Final Checklist - - [x] Stability is not compromised - - [x] Performance impact is understood, tested, and acceptable - - [x] Added logic complexity is justified and explained - - [x] Documentation updated if needed --- ## Notes for Reviewers Anything that significantly improves realism at the cost of stability or performance should be carefully discussed before merging. --- src/Ai/Base/Actions/TaxiAction.cpp | 24 +++++++++++++----------- src/PlayerbotAIConfig.cpp | 8 ++++---- src/PlayerbotAIConfig.h | 8 ++++---- 3 files changed, 21 insertions(+), 19 deletions(-) diff --git a/src/Ai/Base/Actions/TaxiAction.cpp b/src/Ai/Base/Actions/TaxiAction.cpp index 1f9e89cc..0bbbb8a1 100644 --- a/src/Ai/Base/Actions/TaxiAction.cpp +++ b/src/Ai/Base/Actions/TaxiAction.cpp @@ -31,8 +31,14 @@ bool TaxiAction::Execute(Event event) GuidVector units = *context->GetValue("nearest npcs"); for (ObjectGuid const guid : units) { - Creature* npc = bot->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_FLIGHTMASTER); - if (!npc) + Creature* npc = ObjectAccessor::GetCreature(*bot, guid); + if (!npc || !npc->IsAlive()) + continue; + + if (!(npc->GetNpcFlags() & UNIT_NPC_FLAG_FLIGHTMASTER)) + continue; + + if (bot->GetDistance(npc) > sPlayerbotAIConfig.farDistance) continue; uint32 curloc = sObjectMgr->GetNearestTaxiNode(npc->GetPositionX(), npc->GetPositionY(), npc->GetPositionZ(), @@ -50,21 +56,17 @@ bool TaxiAction::Execute(Event event) } } - // stagger bot takeoff - uint32 delayMin = sConfigMgr->GetOption("AiPlayerbot.BotTaxiDelayMinMs", 350u, false); - uint32 delayMax = sConfigMgr->GetOption("AiPlayerbot.BotTaxiDelayMaxMs", 5000u, false); - uint32 gapMs = sConfigMgr->GetOption("AiPlayerbot.BotTaxiGapMs", 200u, false); - uint32 gapJitterMs = sConfigMgr->GetOption("AiPlayerbot.BotTaxiGapJitterMs", 100u, false); - // Only for follower bots if (botAI->HasRealPlayerMaster()) { uint32 index = botAI->GetGroupSlotIndex(bot); - uint32 delay = delayMin + index * gapMs + urand(0, gapJitterMs); + uint32 delay = sPlayerbotAIConfig.botTaxiDelayMin + + index * sPlayerbotAIConfig.botTaxiGapMs + + urand(0, sPlayerbotAIConfig.botTaxiGapJitterMs); - delay = std::min(delay, delayMax); + delay = std::min(delay, sPlayerbotAIConfig.botTaxiDelayMax); - // Store the npc’s GUID so we can re-acquire the pointer later + // Store the NPC's GUID so we can re-acquire the pointer later ObjectGuid npcGuid = npc->GetGUID(); // schedule the take-off diff --git a/src/PlayerbotAIConfig.cpp b/src/PlayerbotAIConfig.cpp index c3aee910..211db9a0 100644 --- a/src/PlayerbotAIConfig.cpp +++ b/src/PlayerbotAIConfig.cpp @@ -415,10 +415,10 @@ bool PlayerbotAIConfig::Initialize() useFastFlyMountAtMinLevel = sConfigMgr->GetOption("AiPlayerbot.UseFastFlyMountAtMinLevel", 70); // stagger bot flightpath takeoff - delayMin = sConfigMgr->GetOption("AiPlayerbot.BotTaxiDelayMinMs", 350u); - delayMax = sConfigMgr->GetOption("AiPlayerbot.BotTaxiDelayMaxMs", 5000u); - gapMs = sConfigMgr->GetOption("AiPlayerbot.BotTaxiGapMs", 200u); - gapJitterMs = sConfigMgr->GetOption("AiPlayerbot.BotTaxiGapJitterMs", 100u); + botTaxiDelayMin = sConfigMgr->GetOption("AiPlayerbot.BotTaxiDelayMinMs", 350); + botTaxiDelayMax = sConfigMgr->GetOption("AiPlayerbot.BotTaxiDelayMaxMs", 5000); + botTaxiGapMs = sConfigMgr->GetOption("AiPlayerbot.BotTaxiGapMs", 200); + botTaxiGapJitterMs = sConfigMgr->GetOption("AiPlayerbot.BotTaxiGapJitterMs", 100); LOG_INFO("server.loading", "Loading TalentSpecs..."); diff --git a/src/PlayerbotAIConfig.h b/src/PlayerbotAIConfig.h index 970bbd50..a5c6e461 100644 --- a/src/PlayerbotAIConfig.h +++ b/src/PlayerbotAIConfig.h @@ -424,10 +424,10 @@ public: uint32 useFastFlyMountAtMinLevel; // stagger flightpath takeoff - uint32 delayMin; - uint32 delayMax; - uint32 gapMs; - uint32 gapJitterMs; + uint32 botTaxiDelayMin; + uint32 botTaxiDelayMax; + uint32 botTaxiGapMs; + uint32 botTaxiGapJitterMs; std::string const GetTimestampStr(); bool hasLog(std::string const fileName)