From 4be96ece08e2a0ca0d9a94f2bccc3cdcf1609151 Mon Sep 17 00:00:00 2001 From: sanderd17 Date: Tue, 5 Apr 2016 14:13:44 +0000 Subject: [PATCH] Implement stackable auras + fix an issue with techs, auras and ownership changes. Patch by fatherbushido. Fixes #3792 This was SVN commit r17982. --- .../data/mods/public/simulation/components/Auras.js | 13 ++++++++----- .../public/simulation/data/auras/wonder_pop_1.json | 3 ++- .../public/simulation/data/auras/wonder_pop_2.json | 3 ++- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/binaries/data/mods/public/simulation/components/Auras.js b/binaries/data/mods/public/simulation/components/Auras.js index 7ed7c12f04..ce451ee66a 100644 --- a/binaries/data/mods/public/simulation/components/Auras.js +++ b/binaries/data/mods/public/simulation/components/Auras.js @@ -25,7 +25,9 @@ Auras.prototype.Init = function() // We can modify identifier if we want stackable auras in some case. Auras.prototype.GetModifierIdentifier = function(name) { - return name; + if (this.auras[name].stackable) + return name + this.entity; + return name; }; Auras.prototype.GetDescriptions = function() @@ -194,6 +196,7 @@ Auras.prototype.Clean = function() // initialise range query this[name] = {}; this[name].targetUnits = []; + this[name].isApplied = this.CanApply(name); var affectedPlayers = this.GetAffectedPlayers(name); if (!affectedPlayers.length) @@ -274,7 +277,7 @@ Auras.prototype.ApplyGarrisonBonus = function(structure) Auras.prototype.ApplyTemplateBonus = function(name, players) { - if (!this.CanApply(name)) + if (!this[name].isApplied) return; if (!this.IsGlobalAura(name)) @@ -304,7 +307,7 @@ Auras.prototype.RemoveGarrisonBonus = function(structure) Auras.prototype.RemoveTemplateBonus = function(name) { - if (!this.CanApply(name)) + if (!this[name].isApplied) return; if (!this.IsGlobalAura(name)) return; @@ -327,7 +330,7 @@ Auras.prototype.ApplyBonus = function(name, ents) this[name].targetUnits = this[name].targetUnits.concat(validEnts); - if (!this.CanApply(name)) + if (!this[name].isApplied) return; var modifications = this.GetModifications(name); @@ -355,7 +358,7 @@ Auras.prototype.RemoveBonus = function(name, ents) this[name].targetUnits = this[name].targetUnits.filter(v => validEnts.indexOf(v) == -1); - if (!this.CanApply(name)) + if (!this[name].isApplied) return; var modifications = this.GetModifications(name); diff --git a/binaries/data/mods/public/simulation/data/auras/wonder_pop_1.json b/binaries/data/mods/public/simulation/data/auras/wonder_pop_1.json index 1d32acfc01..bc3f711526 100644 --- a/binaries/data/mods/public/simulation/data/auras/wonder_pop_1.json +++ b/binaries/data/mods/public/simulation/data/auras/wonder_pop_1.json @@ -3,5 +3,6 @@ "affects": ["Player"], "modifications": [ { "value": "Player/MaxPopulation", "add": 10 } ], "auraName": "Wonder Aura", - "auraDescription": "+10 max. population cap" + "auraDescription": "+10 max. population cap", + "stackable": true } diff --git a/binaries/data/mods/public/simulation/data/auras/wonder_pop_2.json b/binaries/data/mods/public/simulation/data/auras/wonder_pop_2.json index e1d610c35e..a8de21bd02 100644 --- a/binaries/data/mods/public/simulation/data/auras/wonder_pop_2.json +++ b/binaries/data/mods/public/simulation/data/auras/wonder_pop_2.json @@ -4,5 +4,6 @@ "modifications": [ { "value": "Player/MaxPopulation", "add": 40 } ], "auraName": "Wonder Aura", "auraDescription": "+40 extra max. population cap (requires \"Glorious Expansion\" tech)", - "requiredTechnology": "pop_wonder" + "requiredTechnology": "pop_wonder", + "stackable": true }