Ticket #4082: ptol-teambonus.patch

File ptol-teambonus.patch, 5.0 KB (added by mimo, 3 years ago)
  • binaries/data/mods/public/simulation/components/Auras.js

     
    210210            continue;
    211211        }
    212212
     213        // When only Player class affected, we do not need a rangeQuery as applicable only to player entity
     214        // and templates TODO maybe add a new type "player"
     215        if (this.IsGlobalAura(name) && this.GetClasses(name).length == 1 && this.GetClasses(name)[0] == "Player")
     216        {
     217            this.ApplyTemplateBonus(name, affectedPlayers);
     218            let cmpPlayerManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_PlayerManager);
     219            let playerEnts = affectedPlayers.map(player => cmpPlayerManager.GetPlayerByID(player));
     220            this.ApplyBonus(name, playerEnts);
     221            continue;
     222        }
     223
    213224        this[name].rangeQuery = cmpRangeManager.CreateActiveQuery(
    214225            this.entity,
    215226            0,
  • binaries/data/mods/public/simulation/components/ResourceTrickle.js

     
    3232
    3333ResourceTrickle.prototype.Init = function()
    3434{
     35    this.ComputeRates();
    3536    // Call the timer
    36     var cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer);
     37    let cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer);
    3738    cmpTimer.SetInterval(this.entity, IID_ResourceTrickle, "Trickle", this.GetTimer(), this.GetTimer(), undefined);
    3839};
    3940
    4041ResourceTrickle.prototype.GetTimer = function()
    4142{
    42     var interval = +this.template.Interval;
    43     return interval;
     43    return +this.template.Interval;
    4444};
    4545
    4646ResourceTrickle.prototype.GetRates = function()
    4747{
    48     var rates = {};
    49     for (var resource in this.template.Rates)
    50         rates[resource] = ApplyValueModificationsToEntity("ResourceTrickle/Rates/"+resource, +this.template.Rates[resource], this.entity);
     48    return this.rates;
     49};
    5150
    52     return rates;
     51ResourceTrickle.prototype.ComputeRates = function()
     52{
     53    this.rates = {};
     54    for (let resource in this.template.Rates)
     55        this.rates[resource] = ApplyValueModificationsToEntity("ResourceTrickle/Rates/"+resource, +this.template.Rates[resource], this.entity);
    5356};
    5457
    5558// Do the actual work here
    5659ResourceTrickle.prototype.Trickle = function(data, lateness)
    5760{
    58     var cmpPlayer = QueryOwnerInterface(this.entity);
     61    // The player entity may also be a ResourceTrickle component
     62    let cmpPlayer = QueryOwnerInterface(this.entity) || Engine.QueryInterface(this.entity, IID_Player);
    5963    if (!cmpPlayer)
    6064        return;
    6165
    62     var rates = this.GetRates();
    63     for (var resource in rates)
    64         cmpPlayer.AddResource(resource, rates[resource]);
     66    for (let resource in this.rates)
     67        cmpPlayer.AddResource(resource, this.rates[resource]);
    6568};
    6669
     70ResourceTrickle.prototype.OnValueModification = function(msg)
     71{
     72    if (msg.component != "ResourceTrickle")
     73        return;
     74
     75    this.ComputeRates();
     76};
     77
    6778Engine.RegisterComponentType(IID_ResourceTrickle, "ResourceTrickle", ResourceTrickle);
  • binaries/data/mods/public/simulation/data/auras/teambonuses/ptol_player_teambonus.json

     
     1{
     2    "type": "global",
     3    "affects": ["Player"],
     4    "affectedPlayers": ["ExclusiveMutualAlly"],
     5    "modifications": [
     6        { "value": "ResourceTrickle/Rates/food", "add": 1.5 }
     7    ],
     8    "auraName": "Breadbasket of the Mediterranean",
     9    "auraDescription": "All allies automatically gain a slow trickle of food income."
     10}
  • binaries/data/mods/public/simulation/templates/special/player.xml

     
    6060    <SharedLosTech>unlock_shared_los</SharedLosTech>
    6161    <SharedDropsitesTech>unlock_shared_dropsites</SharedDropsitesTech>
    6262  </Player>
     63  <ResourceTrickle>
     64    <Rates>
     65      <food>0.0</food>
     66      <wood>0.0</wood>
     67      <stone>0.0</stone>
     68      <metal>0.0</metal>
     69    </Rates>
     70    <Interval>1000</Interval>
     71  </ResourceTrickle>
    6372  <StatisticsTracker/>
    6473  <TechnologyManager/>
    6574</Entity>
  • binaries/data/mods/public/simulation/templates/special/player_ptol.xml

     
    11<?xml version="1.0" encoding="utf-8"?>
    22<Entity parent="special/player">
     3  <Auras datatype="tokens">teambonuses/ptol_player_teambonus</Auras>
    34  <EntityLimits>
    45    <LimitRemovers>
    56      <CivilCentre>