Ticket #2946: NonworkerDistance_PATCHv2.patch
File NonworkerDistance_PATCHv2.patch, 2.7 KB (added by , 9 years ago) |
---|
-
binaries/data/mods/public/simulation/components/UnitAI.js
324 324 return; 325 325 } 326 326 327 var ok = this.MoveToTarget (this.order.data.target);327 var ok = this.MoveToTargetRangeExplicit(this.order.data.target, this.order.data.min, this.order.data.max); 328 328 if (ok) 329 329 { 330 330 // We've started walking to the given point … … 4914 4914 */ 4915 4915 UnitAI.prototype.WalkToTarget = function(target, queued) 4916 4916 { 4917 this.AddOrder("WalkToTarget", { " target": target, "force": true }, queued);4917 this.AddOrder("WalkToTarget", { "min":0, "max":0, "target": target, "force": true }, queued); 4918 4918 }; 4919 4919 4920 4920 /** 4921 * Adds walk to target order with explicit range to queue. 4922 * Used when a unit which cannot build/repair is told to do so - they should walk to 4923 * the structure but not get so close to interfere with other workers. 4924 */ 4925 UnitAI.prototype.WalkToTargetRangeExplicit = function(rangeMin, rangeMax, target, queued) 4926 { 4927 this.AddOrder("WalkToTarget", { "min":rangeMin, "max":rangeMax, "target": target, "force": true }, queued); 4928 }; 4929 4930 /** 4921 4931 * Adds walk-and-fight order to queue, this only occurs in response 4922 4932 * to a player order, and so is forced. 4923 4933 * If targetClasses is given, only entities matching the targetClasses can be attacked. … … 5012 5022 { 5013 5023 if (!this.CanGather(target)) 5014 5024 { 5015 this.WalkToTarget(target, queued); 5025 var cmpObstruction = Engine.QueryInterface(this.entity, IID_Obstruction); 5026 var distance = 10 * cmpObstruction.GetUnitRadius(); 5027 this.WalkToTargetRangeExplicit(10, 10, target, queued); 5016 5028 return; 5017 5029 } 5018 5030 … … 5071 5083 { 5072 5084 if (!this.CanHeal(target)) 5073 5085 { 5074 this.WalkToTarget (target, queued);5086 this.WalkToTargetRangeExplicit(10, 10, target, queued); 5075 5087 return; 5076 5088 } 5077 5089 … … 5085 5097 { 5086 5098 if (!this.CanReturnResource(target, true)) 5087 5099 { 5088 this.WalkToTarget(target, queued); 5100 var cmpObstruction = Engine.QueryInterface(this.entity, IID_Obstruction); 5101 var distance = 10 * cmpObstruction.GetUnitRadius(); 5102 this.WalkToTargetRangeExplicit(distance, distance, target, queued); 5089 5103 return; 5090 5104 } 5091 5105 … … 5102 5116 { 5103 5117 if (!this.CanTrade(target)) 5104 5118 { 5105 this.WalkToTarget (target, queued);5119 this.WalkToTargetRangeExplicit(10, 10, target, queued); 5106 5120 return; 5107 5121 } 5108 5122 … … 5227 5241 { 5228 5242 if (!this.CanRepair(target)) 5229 5243 { 5230 this.WalkToTarget(target, queued); 5244 var cmpObstruction = Engine.QueryInterface(this.entity, IID_Obstruction); 5245 var distance = 10 * cmpObstruction.GetUnitRadius(); 5246 this.WalkToTargetRangeExplicit(distance, distance, target, queued); 5231 5247 return; 5232 5248 } 5233 5249