From 239e2ef86d84cfea8b4fbb7c532c01b44477ac1d Mon Sep 17 00:00:00 2001 From: Applevangelist Date: Fri, 18 Nov 2022 09:58:39 +0100 Subject: [PATCH] #GROUP/CONTROLLABLE * Added RecoveryTanker Task --- .../Moose/Wrapper/Controllable.lua | 26 +++++++++++++++++++ Moose Development/Moose/Wrapper/Group.lua | 24 +++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/Moose Development/Moose/Wrapper/Controllable.lua b/Moose Development/Moose/Wrapper/Controllable.lua index d93cd50ab..0a57ad791 100644 --- a/Moose Development/Moose/Wrapper/Controllable.lua +++ b/Moose Development/Moose/Wrapper/Controllable.lua @@ -62,6 +62,7 @@ -- * @{#CONTROLLABLE.TaskOrbitCircle}: (AIR) Orbit at the current position of the first unit of the controllable at a specified altitude. -- * @{#CONTROLLABLE.TaskOrbitCircleAtVec2}: (AIR) Orbit at a specified position at a specified altitude during a specified duration with a specified speed. -- * @{#CONTROLLABLE.TaskRefueling}: (AIR) Refueling from the nearest tanker. No parameters. +-- * @{#CONTROLLABLE.TaskRecoveryTanker}: (AIR) Set group to act as recovery tanker for a naval group. -- * @{#CONTROLLABLE.TaskRoute}: (AIR + GROUND) Return a Mission task to follow a given route defined by Points. -- * @{#CONTROLLABLE.TaskRouteToVec2}: (AIR + GROUND) Make the Controllable move to a given point. -- * @{#CONTROLLABLE.TaskRouteToVec3}: (AIR + GROUND) Make the Controllable move to a given point. @@ -1367,6 +1368,31 @@ function CONTROLLABLE:TaskRefueling() return DCSTask end +--- (AIR) Act as Recovery Tanker for a naval/carrier group. +-- @param #CONTROLLABLE self +-- @param Wrapper.Group#GROUP CarrierGroup +-- @param #number Speed Speed in meters per second +-- @param #number Altitude Altitude the tanker orbits at in meters +-- @param #number LastWptNumber (optional) Waypoint of carrier group that when reached, ends the recovery tanker task +-- @return DCS#Task The DCS task structure. +function CONTROLLABLE:TaskRecoveryTanker(CarrierGroup, Speed, Altitude, LastWptNumber) + + local LastWptFlag = LastWptNumber and true or false + + local DCSTask = { + id = "RecoveryTanker", + params = { + groupId = CarrierGroup:GetID(), + speed = Speed, + altitude = Altitude, + lastWptIndexFlag = LastWptFlag, + lastWptIndex = LastWptNumber + } + } + + return DCSTask +end + --- (AIR HELICOPTER) Landing at the ground. For helicopters only. -- @param #CONTROLLABLE self -- @param DCS#Vec2 Vec2 The point where to land. diff --git a/Moose Development/Moose/Wrapper/Group.lua b/Moose Development/Moose/Wrapper/Group.lua index b0f4bb940..479df92a5 100644 --- a/Moose Development/Moose/Wrapper/Group.lua +++ b/Moose Development/Moose/Wrapper/Group.lua @@ -2855,3 +2855,27 @@ function GROUP:GetCustomCallSign(ShortCallsign,Keepnumber,CallsignTranslations) return callsign end + +--- +-- @param #GROUP self +-- @param Wrapper.Group#GROUP CarrierGroup. +-- @param #number Speed Speed in knots. +-- @param #boolean ToKIAS If true, adjust speed to altitude (KIAS). +-- @param #number Altitude Altitude the tanker orbits at in feet. +-- @param #number Delay (optional) Set the task after this many seconds. Defaults to one. +-- @param #number LastWaypoint (optional) Waypoint number of carrier group that when reached, ends the recovery tanker task. +-- @return #GROUP self +function GROUP:SetAsRecoveryTanker(CarrierGroup,Speed,ToKIAS,Altitude,Delay,LastWaypoint) + + local speed = ToKIAS == true and UTILS.KnotsToAltKIAS(Speed,Altitude) or Speed + speed = UTILS.KnotsToMps(speed) + + local alt = UTILS.FeetToMeters(Altitude) + local delay = Delay or 1 + + local task = self:TaskRecoveryTanker(CarrierGroup,speed,alt,LastWaypoint) + + self:SetTask(task,delay) + + return self +end