mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2026-08-09 18:27:47 +00:00
Ops
This commit is contained in:
@@ -70,6 +70,7 @@
|
||||
--
|
||||
-- @field Core.Set#SET_GROUP transportGroupSet Groups to be transported.
|
||||
-- @field Core.Point#COORDINATE transportPickup Coordinate where to pickup the cargo.
|
||||
-- @field Core.Point#COORDINATE transportDropoff Coordinate where to drop off the cargo.
|
||||
--
|
||||
-- @field Ops.WingCommander#WINGCOMMANDER wingcommander The WINGCOMMANDER managing this mission.
|
||||
-- @field Ops.AirWing#AIRWING airwing The assigned airwing.
|
||||
@@ -197,7 +198,7 @@ _AUFTRAGSNR=0
|
||||
-- @field #string SEAD Suppression/destruction of enemy air defences.
|
||||
-- @field #string STRIKE Strike mission.
|
||||
-- @field #string TANKER Tanker mission.
|
||||
-- @field #string TRANSPORT Transport mission.
|
||||
-- @field #string TROOPTRANSPORT Troop transport mission.
|
||||
AUFTRAG.Type={
|
||||
ANTISHIP="Anti Ship",
|
||||
AWACS="AWACS",
|
||||
@@ -219,7 +220,7 @@ AUFTRAG.Type={
|
||||
SEAD="SEAD",
|
||||
STRIKE="Strike",
|
||||
TANKER="Tanker",
|
||||
TRANSPORT="Transport",
|
||||
TROOPTRANSPORT="Troop Transport",
|
||||
}
|
||||
|
||||
--- Mission status.
|
||||
@@ -963,14 +964,15 @@ function AUFTRAG:NewESCORT(EscortGroup, OffsetVector, EngageMaxDistance, TargetT
|
||||
return mission
|
||||
end
|
||||
|
||||
--- Create an TRANSPORT mission.
|
||||
--- Create a TROOP TRANSPORT mission.
|
||||
-- @param #AUFTRAG self
|
||||
-- @param Core.Set#SET_GROUP TransportGroupSet The set group(s) to be transported.
|
||||
-- @param Core.Point#COORDINATE DropoffCoordinate Coordinate where the helo will land drop off the the troops.
|
||||
-- @param Core.Point#COORDINATE PickupCoordinate Coordinate where the helo will land to pick up the the cargo. Default is the fist transport group.
|
||||
-- @return #AUFTRAG self
|
||||
function AUFTRAG:NewTRANSPORT(TransportGroupSet, PickupCoordinate)
|
||||
function AUFTRAG:NewTROOPTRANSPORT(TransportGroupSet, DropoffCoordinate, PickupCoordinate)
|
||||
|
||||
local mission=AUFTRAG:New(AUFTRAG.Type.TRANSPORT)
|
||||
local mission=AUFTRAG:New(AUFTRAG.Type.TROOPTRANSPORT)
|
||||
|
||||
if TransportGroupSet:IsInstanceOf("GROUP") then
|
||||
mission.transportGroupSet=SET_GROUP:New()
|
||||
@@ -978,14 +980,17 @@ function AUFTRAG:NewTRANSPORT(TransportGroupSet, PickupCoordinate)
|
||||
elseif TransportGroupSet:IsInstanceOf("SET_GROUP") then
|
||||
mission.transportGroupSet=TransportGroupSet
|
||||
else
|
||||
env.info("FF error in TRANSPORT auftrag")
|
||||
mission:E(mission.lid.."ERROR: TransportGroupSet must be a GROUP or SET_GROUP object!")
|
||||
return nil
|
||||
end
|
||||
|
||||
mission:_TargetFromObject(mission.transportGroupSet)
|
||||
|
||||
mission.transportPickup=PickupCoordinate or mission:GetTargetCoordinate()
|
||||
mission.transportPickup=PickupCoordinate or mission:GetTargetCoordinate()
|
||||
mission.transportDropoff=DropoffCoordinate
|
||||
|
||||
mission.transportPickup:MarkToAll("Pickup")
|
||||
mission.transportDropoff:MarkToAll("Drop off")
|
||||
|
||||
-- TODO: what's the best ROE here?
|
||||
mission.optionROE=ENUMS.ROE.ReturnFire
|
||||
@@ -1673,8 +1678,18 @@ function AUFTRAG:Evaluate()
|
||||
local Ntargets=self:CountMissionTargets()
|
||||
|
||||
-- Number of current targets is still >0 ==> Not everything was destroyed.
|
||||
if self.Ntargets>0 and Ntargets>0 then
|
||||
failed=true
|
||||
if self.type==AUFTRAG.Type.TROOPTRANSPORT then
|
||||
|
||||
if self.Ntargets>0 and Ntargets<self.Ntargets then
|
||||
failed=true
|
||||
end
|
||||
|
||||
else
|
||||
|
||||
if self.Ntargets>0 and Ntargets>0 then
|
||||
failed=true
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
--TODO: all assets dead? Is this a FAILED criterion even if all targets have been destroyed? What if there are no initial targets (e.g. when ORBIT, PATROL, RECON missions).
|
||||
@@ -2808,7 +2823,7 @@ function AUFTRAG:GetDCSMissionTask()
|
||||
|
||||
table.insert(self.enrouteTasks, DCStask)
|
||||
|
||||
elseif self.type==AUFTRAG.Type.TRANSPORT then
|
||||
elseif self.type==AUFTRAG.Type.TROOPTRANSPORT then
|
||||
|
||||
-----------------------
|
||||
-- TRANSPORT Mission --
|
||||
@@ -2818,7 +2833,7 @@ function AUFTRAG:GetDCSMissionTask()
|
||||
|
||||
local Vec2=self.transportPickup:GetVec2()
|
||||
|
||||
local DCStask=CONTROLLABLE.TaskEmbarking(self, Vec2, self.transportGroupSet, 120, DistributionGroupSet)
|
||||
local DCStask=CONTROLLABLE.TaskEmbarking(nil, self.transportPickup, self.transportGroupSet, 120, DistributionGroupSet)
|
||||
|
||||
table.insert(DCStasks, DCStask)
|
||||
|
||||
|
||||
@@ -1650,7 +1650,6 @@ function FLIGHTGROUP:onafterFlightStatus(From, Event, To)
|
||||
-- Fuel State
|
||||
---
|
||||
|
||||
|
||||
-- Only if group is in air.
|
||||
if self:IsAlive() and self.group:IsAirborne(true) then
|
||||
|
||||
@@ -2796,6 +2795,12 @@ function FLIGHTGROUP:onbeforeRTB(From, Event, To, airbase, SpeedTo, SpeedHold)
|
||||
allowed=false
|
||||
end
|
||||
|
||||
if not self.group:IsAirborne(true) then
|
||||
self:I(self.lid..string.format("WARNING: Group is not AIRBORNE ==> RTB event is suspended for 10 sec."))
|
||||
allowed=false
|
||||
Tsuspend=-10
|
||||
end
|
||||
|
||||
-- Only if fuel is not low or critical.
|
||||
if not (self:IsFuelLow() or self:IsFuelCritical()) then
|
||||
|
||||
@@ -2840,7 +2845,7 @@ end
|
||||
-- @param #number SpeedLand Landing speed in knots. Default 170 kts.
|
||||
function FLIGHTGROUP:onafterRTB(From, Event, To, airbase, SpeedTo, SpeedHold, SpeedLand)
|
||||
|
||||
self:I(self.lid..string.format("RTB: event=%s: %s --> %s", Event, From, To))
|
||||
self:I(self.lid..string.format("RTB: event=%s: %s --> %s to %s", Event, From, To, airbase:GetName()))
|
||||
|
||||
self.destbase=airbase
|
||||
|
||||
@@ -2907,10 +2912,10 @@ function FLIGHTGROUP:onafterRTB(From, Event, To, airbase, SpeedTo, SpeedHold, Sp
|
||||
local TaskArrived=self.group:TaskFunction("FLIGHTGROUP._ReachedHolding", self)
|
||||
|
||||
-- Orbit until flaghold=1 (true) but max 5 min if no FC is giving the landing clearance.
|
||||
local TaskOrbit=self.group:TaskOrbit(p0, nil, UTILS.KnotsToMps(SpeedHold), p1)
|
||||
local TaskLand=self.group:TaskCondition(nil, self.flaghold.UserFlagName, 1, nil, holdtime)
|
||||
local TaskHold=self.group:TaskControlled(TaskOrbit, TaskLand)
|
||||
local TaskKlar=self.group:TaskFunction("FLIGHTGROUP._ClearedToLand", self) -- Once the holding flag becomes true, set trigger FLIGHTLANDING, i.e. set flight STATUS to LANDING.
|
||||
local TaskOrbit = self.group:TaskOrbit(p0, nil, UTILS.KnotsToMps(SpeedHold), p1)
|
||||
local TaskLand = self.group:TaskCondition(nil, self.flaghold.UserFlagName, 1, nil, holdtime)
|
||||
local TaskHold = self.group:TaskControlled(TaskOrbit, TaskLand)
|
||||
local TaskKlar = self.group:TaskFunction("FLIGHTGROUP._ClearedToLand", self) -- Once the holding flag becomes true, set trigger FLIGHTLANDING, i.e. set flight STATUS to LANDING.
|
||||
|
||||
-- Waypoints from current position to holding point.
|
||||
local wp={}
|
||||
@@ -2950,14 +2955,14 @@ function FLIGHTGROUP:onafterRTB(From, Event, To, airbase, SpeedTo, SpeedHold, Sp
|
||||
-- Respawn?
|
||||
if routeto then
|
||||
|
||||
self:I(self.lid.."FF route (not repawn)")
|
||||
--self:I(self.lid.."FF route (not repawn)")
|
||||
|
||||
-- Just route the group. Respawn might happen when going from holding to final.
|
||||
self:Route(wp, 1)
|
||||
|
||||
else
|
||||
|
||||
self:I(self.lid.."FF respawn (not route)")
|
||||
--self:I(self.lid.."FF respawn (not route)")
|
||||
|
||||
-- Get group template.
|
||||
local Template=self.group:GetTemplate()
|
||||
@@ -3117,9 +3122,13 @@ function FLIGHTGROUP:onafterHolding(From, Event, To)
|
||||
|
||||
-- Add flight to waiting/holding queue.
|
||||
if self.flightcontrol then
|
||||
-- Add flight to holding queue.
|
||||
|
||||
-- Remove flight from inbound queue.
|
||||
self.flightcontrol:_RemoveFlightFromQueue(self.flightcontrol.Qinbound, self, "inbound")
|
||||
|
||||
-- Add flight to holding queue.
|
||||
self.flightcontrol:_AddFlightToHoldingQueue(self)
|
||||
|
||||
if not self.ai then
|
||||
self:_UpdateMenu()
|
||||
end
|
||||
@@ -3754,7 +3763,6 @@ function FLIGHTGROUP:onafterMissionStart(From, Event, To, Mission)
|
||||
|
||||
-- Route flight to mission zone.
|
||||
self:RouteToMission(Mission, 5)
|
||||
|
||||
end
|
||||
|
||||
--- On after "MissionExecute" event. Mission execution began.
|
||||
@@ -3927,6 +3935,26 @@ function FLIGHTGROUP:RouteToMission(mission, delay)
|
||||
-- Add waypoint.
|
||||
self:AddWaypointAir(waypointcoord, nextwaypoint, speed, false)
|
||||
|
||||
if mission.type==AUFTRAG.Type.TROOPTRANSPORT then
|
||||
|
||||
local Temb=self.group:TaskEmbarking(mission.transportPickup, mission.transportGroupSet, 300)
|
||||
local Tdis=self.group:TaskDisembarking(mission.transportDropoff, mission.transportGroupSet)
|
||||
|
||||
mission.DCStask=self.group:TaskCombo({Temb, Tdis})
|
||||
|
||||
|
||||
for _,_group in pairs(mission.transportGroupSet.Set) do
|
||||
local group=_group --Wrapper.Group#GROUP
|
||||
|
||||
if group and group:IsAlive() then
|
||||
local DCSTask=group:TaskEmbarkToTransport(mission.transportPickup, 500)
|
||||
group:SetTask(DCSTask, 5)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
-- Add waypoint task. UpdateRoute is called inside.
|
||||
local waypointtask=self:AddTaskWaypoint(mission.DCStask, nextwaypoint, mission.name, mission.prio, mission.duration)
|
||||
|
||||
|
||||
@@ -1063,7 +1063,7 @@ end
|
||||
-- @param #number Duration (Optional) The maximum duration in seconds to wait until all groups have embarked.
|
||||
-- @param #table Distribution (Optional) Distribution used to put the infantry groups into specific carrier units.
|
||||
-- @return DCS#Task The DCS task structure.
|
||||
function CONTROLLABLE:TaskEmbarking(Vec2, GroupSetForEmbarking, Duration, Distribution)
|
||||
function CONTROLLABLE:TaskEmbarking(Coordinate, GroupSetForEmbarking, Duration, Distribution)
|
||||
|
||||
-- Table of group IDs for embarking.
|
||||
local g4e={}
|
||||
@@ -1091,9 +1091,8 @@ function CONTROLLABLE:TaskEmbarking(Vec2, GroupSetForEmbarking, Duration, Distri
|
||||
id = 'Embarking',
|
||||
params = {
|
||||
selectedTransport = groupID,
|
||||
Vec2 = Vec2,
|
||||
x = Vec2.x,
|
||||
y = Vec2.y,
|
||||
x = Coordinate.x,
|
||||
y = Coordinate.z,
|
||||
groupsForEmbarking = g4e,
|
||||
durationFlag = Duration and true or false,
|
||||
duration = Duration,
|
||||
@@ -1101,6 +1100,9 @@ function CONTROLLABLE:TaskEmbarking(Vec2, GroupSetForEmbarking, Duration, Distri
|
||||
distribution = Distribution,
|
||||
}
|
||||
}
|
||||
|
||||
env.info("FF")
|
||||
BASE:E(DCSTask)
|
||||
|
||||
return DCSTask
|
||||
end
|
||||
@@ -1149,8 +1151,8 @@ function CONTROLLABLE:TaskDisembarking(Coordinate, GroupSetToDisembark)
|
||||
return nil
|
||||
end
|
||||
|
||||
local DisembarkFromTransport={
|
||||
id="DisembarkFromTransport",
|
||||
local Disembarking={
|
||||
id = "Disembarking",
|
||||
params = {
|
||||
x = Coordinate.x,
|
||||
y = Coordinate.z,
|
||||
@@ -1158,7 +1160,7 @@ function CONTROLLABLE:TaskDisembarking(Coordinate, GroupSetToDisembark)
|
||||
}
|
||||
}
|
||||
|
||||
return DisembarkFromTransport
|
||||
return Disembarking
|
||||
end
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user