Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/ai/petra/attackManager.js
Show First 20 Lines • Show All 174 Lines • ▼ Show 20 Lines | for (let ent of bombers.values()) | ||||
if (alreadyBombing) | if (alreadyBombing) | ||||
break; | break; | ||||
let range = ent.attackRange("Ranged").max; | let range = ent.attackRange("Ranged").max; | ||||
let entPos = ent.position(); | let entPos = ent.position(); | ||||
let access = PETRA.getLandAccess(gameState, ent); | let access = PETRA.getLandAccess(gameState, ent); | ||||
for (let struct of gameState.getEnemyStructures().values()) | for (let struct of gameState.getEnemyStructures().values()) | ||||
{ | { | ||||
if (!ent.canAttackTarget(struct, PETRA.allowCapture(gameState, ent, struct))) | if (!ent.canAttackTarget(struct, false, PETRA.ignoreAttackEffects(gameState, ent, struct))) | ||||
continue; | continue; | ||||
let structPos = struct.position(); | let structPos = struct.position(); | ||||
let x; | let x; | ||||
let z; | let z; | ||||
if (struct.hasClass("Field")) | if (struct.hasClass("Field")) | ||||
{ | { | ||||
if (!struct.resourceSupplyNumGatherers() || | if (!struct.resourceSupplyNumGatherers() || | ||||
Show All 28 Lines | for (let struct of gameState.getEnemyStructures().values()) | ||||
if (!attackingUnits) | if (!attackingUnits) | ||||
{ | { | ||||
attackingUnits = new Set(); | attackingUnits = new Set(); | ||||
this.bombingAttacks.set(struct.id(), attackingUnits); | this.bombingAttacks.set(struct.id(), attackingUnits); | ||||
} | } | ||||
attackingUnits.add(ent.id()); | attackingUnits.add(ent.id()); | ||||
if (dist > range) | if (dist > range) | ||||
ent.move(x, z); | ent.move(x, z); | ||||
ent.attack(struct.id(), false, dist > range); | ent.attack(struct.id(), { "Capture": true }, [], undefined, dist > range); | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
}; | }; | ||||
/** | /** | ||||
* Some functions are run every turn | * Some functions are run every turn | ||||
* Others once in a while | * Others once in a while | ||||
▲ Show 20 Lines • Show All 567 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator