Ticket #3522: 3522.6.diff

File 3522.6.diff, 20.0 KB (added by fatherbushido, 8 years ago)
  • binaries/data/mods/public/simulation/components/Auras.js

    Auras.prototype.Init = function()  
    7676        this.affectedPlayers[name] = []; // will be calculated on ownership change
    7777        var aura = {};
    7878        aura.affects = this.template[name].Affects;
    7979        if (this.template[name].AffectedPlayers)
    8080            aura.affectedPlayers = this.template[name].AffectedPlayers.split(/\s+/);
    81         aura.modifications = [];
    82         for (var value in this.template[name].Modifications)
    83         {
    84             var mod = {};
    85             mod.value = value.replace(/\./g, "/").replace(/\/\//g, ".");
    86             if (this.template[name].Modifications[value].Add)
    87                 mod.add = +this.template[name].Modifications[value].Add;
    88             else if (this.template[name].Modifications[value].Multiply)
    89                 mod.multiply = +this.template[name].Modifications[value].Multiply;
    90             aura.modifications.push(mod);
    91         }
    9281        this.auras[name] = aura;
    9382    }
    9483};
    9584
     85Auras.prototype.GetModifierIdentifier = function(name, mod)
     86{
     87        return this.templateName + "/" + name + "/" + mod.value;
     88};
     89
    9690Auras.prototype.GetDescriptions = function()
    9791{
    9892    var ret = {};
    9993    for each (var aura in this.template)
    10094        if (aura.AuraName)
    Auras.prototype.Clean = function()  
    236230
    237231        if (this[name].rangeQuery)
    238232            cmpRangeManager.DestroyActiveQuery(this[name].rangeQuery);
    239233    }
    240234
     235    for (let name in this.template)
     236    {
     237        let modifications = [];
     238        for (let value in this.template[name].Modifications)
     239        {
     240            let mod = {};
     241            mod.value = value.replace(/\./g, "/").replace(/\/\//g, ".");
     242            let templateModifications = this.template[name].Modifications[value];
     243            if (templateModifications.Add)
     244                mod.add = ApplyValueModificationsToEntity("Auras/"+name+"/Modifications/"+mod.value+"/Add", +templateModifications.Add, this.entity);
     245            else if (templateModifications.Multiply)
     246                mod.multiply = ApplyValueModificationsToEntity("Auras/"+name+"/Modifications/"+mod.value+"/Multiply", +templateModifications.Multiply, this.entity);
     247            modifications.push(mod);
     248        }
     249        this.auras[name].modifications = modifications;
     250    }
     251
    241252    for (let name of auraNames)
    242253    {
    243254        // only calculate the affected players on re-applying the bonuses
    244255        // this makes sure the template bonuses are removed from the correct players
    245256        this.CalculateAffectedPlayers(name);
    Auras.prototype.ApplyTemplateBonus = fun  
    329340    var cmpAuraManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_AuraManager);
    330341    var classes = this.GetClasses(name);
    331342
    332343    for (let mod of modifications)
    333344        for (let player of players)
    334             cmpAuraManager.ApplyTemplateBonus(mod.value, player, classes, mod, this.templateName + "/" + name + "/" + mod.value);
     345            cmpAuraManager.ApplyTemplateBonus(mod.value, player, classes, mod, this.GetModifierIdentifier(name, mod));
    335346};
    336347
    337348Auras.prototype.RemoveFormationBonus = function(memberList)
    338349{
    339350    var auraNames = this.GetAuraNames().filter(n => this.IsFormationAura(n));
    Auras.prototype.RemoveTemplateBonus = fu  
    358369    var classes = this.GetClasses(name);
    359370    var players =  this.GetAffectedPlayers(name);
    360371
    361372    for each (var mod in modifications)
    362373        for each (var player in players)
    363             cmpAuraManager.RemoveTemplateBonus(mod.value, player, classes, this.templateName + "/" + name + "/" + mod.value);
     374            cmpAuraManager.RemoveTemplateBonus(mod.value, player, classes, this.GetModifierIdentifier(name, mod));
    364375};
    365376
    366377Auras.prototype.ApplyBonus = function(name, ents)
    367378{
    368379    var validEnts = this.GiveMembersWithValidClass(name, ents);
    Auras.prototype.ApplyBonus = function(na  
    370381        return;
    371382    this[name].targetUnits = this[name].targetUnits.concat(validEnts);
    372383    var modifications = this.GetModifications(name);
    373384    var cmpAuraManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_AuraManager);
    374385    for each (let mod in modifications)
    375         cmpAuraManager.ApplyBonus(mod.value, validEnts, mod, this.templateName + "/" + name + "/" + mod.value);
     386        cmpAuraManager.ApplyBonus(mod.value, validEnts, mod, this.GetModifierIdentifier(name, mod));
    376387    // update status bars if this has an icon
    377388    if (!this.GetOverlayIcon(name))
    378389        return;
    379390    for (let ent of validEnts)
    380391    {
    Auras.prototype.RemoveBonus = function(n  
    391402        return;
    392403    this[name].targetUnits = this[name].targetUnits.filter(v => validEnts.indexOf(v) == -1);
    393404    var modifications = this.GetModifications(name);
    394405    var cmpAuraManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_AuraManager);
    395406    for each (let mod in modifications)
    396         cmpAuraManager.RemoveBonus(mod.value, validEnts, this.templateName + "/" + name + "/" + mod.value);
     407        cmpAuraManager.RemoveBonus(mod.value, validEnts, this.GetModifierIdentifier(name, mod));
    397408    // update status bars if this has an icon
    398409    if (!this.GetOverlayIcon(name))
    399410        return;
    400411    for (let ent of validEnts)
    401412    {
  • binaries/data/mods/public/simulation/components/Player.js

    Player.prototype.SetMaxPopulation = func  
    142142    this.maxPop = max;
    143143};
    144144
    145145Player.prototype.GetMaxPopulation = function()
    146146{
    147     return Math.round(ApplyValueModificationsToPlayer("Player/MaxPopulation", this.maxPop, this.entity));
     147    return Math.round(ApplyValueModificationsToPlayer("Player/MaxPopulation", this.maxPop, this.entity, this.playerID));
    148148};
    149149
    150150Player.prototype.SetGatherRateMultiplier = function(value)
    151151{
    152152    this.gatherRateMultiplier = value;
  • binaries/data/mods/public/simulation/data/technologies/pop_wonder.json

     
    88        "ptol": "Peristyle",
    99        "rome": "Peristyle",
    1010        "pers": "Paradise"
    1111    },
    1212    "description": "The wonder attracts many more people to your civilization.",
    13     "cost": {"food": 3000, "wood": 3000, "stone": 500, "metal": 500},
     13    "cost": {"food": 2000, "wood": 3000, "stone": 500, "metal": 500},
    1414    "requirements": {"tech": "phase_city"},
    1515    "requirementsTooltip": "Unlocked in City Phase.",
    1616    "icon": "special_treasure.png",
    1717    "researchTime": 40,
    18     "tooltip": "+50 maximum population cap.",
    19     "modifications": [{"value": "Player/MaxPopulation", "add": 50}],
     18    "tooltip": "Increase the population bonus of the wonder by 40.",
     19    "modifications": [{"value": "Auras/Aura1/Modifications/Player/MaxPopulation/Add", "add": 40}],
    2020    "soundComplete": "interface/alarm/alarm_upgradearmory.xml"
    2121}
  • binaries/data/mods/public/simulation/helpers/ValueModification.js

     
    1 // Little helper functions to make applying technology more convenient
     1// Little helper functions to make applying technology and auras more convenient
    22
    33function ApplyValueModificationsToEntity(tech_type, current_value, entity)
    44{
    55    let value = current_value;
    66    let cmpTechnologyManager = QueryOwnerInterface(entity, IID_TechnologyManager);
    function ApplyValueModificationsToEntity  
    1111    if (!cmpAuraManager)
    1212        return value;
    1313    return cmpAuraManager.ApplyModifications(tech_type, value, entity);
    1414}
    1515
    16 function ApplyValueModificationsToPlayer(tech_type, current_value, player_entity)
     16function ApplyValueModificationsToPlayer(tech_type, current_value, playerEntity, playerID)
    1717{
    18     let cmpTechnologyManager = Engine.QueryInterface(player_entity, IID_TechnologyManager);
    19 
    20     if (!cmpTechnologyManager)
    21         return current_value;
    22 
    23     return cmpTechnologyManager.ApplyModifications(tech_type, current_value, player_entity);
     18    let cmpTemplateManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_TemplateManager);
     19    let entityTemplateName = cmpTemplateManager.GetCurrentTemplateName(playerEntity);
     20    let entityTemplate = cmpTemplateManager.GetTemplate(entityTemplateName);
     21    return ApplyValueModificationsToTemplate(tech_type, current_value, playerID, entityTemplate);
    2422}
    2523
    2624function ApplyValueModificationsToTemplate(tech_type, current_value, playerID, template)
    2725{
    2826    let value = current_value;
  • binaries/data/mods/public/simulation/templates/special/player.xml

     
    4646      <CivilCentre>
    4747        <RequiredTechs datatype="tokens">phase_town</RequiredTechs>
    4848      </CivilCentre>
    4949    </LimitRemovers>
    5050  </EntityLimits>
     51  <Identity>
     52    <Civ></Civ>
     53    <GenericName>Player</GenericName>
     54    <Classes datatype="tokens">Player</Classes>
     55  </Identity>
    5156  <Player>
    52     <SharedLosTech>unlock_shared_los</SharedLosTech>
     57    <SharedLosTech>unlock_shared_los</SharedLosTech>
    5358  </Player>
    5459  <StatisticsTracker/>
    5560  <TechnologyManager/>
    5661</Entity>
  • binaries/data/mods/public/simulation/templates/structures/athen_wonder.xml

     
    22<Entity parent="template_structure_wonder">
    33  <Footprint>
    44    <Square width="28.0" depth="58.0"/>
    55    <Height>12.0</Height>
    66  </Footprint>
    7   <GarrisonHolder>
    8     <Max>30</Max>
    9     <EjectHealth>0.1</EjectHealth>
    10     <EjectClassesOnDestroy datatype="tokens">Unit</EjectClassesOnDestroy>
    11     <List datatype="tokens">Support Infantry Cavalry</List>
    12     <BuffHeal>3</BuffHeal>
    13     <LoadingRange>2</LoadingRange>
    14   </GarrisonHolder>
    157  <Identity>
    168    <Civ>athen</Civ>
    179    <SpecificName>Naós Parthenṓn</SpecificName>
    1810    <History>The Hellenes built marvelous temples in order to honour their polytheistic pantheon. While all gods were venerated, a specific patron deity was supposed to watch over each polis.</History>
    1911    <Tooltip>Bring glory to your civilization and add large tracts of land to your empire. Garrison up to 30 units to heal them at a quick rate.</Tooltip>
  • binaries/data/mods/public/simulation/templates/structures/cart_wonder.xml

     
    22<Entity parent="template_structure_wonder">
    33  <Footprint>
    44    <Square width="29.0" depth="59.0"/>
    55    <Height>12.0</Height>
    66  </Footprint>
    7   <GarrisonHolder>
    8     <Max>30</Max>
    9     <EjectHealth>0.1</EjectHealth>
    10     <EjectClassesOnDestroy datatype="tokens">Unit</EjectClassesOnDestroy>
    11     <List datatype="tokens">Support Infantry Cavalry</List>
    12     <BuffHeal>3</BuffHeal>
    13     <LoadingRange>2</LoadingRange>
    14   </GarrisonHolder>
    157  <Identity>
    168   <Civ>cart</Civ>
    179    <SpecificName>Temple of Ba'al Hammon</SpecificName>
    1810    <History>Dating from the 2nd Century BC, the Mausoleum of Atban in northern Tunisia is over twenty metres high and was built by the inhabitants of Dougga for a Numidian prince.</History>
    1911  </Identity>
  • binaries/data/mods/public/simulation/templates/structures/iber_wonder.xml

     
    22<Entity parent="template_structure_wonder">
    33  <Footprint>
    44    <Square width="43.0" depth="43.0"/>
    55    <Height>14.0</Height>
    66  </Footprint>
    7   <GarrisonHolder>
    8     <Max>30</Max>
    9     <EjectHealth>0.1</EjectHealth>
    10     <EjectClassesOnDestroy datatype="tokens">Unit</EjectClassesOnDestroy>
    11     <List datatype="tokens">Support Infantry Cavalry</List>
    12     <BuffHeal>3</BuffHeal>
    13     <LoadingRange>2</LoadingRange>
    14   </GarrisonHolder>
    157  <Identity>
    168    <Civ>iber</Civ>
    179    <SpecificName>Cancho Roano</SpecificName>
    1810    <History>ToDo</History>
    1911  </Identity>
  • binaries/data/mods/public/simulation/templates/structures/mace_wonder.xml

     
    22<Entity parent="template_structure_wonder">
    33  <Footprint>
    44    <Square width="28.0" depth="58.0"/>
    55    <Height>12.0</Height>
    66  </Footprint>
    7   <GarrisonHolder>
    8     <Max>30</Max>
    9     <EjectHealth>0.1</EjectHealth>
    10     <EjectClassesOnDestroy datatype="tokens">Unit</EjectClassesOnDestroy>
    11     <List datatype="tokens">Support Infantry Cavalry</List>
    12     <BuffHeal>3</BuffHeal>
    13     <LoadingRange>2</LoadingRange>
    14   </GarrisonHolder>
    157  <Identity>
    168    <Civ>mace</Civ>
    179    <SpecificName>Naós Parthenṓn</SpecificName>
    1810    <History>The Hellenes built marvelous temples in order to honour their polytheistic pantheon. While all gods were venerated, a specific patron deity was supposed to watch over each polis.</History>
    1911    <Tooltip>Bring glory to your civilization and add large tracts of land to your empire. Garrison up to 30 units to heal them at a quick rate.</Tooltip>
  • binaries/data/mods/public/simulation/templates/structures/pers_wonder.xml

     
    1010  <Identity>
    1111    <Civ>pers</Civ>
    1212    <SpecificName>Hanging Gardens of Babylon</SpecificName>
    1313    <History>A magnificent structure built in the 6th century BC by the Neo-Babylonian king Nebuchadnezzar II in order to please his wife Amytis of Media, who was homesick for the gardens and mountains of her homeland.</History>
    1414  </Identity>
    15   <Loot>
    16     <xp>200</xp>
    17   </Loot>
    1815  <Obstruction>
    1916    <Static width="59.0" depth="59.0"/>
    2017  </Obstruction>
    2118  <StatusBars>
    2219    <BarWidth>6.0</BarWidth>
  • binaries/data/mods/public/simulation/templates/structures/ptol_wonder.xml

     
    22<Entity parent="template_structure_wonder">
    33  <Footprint>
    44    <Square width="48.0" depth="66.0"/>
    55    <Height>20.0</Height>
    66  </Footprint>
    7   <GarrisonHolder>
    8     <Max>30</Max>
    9     <EjectHealth>0.1</EjectHealth>
    10     <EjectClassesOnDestroy datatype="tokens">Unit</EjectClassesOnDestroy>
    11     <List datatype="tokens">Support Infantry Cavalry</List>
    12     <BuffHeal>3</BuffHeal>
    13     <LoadingRange>2</LoadingRange>
    14   </GarrisonHolder>
    157  <Identity>
    168    <Civ>ptol</Civ>
    179    <SpecificName>Temple of Edfu</SpecificName>
    1810    <History>The Temple of Edfu is an ancient Egyptian temple located on the west bank of the Nile in the city of Edfu which was known in Greco-Roman times as Apollonopolis Magna, after the chief god Horus-Apollo.The temple, dedicated to the falcon god Horus, was built in the Ptolemaic period between 237 and 57 BCE. In modern times, it is one of the best preserved temples of Egypt.</History>
    1911  </Identity>
  • binaries/data/mods/public/simulation/templates/structures/rome_wonder.xml

     
    22<Entity parent="template_structure_wonder">
    33  <Footprint>
    44    <Square width="24.0" depth="44.0"/>
    55    <Height>12.0</Height>
    66  </Footprint>
    7   <GarrisonHolder>
    8     <Max>30</Max>
    9     <EjectHealth>0.1</EjectHealth>
    10     <EjectClassesOnDestroy datatype="tokens">Unit</EjectClassesOnDestroy>
    11     <List datatype="tokens">Support Infantry Cavalry</List>
    12     <BuffHeal>3</BuffHeal>
    13     <LoadingRange>2</LoadingRange>
    14   </GarrisonHolder>
    157  <Identity>
    168    <Civ>rome</Civ>
    179    <SpecificName>Aedes Iovis Optimi Maximi</SpecificName>
    1810    <History>.</History>
    1911  </Identity>
  • binaries/data/mods/public/simulation/templates/structures/spart_wonder.xml

     
    22<Entity parent="template_structure_wonder">
    33  <Footprint>
    44    <Square width="28.0" depth="58.0"/>
    55    <Height>12.0</Height>
    66  </Footprint>
    7   <GarrisonHolder>
    8     <Max>30</Max>
    9     <EjectHealth>0.1</EjectHealth>
    10     <EjectClassesOnDestroy datatype="tokens">Unit</EjectClassesOnDestroy>
    11     <List datatype="tokens">Support Infantry Cavalry</List>
    12     <BuffHeal>3</BuffHeal>
    13     <LoadingRange>2</LoadingRange>
    14   </GarrisonHolder>
    157  <Identity>
    168    <Civ>spart</Civ>
    179    <SpecificName>Naós Parthenṓn</SpecificName>
    1810    <History>The Hellenes built marvelous temples in order to honour their polytheistic pantheon. While all gods were venerated, a specific patron deity was supposed to watch over each polis.</History>
    1911    <Tooltip>Bring glory to your civilization and add large tracts of land to your empire. Garrison up to 30 units to heal them at a quick rate.</Tooltip>
  • binaries/data/mods/public/simulation/templates/template_structure_wonder.xml

     
    88      <Hack>2</Hack>
    99      <Pierce>10</Pierce>
    1010      <Crush>2</Crush>
    1111    </Foundation>
    1212  </Armour>
     13  <Auras>
     14    <Aura1>
     15      <Type>global</Type>
     16      <Affects>Player</Affects>
     17      <Modifications>
     18        <Player.MaxPopulation> <Add>10</Add> </Player.MaxPopulation>
     19      </Modifications>
     20      <AuraName>Wonder Aura</AuraName>
     21      <AuraDescription>+10 maximum population cap.</AuraDescription>
     22     </Aura1>
     23  </Auras>
    1324  <BuildRestrictions>
    1425    <Category>Wonder</Category>
    1526  </BuildRestrictions>
    1627  <Capturable>
    17     <CapturePoints>1500</CapturePoints>
     28    <CapturePoints>2000</CapturePoints>
    1829    <RegenRate>5.0</RegenRate>
    1930  </Capturable>
    2031  <Cost>
    2132    <BuildTime>1000</BuildTime>
    2233    <Resources>
    23       <food>0</food>
     34      <food>1000</food>
    2435      <wood>1000</wood>
    2536      <stone>1000</stone>
    2637      <metal>1000</metal>
    2738    </Resources>
    2839  </Cost>
    2940  <Footprint>
    3041    <Square width="34.0" depth="34.0"/>
    3142    <Height>10.0</Height>
    3243  </Footprint>
    33   <GarrisonHolder disable=""/>
     44  <GarrisonHolder>
     45    <Max>30</Max>
     46    <EjectHealth>0.1</EjectHealth>
     47    <EjectClassesOnDestroy datatype="tokens">Unit</EjectClassesOnDestroy>
     48    <List datatype="tokens">Support Infantry Cavalry</List>
     49    <BuffHeal>3</BuffHeal>
     50    <LoadingRange>2</LoadingRange>
     51  </GarrisonHolder>
    3452  <Health>
    3553    <Max>5000</Max>
    3654    <SpawnEntityOnDeath>rubble/rubble_stone_6x6</SpawnEntityOnDeath>
    3755  </Health>
    3856  <Identity>
    3957    <GenericName>Wonder</GenericName>
    4058    <Tooltip>Bring glory to your civilization and add large tracts of land to your empire.</Tooltip>
    4159    <Classes datatype="tokens">
    4260      City
    4361      Wonder
    44     </Classes>
     62    </Classes>
    4563    <Icon>structures/wonder.png</Icon>
    4664    <RequiredTechnology>phase_city</RequiredTechnology>
    4765  </Identity>
    4866  <Loot>
    4967    <xp>200</xp>