Ticket #3430: ticket3430-v2.patch
File ticket3430-v2.patch, 2.9 KB (added by , 9 years ago) |
---|
-
binaries/data/mods/public/simulation/ai/common-api/entity.js
721 721 res = this._ai._entities.get(this.unitAIOrderData()[0]["target"]); 722 722 else if (this.unitAIOrderData()[1] !== undefined && this.unitAIOrderData()[1]["target"] !== undefined) 723 723 res = this._ai._entities.get(this.unitAIOrderData()[1]["target"]); 724 if (res === undefined) 725 return undefined; 724 if (!res) 725 return 0; 726 let type = res.resourceSupplyType(); 727 if (!type) 728 return 0; 726 729 727 let type = res.resourceSupplyType();728 730 if (type.generic === "treasure") 729 731 return 1000; 730 732 -
binaries/data/mods/public/simulation/components/UnitAI.js
2036 2036 // It's probably better in this case, to avoid units getting stuck around a dropsite 2037 2037 // in a "Target is far away, full, nearby are no good resources, return to dropsite" loop 2038 2038 // to order it to GatherNear the resource position. 2039 var cmpPosition = Engine.QueryInterface( this.gatheringTarget, IID_Position);2039 var cmpPosition = Engine.QueryInterface(oldTarget, IID_Position); 2040 2040 if (cmpPosition) 2041 2041 { 2042 2042 var pos = cmpPosition.GetPosition(); 2043 2043 this.GatherNearPosition(pos.x, pos.z, oldType, oldTemplate); 2044 2044 return true; 2045 } else { 2045 } 2046 else 2047 { 2046 2048 // we're kind of stuck here. Return resource. 2047 2049 var nearby = this.FindNearestDropsite(oldType.generic); 2048 2050 if (nearby) … … 2340 2342 2341 2343 // If hunting, try to go to the initial herd position to see if we are more lucky 2342 2344 if (herdPos) 2345 { 2343 2346 this.GatherNearPosition(herdPos.x, herdPos.z, resourceType, resourceTemplate); 2347 return; 2348 } 2344 2349 2345 2350 // Nothing else to gather - if we're carrying anything then we should 2346 2351 // drop it off, and if not then we might as well head to the dropsite … … 3530 3535 } 3531 3536 else 3532 3537 { 3533 this.SetNextState("IDLE"); 3538 // We must switch to the idle state immediately (and not do a simple SetNextState) 3539 // otherwise we may be in a weird state if a ProcessMessage is triggered (by a MoveStarted 3540 // or MoveCompleted) when starting a new order and before we have set our new state. 3541 let index = this.GetCurrentState().indexOf("."); 3542 if (index != -1) 3543 this.UnitFsm.SwitchToNextState(this, this.GetCurrentState().slice(0,index+1) + "IDLE"); 3544 else 3545 this.SetNextState("IDLE"); // should never happen 3534 3546 3535 3547 Engine.PostMessage(this.entity, MT_UnitAIOrderDataChanged, { "to": this.GetOrderData() }); 3536 3548