diff --git a/LuaRules/Configs/customcmds.lua b/LuaRules/Configs/customcmds.lua index 9538a4a60a..ed33cdce5a 100644 --- a/LuaRules/Configs/customcmds.lua +++ b/LuaRules/Configs/customcmds.lua @@ -99,7 +99,8 @@ local commands = { FIELD_FAC_SELECT = 38693, FIELD_FAC_UNIT_TYPE = 38694, FIELD_FAC_QUEUELESS = 38695, - + IMMEDIATETAKEOFF = 39384, -- Airpad abort. + -- terraform RAMP = 39734, LEVEL = 39736, diff --git a/LuaRules/Gadgets/unit_refuel_pad_handler.lua b/LuaRules/Gadgets/unit_refuel_pad_handler.lua index fee7cc4561..6e40958a36 100644 --- a/LuaRules/Gadgets/unit_refuel_pad_handler.lua +++ b/LuaRules/Gadgets/unit_refuel_pad_handler.lua @@ -37,6 +37,7 @@ local mcSetPosition = Spring.MoveCtrl.SetPosition local mcSetRotation = Spring.MoveCtrl.SetRotation local mcDisable = Spring.MoveCtrl.Disable local mcEnable = Spring.MoveCtrl.Enable +local CMD_IMMEDIATETAKEOFF = Spring.Utilities.CMD.IMMEDIATETAKEOFF local coroutine = coroutine local Sleep = coroutine.yield @@ -59,6 +60,24 @@ local min = math.min local mobilePadDefs = {} +local takeoffCMD = { + id = CMD_IMMEDIATETAKEOFF, + name = "Takeoff", + action = "takeoff", + cursor = 'Repair', + type = CMDTYPE.ICON, +} + +local giveTakeOffCommandToUnits = {} + +for i = 1, #UnitDefs do + local unitDef = UnitDefs[i] + local movetype = Spring.Utilities.getMovetype(unitDef) + if (movetype == 1 or movetype == 0) and (not Spring.Utilities.tobool(unitDef.customParams.cantuseairpads)) then + giveTakeOffCommandToUnits[i] = true + end +end + for unitDefID, ud in pairs(UnitDefs) do if ud.customParams.ispad and (not ud.isImmobile) then mobilePadDefs[unitDefID] = true @@ -608,3 +627,27 @@ end function gadget:GameFrame(f) UpdateCoroutines() end + +function gadget:AllowCommand_GetWantedCommand() + return {[CMD_IMMEDIATETAKEOFF] = true} +end + +function gadget:AllowCommand(unitID, unitDefID, unitTeam, cmdID, cmdParams, cmdOptions) + --local isMoveCommand = (cmdID == CMD.MOVE or cmdID == CMD_RAW_MOVE) + if landingUnit[unitID] then -- not one of us. + GG.LandAborted(unitID) + local cmdID, _, cmdTag = Spring.GetUnitCurrentCommand(unitID) + if cmdID == CMD_REARM or cmdID == CMD_FIND_PAD then + Spring.GiveOrderToUnit(unitID, CMD.REMOVE, cmdTag, 0) + end + end + return false + --elseif isMoveCommand and cmdOptions.shift == false and not landingUnit.landed then -- user wants to move somewhere else. + --landingUnit[unitID].abort = true +end + +function gadget:UnitCreated(unitID, unitDefID, unitTeam) + if giveTakeOffCommandToUnits[unitDefID] then + Spring.InsertUnitCmdDesc(unitID, takeoffCMD) + end +end diff --git a/LuaUI/Configs/integral_menu_commands_orders.lua b/LuaUI/Configs/integral_menu_commands_orders.lua index 51544ba830..76d73e07f0 100644 --- a/LuaUI/Configs/integral_menu_commands_orders.lua +++ b/LuaUI/Configs/integral_menu_commands_orders.lua @@ -60,6 +60,7 @@ local cmdPosDef = { [CMD_EMBARK] = {pos = 13, priority = 5}, [CMD_DISEMBARK] = {pos = 13, priority = 6}, [CMD_EXCLUDE_PAD] = {pos = 13, priority = 7}, + [CMD_IMMEDIATETAKEOFF] = {pos = 13, priority = 8}, -- States [CMD.REPEAT] = {pos = 1, priority = 1}, diff --git a/LuaUI/Configs/integral_menu_config.lua b/LuaUI/Configs/integral_menu_config.lua index e5354841bf..cec6a8452a 100644 --- a/LuaUI/Configs/integral_menu_config.lua +++ b/LuaUI/Configs/integral_menu_config.lua @@ -83,6 +83,7 @@ local commandDisplayConfig = { [CMD_JUMP] = {texture = imageDir .. 'Bold/jump.png'}, [CMD_FIND_PAD] = {texture = imageDir .. 'Bold/rearm.png', tooltip = "Resupply: Return to nearest Airpad for repairs and, for bombers, ammo."}, + [CMD_IMMEDIATETAKEOFF] = {texture = imageDir .. 'takeoff.png', tooltip = "Abort Landing\nImmediately take off from airpads or abort landing."}, [CMD_EXCLUDE_PAD] = {texture = imageDir .. 'Bold/excludeairpad.png', tooltip = "Exclude Airpad: Toggle whether any of your aircraft use the targeted airpad."}, [CMD_FIELD_FAC_SELECT] = {texture = imageDir .. 'Bold/fac_select.png', tooltip = "Copy Factory Blueprint: Copy a production option from target functional friendly factory."}, @@ -93,7 +94,7 @@ local commandDisplayConfig = { [CMD_ONECLICK_WEAPON] = {},--texture = imageDir .. 'Bold/action.png'}, [CMD_UNIT_SET_TARGET_CIRCLE] = {texture = imageDir .. 'Bold/settarget.png'}, [CMD_UNIT_CANCEL_TARGET] = {texture = imageDir .. 'Bold/canceltarget.png'}, - + [CMD_ABANDON_PW] = {texture = imageDir .. 'Bold/drop_beacon.png'}, [CMD_PLACE_BEACON] = {texture = imageDir .. 'Bold/drop_beacon.png'}, diff --git a/LuaUI/Images/commands/takeoff.png b/LuaUI/Images/commands/takeoff.png new file mode 100644 index 0000000000..7a88d30409 Binary files /dev/null and b/LuaUI/Images/commands/takeoff.png differ