Fix walk and fight with formations.

Introduced in c87229aa48, FindWalkAndFightTargets returns after the
first UnitAI finds a target, instead of also querying the rest of the
members.

Differential revision: https://code.wildfiregames.com/D4208
Comments by: @Stan, @wraitii
Fixes: #6260

This was SVN commit r25847.
This commit is contained in:
Freagarach
2021-08-03 16:43:43 +00:00
parent c48d0c562f
commit 32f3d18a15
@@ -5961,16 +5961,12 @@ UnitAI.prototype.FindWalkAndFightTargets = function()
{
if (this.IsFormationController())
{
let cmpUnitAI;
let foundSomething = false;
let cmpFormation = Engine.QueryInterface(this.entity, IID_Formation);
for (let ent of cmpFormation.members)
{
if (!(cmpUnitAI = Engine.QueryInterface(ent, IID_UnitAI)))
continue;
if (cmpUnitAI.FindWalkAndFightTargets())
return true;
}
return false;
for (const ent of cmpFormation.members)
if (Engine.QueryInterface(ent, IID_UnitAI)?.FindWalkAndFightTargets())
foundSomething = true;
return foundSomething;
}
let cmpAttack = Engine.QueryInterface(this.entity, IID_Attack);