Index: ps/trunk/binaries/data/mods/public/simulation/components/Promotion.js =================================================================== --- ps/trunk/binaries/data/mods/public/simulation/components/Promotion.js +++ ps/trunk/binaries/data/mods/public/simulation/components/Promotion.js @@ -4,6 +4,11 @@ "" + "" + "" + + "" + + "" + + "" + + "" + + "" + "" + "" + ""; @@ -11,6 +16,7 @@ Promotion.prototype.Init = function() { this.currentXp = 0; + this.ComputeTrickleRate(); }; Promotion.prototype.GetRequiredXp = function() @@ -91,10 +97,44 @@ Engine.PostMessage(this.entity, MT_ExperienceChanged, {}); }; +Promotion.prototype.ComputeTrickleRate = function() +{ + this.trickleRate = ApplyValueModificationsToEntity("Promotion/TrickleRate", +(this.template.TrickleRate || 0), this.entity); + this.CheckTrickleTimer(); +}; + +Promotion.prototype.CheckTrickleTimer = function() +{ + if (!this.trickleRate) + { + if (this.trickleTimer) + { + let cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer); + cmpTimer.CancelTimer(this.trickleTimer); + delete this.trickleTimer; + } + return; + } + + if (this.trickleTimer) + return; + + let cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer); + this.trickleTimer = cmpTimer.SetInterval(this.entity, IID_Promotion, "TrickleTick", 1000, 1000, null); +}; + +Promotion.prototype.TrickleTick = function() +{ + this.IncreaseXp(this.trickleRate); +}; + Promotion.prototype.OnValueModification = function(msg) { - if (msg.component == "Promotion") - this.IncreaseXp(0); + if (msg.component != "Promotion") + return; + + this.ComputeTrickleRate(); + this.IncreaseXp(0); }; Engine.RegisterComponentType(IID_Promotion, "Promotion", Promotion); Index: ps/trunk/binaries/data/mods/public/simulation/data/auras/structures/barracks_xp_trickle.json =================================================================== --- ps/trunk/binaries/data/mods/public/simulation/data/auras/structures/barracks_xp_trickle.json +++ ps/trunk/binaries/data/mods/public/simulation/data/auras/structures/barracks_xp_trickle.json @@ -0,0 +1,9 @@ +{ + "type": "garrisonedUnits", + "affects": ["Unit"], + "modifications": [ + { "value": "Promotion/TrickleRate", "add": 1 } + ], + "auraName": "Rigorous Training", + "auraDescription": "Units gain experience while garrisoned in barracks." +} Index: ps/trunk/binaries/data/mods/public/simulation/templates/template_structure_military_barracks.xml =================================================================== --- ps/trunk/binaries/data/mods/public/simulation/templates/template_structure_military_barracks.xml +++ ps/trunk/binaries/data/mods/public/simulation/templates/template_structure_military_barracks.xml @@ -1,5 +1,8 @@ + + structures/barracks_xp_trickle + 150