Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/UnitAI.js
Show First 20 Lines • Show All 469 Lines • ▼ Show 20 Lines | "Order.Attack": function(msg) { | ||||
if (this.CanPack()) | if (this.CanPack()) | ||||
{ | { | ||||
this.PushOrderFront("Pack", { "force": true }); | this.PushOrderFront("Pack", { "force": true }); | ||||
return; | return; | ||||
} | } | ||||
// If we can't reach the target, but are standing ground, then abandon this attack order. | // If we can't reach the target, but are standing ground, then abandon this attack order. | ||||
// Unless we're hunting, that's a special case where we should continue attacking our target. | // Unless we're hunting, that's a special case where we should continue attacking our target. | ||||
if (this.GetStance().respondStandGround && !this.order.data.force && !this.order.data.hunting || this.IsTurret()) | if (this.GetStance().respondStandGround && !this.order.data.force && !this.order.data.hunting || this.IsTurret()) | ||||
temple: (Don't really like all these special cases, but whatever. Maybe they can't be avoided.) | |||||
mimoAuthorUnsubmitted Not Done Inline Actionsagree, but that's typically a post-a23 change. mimo: agree, but that's typically a post-a23 change. | |||||
{ | { | ||||
this.FinishOrder(); | this.FinishOrder(); | ||||
return; | return; | ||||
} | } | ||||
// Try to move within attack range | // Try to move within attack range | ||||
if (this.MoveToTargetAttackRange(this.order.data.target, this.order.data.attackType)) | if (this.MoveToTargetAttackRange(this.order.data.target, this.order.data.attackType)) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 95 Lines • ▼ Show 20 Lines | if (this.MustKillGatherTarget(this.order.data.target)) | ||||
else | else | ||||
{ | { | ||||
// We couldn't move there, or the target moved away | // We couldn't move there, or the target moved away | ||||
this.FinishOrder(); | this.FinishOrder(); | ||||
} | } | ||||
return; | return; | ||||
} | } | ||||
this.PushOrderFront("Attack", { "target": this.order.data.target, "force": false, "hunting": true, "allowCapture": false }); | this.PushOrderFront("Attack", { "target": this.order.data.target, "force": !!this.order.data.force, "hunting": true, "allowCapture": false }); | ||||
return; | return; | ||||
} | } | ||||
// Try to move within range | // Try to move within range | ||||
if (this.MoveToTargetRange(this.order.data.target, IID_ResourceGatherer)) | if (this.MoveToTargetRange(this.order.data.target, IID_ResourceGatherer)) | ||||
{ | { | ||||
// We've started walking to the given point | // We've started walking to the given point | ||||
this.SetNextState("INDIVIDUAL.GATHER.APPROACHING"); | this.SetNextState("INDIVIDUAL.GATHER.APPROACHING"); | ||||
▲ Show 20 Lines • Show All 295 Lines • ▼ Show 20 Lines | "Order.Gather": function(msg) { | ||||
else | else | ||||
{ | { | ||||
// We couldn't move there, or the target moved away | // We couldn't move there, or the target moved away | ||||
this.FinishOrder(); | this.FinishOrder(); | ||||
} | } | ||||
return; | return; | ||||
} | } | ||||
this.PushOrderFront("Attack", { "target": msg.data.target, "hunting": true, "allowCapture": false }); | this.PushOrderFront("Attack", { "target": msg.data.target, "force": !!msg.data.force, "hunting": true, "allowCapture": false }); | ||||
return; | return; | ||||
} | } | ||||
// TODO: on what should we base this range? | // TODO: on what should we base this range? | ||||
// Check if we are already in range, otherwise walk there | // Check if we are already in range, otherwise walk there | ||||
if (!this.CheckTargetRangeExplicit(msg.data.target, 0, 10)) | if (!this.CheckTargetRangeExplicit(msg.data.target, 0, 10)) | ||||
{ | { | ||||
if (!this.CanGather(msg.data.target) || !this.CheckTargetVisible(msg.data.target)) | if (!this.CanGather(msg.data.target) || !this.CheckTargetVisible(msg.data.target)) | ||||
▲ Show 20 Lines • Show All 5,049 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
(Don't really like all these special cases, but whatever. Maybe they can't be avoided.)