Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/ai/petra/victoryManager.js
Show First 20 Lines • Show All 656 Lines • ▼ Show 20 Lines | m.VictoryManager.prototype.captureGaiaRelic = function(gameState, relic) | ||||
let sumCapturePoints = relic.capturePoints().reduce((a, b) => a + b); | let sumCapturePoints = relic.capturePoints().reduce((a, b) => a + b); | ||||
let plans = this.targetedGaiaRelics.get(relic.id()); | let plans = this.targetedGaiaRelics.get(relic.id()); | ||||
for (let plan of plans) | for (let plan of plans) | ||||
{ | { | ||||
let attack = gameState.ai.HQ.attackManager.getPlan(plan); | let attack = gameState.ai.HQ.attackManager.getPlan(plan); | ||||
if (!attack) | if (!attack) | ||||
continue; | continue; | ||||
for (let ent of attack.unitCollection.values()) | for (let ent of attack.unitCollection.values()) | ||||
capture += ent.captureStrength() * m.getAttackBonus(ent, relic, "Capture"); | capture += ent.attackStrengths("Capture").Capture * m.getAttackBonus(ent, relic, "Capture"); | ||||
} | } | ||||
// No need to make a new attack if already enough units | // No need to make a new attack if already enough units | ||||
if (capture > sumCapturePoints / 50) | if (capture > sumCapturePoints / 50) | ||||
return; | return; | ||||
let relicPosition = relic.position(); | let relicPosition = relic.position(); | ||||
let access = m.getLandAccess(gameState, relic); | let access = m.getLandAccess(gameState, relic); | ||||
let units = gameState.getOwnUnits().filter(ent => { | let units = gameState.getOwnUnits().filter(ent => { | ||||
if (!ent.position() || !ent.canCapture(relic)) | if (!ent.position() || !ent.canCapture(relic)) | ||||
Show All 13 Lines | let units = gameState.getOwnUnits().filter(ent => { | ||||
} | } | ||||
if (m.getLandAccess(gameState, ent) != access) | if (m.getLandAccess(gameState, ent) != access) | ||||
return false; | return false; | ||||
return true; | return true; | ||||
}).filterNearest(relicPosition); | }).filterNearest(relicPosition); | ||||
let expedition = []; | let expedition = []; | ||||
for (let ent of units.values()) | for (let ent of units.values()) | ||||
{ | { | ||||
capture += ent.captureStrength() * m.getAttackBonus(ent, relic, "Capture"); | capture += ent.attackStrengths("Capture").Capture * m.getAttackBonus(ent, relic, "Capture"); | ||||
expedition.push(ent); | expedition.push(ent); | ||||
if (capture > sumCapturePoints / 25) | if (capture > sumCapturePoints / 25) | ||||
break; | break; | ||||
} | } | ||||
if (!expedition.length || !plans.length && capture < sumCapturePoints / 100) | if (!expedition.length || !plans.length && capture < sumCapturePoints / 100) | ||||
return; | return; | ||||
let attack = gameState.ai.HQ.attackManager.raidTargetEntity(gameState, relic); | let attack = gameState.ai.HQ.attackManager.raidTargetEntity(gameState, relic); | ||||
if (!attack) | if (!attack) | ||||
▲ Show 20 Lines • Show All 45 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator