Index: ps/trunk/binaries/data/mods/public/simulation/ai/common-api/entity.js =================================================================== --- ps/trunk/binaries/data/mods/public/simulation/ai/common-api/entity.js +++ ps/trunk/binaries/data/mods/public/simulation/ai/common-api/entity.js @@ -786,9 +786,10 @@ { if (!this.get("Attack/Capture")) return false; - if (!target) return true; + if (!target.get("Capturable")) + return false; let restrictedClasses = this.get("Attack/Capture/RestrictedClasses/_string"); return !restrictedClasses || !MatchesClassList(target.classes(), restrictedClasses); }, @@ -797,7 +798,7 @@ "canGuard": function() { return this.get("UnitAI/CanGuard") === "true"; }, - "canGarrison": function() { return this.get("Garrisonable") !== "false"; }, + "canGarrison": function() { return "Garrisonable" in this._template; }, move: function(x, z, queued = false) { Engine.PostCommand(PlayerID,{"type": "walk", "entities": [this.id()], "x": x, "z": z, "queued": queued }); Index: ps/trunk/binaries/data/mods/public/simulation/ai/common-api/shared.js =================================================================== --- ps/trunk/binaries/data/mods/public/simulation/ai/common-api/shared.js +++ ps/trunk/binaries/data/mods/public/simulation/ai/common-api/shared.js @@ -54,33 +54,6 @@ this.isDeserialized = true; }; -/** - * Components that will be disabled in foundation entity templates. - * (This is a bit yucky and fragile since it's the inverse of - * CCmpTemplateManager::CopyFoundationSubset and only includes components - * that our Template class currently uses.) - */ -m.g_FoundationForbiddenComponents = { - "ProductionQueue": 1, - "ResourceSupply": 1, - "ResourceDropsite": 1, - "GarrisonHolder": 1, - "Capturable": 1 -}; - -/** - * Components that will be disabled in resource entity templates. - * Roughly the inverse of CCmpTemplateManager::CopyResourceSubset. - */ -m.g_ResourceForbiddenComponents = { - "Cost": 1, - "Decay": 1, - "Health": 1, - "UnitAI": 1, - "UnitMotion": 1, - "Vision": 1 -}; - m.SharedScript.prototype.GetTemplate = function(name) { if (this._templates[name]) @@ -89,44 +62,11 @@ if (this._derivedTemplates[name]) return this._derivedTemplates[name]; - // If this is a foundation template, construct it automatically - if (name.indexOf("foundation|") !== -1) - { - let base = this.GetTemplate(name.substr(11)); - - let foundation = {}; - for (let key in base) - if (!m.g_FoundationForbiddenComponents[key]) - foundation[key] = base[key]; - - this._derivedTemplates[name] = foundation; - return foundation; - } - else if (name.indexOf("resource|") !== -1) + let template = Engine.GetTemplate(name); + if (template) { - let base = this.GetTemplate(name.substr(9)); - - let resource = {}; - for (let key in base) - if (!m.g_ResourceForbiddenComponents[key]) - resource[key] = base[key]; - - this._derivedTemplates[name] = resource; - return resource; - } - else if (name.indexOf("ungarrisonable|") !== -1) - { - let base = this.GetTemplate(name.substr(15)); - - let ent = {}; - for (let key in base) - if (key !== "Garrisonable") - ent[key] = base[key]; - else - ent[key] = "false"; - - this._derivedTemplates[name] = ent; - return ent; + this._derivedTemplates[name] = template; + return template; } error("Tried to retrieve invalid template '"+name+"'"); Index: ps/trunk/binaries/data/mods/public/simulation/ai/petra/baseManager.js =================================================================== --- ps/trunk/binaries/data/mods/public/simulation/ai/petra/baseManager.js +++ ps/trunk/binaries/data/mods/public/simulation/ai/petra/baseManager.js @@ -74,9 +74,9 @@ m.BaseManager.prototype.setAnchor = function(gameState, anchorEntity) { - if (!anchorEntity.hasClass("Structure") || !anchorEntity.hasTerritoryInfluence()) + if (!anchorEntity.hasClass("CivCentre")) { - warn("Error: Petra base " + this.ID + " has been assigned an anchor building that has no territorial influence."); + warn("Error: Petra base " + this.ID + " has been assigned an anchor that is not a civil centre."); return false; } this.anchor = anchorEntity; Index: ps/trunk/binaries/data/mods/public/simulation/ai/petra/headquarters.js =================================================================== --- ps/trunk/binaries/data/mods/public/simulation/ai/petra/headquarters.js +++ ps/trunk/binaries/data/mods/public/simulation/ai/petra/headquarters.js @@ -1139,7 +1139,7 @@ continue; if (this.basesMap.map[j] === 0) // only in our territory continue; - // with enough room around to build the cc + // with enough room around to build the market let i = this.territoryMap.getNonObstructedTile(j, radius, obstructions); if (i < 0) continue;