1
0
forked from 0ad/0ad

trained animals in corral should not respond to alert, adresses #2792

This was SVN commit r15736.
This commit is contained in:
mimo 2014-09-12 22:01:21 +00:00
parent 134e3c84b0
commit dd6b6779af
2 changed files with 6 additions and 4 deletions

View File

@ -38,11 +38,12 @@ AlertRaiser.prototype.SoundAlert = function()
};
AlertRaiser.prototype.UpdateUnits = function(units)
{
{
var level = this.GetLevel();
for each (var unit in units)
{
var cmpUnitAI = Engine.QueryInterface(unit, IID_UnitAI);
if (!cmpUnitAI)
if (!cmpUnitAI || !cmpUnitAI.ReactsToAlert(level))
continue;
cmpUnitAI.ReplaceOrder("Alert", {"raiser": this.entity, "force": true});
this.walkingUnits.push(unit);
@ -78,12 +79,12 @@ AlertRaiser.prototype.IncreaseAlertLevel = function()
this.prodBuildings.push(building);
}
// Select units to put under alert, ignoring domestic animals (NB : war dogs are not domestic)
// Select units to put under alert, according to their reaction to this level
var rangeMan = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager);
var level = this.GetLevel();
var units = rangeMan.ExecuteQuery(this.entity, 0, this.template.Range, players, IID_UnitAI).filter( function(e){
var cmpUnitAI = Engine.QueryInterface(e, IID_UnitAI);
return (!cmpUnitAI.IsUnderAlert() && cmpUnitAI.ReactsToAlert(level) && !cmpUnitAI.IsDomestic());
return (!cmpUnitAI.IsUnderAlert() && cmpUnitAI.ReactsToAlert(level));
});
for each (var unit in units)

View File

@ -22,6 +22,7 @@
</Minimap>
<ResourceGatherer disable=""/>
<UnitAI>
<AlertReactiveLevel>99</AlertReactiveLevel>
<CanGuard>false</CanGuard>
<RoamDistance>8.0</RoamDistance>
<FleeDistance>24.0</FleeDistance>