From 103d89f026f742adf03c36d514704f722acf6710 Mon Sep 17 00:00:00 2001 From: wraitii Date: Sun, 28 Jul 2019 09:48:23 +0000 Subject: [PATCH] GatherNearPositiion when the target remains invisible on our second try, instead of going idle. This improves hunting behaviour, as targets may still be in FOW on the second try, and the unit would go idle - instead it'll now gather near position, which is more likely to find a proper resource. Differential Revision: https://code.wildfiregames.com/D2071 This was SVN commit r22565. --- .../public/simulation/components/UnitAI.js | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/binaries/data/mods/public/simulation/components/UnitAI.js b/binaries/data/mods/public/simulation/components/UnitAI.js index 7eba56aa90..546ffbe2a2 100644 --- a/binaries/data/mods/public/simulation/components/UnitAI.js +++ b/binaries/data/mods/public/simulation/components/UnitAI.js @@ -527,10 +527,17 @@ UnitAI.prototype.UnitFsmSpec = { this.order.data.secondTry = true; this.PushOrderFront("Walk", this.order.data.lastPos); } + // We couldn't move there, or the target moved away else { - // We couldn't move there, or the target moved away - this.FinishOrder(); + let data = this.order.data; + if (!this.FinishOrder()) + this.PushOrderFront("GatherNearPosition", { + "x": data.lastPos.x, + "z": data.lastPos.z, + "type": data.type, + "template": data.template + }); } return; } @@ -777,14 +784,20 @@ UnitAI.prototype.UnitFsmSpec = { msg.data.secondTry = true; this.PushOrderFront("Walk", msg.data.lastPos); } + // We couldn't move there, or the target moved away else { - // We couldn't move there, or the target moved away - this.FinishOrder(); + let data = msg.data; + if (!this.FinishOrder()) + this.PushOrderFront("GatherNearPosition", { + "x": data.lastPos.x, + "z": data.lastPos.z, + "type": data.type, + "template": data.template + }); } return; } - this.PushOrderFront("Attack", { "target": msg.data.target, "force": !!msg.data.force, "hunting": true, "allowCapture": false, "min": 0, "max": 10 }); return; }