Differential D2150 Diff 17818 ps/trunk/binaries/data/mods/public/simulation/ai/petra/attackManager.js
Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/simulation/ai/petra/attackManager.js
Show First 20 Lines • Show All 145 Lines • ▼ Show 20 Lines | else | ||||
} | } | ||||
unitIds.delete(entId); | unitIds.delete(entId); | ||||
} | } | ||||
if (!unitIds.size) | if (!unitIds.size) | ||||
this.bombingAttacks.delete(targetId); | this.bombingAttacks.delete(targetId); | ||||
} | } | ||||
} | } | ||||
let bombers = gameState.updatingCollection("bombers", API3.Filters.byClassesOr(["BoltShooter", "StoneThrower"]), gameState.getOwnUnits()); | const bombers = gameState.updatingCollection("bombers", API3.Filters.byClasses(["BoltShooter", "StoneThrower"]), gameState.getOwnUnits()); | ||||
for (let ent of bombers.values()) | for (let ent of bombers.values()) | ||||
{ | { | ||||
if (!ent.position() || !ent.isIdle() || !ent.attackRange("Ranged")) | if (!ent.position() || !ent.isIdle() || !ent.attackRange("Ranged")) | ||||
continue; | continue; | ||||
if (ent.getMetadata(PlayerID, "plan") == -2 || ent.getMetadata(PlayerID, "plan") == -3) | if (ent.getMetadata(PlayerID, "plan") == -2 || ent.getMetadata(PlayerID, "plan") == -3) | ||||
continue; | continue; | ||||
if (ent.getMetadata(PlayerID, "plan") !== undefined && ent.getMetadata(PlayerID, "plan") != -1) | if (ent.getMetadata(PlayerID, "plan") !== undefined && ent.getMetadata(PlayerID, "plan") != -1) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 307 Lines • ▼ Show 20 Lines | if (attack.type == "Rush") | ||||
for (let i = 1; i < gameState.sharedScript.playersData.length; ++i) | for (let i = 1; i < gameState.sharedScript.playersData.length; ++i) | ||||
{ | { | ||||
if (!gameState.isPlayerEnemy(i) || veto[i]) | if (!gameState.isPlayerEnemy(i) || veto[i]) | ||||
continue; | continue; | ||||
if (this.defeated[i]) | if (this.defeated[i]) | ||||
continue; | continue; | ||||
let enemyDefense = 0; | let enemyDefense = 0; | ||||
for (let ent of gameState.getEnemyStructures(i).values()) | for (let ent of gameState.getEnemyStructures(i).values()) | ||||
if (ent.hasClass("Tower") || ent.hasClass("WallTower") || ent.hasClass("Fortress")) | if (ent.hasClasses(["Tower", "WallTower", "Fortress"])) | ||||
enemyDefense++; | enemyDefense++; | ||||
if (enemyDefense > 6) | if (enemyDefense > 6) | ||||
veto[i] = true; | veto[i] = true; | ||||
} | } | ||||
} | } | ||||
// then if not a huge attack, continue attacking our previous target as long as it has some entities, | // then if not a huge attack, continue attacking our previous target as long as it has some entities, | ||||
// otherwise target the most accessible one | // otherwise target the most accessible one | ||||
▲ Show 20 Lines • Show All 317 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator