diff --git a/lua/SimCallbacks.lua b/lua/SimCallbacks.lua index 9fbf746aa45..9f9f818c68f 100644 --- a/lua/SimCallbacks.lua +++ b/lua/SimCallbacks.lua @@ -826,6 +826,38 @@ do end +do + + ---@param data { Enable: boolean, ShowMsg: boolean } + ---@param selection Unit[] + Callbacks.ForceReclaim = function(data, selection) + -- verify selection + selection = SecureUnits(selection) + if (not selection) or TableEmpty(selection) then + return + end + + -- verify we have engineers + local engineers = EntityCategoryFilterDown(categories.ENGINEER, selection) + if TableEmpty(engineers) then + return + end + + for k, unit in engineers do + unit:ForceReclaim(data.Enable) + end + + if data.ShowMsg then + if data.Enable == true then + print(string.format("Force reclaim ENABLED for %d engineers", table.getn(engineers))) + else + print(string.format("Force reclaim DISABLED for %d engineers", table.getn(engineers))) + end + end + end +end + + --#endregion diff --git a/lua/keymap/keyactions.lua b/lua/keymap/keyactions.lua index 77270012582..208e7271523 100755 --- a/lua/keymap/keyactions.lua +++ b/lua/keymap/keyactions.lua @@ -1653,7 +1653,23 @@ local keyActionsOrdersAdvanced = { ['shift_discharge'] = { action = 'UI_Lua import("/lua/keymap/misckeyactions.lua").DischargeShields()', category = 'ordersAdvanced', - } + }, + ['enable_force_reclaim'] = { + action = 'UI_Lua import("/lua/keymap/misckeyactions.lua").SetForceReclaim(true)', + category = 'ordersAdvanced', + }, + ['shift_enable_force_reclaim'] = { + action = 'UI_Lua import("/lua/keymap/misckeyactions.lua").SetForceReclaim(true)', + category = 'ordersAdvanced', + }, + ['disable_force_reclaim'] = { + action = 'UI_Lua import("/lua/keymap/misckeyactions.lua").SetForceReclaim(false)', + category = 'ordersAdvanced', + }, + ['shift_disable_force_reclaim'] = { + action = 'UI_Lua import("/lua/keymap/misckeyactions.lua").SetForceReclaim(false)', + category = 'ordersAdvanced', + }, } local keyActionsOrdersQueueBased = { diff --git a/lua/keymap/keydescriptions.lua b/lua/keymap/keydescriptions.lua index 7ff7890c52f..8ac9644026a 100755 --- a/lua/keymap/keydescriptions.lua +++ b/lua/keymap/keydescriptions.lua @@ -559,6 +559,11 @@ keyDescriptions = { ['shift_load_transports_clear'] = 'Load into transports. Applies immediately', ['copy_orders'] = 'Copy orders of the unit the mouse is on top of', ['shift_copy_orders'] = 'Copy orders of the unit the mouse is on top of', + + ['enable_force_reclaim'] = 'Enable "Force reclaim" for selected units.', + ['disable_force_reclaim'] = 'Disable "Force reclaim" for selected units.', + ['shift_enable_force_reclaim'] = 'Enable "Force reclaim" for selected units.', + ['shift_disable_force_reclaim'] = 'Disable "Force reclaim" for selected units', ['select_surface_bombers'] = 'Select all Bombers (Normal)', ['select_torpedo_bombers'] = 'Select all Bombers (Torpedo)', diff --git a/lua/keymap/misckeyactions.lua b/lua/keymap/misckeyactions.lua index 8d1bf7ac75c..12194e19f4a 100644 --- a/lua/keymap/misckeyactions.lua +++ b/lua/keymap/misckeyactions.lua @@ -557,6 +557,10 @@ AIPlatoonSimpleStructureBehavior = function() SimCallback({ Func = 'AIPlatoonSimpleStructureBehavior', Args = {} }, true) end +function SetForceReclaim(enable, showMsg) + SimCallback({ Func = 'ForceReclaim', Args = { Enable = enable, ShowMsg = showMsg or true} }, true) +end + StoreCameraPosition = function() local camera = GetCamera('WorldCamera') local settings = camera:SaveSettings()