Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/ai/petra/defenseArmy.js
var PETRA = function(m) | (function(m) | ||||
{ | { | ||||
/** Armies used by the defense manager. | /** Armies used by the defense manager. | ||||
* An army is a collection of own entities and enemy entities. | * An army is a collection of own entities and enemy entities. | ||||
* | * | ||||
* Types of armies: | * Types of armies: | ||||
* "default": army to counter an invading army | * "default": army to counter an invading army | ||||
* "capturing": army set to capture a gaia building or recover capture points to one of its own structures | * "capturing": army set to capture a gaia building or recover capture points to one of its own structures | ||||
▲ Show 20 Lines • Show All 154 Lines • ▼ Show 20 Lines | m.DefenseArmy.prototype.removeOwn = function(gameState, id, Entity) | ||||
// Remove from tranport plan if not yet on Board | // Remove from tranport plan if not yet on Board | ||||
if (ent.getMetadata(PlayerID, "transport") !== undefined) | if (ent.getMetadata(PlayerID, "transport") !== undefined) | ||||
{ | { | ||||
let plan = gameState.ai.HQ.navalManager.getPlan(ent.getMetadata(PlayerID, "transport")); | let plan = gameState.ai.HQ.navalManager.getPlan(ent.getMetadata(PlayerID, "transport")); | ||||
if (plan && plan.state == "boarding" && ent.position()) | if (plan && plan.state == "boarding" && ent.position()) | ||||
plan.removeUnit(gameState, ent); | plan.removeUnit(gameState, ent); | ||||
} | } | ||||
/* | /* | ||||
// TODO be sure that all units in the transport need the cancelation | // TODO be sure that all units in the transport need the cancelation | ||||
if (!ent.position()) // this unit must still be in a transport plan ... try to cancel it | if (!ent.position()) // this unit must still be in a transport plan ... try to cancel it | ||||
{ | { | ||||
let planID = ent.getMetadata(PlayerID, "transport"); | let planID = ent.getMetadata(PlayerID, "transport"); | ||||
// no plans must mean that the unit was in a ship which was destroyed, so do nothing | // no plans must mean that the unit was in a ship which was destroyed, so do nothing | ||||
if (planID) | if (planID) | ||||
{ | { | ||||
if (gameState.ai.Config.debug > 0) | if (gameState.ai.Config.debug > 0) | ||||
warn("ent from army still in transport plan: plan " + planID + " canceled"); | warn("ent from army still in transport plan: plan " + planID + " canceled"); | ||||
let plan = gameState.ai.HQ.navalManager.getPlan(planID); | let plan = gameState.ai.HQ.navalManager.getPlan(planID); | ||||
if (plan && !plan.canceled) | if (plan && !plan.canceled) | ||||
plan.cancelTransport(gameState); | plan.cancelTransport(gameState); | ||||
} | } | ||||
} | } | ||||
*/ | */ | ||||
return true; | return true; | ||||
}; | }; | ||||
/** | /** | ||||
* resets the army properly. | * resets the army properly. | ||||
* assumes we already cleared dead units. | * assumes we already cleared dead units. | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 446 Lines • ▼ Show 20 Lines | |||||
}; | }; | ||||
m.DefenseArmy.prototype.Deserialize = function(data) | m.DefenseArmy.prototype.Deserialize = function(data) | ||||
{ | { | ||||
for (let key in data) | for (let key in data) | ||||
this[key] = data[key]; | this[key] = data[key]; | ||||
}; | }; | ||||
return m; | }(PETRA)); | ||||
}(PETRA); |
Wildfire Games · Phabricator