Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/ai/petra/defenseManager.js
Show First 20 Lines • Show All 150 Lines • ▼ Show 20 Lines | m.DefenseManager.prototype.isDangerous = function(gameState, entity) | ||||
} | } | ||||
let ccEnts = gameState.updatingGlobalCollection("allCCs", API3.Filters.byClass("CivCentre")); | let ccEnts = gameState.updatingGlobalCollection("allCCs", API3.Filters.byClass("CivCentre")); | ||||
for (let cc of ccEnts.values()) | for (let cc of ccEnts.values()) | ||||
{ | { | ||||
if (!gameState.isEntityExclusiveAlly(cc) || cc.foundationProgress() == 0) | if (!gameState.isEntityExclusiveAlly(cc) || cc.foundationProgress() == 0) | ||||
continue; | continue; | ||||
let cooperation = this.GetCooperationLevel(cc.owner()); | let cooperation = this.GetCooperationLevel(cc.owner()); | ||||
if (cooperation < 0.6 && cc.foundationProgress() !== undefined) | |||||
continue; | |||||
if (cooperation < 0.3) | if (cooperation < 0.3) | ||||
continue; | continue; | ||||
if (cooperation < 0.6 && cc.foundationProgress() !== undefined) | |||||
Stan: !!cc.foundationProgress() ?
Maybe merge the two with a || operator ? | |||||
continue; | |||||
if (API3.SquareVectorDistance(cc.position(), entity.position()) < dist2Min) | if (API3.SquareVectorDistance(cc.position(), entity.position()) < dist2Min) | ||||
return true; | return true; | ||||
} | } | ||||
for (let building of gameState.getOwnStructures().values()) | for (let building of gameState.getOwnStructures().values()) | ||||
{ | { | ||||
if (building.foundationProgress() == 0 || | if (building.foundationProgress() == 0 || | ||||
API3.SquareVectorDistance(building.position(), entity.position()) > dist2Min) | API3.SquareVectorDistance(building.position(), entity.position()) > dist2Min) | ||||
▲ Show 20 Lines • Show All 111 Lines • ▼ Show 20 Lines | |||||
m.DefenseManager.prototype.checkEnemyArmies = function(gameState) | m.DefenseManager.prototype.checkEnemyArmies = function(gameState) | ||||
{ | { | ||||
for (let i = 0; i < this.armies.length; ++i) | for (let i = 0; i < this.armies.length; ++i) | ||||
{ | { | ||||
let army = this.armies[i]; | let army = this.armies[i]; | ||||
// this returns a list of IDs: the units that broke away from the army for being too far. | // this returns a list of IDs: the units that broke away from the army for being too far. | ||||
let breakaways = army.update(gameState); | let breakaways = army.update(gameState); | ||||
for (let breaker of breakaways) | for (let breaker of breakaways) | ||||
this.makeIntoArmy(gameState, breaker); // assume dangerosity | this.makeIntoArmy(gameState, breaker); // assume dangerosity | ||||
StanUnsubmitted Not Done Inline ActionsCaps for comments. Stan: Caps for comments. | |||||
Not Done Inline Actions+'.' wraitii: +'.' | |||||
if (army.getState() == 0) | if (army.getState() == 0) | ||||
{ | { | ||||
if (army.getType() == "default") | if (army.getType() == "default") | ||||
this.switchToAttack(gameState, army); | this.switchToAttack(gameState, army); | ||||
army.clear(gameState); | army.clear(gameState); | ||||
this.armies.splice(i--, 1); | this.armies.splice(i--, 1); | ||||
continue; | |||||
} | } | ||||
} | } | ||||
// Check if we can't merge it with another | // Check if we can't merge it with another | ||||
for (let i = 0; i < this.armies.length - 1; ++i) | for (let i = 0; i < this.armies.length - 1; ++i) | ||||
{ | { | ||||
let army = this.armies[i]; | let army = this.armies[i]; | ||||
if (army.getType() != "default") | if (army.getType() != "default") | ||||
continue; | continue; | ||||
▲ Show 20 Lines • Show All 651 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
!!cc.foundationProgress() ?
Maybe merge the two with a || operator ?