#AUFTRAG #OPSGROUP Handling of Ingress and Holding points for FlightGroups

This commit is contained in:
Applevangelist 2024-12-12 13:11:54 +01:00
parent 171af5a3c3
commit 6025c05f33
2 changed files with 68 additions and 9 deletions

View File

@ -665,7 +665,7 @@ AUFTRAG.Category={
--- AUFTRAG class version. --- AUFTRAG class version.
-- @field #string version -- @field #string version
AUFTRAG.version="1.2.3" AUFTRAG.version="1.2.1"
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- TODO list -- TODO list
@ -4664,6 +4664,7 @@ end
-- @return #AUFTRAG self -- @return #AUFTRAG self
function AUFTRAG:SetIngressCoordinate(coordinate) function AUFTRAG:SetIngressCoordinate(coordinate)
self.missionIngressCoord = coordinate self.missionIngressCoord = coordinate
self.missionIngressCoordAlt = UTILS.MetersToFeet(coordinate.y) or 10000
return self return self
end end
@ -5722,7 +5723,7 @@ function AUFTRAG:GetMissionTypesText(MissionTypes)
return text return text
end end
--- Set the mission waypoint coordinate where the mission is executed. Note that altitude is set via `:SetMissionAltitude`. --- [NON-AIR] Set the mission waypoint coordinate where the mission is executed. Note that altitude is set via `:SetMissionAltitude`.
-- @param #AUFTRAG self -- @param #AUFTRAG self
-- @param Core.Point#COORDINATE Coordinate Coordinate where the mission is executed. -- @param Core.Point#COORDINATE Coordinate Coordinate where the mission is executed.
-- @return #AUFTRAG self -- @return #AUFTRAG self
@ -5762,6 +5763,7 @@ function AUFTRAG:SetMissionEgressCoord(Coordinate, Altitude)
if Altitude then if Altitude then
self.missionEgressCoord.y=UTILS.FeetToMeters(Altitude) self.missionEgressCoord.y=UTILS.FeetToMeters(Altitude)
self.missionEgressCoordAlt = UTILS.FeetToMeters(Altitude)
end end
end end
@ -5781,6 +5783,29 @@ function AUFTRAG:SetMissionIngressCoord(Coordinate, Altitude)
if Altitude then if Altitude then
self.missionIngressCoord.y=UTILS.FeetToMeters(Altitude) self.missionIngressCoord.y=UTILS.FeetToMeters(Altitude)
self.missionIngressCoordAlt = UTILS.FeetToMeters(Altitude or 10000)
end
end
--- [Air] Set the mission holding coordinate. This is the coordinate where the assigned group will fly before the actual mission execution starts. Do not forget to add a push condition, too!
-- @param #AUFTRAG self
-- @param Core.Point#COORDINATE Coordinate Holding coordinate.
-- @param #number Altitude (Optional) Altitude in feet. Default is y component of coordinate.
-- @param #number Duration (Optional) Duration in seconds on how long to hold, defaults to 15 minutes. Mission continues if either a push condition is met or the time is up.
-- @return #AUFTRAG self
function AUFTRAG:SetMissionHoldingCoord(Coordinate, Altitude, Duration)
-- Obviously a zone was passed. We get the coordinate.
if Coordinate:IsInstanceOf("ZONE_BASE") then
Coordinate=Coordinate:GetCoordinate()
end
self.missionHoldingCoord=Coordinate
self.missionHoldingDuration=Duration or 900
if Altitude then
self.missionHoldingCoord.y=UTILS.FeetToMeters(Altitude)
self.missionHoldingCoordAlt = UTILS.FeetToMeters(Altitude or 10000)
end end
end end
@ -5798,6 +5823,13 @@ function AUFTRAG:GetMissionIngressCoord()
return self.missionIngressCoord return self.missionIngressCoord
end end
--- Get the mission holding coordinate if this was defined.
-- @param #AUFTRAG self
-- @return Core.Point#COORDINATE Coordinate Coordinate or nil.
function AUFTRAG:GetMissionHoldingCoord()
return self.missionHoldingCoord
end
--- Get coordinate which was set as mission waypoint coordinate. --- Get coordinate which was set as mission waypoint coordinate.
-- @param #AUFTRAG self -- @param #AUFTRAG self
-- @return Core.Point#COORDINATE Coordinate where the mission is executed or `#nil`. -- @return Core.Point#COORDINATE Coordinate where the mission is executed or `#nil`.
@ -5833,15 +5865,26 @@ function AUFTRAG:GetMissionWaypointCoord(group, randomradius, surfacetypes)
return coord return coord
end end
-- Check if a coord has been explicitly set. local coord=group:GetCoordinate()
-- Check if an ingress or holding coord has been explicitly set.
if self.missionHoldingCoord then
coord=self.missionHoldingCoord
if self.missionHoldingCoorddAlt then
coord:SetAltitude(self.missionHoldingCoordAlt, true)
end
end
if self.missionIngressCoord then if self.missionIngressCoord then
local coord=self.missionIngressCoord coord=self.missionIngressCoord
return coord if self.missionIngressCoordAlt then
coord:SetAltitude(self.missionIngressCoordAlt, true)
end
end end
-- Create waypoint coordinate half way between us and the target. -- Create waypoint coordinate half way between us and the target.
local waypointcoord=COORDINATE:New(0,0,0) local waypointcoord=COORDINATE:New(0,0,0)
local coord=group:GetCoordinate()
if coord then if coord then
waypointcoord=coord:GetIntermediateCoordinate(self:GetTargetCoordinate(), self.missionFraction) waypointcoord=coord:GetIntermediateCoordinate(self:GetTargetCoordinate(), self.missionFraction)
else else

View File

@ -6121,9 +6121,25 @@ function OPSGROUP:RouteToMission(mission, delay)
local ingresscoord = mission:GetMissionIngressCoord() local ingresscoord = mission:GetMissionIngressCoord()
local holdingcoord = mission:GetMissionHoldingCoord()
if ingresscoord and mission:IsReadyToPush() then if holdingcoord then
waypoint=FLIGHTGROUP.AddWaypoint(self, ingresscoord, SpeedToMission, uid, UTILS.MetersToFeet(self.altitudeCruise), false) waypoint=FLIGHTGROUP.AddWaypoint(self, holdingcoord, SpeedToMission, uid, UTILS.MetersToFeet(mission.missionHoldingCoordAlt or self.altitudeCruise), false)
uid=waypoint.uid
-- Orbit until flaghold=1 (true) but max 5 min
self.flaghold:Set(0)
local TaskOrbit = self.group:TaskOrbit(holdingcoord, mission.missionHoldingCoordAlt)
local TaskStop = self.group:TaskCondition(nil, self.flaghold.UserFlagName, 1, nil, mission.missionHoldingDuration or 900)
local TaskCntr = self.group:TaskControlled(TaskOrbit, TaskStop)
local TaskOver = self.group:TaskFunction("FLIGHTGROUP._FinishedWaiting", self)
local DCSTasks=self.group:TaskCombo({TaskCntr, TaskOver})
-- Add waypoint task. UpdateRoute is called inside.
local waypointtask=self:AddTaskWaypoint(DCSTasks, waypoint, "Holding")
waypointtask.ismission=false
end
if ingresscoord then
waypoint=FLIGHTGROUP.AddWaypoint(self, ingresscoord, SpeedToMission, uid, UTILS.MetersToFeet(mission.missionIngressCoordAlt or self.altitudeCruise), false)
uid=waypoint.uid uid=waypoint.uid
end end
@ -6165,7 +6181,7 @@ function OPSGROUP:RouteToMission(mission, delay)
if egresscoord then if egresscoord then
local Ewaypoint=nil --#OPSGROUP.Waypoint local Ewaypoint=nil --#OPSGROUP.Waypoint
if self:IsFlightgroup() then if self:IsFlightgroup() then
Ewaypoint=FLIGHTGROUP.AddWaypoint(self, egresscoord, SpeedToMission, waypoint.uid, UTILS.MetersToFeet(mission.missionAltitude or self.altitudeCruise), false) Ewaypoint=FLIGHTGROUP.AddWaypoint(self, egresscoord, SpeedToMission, waypoint.uid, UTILS.MetersToFeet(mission.missionEgressCoordAlt or self.altitudeCruise), false)
elseif self:IsArmygroup() then elseif self:IsArmygroup() then
Ewaypoint=ARMYGROUP.AddWaypoint(self, egresscoord, SpeedToMission, waypoint.uid, mission.optionFormation, false) Ewaypoint=ARMYGROUP.AddWaypoint(self, egresscoord, SpeedToMission, waypoint.uid, mission.optionFormation, false)
elseif self:IsNavygroup() then elseif self:IsNavygroup() then