mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-06-18 22:33:56 -07:00
Restore previous formation behaviour of targeting nearby enemies when idle / aborting orders
This restores A23 formation behaviour, changed by 4ca448a686. Units will
now start attacking nearby enemies when the formation goes idle (such as
when the abort order button is clicked).
This introduces a change that formation units that actually go idle will
try to move back in formation shape, so it looks more like they're still
in formation.
Fixes #5519.
Differential Revision: https://code.wildfiregames.com/D2097
This was SVN commit r22506.
This commit is contained in:
parent
bac777cb29
commit
b807c39e6a
1 changed files with 12 additions and 10 deletions
|
|
@ -1266,13 +1266,11 @@ UnitAI.prototype.UnitFsmSpec = {
|
|||
this.SetDefaultAnimationVariant();
|
||||
},
|
||||
|
||||
"IDLE": {
|
||||
// Formation members do nothing while Idle, but we need the state
|
||||
// so that they keep the formation variant.
|
||||
},
|
||||
"IDLE": "INDIVIDUAL.IDLE",
|
||||
|
||||
"WALKING": {
|
||||
"enter": function() {
|
||||
this.formationOffset = { "x": this.order.data.x, "z": this.order.data.z };
|
||||
let cmpUnitMotion = Engine.QueryInterface(this.entity, IID_UnitMotion);
|
||||
cmpUnitMotion.MoveToFormationOffset(this.order.data.target, this.order.data.x, this.order.data.z);
|
||||
},
|
||||
|
|
@ -1402,12 +1400,6 @@ UnitAI.prototype.UnitFsmSpec = {
|
|||
// get stuck with an incorrect animation
|
||||
this.SelectAnimation("idle");
|
||||
|
||||
if (this.formationController)
|
||||
{
|
||||
this.SetNextState("FORMATIONMEMBER.IDLE");
|
||||
return true;
|
||||
}
|
||||
|
||||
// Idle is the default state. If units try, from the IDLE.enter sub-state, to
|
||||
// begin another order, and that order fails (calling FinishOrder), they might
|
||||
// end up in an infinite loop. To avoid this, all methods that could put the unit in
|
||||
|
|
@ -1468,6 +1460,16 @@ UnitAI.prototype.UnitFsmSpec = {
|
|||
if (this.FindNewTargets())
|
||||
return; // (abort the FSM transition since we may have already switched state)
|
||||
|
||||
if (this.formationOffset && this.formationController)
|
||||
{
|
||||
this.PushOrder("FormationWalk", {
|
||||
"target": this.formationController,
|
||||
"x": this.formationOffset.x,
|
||||
"z": this.formationOffset.z,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.isIdle)
|
||||
{
|
||||
this.isIdle = true;
|
||||
|
|
|
|||
Loading…
Reference in a new issue