Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/ai/petra/entityExtend.js
var PETRA = function(m) | (function(m) | ||||
{ | { | ||||
/** returns true if this unit should be considered as a siege unit */ | /** returns true if this unit should be considered as a siege unit */ | ||||
m.isSiegeUnit = function(ent) | m.isSiegeUnit = function(ent) | ||||
{ | { | ||||
return ent.hasClass("Siege") || ent.hasClass("Elephant") && ent.hasClass("Melee") && ent.hasClass("Champion"); | return ent.hasClass("Siege") || ent.hasClass("Elephant") && ent.hasClass("Melee") && ent.hasClass("Champion"); | ||||
}; | }; | ||||
▲ Show 20 Lines • Show All 310 Lines • ▼ Show 20 Lines | m.getBestBase = function(gameState, ent, onlyConstructedBase = false, exclude = false) | ||||
if (!bestbase && !ent.hasClass("Structure")) | if (!bestbase && !ent.hasClass("Structure")) | ||||
bestbase = gameState.ai.HQ.baseManagers[0]; | bestbase = gameState.ai.HQ.baseManagers[0]; | ||||
return bestbase; | return bestbase; | ||||
}; | }; | ||||
m.getHolder = function(gameState, ent) | m.getHolder = function(gameState, ent) | ||||
{ | { | ||||
for (let holder of gameState.getEntities().values()) | for (let holder of gameState.getEntities().values()) | ||||
{ | |||||
if (holder.isGarrisonHolder() && holder.garrisoned().indexOf(ent.id()) !== -1) | if (holder.isGarrisonHolder() && holder.garrisoned().indexOf(ent.id()) !== -1) | ||||
return holder; | return holder; | ||||
} | |||||
return undefined; | return undefined; | ||||
}; | }; | ||||
/** return the template of the built foundation if a foundation, otherwise return the entity itself */ | /** return the template of the built foundation if a foundation, otherwise return the entity itself */ | ||||
m.getBuiltEntity = function(gameState, ent) | m.getBuiltEntity = function(gameState, ent) | ||||
{ | { | ||||
if (ent.foundationProgress() !== undefined) | if (ent.foundationProgress() !== undefined) | ||||
return gameState.getBuiltTemplate(ent.templateName()); | return gameState.getBuiltTemplate(ent.templateName()); | ||||
▲ Show 20 Lines • Show All 92 Lines • ▼ Show 20 Lines | API3.warn(" garrisoning " + ent.getMetadata(PlayerID, "garrisoning") + | ||||
" garrisonHolder " + ent.getMetadata(PlayerID, "garrisonHolder") + | " garrisonHolder " + ent.getMetadata(PlayerID, "garrisonHolder") + | ||||
" plan " + ent.getMetadata(PlayerID, "plan") + " transport " + ent.getMetadata(PlayerID, "transport")); | " plan " + ent.getMetadata(PlayerID, "plan") + " transport " + ent.getMetadata(PlayerID, "transport")); | ||||
API3.warn(" stance " + ent.getStance() + " transporter " + ent.getMetadata(PlayerID, "transporter") + | API3.warn(" stance " + ent.getStance() + " transporter " + ent.getMetadata(PlayerID, "transporter") + | ||||
" gather-type " + ent.getMetadata(PlayerID, "gather-type") + | " gather-type " + ent.getMetadata(PlayerID, "gather-type") + | ||||
" target-foundation " + ent.getMetadata(PlayerID, "target-foundation") + | " target-foundation " + ent.getMetadata(PlayerID, "target-foundation") + | ||||
" PartOfArmy " + ent.getMetadata(PlayerID, "PartOfArmy")); | " PartOfArmy " + ent.getMetadata(PlayerID, "PartOfArmy")); | ||||
}; | }; | ||||
return m; | }(PETRA)); | ||||
}(PETRA); |
Wildfire Games · Phabricator