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,793 Lines • ▼ Show 20 Lines | if (this.target && this.target.owner() !== this.targetPlayer) | ||||
this.target = undefined; | this.target = undefined; | ||||
} | } | ||||
if (this.target && this.target.owner() === 0 && this.targetPlayer !== 0) // this enemy has resigned | if (this.target && this.target.owner() === 0 && this.targetPlayer !== 0) // this enemy has resigned | ||||
this.target = undefined; | this.target = undefined; | ||||
if (!this.target || !gameState.getEntityById(this.target.id())) | if (!this.target || !gameState.getEntityById(this.target.id())) | ||||
{ | { | ||||
if (this.Config.debug > 1) | if (this.Config.debug > 1) | ||||
API3.warn("Seems like our target has been destroyed. Switching."); | API3.warn("Seems like our target for plan " + this.name + " has been destroyed or captured. Switching."); | ||||
this.target = this.getNearestTarget(gameState, this.position, true); | this.target = this.getNearestTarget(gameState, this.position, true); | ||||
if (!this.target) | if (!this.target) | ||||
{ | { | ||||
if (this.uniqueTargetId) | if (this.uniqueTargetId) | ||||
return false; | return false; | ||||
// Check if we could help any current attack | // Check if we could help any current attack | ||||
let attackManager = gameState.ai.HQ.attackManager; | let attackManager = gameState.ai.HQ.attackManager; | ||||
let accessIndex = gameState.ai.accessibility.getAccessValue(this.position); | let accessIndex = gameState.ai.accessibility.getAccessValue(this.position); | ||||
for (let attackType in attackManager.startedAttacks) | for (let attackType in attackManager.startedAttacks) | ||||
{ | { | ||||
for (let attack of attackManager.startedAttacks[attackType]) | for (let attack of attackManager.startedAttacks[attackType]) | ||||
{ | { | ||||
if (attack.name === this.name) | if (attack.name === this.name) | ||||
continue; | continue; | ||||
if (!attack.target || !gameState.getEntityById(attack.target.id())) | if (!attack.target || !gameState.getEntityById(attack.target.id()) || | ||||
!gameState.isPlayerEnemy(attack.target.owner())) | |||||
continue; | continue; | ||||
if (accessIndex !== gameState.ai.accessibility.getAccessValue(attack.targetPos)) | if (accessIndex !== gameState.ai.accessibility.getAccessValue(attack.targetPos)) | ||||
continue; | continue; | ||||
if (attack.target.owner() === 0 && attack.targetPlayer !== 0) // looks like it has resigned | if (attack.target.owner() === 0 && attack.targetPlayer !== 0) // looks like it has resigned | ||||
continue; | continue; | ||||
if (!gameState.isPlayerEnemy(attack.targetPlayer)) | if (!gameState.isPlayerEnemy(attack.targetPlayer)) | ||||
continue; | continue; | ||||
this.target = attack.target; | this.target = attack.target; | ||||
▲ Show 20 Lines • Show All 192 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator