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;