Ticket #1841: idle.diff
File idle.diff, 1.9 KB (added by , 11 years ago) |
---|
-
binaries/data/mods/public/simulation/components/UnitAI.js
1108 1108 }, 1109 1109 1110 1110 "LosRangeUpdate": function(msg) { 1111 this.entitiesInLos = undefined; 1111 1112 if (this.GetStance().targetVisibleEnemies) 1112 1113 { 1113 1114 // Start attacking one of the newly-seen enemy (if any) 1114 this.AttackEntitiesByPreference(msg.data.added); 1115 var ok = this.AttackEntitiesByPreference(msg.data.added); 1116 // if !ok, the attacker is probably too far for our stance 1117 // but still we should keep an eye on him 1118 if (!ok && msg.data.added.length) 1119 { 1120 this.entitiesInLos = msg.data; 1121 if (!this.timer) 1122 this.StartTimer(1000); 1123 } 1115 1124 } 1116 1125 }, 1117 1126 1118 1127 "LosGaiaRangeUpdate": function(msg) { 1128 this.gaiaEntitiesInLos = undefined; 1119 1129 if (this.GetStance().targetVisibleEnemies) 1120 1130 { 1121 1131 // Start attacking one of the newly-seen enemy (if any) 1122 this.AttackGaiaEntitiesByPreference(msg.data.added); 1132 var ok = this.AttackGaiaEntitiesByPreference(msg.data.added); 1133 // if !ok, the attacker is probably too far for our stance 1134 // but still we should keep an eye on him 1135 if (!ok && msg.data.added.length) 1136 { 1137 this.gaiaEntitiesInLos = msg.data; 1138 if (!this.timer) 1139 this.StartTimer(1000); 1140 } 1123 1141 } 1124 1142 }, 1125 1143 … … 1133 1151 this.isIdle = true; 1134 1152 Engine.PostMessage(this.entity, MT_UnitIdleChanged, { "idle": this.isIdle }); 1135 1153 } 1154 // then check if the detected attackers have come nearer 1155 if (this.entitiesInLos) 1156 UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": this.entitiesInLos}); 1157 if (this.gaiaEntitiesInLos) 1158 UnitFsm.ProcessMessage(this, {"type": "LosGaiaRangeUpdate", "data": this.gaiaEntitiesInLos}); 1136 1159 }, 1137 1160 }, 1138 1161