Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/session/unit_actions.js
Show First 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | var g_UnitActions = | ||||
{ | { | ||||
"execute": function(target, action, selection, queued) | "execute": function(target, action, selection, queued) | ||||
{ | { | ||||
Engine.PostNetworkCommand({ | Engine.PostNetworkCommand({ | ||||
"type": "walk", | "type": "walk", | ||||
"entities": selection, | "entities": selection, | ||||
"x": target.x, | "x": target.x, | ||||
"z": target.z, | "z": target.z, | ||||
"target": action.target, | |||||
"queued": queued | "queued": queued | ||||
}); | }); | ||||
if (!action.target) | |||||
DrawTargetMarker(target); | DrawTargetMarker(target); | ||||
Engine.GuiInterfaceCall("PlaySound", { | Engine.GuiInterfaceCall("PlaySound", { | ||||
"name": "order_walk", | "name": "order_walk", | ||||
"entity": selection[0] | "entity": selection[0] | ||||
}); | }); | ||||
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, selection).possible) | if (!someUnitAI(selection) || !getActionInfo("move", target, selection).possible) | ||||
return false; | return false; | ||||
return { "type": "move" }; | return { | ||||
"type": "move", | |||||
"target": target | |||||
}; | |||||
}, | }, | ||||
"specificness": 12, | "specificness": 12, | ||||
}, | }, | ||||
"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, | ||||
bb: why don't do the same here?
also rallypoint (or was there a patch for that already?) and… | |||||
Not Done Inline ActionsAttack-move and patrol are trickier, you'd have to rewrite chunks of UnitAI to use a target rather than position, and I'm not sure it's worth it. (Although I think those need some work anyway, e.g. if a unit is dead when we're trying to attack it, in regular attacking we'll use the attack on a new unit, but in walking-and-fighting we won't so we waste the attack). It could be used in rally point, although usually there's some other action that takes precedence, e.g. gather or garrison, and units that can't do that action already walk to target instead. temple: Attack-move and patrol are trickier, you'd have to rewrite chunks of UnitAI to use a target… | |||||
"targetClasses": targetClasses, | "targetClasses": targetClasses, | ||||
"queued": queued | "queued": queued | ||||
}); | }); | ||||
DrawTargetMarker(target); | DrawTargetMarker(target); | ||||
Engine.GuiInterfaceCall("PlaySound", { | Engine.GuiInterfaceCall("PlaySound", { | ||||
"name": "order_walk", | "name": "order_walk", | ||||
▲ Show 20 Lines • Show All 1,425 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
why don't do the same here?
also rallypoint (or was there a patch for that already?) and patrol (or does it do it already?)