Skip to content

Commit 2a6e034

Browse files
committed
Add immediate takeoff command
1 parent 53f0163 commit 2a6e034

File tree

5 files changed

+38
-2
lines changed

5 files changed

+38
-2
lines changed

LuaRules/Configs/customcmds.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ local commands = {
9999
FIELD_FAC_SELECT = 38693,
100100
FIELD_FAC_UNIT_TYPE = 38694,
101101
FIELD_FAC_QUEUELESS = 38695,
102-
102+
IMMEDIATETAKEOFF = 39384, -- Airpad abort.
103+
103104
-- terraform
104105
RAMP = 39734,
105106
LEVEL = 39736,

LuaRules/Gadgets/unit_refuel_pad_handler.lua

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ local mcSetPosition = Spring.MoveCtrl.SetPosition
3737
local mcSetRotation = Spring.MoveCtrl.SetRotation
3838
local mcDisable = Spring.MoveCtrl.Disable
3939
local mcEnable = Spring.MoveCtrl.Enable
40+
local CMD_IMMEDIATETAKEOFF = Spring.Utilities.CMD.IMMEDIATETAKEOFF
4041

4142
local coroutine = coroutine
4243
local Sleep = coroutine.yield
@@ -59,6 +60,14 @@ local min = math.min
5960

6061
local mobilePadDefs = {}
6162

63+
local takeoffCMD = {
64+
id = CMD_IMMEDIATETAKEOFF,
65+
name = "Takeoff",
66+
action = "takeoff",
67+
cursor = 'Repair',
68+
type = CMDTYPE.ICON,
69+
}
70+
6271
for unitDefID, ud in pairs(UnitDefs) do
6372
if ud.customParams.ispad and (not ud.isImmobile) then
6473
mobilePadDefs[unitDefID] = true
@@ -608,3 +617,27 @@ end
608617
function gadget:GameFrame(f)
609618
UpdateCoroutines()
610619
end
620+
621+
function gadget:AllowCommand_GetWantedCommand()
622+
return {[CMD_IMMEDIATETAKEOFF] = true}
623+
end
624+
625+
function gadget:AllowCommand(unitID, unitDefID, unitTeam, cmdID, cmdParams, cmdOptions)
626+
--local isMoveCommand = (cmdID == CMD.MOVE or cmdID == CMD_RAW_MOVE)
627+
if landingUnit[unitID] then -- not one of us.
628+
GG.LandAborted(unitID)
629+
local cmdID, _, cmdTag = Spring.GetUnitCurrentCommand(unitID)
630+
if cmdID == CMD_REARM or cmdID == CMD_FIND_PAD then
631+
Spring.GiveOrderToUnit(unitID, CMD.REMOVE, cmdTag, 0)
632+
end
633+
end
634+
return false
635+
--elseif isMoveCommand and cmdOptions.shift == false and not landingUnit.landed then -- user wants to move somewhere else.
636+
--landingUnit[unitID].abort = true
637+
end
638+
639+
function gadget:UnitCreated(unitID, unitDefID, unitTeam)
640+
if wantedUnits[unitDefID] then
641+
Spring.InsertUnitCmdDesc(unitID, takeoffCMD)
642+
end
643+
end

LuaUI/Configs/integral_menu_commands_orders.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ local cmdPosDef = {
6060
[CMD_EMBARK] = {pos = 13, priority = 5},
6161
[CMD_DISEMBARK] = {pos = 13, priority = 6},
6262
[CMD_EXCLUDE_PAD] = {pos = 13, priority = 7},
63+
[CMD_IMMEDIATETAKEOFF] = {pos = 13, priority = 8},
6364

6465
-- States
6566
[CMD.REPEAT] = {pos = 1, priority = 1},

LuaUI/Configs/integral_menu_config.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ local commandDisplayConfig = {
8383
[CMD_JUMP] = {texture = imageDir .. 'Bold/jump.png'},
8484

8585
[CMD_FIND_PAD] = {texture = imageDir .. 'Bold/rearm.png', tooltip = "Resupply: Return to nearest Airpad for repairs and, for bombers, ammo."},
86+
[CMD_IMMEDIATETAKEOFF] = {texture = imageDir .. 'takeoff.png', tooltip = "Abort Landing\nImmediately take off from airpads or abort landing."},
8687

8788
[CMD_EXCLUDE_PAD] = {texture = imageDir .. 'Bold/excludeairpad.png', tooltip = "Exclude Airpad: Toggle whether any of your aircraft use the targeted airpad."},
8889
[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 = {
9394
[CMD_ONECLICK_WEAPON] = {},--texture = imageDir .. 'Bold/action.png'},
9495
[CMD_UNIT_SET_TARGET_CIRCLE] = {texture = imageDir .. 'Bold/settarget.png'},
9596
[CMD_UNIT_CANCEL_TARGET] = {texture = imageDir .. 'Bold/canceltarget.png'},
96-
97+
9798
[CMD_ABANDON_PW] = {texture = imageDir .. 'Bold/drop_beacon.png'},
9899

99100
[CMD_PLACE_BEACON] = {texture = imageDir .. 'Bold/drop_beacon.png'},

LuaUI/Images/commands/takeoff.png

3.97 KB
Loading

0 commit comments

Comments
 (0)