Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/ai/petra/defenseArmy.js
Show First 20 Lines • Show All 351 Lines • ▼ Show 20 Lines | m.DefenseArmy.prototype.assignUnit = function(gameState, entID) | ||||
let ownIndex = m.getLandAccess(gameState, ent); | let ownIndex = m.getLandAccess(gameState, ent); | ||||
let foeEnt = gameState.getEntityById(idFoe); | let foeEnt = gameState.getEntityById(idFoe); | ||||
let foePosition = foeEnt.position(); | let foePosition = foeEnt.position(); | ||||
let foeIndex = gameState.ai.accessibility.getAccessValue(foePosition); | let foeIndex = gameState.ai.accessibility.getAccessValue(foePosition); | ||||
if (ownIndex == foeIndex || ent.hasClass("Ship")) | if (ownIndex == foeIndex || ent.hasClass("Ship")) | ||||
{ | { | ||||
this.assignedTo[entID] = idFoe; | this.assignedTo[entID] = idFoe; | ||||
this.assignedAgainst[idFoe].push(entID); | this.assignedAgainst[idFoe].push(entID); | ||||
ent.attack(idFoe, m.allowCapture(gameState, ent, foeEnt), queued); | ent.attack(idFoe, m.getPrefAttackTypes(gameState, ent, foeEnt), queued); | ||||
} | } | ||||
else | else | ||||
gameState.ai.HQ.navalManager.requireTransport(gameState, ent, ownIndex, foeIndex, foePosition); | gameState.ai.HQ.navalManager.requireTransport(gameState, ent, ownIndex, foeIndex, foePosition); | ||||
return true; | return true; | ||||
}; | }; | ||||
m.DefenseArmy.prototype.getType = function() | m.DefenseArmy.prototype.getType = function() | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 199 Lines • ▼ Show 20 Lines | for (let entId of this.ownEntities) | ||||
if (!ent) | if (!ent) | ||||
continue; | continue; | ||||
let orderData = ent.unitAIOrderData(); | let orderData = ent.unitAIOrderData(); | ||||
if (!orderData.length && !ent.getMetadata(PlayerID, "transport")) | if (!orderData.length && !ent.getMetadata(PlayerID, "transport")) | ||||
this.assignUnit(gameState, entId); | this.assignUnit(gameState, entId); | ||||
else if (orderData.length && orderData[0].target && orderData[0].attackType && orderData[0].attackType === "Capture") | else if (orderData.length && orderData[0].target && orderData[0].attackType && orderData[0].attackType === "Capture") | ||||
{ | { | ||||
let target = gameState.getEntityById(orderData[0].target); | let target = gameState.getEntityById(orderData[0].target); | ||||
if (target && !m.allowCapture(gameState, ent, target)) | if (target && m.getPrefAttackTypes(gameState, ent, target).indexOf("Capture") != -1) // TODO doesn't cover all cases | ||||
ent.attack(orderData[0].target, false); | ent.attack(orderData[0].target, ["!Capture"]); | ||||
} | } | ||||
} | } | ||||
if (this.type == "capturing") | if (this.type == "capturing") | ||||
{ | { | ||||
if (this.foeEntities.length && gameState.getEntityById(this.foeEntities[0])) | if (this.foeEntities.length && gameState.getEntityById(this.foeEntities[0])) | ||||
{ | { | ||||
// Check if we still still some capturePoints to recover | // Check if we still still some capturePoints to recover | ||||
▲ Show 20 Lines • Show All 66 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator