diff --git a/binaries/data/mods/public/globalscripts/Templates.js b/binaries/data/mods/public/globalscripts/Templates.js
index db54ca469..19832ba94 100644
a
|
b
|
function GetTemplateDataHelper(template, player, auraTemplates, resources)
|
312 | 312 | ret.speed.run = getEntityValue("UnitMotion/Run/Speed"); |
313 | 313 | } |
314 | 314 | |
| 315 | if (template.Upgrade) |
| 316 | { |
| 317 | ret.upgrades = []; |
| 318 | for (let upKey in template.Upgrade) |
| 319 | { |
| 320 | let upgrade = { |
| 321 | "name": upKey, |
| 322 | "entity": template.Upgrade[upKey].Entity, |
| 323 | "tooltip": template.Upgrade[upKey].Tooltip, |
| 324 | "cost": {}, |
| 325 | }; |
| 326 | |
| 327 | for (let res in template.Upgrade[upKey].Cost) |
| 328 | upgrade.cost[res] = getEntityValue("Upgrade/" + upKey + "/Cost/" + res); |
| 329 | |
| 330 | if (template.Upgrade[upKey].Time) |
| 331 | upgrade.cost.time = getEntityValue("Upgrade/" + upKey + "/Time"); |
| 332 | |
| 333 | if (template.Upgrade[upKey].Icon) |
| 334 | upgrade.icon = template.Upgrade[upKey].Icon; |
| 335 | |
| 336 | if (template.RequiredTechnology) |
| 337 | upgrade.requiredTechnology = template.RequiredTechnology; |
| 338 | |
| 339 | ret.upgrades.push(upgrade); |
| 340 | } |
| 341 | } |
| 342 | |
315 | 343 | if (template.ProductionQueue) |
316 | 344 | { |
317 | 345 | ret.techCostMultiplier = {}; |
diff --git a/binaries/data/mods/public/gui/structree/draw.js b/binaries/data/mods/public/gui/structree/draw.js
index 44be50783..91a96e0f7 100644
a
|
b
|
function draw()
|
83 | 83 | prod = g_ParsedData.units[prod]; |
84 | 84 | if (!drawProdIcon(i, s, r, p, prod)) |
85 | 85 | break; |
86 | | p++; |
| 86 | ++p; |
| 87 | } |
| 88 | |
| 89 | if (stru.upgrades[prod_pha]) |
| 90 | for (let upgrade of stru.upgrades[prod_pha]) |
| 91 | { |
| 92 | if (!drawProdIcon(i, s, r, p, upgrade.data)) |
| 93 | break; |
| 94 | ++p; |
87 | 95 | } |
88 | 96 | |
89 | 97 | if (stru.wallset && prod_pha == pha) |
90 | | for (let prod of [stru.wallset.gate, stru.wallset.tower]) |
| 98 | for (let prod of [stru.wallset.tower]) |
91 | 99 | { |
92 | 100 | if (!drawProdIcon(i, s, r, p, prod)) |
93 | 101 | break; |
94 | | p++; |
| 102 | ++p; |
95 | 103 | } |
96 | 104 | |
97 | 105 | if (stru.production.technology[prod_pha]) |
… |
… |
function draw()
|
173 | 181 | thisEle.hidden = false; |
174 | 182 | |
175 | 183 | let p = 0; |
176 | | for (let prodType in trainer.production) |
177 | | { |
178 | | for (let prod of trainer.production[prodType]) |
| 184 | if (trainer.production) |
| 185 | for (let prodType in trainer.production) |
179 | 186 | { |
180 | | switch (prodType) |
| 187 | for (let prod of trainer.production[prodType]) |
181 | 188 | { |
182 | | case "units": |
183 | | prod = g_ParsedData.units[prod]; |
184 | | break; |
185 | | case "techs": |
186 | | prod = clone(g_ParsedData.techs[civCode][prod]); |
187 | | for (let res in trainer.techCostMultiplier) |
188 | | if (prod.cost[res]) |
189 | | prod.cost[res] *= trainer.techCostMultiplier[res]; |
190 | | break; |
191 | | default: |
192 | | continue; |
| 189 | switch (prodType) |
| 190 | { |
| 191 | case "units": |
| 192 | prod = g_ParsedData.units[prod]; |
| 193 | break; |
| 194 | case "techs": |
| 195 | prod = clone(g_ParsedData.techs[civCode][prod]); |
| 196 | for (let res in trainer.techCostMultiplier) |
| 197 | if (prod.cost[res]) |
| 198 | prod.cost[res] *= trainer.techCostMultiplier[res]; |
| 199 | break; |
| 200 | default: |
| 201 | continue; |
| 202 | } |
| 203 | if (!drawProdIcon(null, t, null, p, prod)) |
| 204 | break; |
| 205 | ++p; |
193 | 206 | } |
194 | | if (!drawProdIcon(null, t, null, p, prod)) |
| 207 | } |
| 208 | if (trainer.upgrades) |
| 209 | for (let upgrade of trainer.upgrades) |
| 210 | { |
| 211 | if (!drawProdIcon(null, t, null, p, upgrade.data)) |
195 | 212 | break; |
196 | 213 | ++p; |
197 | 214 | } |
198 | | } |
199 | 215 | hideRemaining("trainer["+t+"]_row", p); |
200 | 216 | |
201 | 217 | let size = thisEle.size; |
diff --git a/binaries/data/mods/public/gui/structree/helper.js b/binaries/data/mods/public/gui/structree/helper.js
index da01b79e1..f5f68afea 100644
a
|
b
|
function loadAuraData(templateName)
|
49 | 49 | } |
50 | 50 | |
51 | 51 | /** |
| 52 | * Function is used to move attribute values from an Upgrade component |
| 53 | * entry to its designated entity data object, overriding current values. |
| 54 | */ |
| 55 | function transferUpgradeData(from, to) |
| 56 | { |
| 57 | to.cost = from.cost; |
| 58 | to.icon = from.icon || to.icon; |
| 59 | to.tooltip = from.tooltip || to.tooltip; |
| 60 | to.requiredTechnology = from.requiredTechnology || to.requiredTechnology; |
| 61 | return to; |
| 62 | } |
| 63 | |
| 64 | /** |
52 | 65 | * This is needed because getEntityCostTooltip in tooltip.js needs to get |
53 | 66 | * the template data of the different wallSet pieces. In the session this |
54 | 67 | * function does some caching, but here we do that in loadTemplate already. |
diff --git a/binaries/data/mods/public/gui/structree/load.js b/binaries/data/mods/public/gui/structree/load.js
index 2d6b58b77..6b041eb15 100644
a
|
b
|
function loadUnit(templateName)
|
40 | 40 | g_Lists.structures.push(build); |
41 | 41 | } |
42 | 42 | |
| 43 | if (unit.upgrades) |
| 44 | for (let idx in unit.upgrades) |
| 45 | { |
| 46 | unit.upgrades[idx].entity = unit.upgrades[idx].entity.replace("{civ}", g_SelectedCiv); |
| 47 | |
| 48 | let data = loadUnit(unit.upgrades[idx].entity); |
| 49 | data = transferUpgradeData(unit.upgrades[idx], data); |
| 50 | unit.upgrades[idx].data = data; |
| 51 | } |
| 52 | |
43 | 53 | return unit; |
44 | 54 | } |
45 | 55 | |
… |
… |
function loadStructure(templateName)
|
73 | 83 | } |
74 | 84 | } |
75 | 85 | |
| 86 | if (structure.upgrades) |
| 87 | for (let idx in structure.upgrades) |
| 88 | { |
| 89 | structure.upgrades[idx].entity = structure.upgrades[idx].entity.replace("{civ}", g_SelectedCiv); |
| 90 | |
| 91 | let data = loadStructure(structure.upgrades[idx].entity); |
| 92 | data = transferUpgradeData(structure.upgrades[idx], data); |
| 93 | structure.upgrades[idx].data = data; |
| 94 | } |
| 95 | |
76 | 96 | if (structure.wallSet) |
77 | 97 | { |
78 | 98 | structure.wallset = {}; |
79 | 99 | |
| 100 | if (!structure.upgrades) |
| 101 | structure.upgrades = []; |
| 102 | |
80 | 103 | // Note: Assume wall segments of all lengths have the same armor and auras |
81 | 104 | let struct = loadStructure(structure.wallSet.templates.long); |
82 | 105 | structure.armour = struct.armour; |
… |
… |
function loadStructure(templateName)
|
96 | 119 | for (let research of wPart.production.technology) |
97 | 120 | structure.production.technology.push(research); |
98 | 121 | |
| 122 | if (wPart.upgrades) |
| 123 | structure.upgrades = structure.upgrades.concat(wPart.upgrades); |
| 124 | |
99 | 125 | if (["gate", "tower"].indexOf(wSegm) != -1) |
100 | 126 | continue; |
101 | 127 | |
diff --git a/binaries/data/mods/public/gui/structree/structree.js b/binaries/data/mods/public/gui/structree/structree.js
index 20f20fdcb..8e65d09a3 100644
a
|
b
|
function selectCiv(civCode)
|
171 | 171 | } |
172 | 172 | } |
173 | 173 | |
174 | | // Group production lists of structures by phase |
| 174 | // Group production and upgrade lists of structures by phase |
175 | 175 | for (let structCode of g_Lists.structures) |
176 | 176 | { |
177 | 177 | let structInfo = g_ParsedData.structures[structCode]; |
… |
… |
function selectCiv(civCode)
|
232 | 232 | "technology": newProdTech, |
233 | 233 | "units": newProdUnits |
234 | 234 | }; |
| 235 | |
| 236 | // Sort upgrades by phase |
| 237 | let newUpgrades = {}; |
| 238 | if (structInfo.upgrades) |
| 239 | for (let upgrade of structInfo.upgrades) |
| 240 | { |
| 241 | let phase = GetPhaseOfTemplate(upgrade.data); |
| 242 | |
| 243 | if (g_ParsedData.phaseList.indexOf(phase) < structPhaseIdx) |
| 244 | phase = structInfo.phase; |
| 245 | |
| 246 | if (!newUpgrades[phase]) |
| 247 | newUpgrades[phase] = []; |
| 248 | newUpgrades[phase].push(upgrade); |
| 249 | } |
| 250 | g_ParsedData.structures[structCode].upgrades = newUpgrades; |
235 | 251 | } |
236 | 252 | |
237 | 253 | // Determine the buildList for the civ (grouped by phase) |
… |
… |
function selectCiv(civCode)
|
244 | 260 | let phase = g_ParsedData.structures[structCode].phase; |
245 | 261 | buildList[phase].push(structCode); |
246 | 262 | } |
| 263 | |
247 | 264 | for (let unitCode of g_Lists.units) |
248 | | if (g_ParsedData.units[unitCode] && g_ParsedData.units[unitCode].production) |
| 265 | if (g_ParsedData.units[unitCode] && (g_ParsedData.units[unitCode].production || g_ParsedData.units[unitCode].upgrades)) |
249 | 266 | trainerList.push(unitCode); |
250 | 267 | |
251 | 268 | g_CivData[g_SelectedCiv].buildList = buildList; |
diff --git a/binaries/data/mods/public/simulation/templates/template_structure_defense_wall_gate.xml b/binaries/data/mods/public/simulation/templates/template_structure_defense_wall_gate.xml
index 60de615b3..d66e26df7 100644
a
|
b
|
|
1 | 1 | <?xml version="1.0" encoding="utf-8"?> |
2 | 2 | <Entity parent="template_structure_defense_wall_long"> |
3 | 3 | <Auras disable=""/> |
| 4 | <Cost> |
| 5 | <Resources> |
| 6 | <stone>0</stone> |
| 7 | </Resources> |
| 8 | </Cost> |
4 | 9 | <GarrisonHolder disable=""/> |
5 | 10 | <Gate> |
6 | 11 | <PassRange>20</PassRange> |