Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/ai/petra/headquarters.js
Show First 20 Lines • Show All 2,468 Lines • ▼ Show 20 Lines | PETRA.HQ.prototype.isNearInvadingArmy = function(pos) | ||||
return false; | return false; | ||||
}; | }; | ||||
PETRA.HQ.prototype.isUnderEnemyFire = function(gameState, pos, radius = 0) | PETRA.HQ.prototype.isUnderEnemyFire = function(gameState, pos, radius = 0) | ||||
{ | { | ||||
if (!this.turnCache.firingStructures) | if (!this.turnCache.firingStructures) | ||||
this.turnCache.firingStructures = gameState.updatingCollection("diplo-FiringStructures", API3.Filters.hasDefensiveFire(), gameState.getEnemyStructures()); | this.turnCache.firingStructures = gameState.updatingCollection("diplo-FiringStructures", API3.Filters.hasDefensiveFire(), gameState.getEnemyStructures()); | ||||
for (let ent of this.turnCache.firingStructures.values()) | for (let ent of this.turnCache.firingStructures.values()) | ||||
{ | { | ||||
let range = radius + ent.attackRange("Ranged").max; | let attackRange = ent.attackRange("Ranged"); | ||||
bb: attackRange might be a better name | |||||
if (API3.SquareVectorDistance(ent.position(), pos) < range*range) | let range = radius * radius + API3.SquaredParabolicRange(attackRange.max, attackRange.elevationBonus); | ||||
SilierAuthorUnsubmitted Done Inline Actionscould do radius*radius out of loop Silier: could do radius*radius out of loop | |||||
Done Inline Actionsissue Silier: issue | |||||
if (API3.SquareVectorDistance(ent.position(), pos) < range) | |||||
return true; | return true; | ||||
} | } | ||||
return false; | return false; | ||||
}; | }; | ||||
/** Compute the capture strength of all units attacking a capturable target */ | /** Compute the capture strength of all units attacking a capturable target */ | ||||
PETRA.HQ.prototype.updateCaptureStrength = function(gameState) | PETRA.HQ.prototype.updateCaptureStrength = function(gameState) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 410 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
attackRange might be a better name