Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
Show First 20 Lines • Show All 1,148 Lines • ▼ Show 20 Lines | if (this.targetPos && (this.overseas || this.path)) | ||||
{ | { | ||||
if (!this.path[0][0] || !this.path[0][1]) | if (!this.path[0][0] || !this.path[0][1]) | ||||
{ | { | ||||
if (this.Config.debug > 1) | if (this.Config.debug > 1) | ||||
API3.warn("StartAttack: Problem with path " + uneval(this.path)); | API3.warn("StartAttack: Problem with path " + uneval(this.path)); | ||||
return false; | return false; | ||||
} | } | ||||
this.state = "walking"; | this.state = "walking"; | ||||
this.unitCollection.move(this.path[0][0], this.path[0][1]); | this.unitCollection.moveToRange(this.path[0][0], this.path[0][1], 0, 15); | ||||
} | } | ||||
else | else | ||||
{ | { | ||||
this.state = "transporting"; | this.state = "transporting"; | ||||
let startIndex = gameState.ai.accessibility.getAccessValue(this.rallyPoint); | let startIndex = gameState.ai.accessibility.getAccessValue(this.rallyPoint); | ||||
let endIndex = gameState.ai.accessibility.getAccessValue(this.targetPos); | let endIndex = gameState.ai.accessibility.getAccessValue(this.targetPos); | ||||
let endPos = this.targetPos; | let endPos = this.targetPos; | ||||
// TODO require a global transport for the collection, | // TODO require a global transport for the collection, | ||||
▲ Show 20 Lines • Show All 581 Lines • ▼ Show 20 Lines | if (this.Config.debug > 1) | ||||
API3.warn("Attack Plan " + this.type + " " + this.name + " has arrived to destination."); | API3.warn("Attack Plan " + this.type + " " + this.name + " has arrived to destination."); | ||||
this.state = "arrived"; | this.state = "arrived"; | ||||
return true; | return true; | ||||
} | } | ||||
else if (this.path.length && API3.SquareVectorDistance(this.position, this.path[0]) < 1600) | else if (this.path.length && API3.SquareVectorDistance(this.position, this.path[0]) < 1600) | ||||
{ | { | ||||
this.path.shift(); | this.path.shift(); | ||||
if (this.path.length) | if (this.path.length) | ||||
this.unitCollection.move(this.path[0][0], this.path[0][1]); | this.unitCollection.moveToRange(this.path[0][0], this.path[0][1], 0, 15); | ||||
else | else | ||||
{ | { | ||||
if (this.Config.debug > 1) | if (this.Config.debug > 1) | ||||
API3.warn("Attack Plan " + this.type + " " + this.name + " has arrived to destination."); | API3.warn("Attack Plan " + this.type + " " + this.name + " has arrived to destination."); | ||||
this.state = "arrived"; | this.state = "arrived"; | ||||
return true; | return true; | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 96 Lines • ▼ Show 20 Lines | if (this.unitCollection.hasEntities()) | ||||
// If the attack was started, and we are on the same land as the rallyPoint, go back there | // If the attack was started, and we are on the same land as the rallyPoint, go back there | ||||
let rallyPoint = this.rallyPoint; | let rallyPoint = this.rallyPoint; | ||||
let withdrawal = this.isStarted() && !this.overseas; | let withdrawal = this.isStarted() && !this.overseas; | ||||
for (let ent of this.unitCollection.values()) | for (let ent of this.unitCollection.values()) | ||||
{ | { | ||||
if (ent.getMetadata(PlayerID, "role") === "attack") | if (ent.getMetadata(PlayerID, "role") === "attack") | ||||
ent.stopMoving(); | ent.stopMoving(); | ||||
if (withdrawal) | if (withdrawal) | ||||
ent.move(rallyPoint[0], rallyPoint[1]); | ent.moveToRange(rallyPoint[0], rallyPoint[1], 0, 15); | ||||
this.removeUnit(ent); | this.removeUnit(ent); | ||||
} | } | ||||
} | } | ||||
for (let unitCat in this.unitStat) | for (let unitCat in this.unitStat) | ||||
this.unit[unitCat].unregister(); | this.unit[unitCat].unregister(); | ||||
gameState.ai.queueManager.removeQueue("plan_" + this.name); | gameState.ai.queueManager.removeQueue("plan_" + this.name); | ||||
▲ Show 20 Lines • Show All 142 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator