Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/ai/petra/attackPlan.js
Show First 20 Lines • Show All 1,520 Lines • ▼ Show 20 Lines | for (let check = 0; check < lgth; check++) | ||||
if (!maybeUpdate) | if (!maybeUpdate) | ||||
continue; | continue; | ||||
let deltat = ent.unitAIState() === "INDIVIDUAL.COMBAT.APPROACHING" ? 10 : 5; | let deltat = ent.unitAIState() === "INDIVIDUAL.COMBAT.APPROACHING" ? 10 : 5; | ||||
let lastAttackPlanUpdateTime = ent.getMetadata(PlayerID, "lastAttackPlanUpdateTime"); | let lastAttackPlanUpdateTime = ent.getMetadata(PlayerID, "lastAttackPlanUpdateTime"); | ||||
if (lastAttackPlanUpdateTime && time - lastAttackPlanUpdateTime < deltat) | if (lastAttackPlanUpdateTime && time - lastAttackPlanUpdateTime < deltat) | ||||
continue; | continue; | ||||
} | } | ||||
ent.setMetadata(PlayerID, "lastAttackPlanUpdateTime", time); | ent.setMetadata(PlayerID, "lastAttackPlanUpdateTime", time); | ||||
let range = 60; | let range = 3600; | ||||
let attackTypes = ent.attackTypes(); | let attackTypes = ent.attackTypes(); | ||||
if (this.isBlocked) | if (this.isBlocked) | ||||
{ | { | ||||
if (attackTypes && attackTypes.indexOf("Ranged") !== -1) | if (attackTypes && attackTypes.indexOf("Ranged") !== -1) | ||||
range = ent.attackRange("Ranged").max; | { | ||||
let attackRange = ent.attackRange("Ranged"); | |||||
range = API3.SquaredParabolicRange(attackRange.max, attackRange.elevationBonus); | |||||
} | |||||
else if (attackTypes && attackTypes.indexOf("Melee") !== -1) | else if (attackTypes && attackTypes.indexOf("Melee") !== -1) | ||||
range = ent.attackRange("Melee").max; | { | ||||
let attackRange = ent.attackRange("Melee"); | |||||
range = attackRange.max * attackRange.max; | |||||
} | |||||
else | else | ||||
range = 10; | range = 10000; | ||||
Silier: ouch | |||||
} | } | ||||
else if (attackTypes && attackTypes.indexOf("Ranged") !== -1) | else if (attackTypes && attackTypes.indexOf("Ranged") !== -1) | ||||
range = 30 + ent.attackRange("Ranged").max; | { | ||||
let attackRange = ent.attackRange("Ranged"); | |||||
range = 900 + API3.SquaredParabolicRange(attackRange.max, attackRange.elevationBonus); | |||||
Done Inline Actionsissue Silier: issue | |||||
} | |||||
else if (ent.hasClass("FastMoving")) | else if (ent.hasClass("FastMoving")) | ||||
range += 30; | range += 900; | ||||
range *= range; | |||||
Done Inline Actionsrange = 8100 Silier: range = 8100 | |||||
let entAccess = PETRA.getLandAccess(gameState, ent); | let entAccess = PETRA.getLandAccess(gameState, ent); | ||||
// Checking for gates if we're a siege unit. | // Checking for gates if we're a siege unit. | ||||
if (siegeUnit) | if (siegeUnit) | ||||
{ | { | ||||
let mStruct = enemyStructures.filter(enemy => { | let mStruct = enemyStructures.filter(enemy => { | ||||
if (!enemy.position() || !ent.canAttackTarget(enemy, PETRA.allowCapture(gameState, ent, enemy))) | if (!enemy.position() || !ent.canAttackTarget(enemy, PETRA.allowCapture(gameState, ent, enemy))) | ||||
return false; | return false; | ||||
if (API3.SquareVectorDistance(enemy.position(), ent.position()) > range) | if (API3.SquareVectorDistance(enemy.position(), ent.position()) > range) | ||||
▲ Show 20 Lines • Show All 621 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
ouch