Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/session/unit_actions.js
Show First 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | "execute": function(target, action, selection, queued) | ||||
return true; | return true; | ||||
}, | }, | ||||
"getActionInfo": function(entState, targetState) | "getActionInfo": function(entState, targetState) | ||||
{ | { | ||||
return { "possible": true }; | return { "possible": true }; | ||||
}, | }, | ||||
"actionCheck": function(target, selection) | "actionCheck": function(target, selection) | ||||
{ | { | ||||
if (!someUnitAI(selection) || !getActionInfo("move", target).possible) | if (!someUnitAI(selection) || !getActionInfo("move", target, selection).possible) | ||||
return false; | return false; | ||||
return { "type": "move" }; | return { "type": "move" }; | ||||
}, | }, | ||||
"specificness": 12, | "specificness": 12, | ||||
}, | }, | ||||
"attack-move": | "attack-move": | ||||
Show All 25 Lines | "attack-move": | ||||
"getActionInfo": function(entState, targetState) | "getActionInfo": function(entState, targetState) | ||||
{ | { | ||||
return { "possible": true }; | return { "possible": true }; | ||||
}, | }, | ||||
"hotkeyActionCheck": function(target, selection) | "hotkeyActionCheck": function(target, selection) | ||||
{ | { | ||||
if (!someUnitAI(selection) || | if (!someUnitAI(selection) || | ||||
!Engine.HotkeyIsPressed("session.attackmove") || | !Engine.HotkeyIsPressed("session.attackmove") || | ||||
!getActionInfo("attack-move", target).possible) | !getActionInfo("attack-move", target, selection).possible) | ||||
return false; | return false; | ||||
return { | return { | ||||
"type": "attack-move", | "type": "attack-move", | ||||
"cursor": "action-attack-move" | "cursor": "action-attack-move" | ||||
}; | }; | ||||
}, | }, | ||||
"specificness": 30, | "specificness": 30, | ||||
Show All 25 Lines | "getActionInfo": function(entState, targetState) | ||||
return { | return { | ||||
"possible": Engine.GuiInterfaceCall("CanCapture", { | "possible": Engine.GuiInterfaceCall("CanCapture", { | ||||
"entity": entState.id, | "entity": entState.id, | ||||
"target": targetState.id | "target": targetState.id | ||||
}) | }) | ||||
}; | }; | ||||
}, | }, | ||||
"actionCheck": function(target) | "actionCheck": function(target, selection) | ||||
{ | { | ||||
if (!getActionInfo("capture", target).possible) | if (!getActionInfo("capture", target, selection).possible) | ||||
return false; | return false; | ||||
return { | return { | ||||
"type": "capture", | "type": "capture", | ||||
"cursor": "action-capture", | "cursor": "action-capture", | ||||
"target": target | "target": target | ||||
}; | }; | ||||
}, | }, | ||||
Show All 26 Lines | "getActionInfo": function(entState, targetState) | ||||
return { | return { | ||||
"possible": Engine.GuiInterfaceCall("CanAttack", { | "possible": Engine.GuiInterfaceCall("CanAttack", { | ||||
"entity": entState.id, | "entity": entState.id, | ||||
"target": targetState.id | "target": targetState.id | ||||
}) | }) | ||||
}; | }; | ||||
}, | }, | ||||
"hotkeyActionCheck": function(target) | "hotkeyActionCheck": function(target, selection) | ||||
{ | { | ||||
if (!Engine.HotkeyIsPressed("session.attack") || | if (!Engine.HotkeyIsPressed("session.attack") || | ||||
!getActionInfo("attack", target).possible) | !getActionInfo("attack", target, selection).possible) | ||||
return false; | return false; | ||||
return { | return { | ||||
"type": "attack", | "type": "attack", | ||||
"cursor": "action-attack", | "cursor": "action-attack", | ||||
"target": target | "target": target | ||||
}; | }; | ||||
}, | }, | ||||
"actionCheck": function(target) | "actionCheck": function(target, selection) | ||||
{ | { | ||||
if (!getActionInfo("attack", target).possible) | if (!getActionInfo("attack", target, selection).possible) | ||||
return false; | return false; | ||||
return { | return { | ||||
"type": "attack", | "type": "attack", | ||||
"cursor": "action-attack", | "cursor": "action-attack", | ||||
"target": target | "target": target | ||||
}; | }; | ||||
}, | }, | ||||
Show All 20 Lines | "patrol": | ||||
"getActionInfo": function(entState, targetState) | "getActionInfo": function(entState, targetState) | ||||
{ | { | ||||
return { "possible": true }; | return { "possible": true }; | ||||
}, | }, | ||||
"hotkeyActionCheck": function(target, selection) | "hotkeyActionCheck": function(target, selection) | ||||
{ | { | ||||
if (!someUnitAI(selection) || | if (!someUnitAI(selection) || | ||||
!Engine.HotkeyIsPressed("session.patrol") || | !Engine.HotkeyIsPressed("session.patrol") || | ||||
!getActionInfo("patrol", target).possible) | !getActionInfo("patrol", target, selection).possible) | ||||
return false; | return false; | ||||
return { | return { | ||||
"type": "patrol", | "type": "patrol", | ||||
"cursor": "action-patrol", | "cursor": "action-patrol", | ||||
"target": target | "target": target | ||||
}; | }; | ||||
}, | }, | ||||
"preSelectedActionCheck" : function(target) | "preSelectedActionCheck" : function(target, selection) | ||||
{ | { | ||||
if (preSelectedAction != ACTION_PATROL || !getActionInfo("patrol", target).possible) | if (preSelectedAction != ACTION_PATROL || !getActionInfo("patrol", target, selection).possible) | ||||
return false; | return false; | ||||
return { | return { | ||||
"type": "patrol", | "type": "patrol", | ||||
"cursor": "action-patrol", | "cursor": "action-patrol", | ||||
"target": target | "target": target | ||||
}; | }; | ||||
}, | }, | ||||
"specificness": 37, | "specificness": 37, | ||||
Show All 30 Lines | "getActionInfo": function(entState, targetState) | ||||
return false; | return false; | ||||
let healableClasses = entState.heal.healableClasses; | let healableClasses = entState.heal.healableClasses; | ||||
if (!MatchesClassList(targetState.identity.classes, healableClasses)) | if (!MatchesClassList(targetState.identity.classes, healableClasses)) | ||||
return false; | return false; | ||||
return { "possible": true }; | return { "possible": true }; | ||||
}, | }, | ||||
"actionCheck": function(target) | "actionCheck": function(target, selection) | ||||
{ | { | ||||
if (!getActionInfo("heal", target).possible) | if (!getActionInfo("heal", target, selection).possible) | ||||
return false; | return false; | ||||
return { | return { | ||||
"type": "heal", | "type": "heal", | ||||
"cursor": "action-heal", | "cursor": "action-heal", | ||||
"target": target | "target": target | ||||
}; | }; | ||||
}, | }, | ||||
Show All 22 Lines | "build": | ||||
"getActionInfo": function(entState, targetState) | "getActionInfo": function(entState, targetState) | ||||
{ | { | ||||
if (!targetState.foundation || !entState.builder || | if (!targetState.foundation || !entState.builder || | ||||
!playerCheck(entState, targetState, ["Player", "Ally"])) | !playerCheck(entState, targetState, ["Player", "Ally"])) | ||||
return false; | return false; | ||||
return { "possible": true }; | return { "possible": true }; | ||||
}, | }, | ||||
"actionCheck": function(target) | "actionCheck": function(target, selection) | ||||
{ | { | ||||
if (!getActionInfo("build", target).possible) | if (!getActionInfo("build", target, selection).possible) | ||||
return false; | return false; | ||||
return { | return { | ||||
"type": "build", | "type": "build", | ||||
"cursor": "action-build", | "cursor": "action-build", | ||||
"target": target | "target": target | ||||
}; | }; | ||||
}, | }, | ||||
Show All 23 Lines | "repair": | ||||
{ | { | ||||
if (!entState.builder || | if (!entState.builder || | ||||
!targetState.needsRepair && !targetState.foundation || | !targetState.needsRepair && !targetState.foundation || | ||||
!playerCheck(entState, targetState, ["Player", "Ally"])) | !playerCheck(entState, targetState, ["Player", "Ally"])) | ||||
return false; | return false; | ||||
return { "possible": true }; | return { "possible": true }; | ||||
}, | }, | ||||
"preSelectedActionCheck" : function(target) | "preSelectedActionCheck" : function(target, selection) | ||||
{ | { | ||||
if (preSelectedAction != ACTION_REPAIR) | if (preSelectedAction != ACTION_REPAIR) | ||||
return false; | return false; | ||||
if (getActionInfo("repair", target).possible) | if (getActionInfo("repair", target, selection).possible) | ||||
return { | return { | ||||
"type": "repair", | "type": "repair", | ||||
"cursor": "action-repair", | "cursor": "action-repair", | ||||
"target": target | "target": target | ||||
}; | }; | ||||
return { | return { | ||||
"type": "none", | "type": "none", | ||||
"cursor": "action-repair-disabled", | "cursor": "action-repair-disabled", | ||||
"target": null | "target": null | ||||
}; | }; | ||||
}, | }, | ||||
"hotkeyActionCheck": function(target) | "hotkeyActionCheck": function(target, selection) | ||||
{ | { | ||||
if (!Engine.HotkeyIsPressed("session.repair") || | if (!Engine.HotkeyIsPressed("session.repair") || | ||||
!getActionInfo("repair", target).possible) | !getActionInfo("repair", target, selection).possible) | ||||
return false; | return false; | ||||
return { | return { | ||||
"type": "build", | "type": "build", | ||||
"cursor": "action-repair", | "cursor": "action-repair", | ||||
"target": target | "target": target | ||||
}; | }; | ||||
}, | }, | ||||
"actionCheck": function(target) | "actionCheck": function(target, selection) | ||||
{ | { | ||||
if (!getActionInfo("repair", target).possible) | if (!getActionInfo("repair", target, selection).possible) | ||||
return false; | return false; | ||||
return { | return { | ||||
"type": "build", | "type": "build", | ||||
"cursor": "action-repair", | "cursor": "action-repair", | ||||
"target": target | "target": target | ||||
}; | }; | ||||
}, | }, | ||||
Show All 27 Lines | "getActionInfo": function(entState, targetState) | ||||
if (!resource) | if (!resource) | ||||
return false; | return false; | ||||
return { | return { | ||||
"possible": true, | "possible": true, | ||||
"cursor": "action-gather-" + resource | "cursor": "action-gather-" + resource | ||||
}; | }; | ||||
}, | }, | ||||
"actionCheck": function(target) | "actionCheck": function(target, selection) | ||||
{ | { | ||||
let actionInfo = getActionInfo("gather", target); | let actionInfo = getActionInfo("gather", target, selection); | ||||
if (!actionInfo.possible) | if (!actionInfo.possible) | ||||
return false; | return false; | ||||
return { | return { | ||||
"type": "gather", | "type": "gather", | ||||
"cursor": actionInfo.cursor, | "cursor": actionInfo.cursor, | ||||
"target": target | "target": target | ||||
▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | "getActionInfo": function(entState, targetState) | ||||
if (targetState.resourceDropsite.types.indexOf(carriedType) == -1) | if (targetState.resourceDropsite.types.indexOf(carriedType) == -1) | ||||
return false; | return false; | ||||
return { | return { | ||||
"possible": true, | "possible": true, | ||||
"cursor": "action-return-" + carriedType | "cursor": "action-return-" + carriedType | ||||
}; | }; | ||||
}, | }, | ||||
"actionCheck": function(target) | "actionCheck": function(target, selection) | ||||
{ | { | ||||
let actionInfo = getActionInfo("returnresource", target); | let actionInfo = getActionInfo("returnresource", target, selection); | ||||
if (!actionInfo.possible) | if (!actionInfo.possible) | ||||
return false; | return false; | ||||
return { | return { | ||||
"type": "returnresource", | "type": "returnresource", | ||||
"cursor": actionInfo.cursor, | "cursor": actionInfo.cursor, | ||||
"target": target | "target": target | ||||
}; | }; | ||||
▲ Show 20 Lines • Show All 73 Lines • ▼ Show 20 Lines | "getActionInfo": function(entState, targetState) | ||||
break; | break; | ||||
} | } | ||||
return { | return { | ||||
"possible": true, | "possible": true, | ||||
"tooltip": tooltip | "tooltip": tooltip | ||||
}; | }; | ||||
}, | }, | ||||
"actionCheck": function(target) | "actionCheck": function(target, selection) | ||||
{ | { | ||||
let actionInfo = getActionInfo("setup-trade-route", target); | let actionInfo = getActionInfo("setup-trade-route", target, selection); | ||||
if (!actionInfo.possible) | if (!actionInfo.possible) | ||||
return false; | return false; | ||||
return { | return { | ||||
"type": "setup-trade-route", | "type": "setup-trade-route", | ||||
"cursor": "action-setup-trade-route", | "cursor": "action-setup-trade-route", | ||||
"tooltip": actionInfo.tooltip, | "tooltip": actionInfo.tooltip, | ||||
"target": target | "target": target | ||||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | "getActionInfo": function(entState, targetState) | ||||
if (!MatchesClassList(entState.identity.classes, targetState.garrisonHolder.allowedClasses)) | if (!MatchesClassList(entState.identity.classes, targetState.garrisonHolder.allowedClasses)) | ||||
return false; | return false; | ||||
return { | return { | ||||
"possible": true, | "possible": true, | ||||
"tooltip": tooltip | "tooltip": tooltip | ||||
}; | }; | ||||
}, | }, | ||||
"preSelectedActionCheck": function(target) | "preSelectedActionCheck": function(target, selection) | ||||
{ | { | ||||
if (preSelectedAction != ACTION_GARRISON) | if (preSelectedAction != ACTION_GARRISON) | ||||
return false; | return false; | ||||
let actionInfo = getActionInfo("garrison", target); | let actionInfo = getActionInfo("garrison", target, selection); | ||||
if (!actionInfo.possible) | if (!actionInfo.possible) | ||||
return { | return { | ||||
"type": "none", | "type": "none", | ||||
"cursor": "action-garrison-disabled", | "cursor": "action-garrison-disabled", | ||||
"target": null | "target": null | ||||
}; | }; | ||||
return { | return { | ||||
"type": "garrison", | "type": "garrison", | ||||
"cursor": "action-garrison", | "cursor": "action-garrison", | ||||
"tooltip": actionInfo.tooltip, | "tooltip": actionInfo.tooltip, | ||||
"target": target | "target": target | ||||
}; | }; | ||||
}, | }, | ||||
"hotkeyActionCheck": function(target) | "hotkeyActionCheck": function(target, selection) | ||||
{ | { | ||||
let actionInfo = getActionInfo("garrison", target); | let actionInfo = getActionInfo("garrison", target, selection); | ||||
if (!Engine.HotkeyIsPressed("session.garrison") || !actionInfo.possible) | if (!Engine.HotkeyIsPressed("session.garrison") || !actionInfo.possible) | ||||
return false; | return false; | ||||
return { | return { | ||||
"type": "garrison", | "type": "garrison", | ||||
"cursor": "action-garrison", | "cursor": "action-garrison", | ||||
"tooltip": actionInfo.tooltip, | "tooltip": actionInfo.tooltip, | ||||
Show All 26 Lines | "getActionInfo": function(entState, targetState) | ||||
if (!targetState.guard || | if (!targetState.guard || | ||||
!playerCheck(entState, targetState, ["Player", "Ally"]) || | !playerCheck(entState, targetState, ["Player", "Ally"]) || | ||||
!entState.unitAI || !entState.unitAI.canGuard || | !entState.unitAI || !entState.unitAI.canGuard || | ||||
targetState.unitAI && targetState.unitAI.isGuarding) | targetState.unitAI && targetState.unitAI.isGuarding) | ||||
return false; | return false; | ||||
return { "possible": true }; | return { "possible": true }; | ||||
}, | }, | ||||
"preSelectedActionCheck" : function(target) | "preSelectedActionCheck" : function(target, selection) | ||||
{ | { | ||||
if (preSelectedAction != ACTION_GUARD) | if (preSelectedAction != ACTION_GUARD) | ||||
return false; | return false; | ||||
if (getActionInfo("guard", target).possible) | if (getActionInfo("guard", target, selection).possible) | ||||
return { | return { | ||||
"type": "guard", | "type": "guard", | ||||
"cursor": "action-guard", | "cursor": "action-guard", | ||||
"target": target | "target": target | ||||
}; | }; | ||||
return { | return { | ||||
"type": "none", | "type": "none", | ||||
"cursor": "action-guard-disabled", | "cursor": "action-guard-disabled", | ||||
"target": null | "target": null | ||||
}; | }; | ||||
}, | }, | ||||
"hotkeyActionCheck": function(target) | "hotkeyActionCheck": function(target, selection) | ||||
{ | { | ||||
if (!Engine.HotkeyIsPressed("session.guard") || | if (!Engine.HotkeyIsPressed("session.guard") || | ||||
!getActionInfo("guard", target).possible) | !getActionInfo("guard", target, selection).possible) | ||||
return false; | return false; | ||||
return { | return { | ||||
"type": "guard", | "type": "guard", | ||||
"cursor": "action-guard", | "cursor": "action-guard", | ||||
"target": target | "target": target | ||||
}; | }; | ||||
}, | }, | ||||
Show All 16 Lines | "execute": function(target, action, selection, queued) | ||||
"entity": selection[0] | "entity": selection[0] | ||||
}); | }); | ||||
return true; | return true; | ||||
}, | }, | ||||
"hotkeyActionCheck": function(target, selection) | "hotkeyActionCheck": function(target, selection) | ||||
{ | { | ||||
if (!Engine.HotkeyIsPressed("session.guard") || | if (!Engine.HotkeyIsPressed("session.guard") || | ||||
!getActionInfo("remove-guard", target).possible || | !getActionInfo("remove-guard", target, selection).possible || | ||||
!someGuarding(selection)) | !someGuarding(selection)) | ||||
return false; | return false; | ||||
return { | return { | ||||
"type": "remove-guard", | "type": "remove-guard", | ||||
"cursor": "action-remove-guard" | "cursor": "action-remove-guard" | ||||
}; | }; | ||||
}, | }, | ||||
▲ Show 20 Lines • Show All 158 Lines • ▼ Show 20 Lines | "getActionInfo": function(entState, targetState) | ||||
}; | }; | ||||
}, | }, | ||||
"actionCheck": function(target, selection) | "actionCheck": function(target, selection) | ||||
{ | { | ||||
if (someUnitAI(selection) || !someRallyPoints(selection)) | if (someUnitAI(selection) || !someRallyPoints(selection)) | ||||
return false; | return false; | ||||
let actionInfo = getActionInfo("set-rallypoint", target); | let actionInfo = getActionInfo("set-rallypoint", target, selection); | ||||
if (!actionInfo.possible) | if (!actionInfo.possible) | ||||
return false; | return false; | ||||
return { | return { | ||||
"type": "set-rallypoint", | "type": "set-rallypoint", | ||||
"cursor": actionInfo.cursor, | "cursor": actionInfo.cursor, | ||||
"data": actionInfo.data, | "data": actionInfo.data, | ||||
"tooltip": actionInfo.tooltip, | "tooltip": actionInfo.tooltip, | ||||
Show All 25 Lines | "getActionInfo": function(entState, targetState) | ||||
!entState.rallyPoint || !entState.rallyPoint.position) | !entState.rallyPoint || !entState.rallyPoint.position) | ||||
return false; | return false; | ||||
return { "possible": true }; | return { "possible": true }; | ||||
}, | }, | ||||
"actionCheck": function(target, selection) | "actionCheck": function(target, selection) | ||||
{ | { | ||||
if (someUnitAI(selection) || !someRallyPoints(selection) || | if (someUnitAI(selection) || !someRallyPoints(selection) || | ||||
!getActionInfo("unset-rallypoint", target).possible) | !getActionInfo("unset-rallypoint", target, selection).possible) | ||||
return false; | return false; | ||||
return { | return { | ||||
"type": "unset-rallypoint", | "type": "unset-rallypoint", | ||||
"cursor": "action-unset-rally" | "cursor": "action-unset-rally" | ||||
}; | }; | ||||
}, | }, | ||||
"specificness": 11, | "specificness": 11, | ||||
▲ Show 20 Lines • Show All 438 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator