Make hunting units disband earlier.

Fix formation disbanding.

This was SVN commit r12921.
This commit is contained in:
leper
2012-12-02 23:11:55 +00:00
parent 37109f5c70
commit 26a22a7bcb
@@ -680,6 +680,12 @@ var UnitFsmSpec = {
},
"Order.Gather": function(msg) {
if (this.MustKillGatherTarget(msg.data.target))
{
this.PushOrderFront("Attack", { "target": msg.data.target, "hunting": true });
return;
}
// TODO: on what should we base this range?
// Check if we are already in range, otherwise walk there
if (!this.CheckTargetRangeExplicit(msg.data.target, 0, 10))
@@ -831,8 +837,8 @@ var UnitFsmSpec = {
return;
}
// If this was the last order, attempt to disband the formation.
cmpFormation.FindInPosition();
// No more orders left.
cmpFormation.Disband();
},
},
@@ -863,6 +869,20 @@ var UnitFsmSpec = {
this.StartTimer(1000, 1000);
},
"EntityRenamed": function(msg) {
if (this.order.data.target == msg.entity)
{
this.order.data.target = msg.newentity;
// If we're hunting, that means we have a queued gather
// order whose target also needs to be updated.
if (this.order.data.hunting && this.orderQueue[1] &&
this.orderQueue[1].type == "Gather")
this.orderQueue[1].data.target = msg.newentity;
}
},
"Timer": function(msg) {
var cmpFormation = Engine.QueryInterface(this.entity, IID_Formation);