From 26a22a7bcb0ae8b3b37f482002a866b1acf024ff Mon Sep 17 00:00:00 2001 From: leper Date: Sun, 2 Dec 2012 23:11:55 +0000 Subject: [PATCH] Make hunting units disband earlier. Fix formation disbanding. This was SVN commit r12921. --- .../public/simulation/components/UnitAI.js | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/binaries/data/mods/public/simulation/components/UnitAI.js b/binaries/data/mods/public/simulation/components/UnitAI.js index e48bcfa9c6..6c71ebdeed 100644 --- a/binaries/data/mods/public/simulation/components/UnitAI.js +++ b/binaries/data/mods/public/simulation/components/UnitAI.js @@ -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);