Fix units restarting orders when tasked to attack/gather/repair/heal same unit.
FSM states would be left/re-entered, resetting the timer, which did not
happen pre a16e7c0a56
and is undesirable in general.
This explicitly checks for a few cases where timers are relevant.
Essentially a Patch by: Freagarach
Differential Revision: https://code.wildfiregames.com/D3531
This was SVN commit r24855.
This commit is contained in:
parent
831e4a183f
commit
a4c698ac48
@ -5586,6 +5586,16 @@ UnitAI.prototype.Attack = function(target, allowCapture = true, queued = false)
|
||||
|
||||
this.RememberTargetPosition(order);
|
||||
|
||||
if (this.order && this.order.type == "Attack" &&
|
||||
this.order.data &&
|
||||
this.order.data.target === order.target &&
|
||||
this.order.data.allowCapture === order.allowCapture)
|
||||
{
|
||||
this.order.data.lastPos = order.lastPos;
|
||||
this.order.data.force = order.force;
|
||||
return;
|
||||
}
|
||||
|
||||
this.AddOrder("Attack", order, queued);
|
||||
};
|
||||
|
||||
@ -5672,6 +5682,16 @@ UnitAI.prototype.PerformGather = function(target, queued, force)
|
||||
this.RememberTargetPosition(order);
|
||||
order.initPos = order.lastPos;
|
||||
|
||||
if (this.order &&
|
||||
(this.order.type == "Gather" || this.order.type == "Attack") &&
|
||||
this.order.data &&
|
||||
this.order.data.target === order.target)
|
||||
{
|
||||
this.order.data.lastPos = order.lastPos;
|
||||
this.order.data.force = order.force;
|
||||
return;
|
||||
}
|
||||
|
||||
this.AddOrder("Gather", order, queued);
|
||||
};
|
||||
|
||||
@ -5701,6 +5721,14 @@ UnitAI.prototype.Heal = function(target, queued)
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.order && this.order.type == "Heal" &&
|
||||
this.order.data &&
|
||||
this.order.data.target === target)
|
||||
{
|
||||
this.order.data.force = true;
|
||||
return;
|
||||
}
|
||||
|
||||
this.AddOrder("Heal", { "target": target, "force": true }, queued);
|
||||
};
|
||||
|
||||
@ -5890,6 +5918,15 @@ UnitAI.prototype.Repair = function(target, autocontinue, queued)
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.order && this.order.type == "Repair" &&
|
||||
this.order.data &&
|
||||
this.order.data.target === target &&
|
||||
this.order.data.autocontinue === autocontinue)
|
||||
{
|
||||
this.order.data.force = true;
|
||||
return;
|
||||
}
|
||||
|
||||
this.AddOrder("Repair", { "target": target, "autocontinue": autocontinue, "force": true }, queued);
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user