Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/UnitAI.js
Show All 12 Lines | "<element name='DefaultStance'>" + | ||||
"</choice>" + | "</choice>" + | ||||
"</element>" + | "</element>" + | ||||
"<element name='FormationController'>" + | "<element name='FormationController'>" + | ||||
"<data type='boolean'/>" + | "<data type='boolean'/>" + | ||||
"</element>" + | "</element>" + | ||||
"<element name='FleeDistance'>" + | "<element name='FleeDistance'>" + | ||||
"<ref name='positiveDecimal'/>" + | "<ref name='positiveDecimal'/>" + | ||||
"</element>" + | "</element>" + | ||||
"<element name='CanGuard'>" + | |||||
"<data type='boolean'/>" + | |||||
"</element>" + | |||||
"<element name='CanPatrol'>" + | |||||
"<data type='boolean'/>" + | |||||
"</element>" + | |||||
"<optional>" + | "<optional>" + | ||||
"<interleave>" + | "<interleave>" + | ||||
"<element name='NaturalBehaviour' a:help='Behaviour of the unit in the absence of player commands (intended for animals)'>" + | "<element name='NaturalBehaviour' a:help='Behaviour of the unit in the absence of player commands (intended for animals)'>" + | ||||
"<choice>" + | "<choice>" + | ||||
"<value a:help='Will actively attack any unit it encounters, even if not threatened'>violent</value>" + | "<value a:help='Will actively attack any unit it encounters, even if not threatened'>violent</value>" + | ||||
"<value a:help='Will attack nearby units if it feels threatened (if they linger within LOS for too long)'>aggressive</value>" + | "<value a:help='Will attack nearby units if it feels threatened (if they linger within LOS for too long)'>aggressive</value>" + | ||||
"<value a:help='Will attack nearby units if attacked'>defensive</value>" + | "<value a:help='Will attack nearby units if attacked'>defensive</value>" + | ||||
"<value a:help='Will never attack units but will attempt to flee when attacked'>passive</value>" + | "<value a:help='Will never attack units but will attempt to flee when attacked'>passive</value>" + | ||||
▲ Show 20 Lines • Show All 4,945 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
// Formation controllers should always respond to commands | // Formation controllers should always respond to commands | ||||
// (then the individual units can make up their own minds) | // (then the individual units can make up their own minds) | ||||
if (this.IsFormationController()) | if (this.IsFormationController()) | ||||
return true; | return true; | ||||
// Do not let a unit already guarded to guard. This would work in principle, | // Do not let a unit already guarded to guard. This would work in principle, | ||||
// but would clutter the gui with too much buttons to take all cases into account | // but would clutter the gui with too much buttons to take all cases into account | ||||
var cmpGuard = Engine.QueryInterface(this.entity, IID_Guard); | let cmpGuard = Engine.QueryInterface(this.entity, IID_Guard); | ||||
if (cmpGuard && cmpGuard.GetEntities().length) | return cmpGuard && !cmpGuard.GetEntities().length; | ||||
return false; | |||||
return this.template.CanGuard == "true"; | |||||
}; | }; | ||||
UnitAI.prototype.CanPatrol = function() | UnitAI.prototype.CanPatrol = function() | ||||
{ | { | ||||
// Formation controllers should always respond to commands | // Formation controllers should always respond to commands | ||||
// (then the individual units can make up their own minds) | // (then the individual units can make up their own minds) | ||||
return this.IsFormationController() || this.template.CanPatrol == "true"; | let cmpPatrol = Engine.QueryInterface(this.entity, IID_Patrol); | ||||
return this.IsFormationController() || cmpPatrol; | |||||
}; | }; | ||||
/** | /** | ||||
* Adds walk order to queue, forced by the player. | * Adds walk order to queue, forced by the player. | ||||
*/ | */ | ||||
UnitAI.prototype.Walk = function(x, z, queued) | UnitAI.prototype.Walk = function(x, z, queued) | ||||
{ | { | ||||
if (this.expectedRoute && queued) | if (this.expectedRoute && queued) | ||||
▲ Show 20 Lines • Show All 1,077 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator