Let formation attack from the moment the first unit is in range

This was SVN commit r14297.
This commit is contained in:
sanderd17 2013-12-05 19:26:55 +00:00
parent 9678cf547a
commit d3f7da1e27
2 changed files with 14 additions and 0 deletions

View file

@ -13,6 +13,13 @@ Formation.prototype.Init = function()
this.formationName = "Line Closed";
this.rearrange = true; // whether we should rearrange all formation members
this.formationMembersWithAura = []; // Members with a formation aura
this.width = 0;
this.depth = 0;
};
Formation.prototype.GetSize = function()
{
return {"width": this.width, "depth": this.depth};
};
Formation.prototype.GetMemberCount = function()
@ -289,6 +296,8 @@ Formation.prototype.MoveMembersIntoFormation = function(moveCenter, force)
}
var offsets = this.ComputeFormationOffsets(active, positions, this.columnar);
var xMax = 0;
var zMax = 0;
for (var i = 0; i < offsets.length; ++i)
{
@ -312,7 +321,11 @@ Formation.prototype.MoveMembersIntoFormation = function(moveCenter, force)
"z": offset.z
});
}
xMax = Math.max(xMax, offset.x);
zMax = Math.max(zMax, offset.z);
}
this.width = xMax * 2;
this.depth = zMax * 2;
};
Formation.prototype.MoveToMembersCenter = function()

View file

@ -776,6 +776,7 @@ var UnitFsmSpec = {
var cmpFormation = Engine.QueryInterface(this.entity, IID_Formation);
var maxRange = cmpFormation.GetMaxAttackRangeFunction(msg.data.target);
maxRange += cmpFormation.GetSize().depth / 2;
// Check if we are already in range, otherwise walk there
if (!this.CheckTargetRangeExplicit(msg.data.target, 0, maxRange))
{