From ef007b9e5a3061121b7f5ddb1649aa07c87cc272 Mon Sep 17 00:00:00 2001 From: Ralph Sennhauser Date: Wed, 27 Aug 2025 20:10:17 +0200 Subject: [PATCH] Fix gliding healers when group attack order In case a healer is currently healing and is part of a selection ordered to attack the healer gets moved along but the fsm state isn't changed which leads to healer healing while gliding to the target. Introduce a WalkToTargetRange function which does transition state in addition by issuing an order instead. Fixes: #6134 Signed-off-by: Ralph Sennhauser --- .../data/mods/public/simulation/components/UnitAI.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/binaries/data/mods/public/simulation/components/UnitAI.js b/binaries/data/mods/public/simulation/components/UnitAI.js index d6bd180f9d..3caa1ae557 100644 --- a/binaries/data/mods/public/simulation/components/UnitAI.js +++ b/binaries/data/mods/public/simulation/components/UnitAI.js @@ -5494,6 +5494,16 @@ UnitAI.prototype.WalkToTarget = function(target, queued, pushFront) this.AddOrder("WalkToTarget", { "target": target, "force": true }, queued, pushFront); }; +/** + * Adds walk-to-target-range order to queue, this only occurs in response + * to a player order, and so is forced. + */ +UnitAI.prototype.WalkToTargetRange = function(target, iid, type, queued, pushFront) +{ + const range = this.GetRange(iid, type, target); + this.AddOrder("WalkToTarget", { "target": target, "min": range.min, "max": range.max, "force": true }, queued, pushFront); +}; + /** * Adds walk-and-fight order to queue, this only occurs in response * to a player order, and so is forced. @@ -5549,7 +5559,7 @@ UnitAI.prototype.Attack = function(target, allowCapture = this.DEFAULT_CAPTURE, // We don't want to let healers walk to the target unit so they can be easily killed. // Instead we just let them get into healing range. if (this.IsHealer()) - this.MoveToTargetRange(target, IID_Heal); + this.WalkToTargetRange(target, IID_Heal, null, queued, pushFront); else this.WalkToTarget(target, queued, pushFront); return;