Ticket #2353: fix.2.patch
File fix.2.patch, 3.6 KB (added by , 10 years ago) |
---|
-
binaries/data/mods/public/simulation/components/AlertRaiser.js
37 37 PlaySound(alertString, this.entity); 38 38 }; 39 39 40 AlertRaiser.prototype.UpdateUnits = function( )40 AlertRaiser.prototype.UpdateUnits = function(units) 41 41 { 42 // Find units owned by this unit's player43 var players = [];44 var cmpOwnership = Engine.QueryInterface(this.entity, IID_Ownership);45 if (cmpOwnership)46 players = [cmpOwnership.GetOwner()];47 48 // Select units to put under alert, ignoring domestic animals (NB : war dogs are not domestic)49 var rangeMan = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager);50 var level = this.GetLevel();51 var units = rangeMan.ExecuteQuery(this.entity, 0, this.template.Range, players, IID_UnitAI).filter( function(e){52 var cmpUnitAI = Engine.QueryInterface(e, IID_UnitAI);53 return (!cmpUnitAI.IsUnderAlert() && cmpUnitAI.ReactsToAlert(level) && !cmpUnitAI.IsDomestic());54 });55 56 42 for each (var unit in units) 57 43 { 58 44 var cmpUnitAI = Engine.QueryInterface(unit, IID_UnitAI); 45 if(!cmpUnitAI) 46 continue; 47 59 48 cmpUnitAI.ReplaceOrder("Alert", {"raiser": this.entity, "force": true}); 60 49 this.walkingUnits.push(unit); 61 50 } … … 69 58 this.level++; 70 59 this.SoundAlert(); 71 60 72 // Find buildings owned by this unit's player61 // Find buildings / units owned by this unit's player 73 62 var players = []; 74 63 var cmpOwnership = Engine.QueryInterface(this.entity, IID_Ownership); 75 64 if (cmpOwnership) … … 89 78 cmpProductionQueue.PutUnderAlert(this.entity); 90 79 this.prodBuildings.push(building); 91 80 } 81 82 // Select units to put under alert, ignoring domestic animals (NB : war dogs are not domestic) 83 var rangeMan = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager); 84 var level = this.GetLevel(); 85 var units = rangeMan.ExecuteQuery(this.entity, 0, this.template.Range, players, IID_UnitAI).filter( function(e){ 86 var cmpUnitAI = Engine.QueryInterface(e, IID_UnitAI); 87 return (!cmpUnitAI.IsUnderAlert() && cmpUnitAI.ReactsToAlert(level) && !cmpUnitAI.IsDomestic()); 88 }); 92 89 93 // Put units under alert 94 this.UpdateUnits(); 90 for each (var unit in units) 91 { 92 var cmpUnitAI = Engine.QueryInterface(unit, IID_UnitAI); 93 cmpUnitAI.ReplaceOrder("Alert", {"raiser": this.entity, "force": true}); 94 this.walkingUnits.push(unit); 95 } 95 96 96 97 return true; 97 98 }; … … 131 132 { 132 133 var cmpGarrisonHolder = Engine.QueryInterface(slot.holder, IID_GarrisonHolder); 133 134 var cmpUnitAI = Engine.QueryInterface(slot.unit, IID_UnitAI); 134 if (!cmpUnitAI || !cmpGarrisonHolder)135 if (!cmpUnitAI) 135 136 continue; 136 137 137 if(cmpGarrisonHolder && cmpGarrisonHolder.PerformEject([slot.unit], true)) 138 // If the garrison building was destroyed, the unit is already ejected 139 if (!cmpGarrisonHolder || cmpGarrisonHolder.PerformEject([slot.unit], true)) 138 140 { 139 141 cmpUnitAI.ResetAlert(); 140 142 if (cmpUnitAI.HasWorkOrders()) -
binaries/data/mods/public/simulation/components/ProductionQueue.js
609 609 { 610 610 var cmpAlertRaiser = Engine.QueryInterface(this.alertRaiser, IID_AlertRaiser); 611 611 if(cmpAlertRaiser) 612 cmpAlertRaiser.UpdateUnits( );612 cmpAlertRaiser.UpdateUnits(createdEnts); 613 613 } 614 614 } 615 615