Differential D179 Diff 987 ps/trunk/binaries/data/mods/public/simulation/components/VisionSharing.js
Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/simulation/components/VisionSharing.js
Show First 20 Lines • Show All 113 Lines • ▼ Show 20 Lines | if (!cmpOwnership || cmpOwnership.GetOwner() == player || player <= 0) | ||||
return 0; | return 0; | ||||
let cmpTechnologyManager = QueryPlayerIDInterface(player, IID_TechnologyManager); | let cmpTechnologyManager = QueryPlayerIDInterface(player, IID_TechnologyManager); | ||||
if (!cmpTechnologyManager || !cmpTechnologyManager.CanProduce("special/spy")) | if (!cmpTechnologyManager || !cmpTechnologyManager.CanProduce("special/spy")) | ||||
return 0; | return 0; | ||||
let template = Engine.QueryInterface(SYSTEM_ENTITY, IID_TemplateManager).GetTemplate("special/spy"); | let template = Engine.QueryInterface(SYSTEM_ENTITY, IID_TemplateManager).GetTemplate("special/spy"); | ||||
let costs = {}; | let costs = {}; | ||||
// Additional cost for this owner | |||||
let cmpPlayerBribed = QueryPlayerIDInterface(cmpOwnership.GetOwner()); | |||||
let multiplier = cmpPlayerBribed.GetSpyCostMultiplier(); | |||||
for (let res in template.Cost.Resources) | for (let res in template.Cost.Resources) | ||||
costs[res] = Math.floor(ApplyValueModificationsToTemplate("Cost/Resources/"+res, +template.Cost.Resources[res], player, template)); | costs[res] = Math.floor(multiplier * ApplyValueModificationsToTemplate("Cost/Resources/" + res, +template.Cost.Resources[res], player, template)); | ||||
let cmpPlayer = QueryPlayerIDInterface(player); | let cmpPlayerSpy = QueryPlayerIDInterface(player); | ||||
if (!cmpPlayer || !cmpPlayer.TrySubtractResources(costs)) | if (!cmpPlayerSpy || !cmpPlayerSpy.TrySubtractResources(costs)) | ||||
return 0; | return 0; | ||||
// If no duration given, take it from the spy template and scale it with the ent vision | // If no duration given, take it from the spy template and scale it with the ent vision | ||||
// When no duration argument nor in spy template, it is a permanent spy | // When no duration argument nor in spy template, it is a permanent spy | ||||
let duration = timeLength; | let duration = timeLength; | ||||
if (!duration && template.VisionSharing && template.VisionSharing.Duration) | if (!duration && template.VisionSharing && template.VisionSharing.Duration) | ||||
{ | { | ||||
duration = ApplyValueModificationsToTemplate("VisionSharing/Duration", +template.VisionSharing.Duration, player, template); | duration = ApplyValueModificationsToTemplate("VisionSharing/Duration", +template.VisionSharing.Duration, player, template); | ||||
Show All 39 Lines |
Wildfire Games · Phabricator