Index: ps/trunk/binaries/data/mods/public/gui/session/menu.js =================================================================== --- ps/trunk/binaries/data/mods/public/gui/session/menu.js +++ ps/trunk/binaries/data/mods/public/gui/session/menu.js @@ -540,8 +540,12 @@ if (template.cost) { + let modifiedTemplate = clone(template); + for (let res in template.cost) + modifiedTemplate.cost[res] = Math.floor(GetSimState().players[i].spyCostMultiplier * template.cost[res]); + tooltips.push(getEntityCostTooltip(modifiedTemplate)); let neededResources = Engine.GuiInterfaceCall("GetNeededResources", { - "cost": template.cost, + "cost": modifiedTemplate.cost, "player": g_ViewedPlayer }); if (neededResources) Index: ps/trunk/binaries/data/mods/public/simulation/components/GuiInterface.js =================================================================== --- ps/trunk/binaries/data/mods/public/simulation/components/GuiInterface.js +++ ps/trunk/binaries/data/mods/public/simulation/components/GuiInterface.js @@ -109,6 +109,7 @@ "disabledTechnologies": cmpPlayer.GetDisabledTechnologies(), "hasSharedDropsites": cmpPlayer.HasSharedDropsites(), "hasSharedLos": cmpPlayer.HasSharedLos(), + "spyCostMultiplier": cmpPlayer.GetSpyCostMultiplier(), "phase": phase, "isAlly": allies, "isMutualAlly": mutualAllies, Index: ps/trunk/binaries/data/mods/public/simulation/components/Player.js =================================================================== --- ps/trunk/binaries/data/mods/public/simulation/components/Player.js +++ ps/trunk/binaries/data/mods/public/simulation/components/Player.js @@ -6,6 +6,9 @@ "" + "" + "" + + "" + + "" + + "" + ""; Player.prototype.Init = function() @@ -38,6 +41,7 @@ this.disabledTemplates = {}; this.disabledTechnologies = {}; this.startingTechnologies = []; + this.spyCostMultiplier = +this.template.SpyCostMultiplier; // Initial resources and trading goods probability in steps of 5 let resCodes = Resources.GetCodes(); @@ -175,6 +179,11 @@ return this.tradeRateMultiplier; }; +Player.prototype.GetSpyCostMultiplier = function() +{ + return this.spyCostMultiplier; +}; + Player.prototype.GetHeroes = function() { return this.heroes; @@ -725,6 +734,13 @@ this.UpdateSharedLos(); }; +Player.prototype.OnValueModification = function(msg) +{ + if (msg.component != "Player" || msg.valueNames.indexOf("Player/SpyCostMultiplier") === -1) + return; + this.spyCostMultiplier = ApplyValueModificationsToPlayer("Player/SpyCostMultiplier", +this.template.SpyCostMultiplier, this.entity, this.playerID); +}; + Player.prototype.SetCheatsEnabled = function(flag) { this.cheatsEnabled = flag; Index: ps/trunk/binaries/data/mods/public/simulation/components/VisionSharing.js =================================================================== --- ps/trunk/binaries/data/mods/public/simulation/components/VisionSharing.js +++ ps/trunk/binaries/data/mods/public/simulation/components/VisionSharing.js @@ -119,10 +119,13 @@ let template = Engine.QueryInterface(SYSTEM_ENTITY, IID_TemplateManager).GetTemplate("special/spy"); let costs = {}; + // Additional cost for this owner + let cmpPlayerBribed = QueryPlayerIDInterface(cmpOwnership.GetOwner()); + let multiplier = cmpPlayerBribed.GetSpyCostMultiplier(); for (let res in template.Cost.Resources) - costs[res] = Math.floor(ApplyValueModificationsToTemplate("Cost/Resources/"+res, +template.Cost.Resources[res], player, template)); - let cmpPlayer = QueryPlayerIDInterface(player); - if (!cmpPlayer || !cmpPlayer.TrySubtractResources(costs)) + costs[res] = Math.floor(multiplier * ApplyValueModificationsToTemplate("Cost/Resources/" + res, +template.Cost.Resources[res], player, template)); + let cmpPlayerSpy = QueryPlayerIDInterface(player); + if (!cmpPlayerSpy || !cmpPlayerSpy.TrySubtractResources(costs)) return 0; // If no duration given, take it from the spy template and scale it with the ent vision Index: ps/trunk/binaries/data/mods/public/simulation/components/tests/test_GuiInterface.js =================================================================== --- ps/trunk/binaries/data/mods/public/simulation/components/tests/test_GuiInterface.js +++ ps/trunk/binaries/data/mods/public/simulation/components/tests/test_GuiInterface.js @@ -109,6 +109,7 @@ IsEnemy: function() { return true; }, GetDisabledTemplates: function() { return {}; }, GetDisabledTechnologies: function() { return {}; }, + GetSpyCostMultiplier: function() { return 1; }, HasSharedDropsites: function() { return false; }, HasSharedLos: function() { return false; }, }); @@ -194,6 +195,7 @@ IsEnemy: function() { return false; }, GetDisabledTemplates: function() { return {}; }, GetDisabledTechnologies: function() { return {}; }, + GetSpyCostMultiplier: function() { return 1; }, HasSharedDropsites: function() { return false; }, HasSharedLos: function() { return false; }, }); @@ -281,6 +283,7 @@ disabledTechnologies: {}, hasSharedDropsites: false, hasSharedLos: false, + spyCostMultiplier: 1, phase: "village", isAlly: [false, false], isMutualAlly: [false, false], @@ -325,6 +328,7 @@ disabledTechnologies: {}, hasSharedDropsites: false, hasSharedLos: false, + spyCostMultiplier: 1, phase: "village", isAlly: [true, true], isMutualAlly: [false, false], @@ -397,6 +401,7 @@ disabledTechnologies: {}, hasSharedDropsites: false, hasSharedLos: false, + spyCostMultiplier: 1, phase: "village", isAlly: [false, false], isMutualAlly: [false, false], @@ -454,6 +459,7 @@ disabledTechnologies: {}, hasSharedDropsites: false, hasSharedLos: false, + spyCostMultiplier: 1, phase: "village", isAlly: [true, true], isMutualAlly: [false, false], Index: ps/trunk/binaries/data/mods/public/simulation/components/tests/test_Player.js =================================================================== --- ps/trunk/binaries/data/mods/public/simulation/components/tests/test_Player.js +++ ps/trunk/binaries/data/mods/public/simulation/components/tests/test_Player.js @@ -8,7 +8,9 @@ "GetResource": () => ({}), }; -var cmpPlayer = ConstructComponent(10, "Player"); +var cmpPlayer = ConstructComponent(10, "Player", { + "SpyCostMultiplier": 1 + }); TS_ASSERT_EQUALS(cmpPlayer.GetPopulationCount(), 0); TS_ASSERT_EQUALS(cmpPlayer.GetPopulationLimit(), 0); @@ -25,3 +27,5 @@ cmpPlayer.SetDiplomacy(diplo); diplo[1] = -1; TS_ASSERT(cmpPlayer.IsAlly(1)); + +TS_ASSERT_EQUALS(cmpPlayer.GetSpyCostMultiplier(), 1); Index: ps/trunk/binaries/data/mods/public/simulation/components/tests/test_VisionSharing.js =================================================================== --- ps/trunk/binaries/data/mods/public/simulation/components/tests/test_VisionSharing.js +++ ps/trunk/binaries/data/mods/public/simulation/components/tests/test_VisionSharing.js @@ -128,6 +128,7 @@ "ApplyModificationsTemplate": (valueName, curValue, template) => curValue }); AddMock(14, IID_Player, { + "GetSpyCostMultiplier": () => 1, "TrySubtractResources": costs => false }); cmpVisionSharing.AddSpy(4, 25); @@ -136,6 +137,7 @@ TS_ASSERT_EQUALS(cmpVisionSharing.spyId, 20); AddMock(14, IID_Player, { + "GetSpyCostMultiplier": () => 1, "TrySubtractResources": costs => true }); AddMock(SYSTEM_ENTITY, IID_Timer, { Index: ps/trunk/binaries/data/mods/public/simulation/data/technologies/spy_counter.json =================================================================== --- ps/trunk/binaries/data/mods/public/simulation/data/technologies/spy_counter.json +++ ps/trunk/binaries/data/mods/public/simulation/data/technologies/spy_counter.json @@ -0,0 +1,12 @@ +{ + "genericName": "Counter Espionage", + "description": "Recruit a network of informants to watch over your people.", + "cost": { "food": 400, "wood": 0, "stone": 0, "metal": 400 }, + "supersedes": "unlock_spies", + "requirements": { "tech": "phase_city" }, + "icon": "vial_poison.png", + "researchTime": 60, + "tooltip": "Make your units 50% more expensive to bribe.", + "modifications": [{ "value": "Player/SpyCostMultiplier", "multiply": 1.5 }], + "soundComplete": "interface/alarm/alarm_upgradearmory.xml" +} Index: ps/trunk/binaries/data/mods/public/simulation/templates/special/player.xml =================================================================== --- ps/trunk/binaries/data/mods/public/simulation/templates/special/player.xml +++ ps/trunk/binaries/data/mods/public/simulation/templates/special/player.xml @@ -60,6 +60,7 @@ unlock_shared_los unlock_shared_dropsites + 1.0 Index: ps/trunk/binaries/data/mods/public/simulation/templates/special/player_gaia.xml =================================================================== --- ps/trunk/binaries/data/mods/public/simulation/templates/special/player_gaia.xml +++ ps/trunk/binaries/data/mods/public/simulation/templates/special/player_gaia.xml @@ -3,5 +3,6 @@ + 1.0 Index: ps/trunk/binaries/data/mods/public/simulation/templates/special/spy.xml =================================================================== --- ps/trunk/binaries/data/mods/public/simulation/templates/special/spy.xml +++ ps/trunk/binaries/data/mods/public/simulation/templates/special/spy.xml @@ -8,7 +8,7 @@ 0 0 0 - 900 + 500 Index: ps/trunk/binaries/data/mods/public/simulation/templates/template_structure_civic_civil_centre.xml =================================================================== --- ps/trunk/binaries/data/mods/public/simulation/templates/template_structure_civic_civil_centre.xml +++ ps/trunk/binaries/data/mods/public/simulation/templates/template_structure_civic_civil_centre.xml @@ -94,6 +94,8 @@ phase_town phase_city + unlock_spies + spy_counter Index: ps/trunk/binaries/data/mods/public/simulation/templates/template_structure_economic_market.xml =================================================================== --- ps/trunk/binaries/data/mods/public/simulation/templates/template_structure_economic_market.xml +++ ps/trunk/binaries/data/mods/public/simulation/templates/template_structure_economic_market.xml @@ -48,7 +48,6 @@ trade_gain_01 trade_gain_02 trade_commercial_treaty - unlock_spies units/{civ}_support_trader