From b6408ca602c377da163a63cdfec1e0bd2d3d3ead Mon Sep 17 00:00:00 2001 From: NoxMax <50133316+NoxMax@users.noreply.github.com> Date: Fri, 24 Apr 2026 15:04:40 -0600 Subject: [PATCH] Fix: Prevent infantry auto attack when IsInVehicle (#2319) ## Pull Request Description While testing vehicle combat in Wintergrasp, I was near two opposing vehicles. They were right on top of each other, and I was hearing the sounds of infantry melee attack. It looks like their auto-attack was on. I had thought the check in [GenericActions](https://github.com/mod-playerbots/mod-playerbots/blob/0c205b8cef5a541cabe080aaf9653adb25695c40/src/Ai/Base/Actions/GenericActions.cpp#L46) would prevent that, but I guess we need the extra defence. Note that IsInVehicle first three parameters are canControl/canCast/canAttack ## 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 There isn't vehicle combat scenarios (particularly vehicle on vehicle) in Playerbots right now that allow for obvious testing. I only learned about this through testing my unpublished Wintergrasp implementation. Regardless, the change is simple and the effect on code should be clear. ## 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**) No more infantry combat of any kind for drivers. - 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/AttackAction.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Ai/Base/Actions/AttackAction.cpp b/src/Ai/Base/Actions/AttackAction.cpp index af964f360..a537dd218 100644 --- a/src/Ai/Base/Actions/AttackAction.cpp +++ b/src/Ai/Base/Actions/AttackAction.cpp @@ -114,6 +114,11 @@ bool AttackAction::Attack(Unit* target, bool /*with_pet*/ /*true*/) return false; } + // Infantry attacks are not allowed from vehicles drivers. + // Check is needed to stop some auto-attack situations. + if (botAI->IsInVehicle() && !botAI->IsInVehicle(false, false, true)) + return false; + Unit* oldTarget = context->GetValue("current target")->Get(); bool shouldMelee = bot->IsWithinMeleeRange(target) || botAI->IsMelee(bot);