Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/simulation/ai/common-api/entity.js
Show First 20 Lines • Show All 780 Lines • ▼ Show 20 Lines | m.Entity = m.Class({ | ||||
/** | /** | ||||
* returns true if the entity can capture the given target entity | * returns true if the entity can capture the given target entity | ||||
* if no target is given, returns true if the entity has the Capture attack | * if no target is given, returns true if the entity has the Capture attack | ||||
*/ | */ | ||||
"canCapture": function(target) | "canCapture": function(target) | ||||
{ | { | ||||
if (!this.get("Attack/Capture")) | if (!this.get("Attack/Capture")) | ||||
return false; | return false; | ||||
if (!target) | if (!target) | ||||
return true; | return true; | ||||
if (!target.get("Capturable")) | |||||
return false; | |||||
let restrictedClasses = this.get("Attack/Capture/RestrictedClasses/_string"); | let restrictedClasses = this.get("Attack/Capture/RestrictedClasses/_string"); | ||||
return !restrictedClasses || !MatchesClassList(target.classes(), restrictedClasses); | return !restrictedClasses || !MatchesClassList(target.classes(), restrictedClasses); | ||||
}, | }, | ||||
"isCapturable": function() { return this.get("Capturable") !== undefined; }, | "isCapturable": function() { return this.get("Capturable") !== undefined; }, | ||||
"canGuard": function() { return this.get("UnitAI/CanGuard") === "true"; }, | "canGuard": function() { return this.get("UnitAI/CanGuard") === "true"; }, | ||||
"canGarrison": function() { return this.get("Garrisonable") !== "false"; }, | "canGarrison": function() { return "Garrisonable" in this._template; }, | ||||
move: function(x, z, queued = false) { | move: function(x, z, queued = false) { | ||||
Engine.PostCommand(PlayerID,{"type": "walk", "entities": [this.id()], "x": x, "z": z, "queued": queued }); | Engine.PostCommand(PlayerID,{"type": "walk", "entities": [this.id()], "x": x, "z": z, "queued": queued }); | ||||
return this; | return this; | ||||
}, | }, | ||||
moveToRange: function(x, z, min, max, queued = false) { | moveToRange: function(x, z, min, max, queued = false) { | ||||
Engine.PostCommand(PlayerID,{"type": "walk-to-range", "entities": [this.id()], "x": x, "z": z, "min": min, "max": max, "queued": queued }); | Engine.PostCommand(PlayerID,{"type": "walk-to-range", "entities": [this.id()], "x": x, "z": z, "min": min, "max": max, "queued": queued }); | ||||
▲ Show 20 Lines • Show All 195 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator