Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/UnitAI.js
Show First 20 Lines • Show All 1,925 Lines • ▼ Show 20 Lines | "COMBAT": { | ||||
// Check the target is still alive and attackable | // Check the target is still alive and attackable | ||||
if (!this.CanAttack(target)) | if (!this.CanAttack(target)) | ||||
{ | { | ||||
this.SetNextState("COMBAT.FINDINGNEWTARGET"); | this.SetNextState("COMBAT.FINDINGNEWTARGET"); | ||||
return; | return; | ||||
} | } | ||||
// Check we can still reach the target for this attack. | |||||
if (!this.CheckTargetAttackRange(target, this.order.data.attackType)) | |||||
{ | |||||
// Can't reach it - try to chase after it. | |||||
if (this.ShouldChaseTargetedEntity(target, this.order.data.force)) | |||||
{ | |||||
if (this.CanPack()) | |||||
{ | |||||
this.PushOrderFront("Pack", { "force": true }); | |||||
return; | |||||
} | |||||
this.SetNextState("COMBAT.CHASING"); | |||||
return; | |||||
} | |||||
this.SetNextState("COMBAT.FINDINGNEWTARGET"); | |||||
return; | |||||
} | |||||
this.RememberTargetPosition(); | this.RememberTargetPosition(); | ||||
if (this.order.data.hunting && this.orderQueue.length > 1 && this.orderQueue[1].type === "Gather") | if (this.order.data.hunting && this.orderQueue.length > 1 && this.orderQueue[1].type === "Gather") | ||||
this.RememberTargetPosition(this.orderQueue[1].data); | this.RememberTargetPosition(this.orderQueue[1].data); | ||||
let cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer); | let cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer); | ||||
this.lastAttacked = cmpTimer.GetTime() - msg.lateness; | this.lastAttacked = cmpTimer.GetTime() - msg.lateness; | ||||
this.FaceTowardsTarget(target); | this.FaceTowardsTarget(target); | ||||
▲ Show 20 Lines • Show All 4,094 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator