Differential D1815 Diff 9584 ps/trunk/binaries/data/mods/public/simulation/ai/petra/defenseManager.js
Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/simulation/ai/petra/defenseManager.js
Show First 20 Lines • Show All 422 Lines • ▼ Show 20 Lines | PETRA.DefenseManager.prototype.assignDefenders = function(gameState) | ||||
let potentialDefenders = []; | let potentialDefenders = []; | ||||
gameState.getOwnUnits().forEach(function(ent) { | gameState.getOwnUnits().forEach(function(ent) { | ||||
if (!ent.position()) | if (!ent.position()) | ||||
return; | return; | ||||
if (ent.getMetadata(PlayerID, "plan") == -2 || ent.getMetadata(PlayerID, "plan") == -3) | if (ent.getMetadata(PlayerID, "plan") == -2 || ent.getMetadata(PlayerID, "plan") == -3) | ||||
return; | return; | ||||
if (ent.hasClass("Support") || ent.attackTypes() === undefined) | if (ent.hasClass("Support") || ent.attackTypes() === undefined) | ||||
return; | return; | ||||
if (ent.hasClass("Catapult")) | if (ent.hasClass("StoneThrower")) | ||||
return; | return; | ||||
if (ent.hasClass("FishingBoat") || ent.hasClass("Trader")) | if (ent.hasClass("FishingBoat") || ent.hasClass("Trader")) | ||||
return; | return; | ||||
if (ent.getMetadata(PlayerID, "transport") !== undefined || | if (ent.getMetadata(PlayerID, "transport") !== undefined || | ||||
ent.getMetadata(PlayerID, "transporter") !== undefined) | ent.getMetadata(PlayerID, "transporter") !== undefined) | ||||
return; | return; | ||||
if (gameState.ai.HQ.victoryManager.criticalEnts.has(ent.id())) | if (gameState.ai.HQ.victoryManager.criticalEnts.has(ent.id())) | ||||
return; | return; | ||||
▲ Show 20 Lines • Show All 204 Lines • ▼ Show 20 Lines | if (target.getMetadata(PlayerID, "PartOfArmy") !== undefined) | ||||
} | } | ||||
} | } | ||||
if (abort) | if (abort) | ||||
this.abortArmy(gameState, army); | this.abortArmy(gameState, army); | ||||
} | } | ||||
continue; | continue; | ||||
} | } | ||||
// try to garrison any attacked support unit if low healthlevel | // Try to garrison any attacked support unit if low health. | ||||
if (target.hasClass("Support") && target.healthLevel() < this.Config.garrisonHealthLevel.medium && | if (target.hasClass("Support") && target.healthLevel() < this.Config.garrisonHealthLevel.medium && | ||||
!target.getMetadata(PlayerID, "transport") && plan != -2 && plan != -3) | !target.getMetadata(PlayerID, "transport") && plan != -2 && plan != -3) | ||||
{ | { | ||||
this.garrisonAttackedUnit(gameState, target); | this.garrisonAttackedUnit(gameState, target); | ||||
continue; | continue; | ||||
} | } | ||||
// try to garrison any attacked catapult | // Try to garrison any attacked stone thrower. | ||||
if (target.hasClass("Catapult") && | if (target.hasClass("StoneThrower") && | ||||
!target.getMetadata(PlayerID, "transport") && plan != -2 && plan != -3) | !target.getMetadata(PlayerID, "transport") && plan != -2 && plan != -3) | ||||
{ | { | ||||
this.garrisonSiegeUnit(gameState, target); | this.garrisonSiegeUnit(gameState, target); | ||||
continue; | continue; | ||||
} | } | ||||
if (!attacker || !attacker.position()) | if (!attacker || !attacker.position()) | ||||
continue; | continue; | ||||
if (target.isGarrisonHolder() && target.getArrowMultiplier()) | if (target.isGarrisonHolder() && target.getArrowMultiplier()) | ||||
this.garrisonUnitsInside(gameState, target, { "attacker": attacker }); | this.garrisonUnitsInside(gameState, target, { "attacker": attacker }); | ||||
if (target.hasClass("Unit") && attacker.hasClass("Unit")) | if (target.hasClass("Unit") && attacker.hasClass("Unit")) | ||||
{ | { | ||||
// Consider if we should retaliate or continue our task | // Consider whether we should retaliate or continue our task. | ||||
if (target.hasClass("Support") || target.attackTypes() === undefined) | if (target.hasClass("Support") || target.attackTypes() === undefined) | ||||
continue; | continue; | ||||
let orderData = target.unitAIOrderData(); | let orderData = target.unitAIOrderData(); | ||||
let currentTarget = orderData && orderData.length && orderData[0].target ? | let currentTarget = orderData && orderData.length && orderData[0].target ? | ||||
gameState.getEntityById(orderData[0].target) : undefined; | gameState.getEntityById(orderData[0].target) : undefined; | ||||
if (currentTarget) | if (currentTarget) | ||||
{ | { | ||||
let unitAIState = target.unitAIState(); | let unitAIState = target.unitAIState(); | ||||
▲ Show 20 Lines • Show All 267 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator