Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/ai/petra/defenseArmy.js
Show First 20 Lines • Show All 308 Lines • ▼ Show 20 Lines | m.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)) | |||||
Silier: This here is ok, just question. In theory what would happen if no entity in army can hurt that… | |||||
Not Done Inline ActionsThen the foe is just fully ignored. Not sure if that is the desired behaviour. Freagarach: Then the foe is just fully ignored. Not sure if that is the desired behaviour. | |||||
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 327 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
This here is ok, just question. In theory what would happen if no entity in army can hurt that foe.
You should take a look into DefenseManager.js assignDefenders