Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/session/unit_actions.js
Show First 20 Lines • Show All 76 Lines • ▼ Show 20 Lines | "move": | ||||
}, | }, | ||||
"actionCheck": function(target, selection) | "actionCheck": function(target, selection) | ||||
{ | { | ||||
if (!someUnitAI(selection) || !getActionInfo("move", target, selection).possible) | if (!someUnitAI(selection) || !getActionInfo("move", target, selection).possible) | ||||
return false; | return false; | ||||
return { "type": "move" }; | return { "type": "move" }; | ||||
}, | }, | ||||
"specificness": 12, | "specificness": 13, | ||||
}, | }, | ||||
"attack-move": | "attack-move": | ||||
{ | { | ||||
"execute": function(target, action, selection, queued) | "execute": function(target, action, selection, queued) | ||||
{ | { | ||||
let targetClasses; | let targetClasses; | ||||
if (Engine.HotkeyIsPressed("session.attackmoveUnit")) | if (Engine.HotkeyIsPressed("session.attackmoveUnit")) | ||||
targetClasses = { "attack": ["Unit"] }; | targetClasses = { "attack": ["Unit"] }; | ||||
else | else | ||||
targetClasses = { "attack": ["Unit", "Structure"] }; | targetClasses = { "attack": ["Unit", "Structure"] }; | ||||
Engine.PostNetworkCommand({ | Engine.PostNetworkCommand({ | ||||
"type": "attack-walk", | "type": "attack-walk", | ||||
"entities": selection, | "entities": selection, | ||||
"x": target.x, | "x": target.x, | ||||
"z": target.z, | "z": target.z, | ||||
"targetClasses": targetClasses, | "targetClasses": targetClasses, | ||||
"prefAttackTypes": ["!Capture"], | |||||
"queued": queued | "queued": queued | ||||
}); | }); | ||||
DrawTargetMarker(target); | DrawTargetMarker(target); | ||||
Engine.GuiInterfaceCall("PlaySound", { | Engine.GuiInterfaceCall("PlaySound", { | ||||
"name": "order_walk", | "name": "order_walk", | ||||
"entity": selection[0] | "entity": selection[0] | ||||
Show All 15 Lines | "hotkeyActionCheck": function(target, selection) | ||||
return { | return { | ||||
"type": "attack-move", | "type": "attack-move", | ||||
"cursor": "action-attack-move" | "cursor": "action-attack-move" | ||||
}; | }; | ||||
}, | }, | ||||
"specificness": 30, | "specificness": 30, | ||||
}, | }, | ||||
"capture": | "attack-capture": | ||||
{ | { | ||||
"execute": function(target, action, selection, queued) | "execute": function(target, action, selection, queued) | ||||
{ | { | ||||
Engine.PostNetworkCommand({ | Engine.PostNetworkCommand({ | ||||
"type": "attack", | "type": "attack", | ||||
"entities": selection, | "entities": selection, | ||||
"target": action.target, | "target": action.target, | ||||
"allowCapture": true, | "prefAttackTypes": ["Capture"], | ||||
"queued": queued | "queued": queued | ||||
}); | }); | ||||
Engine.GuiInterfaceCall("PlaySound", { | Engine.GuiInterfaceCall("PlaySound", { | ||||
"name": "order_attack", | "name": "order_attack", | ||||
"entity": selection[0] | "entity": selection[0] | ||||
}); | }); | ||||
Show All 9 Lines | "getActionInfo": function(entState, targetState) | ||||
"entity": entState.id, | "entity": entState.id, | ||||
"target": targetState.id, | "target": targetState.id, | ||||
"types": ["Capture"] | "types": ["Capture"] | ||||
}) | }) | ||||
}; | }; | ||||
}, | }, | ||||
"actionCheck": function(target, selection) | "actionCheck": function(target, selection) | ||||
{ | { | ||||
if (!getActionInfo("capture", target, selection).possible) | if (!getActionInfo("attack-capture", target, selection).possible) | ||||
return false; | return false; | ||||
return { | return { | ||||
"type": "capture", | "type": "attack-capture", | ||||
"cursor": "action-capture", | "cursor": "action-attack-capture", | ||||
"target": target | "target": target | ||||
}; | }; | ||||
}, | }, | ||||
"specificness": 9, | "specificness": 7, | ||||
}, | }, | ||||
"attack": | "attack-nocapture": | ||||
{ | { | ||||
"execute": function(target, action, selection, queued) | "execute": function(target, action, selection, queued) | ||||
{ | { | ||||
Engine.PostNetworkCommand({ | Engine.PostNetworkCommand({ | ||||
"type": "attack", | "type": "attack", | ||||
"entities": selection, | "entities": selection, | ||||
"target": action.target, | "target": action.target, | ||||
"queued": queued, | "prefAttackTypes": ["!Capture"], | ||||
"allowCapture": false | "queued": queued | ||||
}); | }); | ||||
Engine.GuiInterfaceCall("PlaySound", { | Engine.GuiInterfaceCall("PlaySound", { | ||||
"name": "order_attack", | "name": "order_attack", | ||||
"entity": selection[0] | "entity": selection[0] | ||||
}); | }); | ||||
return true; | return true; | ||||
Show All 9 Lines | "getActionInfo": function(entState, targetState) | ||||
"target": targetState.id, | "target": targetState.id, | ||||
"types": ["!Capture"] | "types": ["!Capture"] | ||||
}) | }) | ||||
}; | }; | ||||
}, | }, | ||||
"hotkeyActionCheck": function(target, selection) | "hotkeyActionCheck": function(target, selection) | ||||
{ | { | ||||
if (!Engine.HotkeyIsPressed("session.attack") || | if (!Engine.HotkeyIsPressed("session.attack") || | ||||
!getActionInfo("attack", target, selection).possible) | !getActionInfo("attack-nocapture", target, selection).possible) | ||||
return false; | return false; | ||||
return { | return { | ||||
"type": "attack-nocapture", | |||||
"cursor": "action-attack-melee", | |||||
"target": target | |||||
}; | |||||
}, | |||||
"actionCheck": function(target, selection) | |||||
{ | |||||
if (!getActionInfo("attack-nocapture", target, selection).possible) | |||||
return false; | |||||
return { | |||||
"type": "attack-nocapture", | |||||
"cursor": "action-attack-melee", | |||||
"target": target | |||||
}; | |||||
}, | |||||
"specificness": 8, | |||||
}, | |||||
"attack-melee": | |||||
{ | |||||
"execute": function(target, action, selection, queued) | |||||
{ | |||||
Engine.PostNetworkCommand({ | |||||
"type": "attack", | "type": "attack", | ||||
"cursor": "action-attack", | "entities": selection, | ||||
"target": action.target, | |||||
"prefAttackTypes": ["Melee"], | |||||
"queued": queued | |||||
}); | |||||
Engine.GuiInterfaceCall("PlaySound", { | |||||
"name": "order_attack", | |||||
"entity": selection[0] | |||||
}); | |||||
return true; | |||||
}, | |||||
"getActionInfo": function(entState, targetState) | |||||
{ | |||||
if (!entState.attack || !targetState.hitpoints) | |||||
return false; | |||||
return { | |||||
"possible": Engine.GuiInterfaceCall("CanAttack", { | |||||
"entity": entState.id, | |||||
"target": targetState.id, | |||||
"types": ["Melee"] | |||||
}) | |||||
}; | |||||
}, | |||||
"hotkeyActionCheck": function(target, selection) | |||||
{ | |||||
if (!Engine.HotkeyIsPressed("session.meleeattack") || !getActionInfo("attack-melee", target, selection).possible) | |||||
return false; | |||||
return { | |||||
"type": "attack-melee", | |||||
"cursor": "action-attack-melee", | |||||
"target": target | "target": target | ||||
}; | }; | ||||
}, | }, | ||||
"actionCheck": function(target, selection) | "actionCheck": function(target, selection) | ||||
{ | { | ||||
if (!getActionInfo("attack", target, selection).possible) | if (!getActionInfo("attack-melee", target, selection).possible) | ||||
return false; | return false; | ||||
return { | return { | ||||
"type": "attack-melee", | |||||
"cursor": "action-attack-melee", | |||||
"target": target | |||||
}; | |||||
}, | |||||
"specificness": 9, | |||||
}, | |||||
"attack-ranged": | |||||
{ | |||||
"execute": function(target, action, selection, queued) | |||||
{ | |||||
Engine.PostNetworkCommand({ | |||||
"type": "attack", | "type": "attack", | ||||
"cursor": "action-attack", | "entities": selection, | ||||
"target": action.target, | |||||
"prefAttackTypes": ["Ranged"], | |||||
"queued": queued | |||||
}); | |||||
Engine.GuiInterfaceCall("PlaySound", { | |||||
"name": "order_attack", | |||||
"entity": selection[0] | |||||
}); | |||||
return true; | |||||
}, | |||||
"getActionInfo": function(entState, targetState) | |||||
{ | |||||
if (!entState.attack || !targetState.hitpoints) | |||||
return false; | |||||
return { | |||||
"possible": Engine.GuiInterfaceCall("CanAttack", { | |||||
"entity": entState.id, | |||||
"target": targetState.id, | |||||
"types": ["Ranged"] | |||||
}) | |||||
}; | |||||
}, | |||||
"hotkeyActionCheck": function(target, selection) | |||||
{ | |||||
if (!Engine.HotkeyIsPressed("session.rangedattack") || !getActionInfo("attack-ranged", target, selection).possible) | |||||
return false; | |||||
return { | |||||
"type": "attack-ranged", | |||||
"cursor": "action-attack-ranged", | |||||
"target": target | |||||
}; | |||||
}, | |||||
"actionCheck": function(target, selection) | |||||
{ | |||||
if (!getActionInfo("attack-ranged", target, selection).possible) | |||||
return false; | |||||
return { | |||||
"type": "attack-ranged", | |||||
"cursor": "action-attack-ranged", | |||||
"target": target | "target": target | ||||
}; | }; | ||||
}, | }, | ||||
"specificness": 10, | "specificness": 10, | ||||
}, | }, | ||||
bb: meh | |||||
"patrol": | "patrol": | ||||
{ | { | ||||
"execute": function(target, action, selection, queued) | "execute": function(target, action, selection, queued) | ||||
{ | { | ||||
Engine.PostNetworkCommand({ | Engine.PostNetworkCommand({ | ||||
"type": "patrol", | "type": "patrol", | ||||
"entities": selection, | "entities": selection, | ||||
"x": target.x, | "x": target.x, | ||||
"z": target.z, | "z": target.z, | ||||
"target": action.target, | "target": action.target, | ||||
"targetClasses": { "attack": g_PatrolTargets }, | "targetClasses": { "attack": g_PatrolTargets }, | ||||
"queued": queued, | "prefAttackTypes": ["!Capture"], | ||||
"allowCapture": false | "queued": queued | ||||
}); | }); | ||||
DrawTargetMarker(target); | DrawTargetMarker(target); | ||||
Engine.GuiInterfaceCall("PlaySound", { "name": "order_patrol", "entity": selection[0] }); | Engine.GuiInterfaceCall("PlaySound", { "name": "order_patrol", "entity": selection[0] }); | ||||
return true; | return true; | ||||
}, | }, | ||||
"getActionInfo": function(entState, targetState) | "getActionInfo": function(entState, targetState) | ||||
▲ Show 20 Lines • Show All 70 Lines • ▼ Show 20 Lines | "actionCheck": function(target, selection) | ||||
return false; | return false; | ||||
return { | return { | ||||
"type": "heal", | "type": "heal", | ||||
"cursor": "action-heal", | "cursor": "action-heal", | ||||
"target": target | "target": target | ||||
}; | }; | ||||
}, | }, | ||||
"specificness": 7, | "specificness": 6, | ||||
}, | }, | ||||
"repair": | "repair": | ||||
{ | { | ||||
"execute": function(target, action, selection, queued) | "execute": function(target, action, selection, queued) | ||||
{ | { | ||||
Engine.PostNetworkCommand({ | Engine.PostNetworkCommand({ | ||||
"type": "repair", | "type": "repair", | ||||
▲ Show 20 Lines • Show All 294 Lines • ▼ Show 20 Lines | "getActionInfo": function(entState, targetState) | ||||
let extraCount = 0; | let extraCount = 0; | ||||
if (entState.garrisonHolder) | if (entState.garrisonHolder) | ||||
extraCount += entState.garrisonHolder.garrisonedEntitiesCount; | extraCount += entState.garrisonHolder.garrisonedEntitiesCount; | ||||
if (targetState.garrisonHolder.garrisonedEntitiesCount + extraCount >= targetState.garrisonHolder.capacity) | if (targetState.garrisonHolder.garrisonedEntitiesCount + extraCount >= targetState.garrisonHolder.capacity) | ||||
tooltip = coloredText(tooltip, "orange"); | tooltip = coloredText(tooltip, "orange"); | ||||
//TODO check for attackTypes | |||||
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 | ||||
}; | }; | ||||
}, | }, | ||||
▲ Show 20 Lines • Show All 253 Lines • ▼ Show 20 Lines | "getActionInfo": function(entState, targetState) | ||||
} | } | ||||
} | } | ||||
else if ((targetState.needsRepair || targetState.foundation) && playerCheck(entState, targetState, ["Ally"])) | else if ((targetState.needsRepair || targetState.foundation) && playerCheck(entState, targetState, ["Ally"])) | ||||
{ | { | ||||
data.command = "repair"; | data.command = "repair"; | ||||
data.target = targetState.id; | data.target = targetState.id; | ||||
cursor = "action-repair"; | cursor = "action-repair"; | ||||
} | } | ||||
// TODO other attackTypes should be allowed too, maybe this needs a rewrite of the rallypoint handling | |||||
else if (playerCheck(entState, targetState, ["Enemy"])) | else if (playerCheck(entState, targetState, ["Enemy"])) | ||||
{ | { | ||||
data.target = targetState.id; | data.target = targetState.id; | ||||
data.command = "attack"; | data.command = "attack-nocapture"; | ||||
cursor = "action-attack"; | cursor = "action-attack-melee"; | ||||
Not Done Inline ActionsAttack-walk? Freagarach: Attack-walk? | |||||
Done Inline Actionsmelee, capture and ranged mostly bb: melee, capture and ranged mostly | |||||
Not Done Inline ActionsI think the former-me meant that if we use attack-walk the entity itself will choose the best attack type ^^' Freagarach: I think the former-me meant that if we use attack-walk the entity itself will choose the best… | |||||
Done Inline Actionsdon't see how we would end up in attack-walk since we send an attack command... (and yes we will choose an attacktype here from the nocapture stuff) attack-walk should also be made possible from rallypoints if it ins't bb: don't see how we would end up in `attack-walk` since we send an `attack` command... (and yes we… | |||||
} | } | ||||
// Don't allow the rally point to be set on any of the currently selected entities (used for unset) | // Don't allow the rally point to be set on any of the currently selected entities (used for unset) | ||||
// except if the autorallypoint hotkey is pressed and the target can produce entities | // except if the autorallypoint hotkey is pressed and the target can produce entities | ||||
if (!Engine.HotkeyIsPressed("session.autorallypoint") || | if (!Engine.HotkeyIsPressed("session.autorallypoint") || | ||||
!targetState.production || | !targetState.production || | ||||
!targetState.production.entities.length) | !targetState.production.entities.length) | ||||
for (let ent in g_Selection.selected) | for (let ent in g_Selection.selected) | ||||
Show All 21 Lines | "actionCheck": function(target, selection) | ||||
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, | ||||
"position": actionInfo.position | "position": actionInfo.position | ||||
}; | }; | ||||
}, | }, | ||||
"specificness": 6, | "specificness": 5, | ||||
}, | }, | ||||
"unset-rallypoint": | "unset-rallypoint": | ||||
{ | { | ||||
"execute": function(target, action, selection, queued) | "execute": function(target, action, selection, queued) | ||||
{ | { | ||||
Engine.PostNetworkCommand({ | Engine.PostNetworkCommand({ | ||||
"type": "unset-rallypoint", | "type": "unset-rallypoint", | ||||
▲ Show 20 Lines • Show All 574 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
meh