Changeset View
Standalone View
binaries/data/mods/public/simulation/helpers/Commands.js
Show First 20 Lines • Show All 746 Lines • ▼ Show 20 Lines | "attack-request": function(player, cmd, data) | ||||
}); | }); | ||||
// And send an attackRequest event to the AIs | // And send an attackRequest event to the AIs | ||||
let cmpAIInterface = Engine.QueryInterface(SYSTEM_ENTITY, IID_AIInterface); | let cmpAIInterface = Engine.QueryInterface(SYSTEM_ENTITY, IID_AIInterface); | ||||
if (cmpAIInterface) | if (cmpAIInterface) | ||||
cmpAIInterface.PushEvent("AttackRequest", cmd); | cmpAIInterface.PushEvent("AttackRequest", cmd); | ||||
}, | }, | ||||
"spy-request": function(player, cmd, data) | |||||
{ | |||||
let cmpRangeManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager); | |||||
let ents = cmpRangeManager.GetEntitiesByPlayer(cmd.target).filter(ent => { | |||||
elexis: **TODO: **`cmd.target` is associated with entities in other commands like attack, heal, repair… | |||||
Not Done Inline Actionsok mimo: ok | |||||
let cmpVisionSharing = Engine.QueryInterface(ent, IID_VisionSharing); | |||||
return cmpVisionSharing && cmpVisionSharing.IsBribable(); | |||||
}); | |||||
Not Done Inline ActionsWhat about filtering out the units that are already spying for the player? Imarok: What about filtering out the units that are already spying for the player?
(So that no unit… | |||||
Not Done Inline Actionsok, i will add a filter for units already sharing los with the player. mimo: ok, i will add a filter for units already sharing los with the player. | |||||
let ent = pickRandom(ents); | |||||
Not Done Inline Actionstiny todo: avoid variable which is used only once let ent = pickRandom(rangeManStuff.filter(...)) \n elexis: tiny todo: avoid variable which is used only once
let ent = pickRandom(rangeManStuff.filter(... | |||||
Not Done Inline Actionsagree to avoid it in general, but here i think it make it more readable. mimo: agree to avoid it in general, but here i think it make it more readable. | |||||
Not Done Inline Actions(Not sure why let ent = pickRandom(cmpRangeManager.GetEntitiesByPlayer(cmd.target).filter(ent => { would be harder to read, but not important) elexis: (Not sure why `let ent = pickRandom(cmpRangeManager.GetEntitiesByPlayer(cmd.target).filter(ent… | |||||
if (ent) | |||||
Engine.QueryInterface(ent, IID_VisionSharing).AddSpy(cmd.source, 10000); | |||||
else | |||||
notifySpyFailure(player); | |||||
Not Done Inline Actions(Is this visible in 1024x768 if the diplo dialog is opened? Might not be in the future. Anyway, ack) elexis: (Is this visible in 1024x768 if the diplo dialog is opened? Might not be in the future. Anyway… | |||||
}, | |||||
"dialog-answer": function(player, cmd, data) | "dialog-answer": function(player, cmd, data) | ||||
{ | { | ||||
// Currently nothing. Triggers can read it anyway, and send this | // Currently nothing. Triggers can read it anyway, and send this | ||||
// message to any component you like. | // message to any component you like. | ||||
}, | }, | ||||
"set-dropsite-sharing": function(player, cmd, data) | "set-dropsite-sharing": function(player, cmd, data) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | cmpGUIInterface.PushNotification({ | ||||
"type": "text", | "type": "text", | ||||
"players": [player], | "players": [player], | ||||
"message": "You can't raise the alert to a higher level!", | "message": "You can't raise the alert to a higher level!", | ||||
"translateMessage": true | "translateMessage": true | ||||
}); | }); | ||||
} | } | ||||
/** | /** | ||||
* Sends a GUI notification when no units to bribe | |||||
*/ | |||||
function notifySpyFailure(player) | |||||
Not Done Inline Actionstiny todo: Do we need a function for this? It's only used in one place and not sure if it's going to be reused elexis: tiny todo:
Do we need a function for this? It's only used in one place and not sure if it's… | |||||
Not Done Inline Actionsok that was copied from other notifyFailure in this function, but agreed that it's not needed. mimo: ok that was copied from other notifyFailure in this function, but agreed that it's not needed. | |||||
{ | |||||
var cmpGUIInterface = Engine.QueryInterface(SYSTEM_ENTITY, IID_GuiInterface); | |||||
cmpGUIInterface.PushNotification({ | |||||
"type": "text", | |||||
"players": [player], | |||||
"message": "There are no bribable units", | |||||
Not Done Inline ActionsTODO: markForTranslation! elexis: **TODO:** markForTranslation! | |||||
Not Done Inline Actionsok mimo: ok | |||||
"translateMessage": true | |||||
}); | |||||
} | |||||
/** | |||||
* Get some information about the formations used by entities. | * Get some information about the formations used by entities. | ||||
* The entities must have a UnitAI component. | * The entities must have a UnitAI component. | ||||
*/ | */ | ||||
function ExtractFormations(ents) | function ExtractFormations(ents) | ||||
{ | { | ||||
var entities = []; // subset of ents that have UnitAI | var entities = []; // subset of ents that have UnitAI | ||||
var members = {}; // { formationentity: [ent, ent, ...], ... } | var members = {}; // { formationentity: [ent, ent, ...], ... } | ||||
for (let ent of ents) | for (let ent of ents) | ||||
▲ Show 20 Lines • Show All 813 Lines • Show Last 20 Lines |
TODO: cmd.target is associated with entities in other commands like attack, heal, repair, garrison and more.
The right name would be cmd.player (like with tributes and diplomacy changes) in my opinion. (The attack request one has that collision too)