Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/ai/petra/worker.js
Show First 20 Lines • Show All 174 Lines • ▼ Show 20 Lines | if (unitAIStateOrder == "COMBAT") | ||||
} | } | ||||
else if (unitAIState == "INDIVIDUAL.COMBAT.ATTACKING" && ent.unitAIOrderData().length && | else if (unitAIState == "INDIVIDUAL.COMBAT.ATTACKING" && ent.unitAIOrderData().length && | ||||
!ent.getMetadata(PlayerID, "PartOfArmy")) | !ent.getMetadata(PlayerID, "PartOfArmy")) | ||||
{ | { | ||||
let orderData = ent.unitAIOrderData()[0]; | let orderData = ent.unitAIOrderData()[0]; | ||||
if (orderData && orderData.target && orderData.attackType && orderData.attackType == "Capture") | if (orderData && orderData.target && orderData.attackType && orderData.attackType == "Capture") | ||||
{ | { | ||||
// If we are here, an enemy structure must have targeted one of our workers | // If we are here, an enemy structure must have targeted one of our workers | ||||
// and UnitAI sent it fight back with allowCapture=true | // and UnitAI sent it fight back with prefAttackForms === undefined | ||||
let target = gameState.getEntityById(orderData.target); | let target = gameState.getEntityById(orderData.target); | ||||
if (target && target.owner() > 0 && !gameState.isPlayerAlly(target.owner())) | if (target && target.owner() > 0 && !gameState.isPlayerAlly(target.owner())) | ||||
ent.attack(orderData.target, PETRA.allowCapture(gameState, ent, target)); | ent.attack(orderData.target, PETRA.getPrefAttackForms(gameState, ent, target)); | ||||
} | } | ||||
} | } | ||||
return; | return; | ||||
} | } | ||||
// Okay so we have a few tasks. | // Okay so we have a few tasks. | ||||
// If we're gathering, we'll check that we haven't run idle. | // If we're gathering, we'll check that we haven't run idle. | ||||
// And we'll also check that we're gathering a resource we want to gather. | // And we'll also check that we're gathering a resource we want to gather. | ||||
▲ Show 20 Lines • Show All 913 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator