Index: binaries/data/mods/public/simulation/components/UnitAI.js =================================================================== --- binaries/data/mods/public/simulation/components/UnitAI.js +++ binaries/data/mods/public/simulation/components/UnitAI.js @@ -1803,11 +1803,9 @@ this.PushOrderFront("Pack", { "force": true }); return; } - if (this.MoveToTargetAttackRange(target, this.order.data.attackType)) - { - this.SetNextState("COMBAT.CHASING"); - return true; - } + + this.SetNextState("COMBAT.CHASING"); + return true; } } @@ -1923,11 +1921,8 @@ this.PushOrderFront("Pack", { "force": true }); return; } - if (this.MoveToTargetRange(target, IID_Attack, this.order.data.attackType)) - { - this.SetNextState("COMBAT.CHASING"); - return; - } + this.SetNextState("COMBAT.CHASING"); + return; } } @@ -1979,7 +1974,7 @@ "CHASING": { "enter": function() { - if (!this.MoveTo(this.order.data)) + if (!this.MoveToTargetAttackRange(this.order.data.target, this.order.data.attackType)) { this.FinishOrder(); return true; @@ -2223,20 +2218,6 @@ this.SetNextState("APPROACHING"); return; } - - // Can't reach the target, or it doesn't exist any more - - // We want to carry on gathering resources in the same area as - // the old one. So try to get close to the old resource's - // last known position - - var maxRange = 8; // get close but not too close - if (this.order.data.lastPos && - this.MoveToPointRange(this.order.data.lastPos.x, this.order.data.lastPos.z, 0, maxRange)) - { - this.SetNextState("APPROACHING"); - return; - } } } @@ -2530,7 +2511,7 @@ "REPAIR": { "APPROACHING": { "enter": function() { - if (!this.MoveTo(this.order.data)) + if (!this.MoveTo(this.order.data, IID_Builder)) { this.FinishOrder(); return true; @@ -2568,10 +2549,7 @@ if (!this.CheckTargetRange(this.repairTarget, IID_Builder)) { - if (this.MoveToTargetRange(this.repairTarget, IID_Builder)) - this.SetNextState("APPROACHING"); - else - this.FinishOrder(); + this.SetNextState("APPROACHING"); return true; } // Check if the target is still repairable @@ -2619,11 +2597,8 @@ // in that case, the repairTarget is deleted, and we can just return if (!this.repairTarget) return; - let inRange = this.CheckTargetRange(this.repairTarget, IID_Builder); - if (!inRange && this.MoveToTargetRange(this.repairTarget, IID_Builder)) + if (!this.CheckTargetRange(this.repairTarget, IID_Builder)) this.SetNextState("APPROACHING"); - else if (!inRange) - this.FinishOrder(); //can't approach and isn't in reach }, },