Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/ai/petra/worker.js
Show First 20 Lines • Show All 171 Lines • ▼ Show 20 Lines | else if (unitAIState == "INDIVIDUAL.COMBAT.APPROACHING" && ent.unitAIOrderData().length && | ||||
ent.stopMoving(); | ent.stopMoving(); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
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) | ||||
{ | { | ||||
// 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 | ||||
// and UnitAI sent it fight back with allowCapture=true | // UnitAI sent it to fight back. Make sure the correct attack values are ignored. | ||||
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.ignoreAttackEffects(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 910 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator