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 <ralph.sennhauser@gmail.com>
This commit is contained in:
Ralph Sennhauser 2025-08-27 20:10:17 +02:00
parent 3a6540110b
commit ef007b9e5a
No known key found for this signature in database

View file

@ -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;