Index: binaries/data/mods/public/gui/session/input.js =================================================================== --- binaries/data/mods/public/gui/session/input.js +++ binaries/data/mods/public/gui/session/input.js @@ -1258,11 +1258,29 @@ var selection = g_Selection.toList(); + const orderone = Engine.HotkeyIsPressed("session.orderone"); var queued = Engine.HotkeyIsPressed("session.queue"); - if (g_UnitActions[action.type] && g_UnitActions[action.type].execute) - return g_UnitActions[action.type].execute(target, action, selection, queued); - error("Invalid action.type " + action.type); - return false; + if (!(g_UnitActions[action.type] && g_UnitActions[action.type].execute)) + { + error("Invalid action.type " + action.type); + return false; + } + // Partly duplicated from doAction() + if (orderone) + { + // pick the first unit that can do this order. + const unit = selection + .find(entity => ["preSelectedActionCheck", "hotkeyActionCheck", "actionCheck"] + .some(method => + g_UnitActions[action.type][method] && + g_UnitActions[action.type][method](action.target || undefined, [entity])) + ); + if (unit) { + selection = [unit]; + g_Selection.removeList(selection); + } + } + return g_UnitActions[action.type].execute(target, action, selection, queued); } function getEntityLimitAndCount(playerState, entType)