Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/UnitAI.js
Show First 20 Lines • Show All 4,540 Lines • ▼ Show 20 Lines | |||||
* Returns true if we should stop following the target entity. | * Returns true if we should stop following the target entity. | ||||
*/ | */ | ||||
UnitAI.prototype.ShouldAbandonChase = function(target, force, iid, type) | UnitAI.prototype.ShouldAbandonChase = function(target, force, iid, type) | ||||
{ | { | ||||
// Forced orders shouldn't be interrupted. | // Forced orders shouldn't be interrupted. | ||||
if (force) | if (force) | ||||
return false; | return false; | ||||
// Abandon chase when the target garrisons, for else we will keep on walking. | |||||
let cmpTargetUnitAI = Engine.QueryInterface(target, IID_UnitAI); | |||||
if (cmpTargetUnitAI && cmpTargetUnitAI.IsGarrisoned() && !cmpTargetUnitAI.IsTurret()) | |||||
return true; | |||||
// If we are guarding/escorting, don't abandon as long as the guarded unit is in target range of the attacker | // If we are guarding/escorting, don't abandon as long as the guarded unit is in target range of the attacker | ||||
if (this.isGuardOf) | if (this.isGuardOf) | ||||
{ | { | ||||
var cmpUnitAI = Engine.QueryInterface(target, IID_UnitAI); | var cmpUnitAI = Engine.QueryInterface(target, IID_UnitAI); | ||||
var cmpAttack = Engine.QueryInterface(target, IID_Attack); | var cmpAttack = Engine.QueryInterface(target, IID_Attack); | ||||
if (cmpUnitAI && cmpAttack && | if (cmpUnitAI && cmpAttack && | ||||
cmpAttack.GetAttackTypes().some(type => cmpUnitAI.CheckTargetAttackRange(this.isGuardOf, type))) | cmpAttack.GetAttackTypes().some(type => cmpUnitAI.CheckTargetAttackRange(this.isGuardOf, type))) | ||||
return false; | return false; | ||||
▲ Show 20 Lines • Show All 1,347 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator