Index: binaries/data/mods/public/simulation/components/Cost.js =================================================================== --- binaries/data/mods/public/simulation/components/Cost.js +++ binaries/data/mods/public/simulation/components/Cost.js @@ -44,9 +44,7 @@ Cost.prototype.GetBuildTime = function() { - var cmpPlayer = QueryOwnerInterface(this.entity); - var buildTime = (+this.template.BuildTime) * cmpPlayer.GetTimeMultiplier(); - return ApplyValueModificationsToEntity("Cost/BuildTime", buildTime, this.entity); + return ApplyValueModificationsToEntity("Cost/BuildTime", +this.template.BuildTime, this.entity); }; Cost.prototype.GetResourceCosts = function(owner) Index: binaries/data/mods/public/simulation/components/Pack.js =================================================================== --- binaries/data/mods/public/simulation/components/Pack.js +++ binaries/data/mods/public/simulation/components/Pack.js @@ -96,9 +96,7 @@ Pack.prototype.GetPackTime = function() { - let cmpPlayer = QueryOwnerInterface(this.entity, IID_Player); - - return ApplyValueModificationsToEntity("Pack/Time", +this.template.Time, this.entity) * cmpPlayer.GetTimeMultiplier(); + return ApplyValueModificationsToEntity("Pack/Time", +this.template.Time, this.entity); }; Pack.prototype.GetElapsedTime = function() Index: binaries/data/mods/public/simulation/components/Player.js =================================================================== --- binaries/data/mods/public/simulation/components/Player.js +++ binaries/data/mods/public/simulation/components/Player.js @@ -64,11 +64,7 @@ this.startCam = undefined; this.controlAllUnits = false; this.isAI = false; - this.timeMultiplier = 1; - this.gatherRateMultiplier = 1; - this.tradeRateMultiplier = 1; this.cheatsEnabled = false; - this.cheatTimeMultiplier = 1; this.panelEntities = []; this.resourceNames = {}; this.disabledTemplates = {}; @@ -224,21 +220,6 @@ return this.barterMultiplier; }; -Player.prototype.GetGatherRateMultiplier = function() -{ - return this.gatherRateMultiplier / this.cheatTimeMultiplier; -}; - -Player.prototype.GetTimeMultiplier = function() -{ - return this.timeMultiplier * this.cheatTimeMultiplier; -}; - -Player.prototype.GetTradeRateMultiplier = function() -{ - return this.tradeRateMultiplier; -}; - Player.prototype.GetSpyCostMultiplier = function() { return this.spyCostMultiplier; @@ -247,22 +228,6 @@ /** * Setters currently used by the AI to set the difficulty level */ -Player.prototype.SetGatherRateMultiplier = function(value) -{ - this.gatherRateMultiplier = value; - Engine.BroadcastMessage(MT_MultiplierChanged, { "player": this.playerID, "type": "gather" }); -}; - -Player.prototype.SetTimeMultiplier = function(value) -{ - this.timeMultiplier = value; - Engine.BroadcastMessage(MT_MultiplierChanged, { "player": this.playerID, "type": "time" }); -}; - -Player.prototype.SetTradeRateMultiplier = function(value) -{ - this.tradeRateMultiplier = value; -}; Player.prototype.GetPanelEntities = function() { @@ -845,17 +810,6 @@ return this.cheatsEnabled; }; -Player.prototype.SetCheatTimeMultiplier = function(time) -{ - this.cheatTimeMultiplier = time; - Engine.BroadcastMessage(MT_MultiplierChanged, { "player": this.playerID, "type": "cheat" }); -}; - -Player.prototype.GetCheatTimeMultiplier = function() -{ - return this.cheatTimeMultiplier; -}; - Player.prototype.TributeResource = function(player, amounts) { var cmpPlayer = QueryPlayerIDInterface(player); Index: binaries/data/mods/public/simulation/components/ProductionQueue.js =================================================================== --- binaries/data/mods/public/simulation/components/ProductionQueue.js +++ binaries/data/mods/public/simulation/components/ProductionQueue.js @@ -335,7 +335,7 @@ let template = TechnologyTemplates.Get(templateName); let techCostMultiplier = this.GetTechCostMultiplier(); - let time = techCostMultiplier.time * template.researchTime * cmpPlayer.GetTimeMultiplier(); + let time = techCostMultiplier.time * template.researchTime; let cost = {}; for (let res in template.cost) @@ -498,12 +498,8 @@ */ ProductionQueue.prototype.GetBatchTime = function(batchSize) { - var cmpPlayer = QueryOwnerInterface(this.entity); - - var batchTimeModifier = ApplyValueModificationsToEntity("ProductionQueue/BatchTimeModifier", +this.template.BatchTimeModifier, this.entity); - // TODO: work out what equation we should use here. - return Math.pow(batchSize, batchTimeModifier) * cmpPlayer.GetTimeMultiplier(); + return Math.pow(batchSize, ApplyValueModificationsToEntity("ProductionQueue/BatchTimeModifier", +this.template.BatchTimeModifier, this.entity)); }; ProductionQueue.prototype.OnOwnershipChanged = function(msg) Index: binaries/data/mods/public/simulation/components/ResourceGatherer.js =================================================================== --- binaries/data/mods/public/simulation/components/ResourceGatherer.js +++ binaries/data/mods/public/simulation/components/ResourceGatherer.js @@ -101,9 +101,7 @@ // Since this code is very performancecritical and applying technologies quite slow, cache it. ResourceGatherer.prototype.RecalculateGatherRatesAndCapacities = function() { - let cmpPlayer = QueryOwnerInterface(this.entity, IID_Player); - let multiplier = cmpPlayer ? cmpPlayer.GetGatherRateMultiplier() : 1; - this.baseSpeed = multiplier * ApplyValueModificationsToEntity("ResourceGatherer/BaseSpeed", +this.template.BaseSpeed, this.entity); + this.baseSpeed = ApplyValueModificationsToEntity("ResourceGatherer/BaseSpeed", +this.template.BaseSpeed, this.entity); this.rates = {}; for (let r in this.template.Rates) Index: binaries/data/mods/public/simulation/components/Upgrade.js =================================================================== --- binaries/data/mods/public/simulation/components/Upgrade.js +++ binaries/data/mods/public/simulation/components/Upgrade.js @@ -275,9 +275,7 @@ if (!this.template[choice].Time) return 0; - let cmpPlayer = QueryPlayerIDInterface(this.owner, IID_Player); - return ApplyValueModificationsToEntity("Upgrade/Time", +this.template[choice].Time, this.entity) * - cmpPlayer.GetTimeMultiplier(); + return ApplyValueModificationsToEntity("Upgrade/Time", +this.template[choice].Time, this.entity); }; Upgrade.prototype.GetElapsedTime = function() Index: binaries/data/mods/public/simulation/components/tests/test_Pack.js =================================================================== --- binaries/data/mods/public/simulation/components/tests/test_Pack.js +++ binaries/data/mods/public/simulation/components/tests/test_Pack.js @@ -33,10 +33,6 @@ "GetPlayerByID": id => 11 }); -AddMock(11, IID_Player, { - "GetTimeMultiplier": () => 1 -}); - AddMock(ent, IID_Sound, { "PlaySoundGroup": name => {} }); Index: binaries/data/mods/public/simulation/components/tests/test_UpgradeModification.js =================================================================== --- binaries/data/mods/public/simulation/components/tests/test_UpgradeModification.js +++ binaries/data/mods/public/simulation/components/tests/test_UpgradeModification.js @@ -110,7 +110,6 @@ AddMock(10, IID_Player, { "AddResources": () => {}, // Called in components/Upgrade.js::CancelUpgrade(). "GetPlayerID": () => playerID, // Called in helpers/Player.js::QueryOwnerInterface() (and several times below). - "GetTimeMultiplier": () => 1.0, // Called in components/Upgrade.js::GetUpgradeTime(). "TrySubtractResources": () => true // Called in components/Upgrade.js::Upgrade(). }); Index: binaries/data/mods/public/simulation/helpers/Cheat.js =================================================================== --- binaries/data/mods/public/simulation/helpers/Cheat.js +++ binaries/data/mods/public/simulation/helpers/Cheat.js @@ -69,10 +69,20 @@ cmpProductionQueue.SpawnUnits(input.templates[i % input.templates.length], 1, null); return; case "fastactions": - cmpPlayer.SetCheatTimeMultiplier((cmpPlayer.GetCheatTimeMultiplier() == 1) ? 0.01 : 1); - return; - case "changespeed": - cmpPlayer.SetCheatTimeMultiplier(input.parameter); + let cmpModifiersManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_ModifiersManager); + if (!cmpModifiersManager) + return; + + if (cmpModifiersManager.HasAnyModifier("cheat/fastactions", playerEnt)) + cmpModifiersManager.RemoveAllModifiers("cheat/fastactions", playerEnt); + else + cmpModifiersManager.AddModifiers("cheat/fastactions", { + "Cost/BuildTime": { "affects": [["Structure"], ["Unit"]], "multiply": 0.01 }, + "ResourceGatherer/BaseSpeed": { "affects": [["Structure"], ["Unit"]], "multiply": 1000 }, + "Pack/Time": { "affects": [["Structure"], ["Unit"]], "multiply": 0.01 }, + "Upgrade/Time": { "affects": [["Structure"], ["Unit"]], "multiply": 0.01 }, + "ProductionQueue/TechCostMultiplier/time": { "affects": [["Structure"], ["Unit"]], "multiply": 0.01 } + }, playerEnt); return; case "changephase": var cmpTechnologyManager = Engine.QueryInterface(playerEnt, IID_TechnologyManager); Index: binaries/data/mods/public/simulation/helpers/InitGame.js =================================================================== --- binaries/data/mods/public/simulation/helpers/InitGame.js +++ binaries/data/mods/public/simulation/helpers/InitGame.js @@ -46,6 +46,7 @@ // time apply on building, upgrading, packing, training and technologies let rate = [ 0.42, 0.56, 0.75, 1.00, 1.25, 1.56 ]; let time = [ 1.40, 1.25, 1.10, 1.00, 1.00, 1.00 ]; + let cmpModifiersManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_ModifiersManager); let cmpAIManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_AIManager); for (let i = 0; i < settings.PlayerData.length; ++i) { @@ -57,9 +58,11 @@ cmpAIManager.AddPlayer(settings.PlayerData[i].AI, i, AIDiff, settings.PlayerData[i].AIBehavior || "random"); cmpPlayer.SetAI(true); AIDiff = Math.min(AIDiff, rate.length - 1); - cmpPlayer.SetGatherRateMultiplier(rate[AIDiff]); - cmpPlayer.SetTradeRateMultiplier(rate[AIDiff]); - cmpPlayer.SetTimeMultiplier(time[AIDiff]); + cmpModifiersManager.AddModifiers("AI Bonus", { + "ResourceGatherer/BaseSpeed": { "affects": ["Unit", "Structure"], "multiply": rate[AIDiff] }, + "Trader/GainMultiplier": { "affects": ["Unit", "Structure"], "multiply": rate[AIDiff] }, + "Cost/BuildTime": { "affects": ["Unit", "Structure"], "multiply": time[AIDiff] }, + }, cmpPlayer.entity); } if (settings.PopulationCap) cmpPlayer.SetMaxPopulation(settings.PopulationCap); Index: binaries/data/mods/public/simulation/helpers/Player.js =================================================================== --- binaries/data/mods/public/simulation/helpers/Player.js +++ binaries/data/mods/public/simulation/helpers/Player.js @@ -95,11 +95,6 @@ continue; } - // Note: this is not yet implemented but I leave it commented to highlight it's easy - // If anyone ever adds handicap. - //if (getSetting(playerData, playerDefaults, i, "GatherRateMultiplier") !== undefined) - // cmpPlayer.SetGatherRateMultiplier(getSetting(playerData, playerDefaults, i, "GatherRateMultiplier")); - if (getSetting(playerData, playerDefaults, i, "PopulationLimit") !== undefined) cmpPlayer.SetMaxPopulation(getSetting(playerData, playerDefaults, i, "PopulationLimit")); Index: binaries/data/mods/public/simulation/helpers/TraderGain.js =================================================================== --- binaries/data/mods/public/simulation/helpers/TraderGain.js +++ binaries/data/mods/public/simulation/helpers/TraderGain.js @@ -27,7 +27,7 @@ return null; gainMultiplier *= cmpTrader.GetTraderGainMultiplier(); } - else //called from the gui, modifications already applied + else // called from the gui, modifications already applied { if (!traderTemplate || !traderTemplate.GainMultiplier) return null; @@ -50,19 +50,15 @@ if (!cmpPlayer) return null; gain.traderOwner = cmpPlayer.GetPlayerID(); - // Add potential player trade multipliers - let playerBonus = cmpPlayer.GetTradeRateMultiplier(); + // If markets belong to different players, add gain from international trading if (gain.market1Owner != gain.market2Owner) { - let market1PlayerBonus = cmpMarket1Player.GetTradeRateMultiplier(); - let market2PlayerBonus = cmpMarket2Player.GetTradeRateMultiplier(); let internationalBonus1 = cmpMarket1.GetInternationalBonus(); let internationalBonus2 = cmpMarket2.GetInternationalBonus(); - gain.market1Gain = Math.round(gain.traderGain * internationalBonus1 * market1PlayerBonus); - gain.market2Gain = Math.round(gain.traderGain * internationalBonus2 * market2PlayerBonus); + gain.market1Gain = Math.round(gain.traderGain * internationalBonus1); + gain.market2Gain = Math.round(gain.traderGain * internationalBonus2); } - gain.traderGain = Math.round(gain.traderGain * playerBonus); return gain; }