Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/simulation/helpers/Commands.js
Show First 20 Lines • Show All 776 Lines • ▼ Show 20 Lines | var g_Commands = { | ||||
{ | { | ||||
let cmpRangeManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager); | let cmpRangeManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager); | ||||
let ent = pickRandom(cmpRangeManager.GetEntitiesByPlayer(cmd.player).filter(ent => { | let ent = pickRandom(cmpRangeManager.GetEntitiesByPlayer(cmd.player).filter(ent => { | ||||
let cmpVisionSharing = Engine.QueryInterface(ent, IID_VisionSharing); | let cmpVisionSharing = Engine.QueryInterface(ent, IID_VisionSharing); | ||||
return cmpVisionSharing && cmpVisionSharing.IsBribable() && !cmpVisionSharing.ShareVisionWith(player); | return cmpVisionSharing && cmpVisionSharing.IsBribable() && !cmpVisionSharing.ShareVisionWith(player); | ||||
})); | })); | ||||
let cmpGUIInterface = Engine.QueryInterface(SYSTEM_ENTITY, IID_GuiInterface); | let cmpGUIInterface = Engine.QueryInterface(SYSTEM_ENTITY, IID_GuiInterface); | ||||
if (ent) | |||||
{ | |||||
Engine.QueryInterface(ent, IID_VisionSharing).AddSpy(cmd.source); | |||||
cmpGUIInterface.PushNotification({ | cmpGUIInterface.PushNotification({ | ||||
"type": "spy-response", | "type": "spy-response", | ||||
"players": [player], | "players": [player], | ||||
"target": cmd.player, | |||||
"entity": ent | "entity": ent | ||||
}); | }); | ||||
} | if (ent) | ||||
Engine.QueryInterface(ent, IID_VisionSharing).AddSpy(cmd.source); | |||||
else | else | ||||
{ | { | ||||
let template = Engine.QueryInterface(SYSTEM_ENTITY, IID_TemplateManager).GetTemplate("special/spy"); | let template = Engine.QueryInterface(SYSTEM_ENTITY, IID_TemplateManager).GetTemplate("special/spy"); | ||||
IncurBribeCost(template, player, cmd.player, true); | IncurBribeCost(template, player, cmd.player, true); | ||||
// update statistics for failed bribes | // update statistics for failed bribes | ||||
let cmpBribesStatisticsTracker = QueryPlayerIDInterface(player, IID_StatisticsTracker); | let cmpBribesStatisticsTracker = QueryPlayerIDInterface(player, IID_StatisticsTracker); | ||||
if (cmpBribesStatisticsTracker) | if (cmpBribesStatisticsTracker) | ||||
cmpBribesStatisticsTracker.IncreaseFailedBribesCounter(); | cmpBribesStatisticsTracker.IncreaseFailedBribesCounter(); | ||||
▲ Show 20 Lines • Show All 932 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator