Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/UnitAI.js
Show First 20 Lines • Show All 5,559 Lines • ▼ Show 20 Lines | UnitAI.prototype.Attack = function(target, allowCapture = true, queued = false, pushFront = false) | ||||
if (this.order && this.order.type == "Attack" && | if (this.order && this.order.type == "Attack" && | ||||
this.order.data && | this.order.data && | ||||
this.order.data.target === order.target && | this.order.data.target === order.target && | ||||
this.order.data.allowCapture === order.allowCapture) | this.order.data.allowCapture === order.allowCapture) | ||||
{ | { | ||||
this.order.data.lastPos = order.lastPos; | this.order.data.lastPos = order.lastPos; | ||||
this.order.data.force = order.force; | this.order.data.force = order.force; | ||||
if (order.force) | |||||
this.orderQueue = [this.order]; | |||||
return; | return; | ||||
} | } | ||||
this.AddOrder("Attack", order, queued, pushFront); | this.AddOrder("Attack", order, queued, pushFront); | ||||
}; | }; | ||||
/** | /** | ||||
* Adds garrison order to the queue, forced by the player. | * Adds garrison order to the queue, forced by the player. | ||||
▲ Show 20 Lines • Show All 69 Lines • ▼ Show 20 Lines | UnitAI.prototype.PerformGather = function(target, queued, force, pushFront = false) | ||||
if (this.order && | if (this.order && | ||||
(this.order.type == "Gather" || this.order.type == "Attack") && | (this.order.type == "Gather" || this.order.type == "Attack") && | ||||
this.order.data && | this.order.data && | ||||
this.order.data.target === order.target) | this.order.data.target === order.target) | ||||
{ | { | ||||
this.order.data.lastPos = order.lastPos; | this.order.data.lastPos = order.lastPos; | ||||
this.order.data.force = order.force; | this.order.data.force = order.force; | ||||
if (order.force) | |||||
this.orderQueue = [this.order]; | |||||
return; | return; | ||||
} | } | ||||
this.AddOrder("Gather", order, queued, pushFront); | this.AddOrder("Gather", order, queued, pushFront); | ||||
}; | }; | ||||
/** | /** | ||||
* Adds gather-near-position order to the queue, not forced, so it can be | * Adds gather-near-position order to the queue, not forced, so it can be | ||||
Show All 21 Lines | if (!this.CanHeal(target)) | ||||
return; | return; | ||||
} | } | ||||
if (this.order && this.order.type == "Heal" && | if (this.order && this.order.type == "Heal" && | ||||
this.order.data && | this.order.data && | ||||
this.order.data.target === target) | this.order.data.target === target) | ||||
{ | { | ||||
this.order.data.force = true; | this.order.data.force = true; | ||||
this.orderQueue = [this.order]; | |||||
return; | return; | ||||
} | } | ||||
this.AddOrder("Heal", { "target": target, "force": true }, queued, pushFront); | this.AddOrder("Heal", { "target": target, "force": true }, queued, pushFront); | ||||
}; | }; | ||||
/** | /** | ||||
* Adds return resource order to the queue, forced by the player. | * Adds return resource order to the queue, forced by the player. | ||||
▲ Show 20 Lines • Show All 207 Lines • ▼ Show 20 Lines | UnitAI.prototype.Repair = function(target, autocontinue, queued, pushFront) | ||||
} | } | ||||
if (this.order && this.order.type == "Repair" && | if (this.order && this.order.type == "Repair" && | ||||
this.order.data && | this.order.data && | ||||
this.order.data.target === target && | this.order.data.target === target && | ||||
this.order.data.autocontinue === autocontinue) | this.order.data.autocontinue === autocontinue) | ||||
{ | { | ||||
this.order.data.force = true; | this.order.data.force = true; | ||||
this.orderQueue = [this.order]; | |||||
return; | return; | ||||
} | } | ||||
this.AddOrder("Repair", { "target": target, "autocontinue": autocontinue, "force": true }, queued, pushFront); | this.AddOrder("Repair", { "target": target, "autocontinue": autocontinue, "force": true }, queued, pushFront); | ||||
}; | }; | ||||
/** | /** | ||||
* Adds flee order to the queue, not forced, so it can be | * Adds flee order to the queue, not forced, so it can be | ||||
▲ Show 20 Lines • Show All 715 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator