Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/ai/petra/defenseArmy.js
Show First 20 Lines • Show All 306 Lines • ▼ Show 20 Lines | PETRA.DefenseArmy.prototype.assignUnit = function(gameState, entID) | ||||
let idMinAll; | let idMinAll; | ||||
let distMinAll; | let distMinAll; | ||||
for (let id of this.foeEntities) | for (let id of this.foeEntities) | ||||
{ | { | ||||
let eEnt = gameState.getEntityById(id); | let eEnt = gameState.getEntityById(id); | ||||
if (!eEnt || !eEnt.position()) // probably can't happen. | if (!eEnt || !eEnt.position()) // probably can't happen. | ||||
continue; | continue; | ||||
if (!ent.canAttackTarget(eEnt, PETRA.allowCapture(gameState, ent, eEnt))) | |||||
continue; | |||||
if (eEnt.hasClass("Unit") && eEnt.unitAIOrderData() && eEnt.unitAIOrderData().length && | if (eEnt.hasClass("Unit") && eEnt.unitAIOrderData() && eEnt.unitAIOrderData().length && | ||||
eEnt.unitAIOrderData()[0].target && eEnt.unitAIOrderData()[0].target == entID) | eEnt.unitAIOrderData()[0].target && eEnt.unitAIOrderData()[0].target == entID) | ||||
{ // being attacked >>> target the unit | { // being attacked >>> target the unit | ||||
idMin = id; | idMin = id; | ||||
break; | break; | ||||
} | } | ||||
// already enough units against it | // already enough units against it | ||||
▲ Show 20 Lines • Show All 324 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator