Ticket #3792: 3792.diff

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

    Auras.prototype.Schema =  
    5858                "<optional>" +
    5959                    "<element name='AffectedPlayers' a:help='Affected players'>" +
    6060                        "<text/>" +
    6161                    "</element>" +
    6262                "</optional>" +
     63                "<optional>" +
     64                "<element name='Stackable' a:help='Allow multiple applications of this aura'>" +
     65                        "<data type='boolean'/>" +
     66                    "</element>" +
     67                "</optional>" +
    6368            "</interleave>" +
    6469        "</element>" +
    6570    "</oneOrMore>";
    6671
    6772Auras.prototype.Init = function()
    Auras.prototype.Init = function()  
    9196        }
    9297        this.auras[name] = aura;
    9398    }
    9499};
    95100
     101Auras.prototype.GetModifierIdentifier = function(name, mod)
     102{
     103        let identifier = name + "/" + mod.value + "/";
     104        if (this.template[name].Stackable)
     105            return identifier + this.entity;
     106        // We add add/mul to prevent applying the same aura of different templates
     107        return identifier + (mod.Add || 0) + "/" + (mod.Multiply || 1);
     108};
     109
    96110Auras.prototype.GetDescriptions = function()
    97111{
    98112    var ret = {};
    99113    for each (var aura in this.template)
    100114        if (aura.AuraName)
    Auras.prototype.ApplyTemplateBonus = fun  
    329343    var cmpAuraManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_AuraManager);
    330344    var classes = this.GetClasses(name);
    331345
    332346    for (let mod of modifications)
    333347        for (let player of players)
    334             cmpAuraManager.ApplyTemplateBonus(mod.value, player, classes, mod, this.templateName + "/" + name + "/" + mod.value);
     348            cmpAuraManager.ApplyTemplateBonus(mod.value, player, classes, mod, this.GetModifierIdentifier(name, mod));
    335349};
    336350
    337351Auras.prototype.RemoveFormationBonus = function(memberList)
    338352{
    339353    var auraNames = this.GetAuraNames().filter(n => this.IsFormationAura(n));
    Auras.prototype.RemoveTemplateBonus = fu  
    358372    var classes = this.GetClasses(name);
    359373    var players =  this.GetAffectedPlayers(name);
    360374
    361375    for each (var mod in modifications)
    362376        for each (var player in players)
    363             cmpAuraManager.RemoveTemplateBonus(mod.value, player, classes, this.templateName + "/" + name + "/" + mod.value);
     377            cmpAuraManager.RemoveTemplateBonus(mod.value, player, classes, this.GetModifierIdentifier(name, mod));
    364378};
    365379
    366380Auras.prototype.ApplyBonus = function(name, ents)
    367381{
    368382    var validEnts = this.GiveMembersWithValidClass(name, ents);
    Auras.prototype.ApplyBonus = function(na  
    370384        return;
    371385    this[name].targetUnits = this[name].targetUnits.concat(validEnts);
    372386    var modifications = this.GetModifications(name);
    373387    var cmpAuraManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_AuraManager);
    374388    for each (let mod in modifications)
    375         cmpAuraManager.ApplyBonus(mod.value, validEnts, mod, this.templateName + "/" + name + "/" + mod.value);
     389        cmpAuraManager.ApplyBonus(mod.value, validEnts, mod, this.GetModifierIdentifier(name, mod));
    376390    // update status bars if this has an icon
    377391    if (!this.GetOverlayIcon(name))
    378392        return;
    379393    for (let ent of validEnts)
    380394    {
    Auras.prototype.RemoveBonus = function(n  
    391405        return;
    392406    this[name].targetUnits = this[name].targetUnits.filter(v => validEnts.indexOf(v) == -1);
    393407    var modifications = this.GetModifications(name);
    394408    var cmpAuraManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_AuraManager);
    395409    for each (let mod in modifications)
    396         cmpAuraManager.RemoveBonus(mod.value, validEnts, this.templateName + "/" + name + "/" + mod.value);
     410        cmpAuraManager.RemoveBonus(mod.value, validEnts, this.GetModifierIdentifier(name, mod));
    397411    // update status bars if this has an icon
    398412    if (!this.GetOverlayIcon(name))
    399413        return;
    400414    for (let ent of validEnts)
    401415    {