Let auras and techs modify tech cost. Patch by fatherbushido. Fixes #3930

This was SVN commit r18233.
This commit is contained in:
sanderd17
2016-05-26 06:28:23 +00:00
parent 9c67cd6743
commit 1b0fbee2d9
50 changed files with 171 additions and 22 deletions
@@ -247,6 +247,13 @@ function GetTemplateDataHelper(template, player, auraTemplates)
ret.speed.run = func("UnitMotion/Run/Speed", +template.UnitMotion.Run.Speed, player, template);
}
if (template.ProductionQueue)
{
ret.techCostMultiplier = {};
for (let res in template.ProductionQueue.TechCostMultiplier)
ret.techCostMultiplier[res] = func("ProductionQueue/TechCostMultiplier/"+res, +template.ProductionQueue.TechCostMultiplier[res], player, template);
}
if (template.Trader)
{
ret.trader = {
@@ -804,6 +804,11 @@ g_SelectionPanels.Research = {
// abort if no template found for any of the techs
if (data.template.some(v => !v))
return false;
for (let template of data.template)
for (let res in template.cost)
template.cost[res] *= data.unitEntState.production.techCostMultiplier[res];
// index one row below
var shiftedIndex = data.i + data.rowLength;
data.positions = data.item.pair ? [data.i, shiftedIndex] : [shiftedIndex];
@@ -70,7 +70,10 @@ function draw()
{
for (let prod of stru.production.technology[prod_pha])
{
prod = (depath(prod).slice(0,5) == "phase") ? g_ParsedData.phases[prod] : g_ParsedData.techs[prod];
prod = clone(depath(prod).slice(0,5) == "phase" ? g_ParsedData.phases[prod] : g_ParsedData.techs[prod]);
for (let res in stru.techCostMultiplier)
if (prod.cost[res])
prod.cost[res] *= stru.techCostMultiplier[res];
if (!drawProdIcon(i, s, r, p, prod))
break;
p++;
@@ -133,7 +136,10 @@ function draw()
prod = g_ParsedData.units[prod];
break;
case "techs":
prod = g_ParsedData.techs[prod];
prod = clone(g_ParsedData.techs[prod]);
for (let res in trainer.techCostMultiplier)
if (prod.cost[res])
prod.cost[res] *= trainer.techCostMultiplier[res];
break;
default:
continue;
@@ -145,6 +145,10 @@ function loadStructure(templateName)
structure.armour = struct.armour;
structure.auras = struct.auras;
// For technology cost multiplier, we need to use the tower
struct = loadStructure(structure.wallSet.templates.tower);
structure.techCostMultiplier = struct.techCostMultiplier;
let health;
for (let wSegm in structure.wallSet.templates)
@@ -308,7 +308,8 @@ GuiInterface.prototype.GetEntityState = function(player, ent)
ret.production = {
"entities": cmpProductionQueue.GetEntitiesList(),
"technologies": cmpProductionQueue.GetTechnologiesList(),
"queue": cmpProductionQueue.GetQueue(),
"techCostMultiplier": cmpProductionQueue.GetTechCostMultiplier(),
"queue": cmpProductionQueue.GetQueue()
};
let cmpTrader = Engine.QueryInterface(ent, IID_Trader);
@@ -29,7 +29,16 @@ ProductionQueue.prototype.Schema =
"</attribute>" +
"<text/>" +
"</element>" +
"</optional>";
"</optional>" +
"<element name='TechCostMultiplier' a:help='Multiplier to modify ressources cost and research time of technologies searched in this building.'>" +
"<interleave>" +
"<element name='food'><ref name='nonNegativeDecimal'/></element>" +
"<element name='wood'><ref name='nonNegativeDecimal'/></element>" +
"<element name='stone'><ref name='nonNegativeDecimal'/></element>" +
"<element name='metal'><ref name='nonNegativeDecimal'/></element>" +
"<element name='time'><ref name='nonNegativeDecimal'/></element>" +
"</interleave>" +
"</element>";
ProductionQueue.prototype.Init = function()
{
@@ -216,6 +225,14 @@ ProductionQueue.prototype.GetTechnologiesList = function()
return ret;
};
ProductionQueue.prototype.GetTechCostMultiplier = function()
{
let techCostMultiplier = {}
for (let res in this.template.TechCostMultiplier)
techCostMultiplier[res] = ApplyValueModificationsToEntity("ProductionQueue/TechCostMultiplier/"+res, +this.template.TechCostMultiplier[res], this.entity);
return techCostMultiplier;
};
ProductionQueue.prototype.IsTechnologyResearchedOrInProgress = function(tech)
{
if (!tech)
@@ -321,12 +338,13 @@ ProductionQueue.prototype.AddBatch = function(templateName, type, count, metadat
if (!template)
return;
var cmpPlayer = QueryOwnerInterface(this.entity);
var time = template.researchTime * cmpPlayer.GetCheatTimeMultiplier();
let techCostMultiplier = this.GetTechCostMultiplier();
let time = techCostMultiplier.time * template.researchTime * cmpPlayer.GetCheatTimeMultiplier();
var cost = {};
for each (var r in ["food", "wood", "stone", "metal"])
cost[r] = Math.floor(template.cost[r]);
for (let res in template.cost)
cost[res] = Math.floor(techCostMultiplier[res] * template.cost[res]);
// TrySubtractResources should report error to player (they ran out of resources)
if (!cmpPlayer.TrySubtractResources(cost))
return;
@@ -0,0 +1,12 @@
{
"type": "global",
"affects": ["Structure"],
"modifications": [
{ "value": "ProductionQueue/TechCostMultiplier/wood", "multiply": 0.9 },
{ "value": "ProductionQueue/TechCostMultiplier/food", "multiply": 0.9 },
{ "value": "ProductionQueue/TechCostMultiplier/metal", "multiply": 0.9 },
{ "value": "ProductionQueue/TechCostMultiplier/stone", "multiply": 0.9 }
],
"auraDescription": "Reduces the cost of all remaining technologies by 10%.",
"auraName": "Library Aura"
}
@@ -0,0 +1,15 @@
{
"type": "global",
"affectedPlayers": ["MutualAlly"],
"affects": ["Temple"],
"modifications": [
{ "value": "ProductionQueue/TechCostMultiplier/wood", "multiply": 0.5 },
{ "value": "ProductionQueue/TechCostMultiplier/food", "multiply": 0.5 },
{ "value": "ProductionQueue/TechCostMultiplier/metal", "multiply": 0.5 },
{ "value": "ProductionQueue/TechCostMultiplier/stone", "multiply": 0.5 },
{ "value": "ProductionQueue/TechCostMultiplier/time", "multiply": 0.5 }
],
"auraDescription": "All player and allied Temple technologies -50% cost and -50% research time.",
"auraName": "Evangelism Aura",
"overlayIcon": "art/textures/ui/session/auras/build_bonus.png"
}
@@ -0,0 +1,10 @@
{
"type": "garrison",
"affects": ["Structure"],
"modifications": [
{ "value": "ProductionQueue/TechCostMultiplier/time", "multiply": 0.5 }
],
"auraDescription": "Empower a building with -50% research time.",
"auraName": "Teacher Aura",
"overlayIcon": "art/textures/ui/session/auras/build_bonus.png"
}
@@ -34,6 +34,7 @@
<Obstruction>
<Static width="1.5" depth="4.0"/>
</Obstruction>
<ProductionQueue disable=""/>
<StatusBars>
<HeightOffset>6.0</HeightOffset>
</StatusBars>
@@ -24,6 +24,7 @@
<Edge width="59" depth="4" x="0" z="5"/>
</Obstructions>
</Obstruction>
<ProductionQueue disable=""/>
<Selectable>
<EditorOnly/>
</Selectable>
@@ -23,6 +23,7 @@
<Edge width="59" depth="4" x="0" z="5"/>
</Obstructions>
</Obstruction>
<ProductionQueue disable=""/>
<Minimap disable=""/>
<Selectable>
<EditorOnly/>
@@ -32,6 +32,7 @@
<Obstruction>
<Static width="2.0" depth="2.0"/>
</Obstruction>
<ProductionQueue disable=""/>
<StatusBars>
<HeightOffset>8.0</HeightOffset>
</StatusBars>
@@ -31,6 +31,7 @@
<Obstruction>
<Static width="2.0" depth="12.0"/>
</Obstruction>
<ProductionQueue disable=""/>
<StatusBars>
<HeightOffset>6.0</HeightOffset>
</StatusBars>
@@ -32,6 +32,7 @@
<Obstruction>
<Static width="2.0" depth="2.0"/>
</Obstruction>
<ProductionQueue disable=""/>
<StatusBars>
<HeightOffset>6.0</HeightOffset>
</StatusBars>
@@ -35,6 +35,7 @@
<Obstruction>
<Static width="1.5" depth="13.0"/>
</Obstruction>
<ProductionQueue disable=""/>
<StatusBars>
<HeightOffset>6.0</HeightOffset>
</StatusBars>
@@ -35,6 +35,7 @@
<Obstruction>
<Static width="1.5" depth="6.5"/>
</Obstruction>
<ProductionQueue disable=""/>
<StatusBars>
<HeightOffset>6.0</HeightOffset>
</StatusBars>
@@ -32,6 +32,7 @@
<Obstruction>
<Static width="1.5" depth="10.5"/>
</Obstruction>
<ProductionQueue disable=""/>
<StatusBars>
<HeightOffset>6.0</HeightOffset>
</StatusBars>
@@ -38,6 +38,7 @@
<Obstruction>
<Static width="26.0" depth="30.0"/>
</Obstruction>
<ProductionQueue disable=""/>
<TerritoryInfluence>
<Root>false</Root>
<Radius>40</Radius>
@@ -38,6 +38,7 @@
<Obstruction>
<Static width="26.0" depth="10.5"/>
</Obstruction>
<ProductionQueue disable=""/>
<RallyPoint disable=""/>
<TerritoryInfluence>
<Root>false</Root>
@@ -33,6 +33,7 @@
<Obstruction>
<Static width="4.0" depth="4.0"/>
</Obstruction>
<ProductionQueue disable=""/>
<TerritoryDecay disable=""/>
<Vision>
<Range>12</Range>
@@ -32,6 +32,7 @@
<Obstruction>
<Static width="1.5" depth="1.5"/>
</Obstruction>
<ProductionQueue disable=""/>
<StatusBars>
<HeightOffset>8.0</HeightOffset>
</StatusBars>
@@ -34,6 +34,7 @@
<Obstruction>
<Static width="3.5" depth="4.75"/>
</Obstruction>
<ProductionQueue disable=""/>
<StatusBars>
<HeightOffset>6.0</HeightOffset>
</StatusBars>
@@ -34,6 +34,7 @@
<Obstruction>
<Static width="4.0" depth="4.0"/>
</Obstruction>
<ProductionQueue disable=""/>
<StatusBars>
<HeightOffset>6.0</HeightOffset>
</StatusBars>
@@ -31,6 +31,7 @@
<Obstruction>
<Static width="46.0" depth="46.0"/>
</Obstruction>
<ProductionQueue disable=""/>
<Sound>
<SoundGroups>
<select>interface/select/building/sel_greek_theater.xml</select>
@@ -28,6 +28,7 @@
<Obstruction>
<Static width="16.0" depth="16.0"/>
</Obstruction>
<ProductionQueue disable=""/>
<RallyPoint disable=""/>
<Sound>
<SoundGroups>
@@ -28,6 +28,7 @@
<Obstruction>
<Static width="16.0" depth="16.0"/>
</Obstruction>
<ProductionQueue disable=""/>
<RallyPoint disable=""/>
<Sound>
<SoundGroups>
@@ -35,6 +35,7 @@
<Obstruction>
<Static width="10.0" depth="10.0"/>
</Obstruction>
<ProductionQueue disable=""/>
<RallyPoint disable=""/>
<Sound>
<SoundGroups>
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Entity parent="template_structure_special">
<Auras datatype="tokens">library</Auras>
<BuildRestrictions>
<Category>Library</Category>
</BuildRestrictions>
@@ -15,7 +16,7 @@
<GenericName>Library</GenericName>
<SpecificName>Bibliothḗkē</SpecificName>
<Classes datatype="tokens">-ConquestCritical</Classes>
<Tooltip>Research special technologies and reduce the research time of all remaining technologies.</Tooltip>
<Tooltip>Research special technologies.</Tooltip>
<History>Alexander the Great founded libraries all over his new empire. These became centers of learning for an entirely new synthesized culture: the Hellenistic culture.</History>
<Icon>structures/library_scroll.png</Icon>
</Identity>
@@ -31,6 +31,7 @@
<Obstruction>
<Static width="46.0" depth="46.0"/>
</Obstruction>
<ProductionQueue disable=""/>
<Sound>
<SoundGroups>
<select>interface/select/building/sel_greek_theater.xml</select>
@@ -33,6 +33,7 @@
<Obstruction>
<Static width="4" depth="4"/>
</Obstruction>
<ProductionQueue disable=""/>
<RallyPoint disable=""/>
<Sound>
<SoundGroups>
@@ -35,6 +35,7 @@
<Door width="14" depth="13" x="0" z="0"/>
</Obstructions>
</Obstruction>
<ProductionQueue disable=""/>
<TerritoryInfluence>
<Root>true</Root>
</TerritoryInfluence>
@@ -30,6 +30,7 @@
<Obstruction>
<Static width="38.5" depth="22.5"/>
</Obstruction>
<ProductionQueue disable=""/>
<TerritoryInfluence>
<Root>true</Root>
<Radius>48</Radius>
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Entity parent="template_structure_special">
<Auras datatype="tokens">library</Auras>
<BuildRestrictions>
<Category>Library</Category>
</BuildRestrictions>
@@ -15,7 +16,7 @@
<GenericName>Library</GenericName>
<SpecificName>Bibliothḗkē</SpecificName>
<Classes datatype="tokens">-ConquestCritical</Classes>
<Tooltip>Research special technologies and reduce the research time of all remaining technologies.</Tooltip>
<Tooltip>Research special technologies.</Tooltip>
<History>Alexander the Great founded libraries all over his new empire. These became centers of learning for an entirely new synthesized culture: the Hellenistic culture.</History>
<Icon>structures/library_scroll.png</Icon>
</Identity>
@@ -28,6 +28,7 @@
<Position>
<Floating>true</Floating>
</Position>
<ProductionQueue disable=""/>
<Sound>
<SoundGroups>
<select>interface/select/building/sel_temple.xml</select>
@@ -47,4 +48,4 @@
<Actor>structures/ptolemies/lighthouse.xml</Actor>
<FoundationActor>structures/fndn_4x4_dock.xml</FoundationActor>
</VisualActor>
</Entity>
</Entity>
@@ -27,6 +27,7 @@
<Obstruction>
<Static width="18.0" depth="9.0"/>
</Obstruction>
<ProductionQueue disable=""/>
<RallyPoint disable=""/>
<Sound>
<SoundGroups>
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Entity parent="template_structure_special">
<Auras datatype="tokens">library</Auras>
<BuildRestrictions>
<Category>Library</Category>
</BuildRestrictions>
@@ -15,7 +16,7 @@
<GenericName>Library</GenericName>
<SpecificName>Bibliothikon</SpecificName>
<Classes datatype="tokens">-ConquestCritical</Classes>
<Tooltip>Research special technologies and reduce the research time of all remaining technologies.</Tooltip>
<Tooltip>Research special technologies.</Tooltip>
<History>Alexander the Great founded libraries all over his new empire. These became centers of learning for an entirely new synthesized culture: the Hellenistic culture.</History>
<Icon>structures/library_scroll.png</Icon>
</Identity>
@@ -31,6 +31,7 @@
<Obstruction>
<Static width="46.0" depth="46.0"/>
</Obstruction>
<ProductionQueue disable=""/>
<Sound>
<SoundGroups>
<select>interface/select/building/sel_greek_theater.xml</select>
@@ -31,6 +31,7 @@
<Obstruction>
<Static width="46.0" depth="46.0"/>
</Obstruction>
<ProductionQueue disable=""/>
<Sound>
<SoundGroups>
<select>interface/select/building/sel_theater.xml</select>
@@ -71,6 +71,15 @@
<DisableBlockPathfinding>false</DisableBlockPathfinding>
</Obstruction>
<OverlayRenderer/>
<ProductionQueue>
<TechCostMultiplier>
<food>1.0</food>
<wood>1.0</wood>
<stone>1.0</stone>
<metal>1.0</metal>
<time>1.0</time>
</TechCostMultiplier>
</ProductionQueue>
<RallyPoint/>
<RallyPointRenderer>
<MarkerTemplate>special/rallypoint</MarkerTemplate>
@@ -39,6 +39,7 @@
<Obstruction>
<Static width="6.0" depth="6.0"/>
</Obstruction>
<ProductionQueue disable=""/>
<RallyPoint disable=""/>
<Sound>
<SoundGroups>
@@ -45,6 +45,7 @@
<Door width="20.0" depth="6.5" x="0" z="0"/>
</Obstructions>
</Obstruction>
<ProductionQueue disable=""/>
<RallyPoint disable=""/>
<Sound>
<SoundGroups>
@@ -17,7 +17,7 @@
<Max>1</Max>
<EjectHealth>0.1</EjectHealth>
<EjectClassesOnDestroy datatype="tokens">Unit</EjectClassesOnDestroy>
<List datatype="tokens">Infantry</List>
<List datatype="tokens">Infantry Healer</List>
<BuffHeal>0</BuffHeal>
<LoadingRange>2</LoadingRange>
</GarrisonHolder>
@@ -45,6 +45,7 @@
<BlockMovement>false</BlockMovement>
<BlockPathfinding>false</BlockPathfinding>
</Obstruction>
<ProductionQueue disable=""/>
<RallyPoint disable=""/>
<ResourceSupply>
<KillBeforeGather>false</KillBeforeGather>
@@ -13,6 +13,13 @@
units/athen_infantry_marine_archer_b
units/athen_champion_marine
</Entities>
<TechCostMultiplier>
<food>1.0</food>
<wood>1.0</wood>
<stone>1.0</stone>
<metal>1.0</metal>
<time>1.0</time>
</TechCostMultiplier>
</ProductionQueue>
<VisualActor>
<Actor>structures/athenians/trireme.xml</Actor>
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Entity parent="template_unit_hero_cavalry_archer">
<Auras datatype="tokens">maur_hero_ashoka</Auras>
<Footprint replace="">
<Square width="6.0" depth="12.0"/>
<Height>5.0</Height>
@@ -5,13 +5,7 @@
<Pierce>8.0</Pierce>
<Crush>4.0</Crush>
</Armour>
<Heal>
<Range>20</Range>
<HP>12</HP>
<Rate>2000</Rate>
<UnhealableClasses datatype="tokens"/>
<HealableClasses datatype="tokens">Human</HealableClasses>
</Heal>
<Auras datatype="tokens">maur_hero_chanakya</Auras>
<Cost>
<Population>2</Population>
<BuildTime>60</BuildTime>
@@ -20,18 +14,24 @@
<metal>250</metal>
</Resources>
</Cost>
<Heal>
<Range>20</Range>
<HP>12</HP>
<Rate>2000</Rate>
<UnhealableClasses datatype="tokens"/>
<HealableClasses datatype="tokens">Human</HealableClasses>
</Heal>
<Health>
<Max>600</Max>
</Health>
<Identity>
<Civ>maur</Civ>
<Classes datatype="tokens">Human Organic</Classes>
<Classes datatype="tokens">Human Organic Support</Classes>
<VisibleClasses datatype="tokens">Hero Healer</VisibleClasses>
<GenericName>Acharya Chanakya</GenericName>
<SpecificName>Acharya Chāṇakya</SpecificName>
<Icon>units/maur_hero_chanakya.png</Icon>
<Tooltip>Hero Special: "Healer" - Heal units at an accelerated rate.
Hero Special: "Teacher" - Empower a building to research and train +50% faster.
Hero Special: "Philosopher" - Research 4 special technologies only available to Chanakya.</Tooltip>
<RequiredTechnology>phase_city</RequiredTechnology>
</Identity>
@@ -11,6 +11,13 @@
<Entities datatype="tokens">
units/maur_champion_maiden_archer
</Entities>
<TechCostMultiplier>
<food>1.0</food>
<wood>1.0</wood>
<stone>1.0</stone>
<metal>1.0</metal>
<time>1.0</time>
</TechCostMultiplier>
</ProductionQueue>
<VisualActor>
<Actor>units/mauryans/elephant_hero.xml</Actor>
@@ -13,6 +13,13 @@
<Entities datatype="tokens">
units/pers_champion_infantry
</Entities>
<TechCostMultiplier>
<food>1.0</food>
<wood>1.0</wood>
<stone>1.0</stone>
<metal>1.0</metal>
<time>1.0</time>
</TechCostMultiplier>
</ProductionQueue>
<VisualActor>
<Actor>units/persians/hero_cyrus.xml</Actor>
@@ -17,6 +17,13 @@
units/pers_cavalry_swordsman_b_trireme
units/pers_cavalry_javelinist_b_trireme
</Entities>
<TechCostMultiplier>
<food>1.0</food>
<wood>1.0</wood>
<stone>1.0</stone>
<metal>1.0</metal>
<time>1.0</time>
</TechCostMultiplier>
</ProductionQueue>
<VisualActor>
<Actor>structures/persians/trireme.xml</Actor>