Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/ai/petra/entityExtend.js
Show First 20 Lines • Show All 162 Lines • ▼ Show 20 Lines | if (!target.isCapturable() || !ent.canCapture(target)) | ||||
return false; | return false; | ||||
if (target.isInvulnerable()) | if (target.isInvulnerable()) | ||||
return true; | return true; | ||||
// always try to recapture capture points from an allied, except if it's decaying | // always try to recapture capture points from an allied, except if it's decaying | ||||
if (gameState.isPlayerAlly(target.owner())) | if (gameState.isPlayerAlly(target.owner())) | ||||
return !target.decaying(); | return !target.decaying(); | ||||
let antiCapture = target.defaultRegenRate(); | let antiCapture = target.defaultRegenRate(); | ||||
if (target.isGarrisonHolder() && target.garrisoned()) | if (target.isGarrisonHolder()) | ||||
antiCapture += target.garrisonRegenRate() * target.garrisoned().length; | for (const garrisonedEntity of target.garrisoned()) | ||||
antiCapture += target.garrisonRegenRate() * (gameState.getEntityById(garrisonedEntity)?.captureStrength() || 0); | |||||
Silier: Uh, potentially getentitybyid might fail and return invalid entity, maybe we should guard… | |||||
Done Inline ActionsI check for the presence now, but I guess we should warn (loudly) if some entity is not in the knowledge of the AI? Freagarach: I check for the presence now, but I guess we should warn (loudly) if some entity is not in the… | |||||
if (target.decaying()) | if (target.decaying()) | ||||
antiCapture -= target.territoryDecayRate(); | antiCapture -= target.territoryDecayRate(); | ||||
let capture; | let capture; | ||||
let capturableTargets = gameState.ai.HQ.capturableTargets; | let capturableTargets = gameState.ai.HQ.capturableTargets; | ||||
if (!capturableTargets.has(target.id())) | if (!capturableTargets.has(target.id())) | ||||
{ | { | ||||
capture = ent.captureStrength() * PETRA.getAttackBonus(ent, target, "Capture"); | capture = ent.captureStrength() * PETRA.getAttackBonus(ent, target, "Capture"); | ||||
▲ Show 20 Lines • Show All 255 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
Uh, potentially getentitybyid might fail and return invalid entity, maybe we should guard against that