Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/gui/session/unit_actions.js
/** | /** | ||||
* Specifies which template should indicate the target location of a player command, | |||||
* given a command type. | |||||
*/ | |||||
var g_TargetMarker = { | |||||
"move": "special/target_marker" | |||||
}; | |||||
/** | |||||
* Which enemy entity types will be attacked on sight when patroling. | * Which enemy entity types will be attacked on sight when patroling. | ||||
*/ | */ | ||||
var g_PatrolTargets = ["Unit"]; | var g_PatrolTargets = ["Unit"]; | ||||
/** | /** | ||||
* List of different actions units can execute, | * List of different actions units can execute, | ||||
* this is mostly used to determine which actions can be executed | * this is mostly used to determine which actions can be executed | ||||
* | * | ||||
Show All 30 Lines | "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, | ||||
"queued": queued | "queued": queued | ||||
}); | }); | ||||
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) | ||||
Show All 24 Lines | "execute": function(target, action, selection, queued) | ||||
"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, | ||||
"queued": queued | "queued": queued | ||||
}); | }); | ||||
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) | ||||
▲ Show 20 Lines • Show All 128 Lines • ▼ Show 20 Lines | "execute": function(target, action, selection, queued) | ||||
"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, | "queued": queued, | ||||
"allowCapture": false | "allowCapture": false | ||||
}); | }); | ||||
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) | ||||
{ | { | ||||
if (!entState.unitAI || !entState.unitAI.canPatrol) | if (!entState.unitAI || !entState.unitAI.canPatrol) | ||||
return false; | return false; | ||||
▲ Show 20 Lines • Show All 81 Lines • ▼ Show 20 Lines | "execute": function(target, action, selection, queued) | ||||
Engine.PostNetworkCommand({ | Engine.PostNetworkCommand({ | ||||
"type": "repair", | "type": "repair", | ||||
"entities": selection, | "entities": selection, | ||||
"target": action.target, | "target": action.target, | ||||
"autocontinue": true, | "autocontinue": true, | ||||
"queued": queued | "queued": queued | ||||
}); | }); | ||||
DrawTargetMarker(target); | |||||
Engine.GuiInterfaceCall("PlaySound", { | Engine.GuiInterfaceCall("PlaySound", { | ||||
"name": "order_repair", | "name": "order_repair", | ||||
"entity": selection[0] | "entity": selection[0] | ||||
}); | }); | ||||
return true; | return true; | ||||
}, | }, | ||||
"getActionInfo": function(entState, targetState) | "getActionInfo": function(entState, targetState) | ||||
▲ Show 20 Lines • Show All 1,133 Lines • ▼ Show 20 Lines | function isUndeletable(entState) | ||||
if (entState.capturePoints && entState.capturePoints[entState.player] < entState.maxCapturePoints / 2) | if (entState.capturePoints && entState.capturePoints[entState.player] < entState.maxCapturePoints / 2) | ||||
return translate("You cannot destroy this entity as you own less than half the capture points"); | return translate("You cannot destroy this entity as you own less than half the capture points"); | ||||
if (!entState.canDelete) | if (!entState.canDelete) | ||||
return translate("This entity is undeletable"); | return translate("This entity is undeletable"); | ||||
return false; | return false; | ||||
} | } | ||||
function DrawTargetMarker(target) | |||||
{ | |||||
Engine.GuiInterfaceCall("AddTargetMarker", { | |||||
"template": g_TargetMarker.move, | |||||
"x": target.x, | |||||
"z": target.z | |||||
}); | |||||
} |
Wildfire Games · Phabricator