Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion LuaRules/Configs/customcmds.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
43 changes: 43 additions & 0 deletions LuaRules/Gadgets/unit_refuel_pad_handler.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
1 change: 1 addition & 0 deletions LuaUI/Configs/integral_menu_commands_orders.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down
3 changes: 2 additions & 1 deletion LuaUI/Configs/integral_menu_config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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."},
Expand All @@ -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'},
Expand Down
Binary file added LuaUI/Images/commands/takeoff.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.