mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2026-07-16 22:22:25 +00:00
AUFTRAG
- improved FREIGHTTRANSPORT mission type
This commit is contained in:
@@ -833,6 +833,16 @@ do -- FSM
|
||||
return self._handler( self, EventName, ... )
|
||||
end
|
||||
end
|
||||
|
||||
--- Clear scheduled FSM event.
|
||||
-- @param #FSM self
|
||||
-- @param #string EventName Event name.
|
||||
function FSM:_ClearFSMEvent( EventName )
|
||||
if self._EventSchedules[EventName] then
|
||||
self.CallScheduler:Remove( self._EventSchedules[EventName] )
|
||||
self._EventSchedules[EventName]=nil
|
||||
end
|
||||
end
|
||||
|
||||
--- Go sub.
|
||||
-- @param #FSM self
|
||||
|
||||
@@ -2175,12 +2175,37 @@ function AUFTRAG:NewCARGOTRANSPORT(StaticCargo, DropZone)
|
||||
end
|
||||
|
||||
--- **[AIR]** Create a FREIGHT TRANSPORT mission.
|
||||
-- This mission type can be used to transport cargo items internally via suitable transport aircraft (planes and helicopters), e.g. C-130 or CH-47.
|
||||
-- It supports transporting one or multiple cargos (weight limits are not checked).
|
||||
-- @param #AUFTRAG self
|
||||
-- @param Wrapper.Static#STATIC StaticCargo Static cargo object.
|
||||
-- @param Wrapper.Static#STATIC StaticCargo Static cargo object. Can also be passed as a `SET_STATIC` object.
|
||||
-- @param Wrapper.Airbase#AIRBASE Destination Destination airbase, where the cargo is unloaded.
|
||||
-- @return #AUFTRAG self
|
||||
function AUFTRAG:NewFREIGHTTRANSPORT(StaticCargo, Destination)
|
||||
|
||||
-- Check if Destination is given
|
||||
if Destination==nil then
|
||||
self:E(self.lid..string.format("ERROR: Destination is nil for AUFTRAG:NewFREIGHTTRANSPORT! You must specify the destination airbase"))
|
||||
return nil
|
||||
elseif type(Destination)=="string" then
|
||||
Destination=AIRBASE:FindByName(Destination)
|
||||
end
|
||||
|
||||
-- Check if Cargo is given
|
||||
if StaticCargo==nil then
|
||||
self:E(self.lid..string.format("ERROR: StaticCargo is nil for AUFTRAG:NewFREIGHTTRANSPORT! You must specify the static object that represents the cargo"))
|
||||
return nil
|
||||
elseif type(StaticCargo)=="string" then
|
||||
StaticCargo=STATIC:FindByName(StaticCargo)
|
||||
end
|
||||
|
||||
-- Convert static to a set if necessary
|
||||
if StaticCargo:IsInstanceOf("STATIC") then
|
||||
local StaticCargoSet=SET_STATIC:New() --Core.Set#SET_STATIC
|
||||
StaticCargoSet:AddCargo(StaticCargo)
|
||||
StaticCargo=StaticCargoSet
|
||||
end
|
||||
|
||||
local mission=AUFTRAG:New(AUFTRAG.Type.FREIGHTTRANSPORT)
|
||||
|
||||
mission:_TargetFromObject(StaticCargo)
|
||||
@@ -2195,7 +2220,6 @@ function AUFTRAG:NewFREIGHTTRANSPORT(StaticCargo, Destination)
|
||||
|
||||
mission.DCStask=mission:GetDCSMissionTask()
|
||||
|
||||
mission.DCStask.params.groupId=StaticCargo:GetID()
|
||||
mission.DCStask.params.cargo=StaticCargo
|
||||
mission.DCStask.params.destination=Destination
|
||||
|
||||
@@ -6581,30 +6605,28 @@ function AUFTRAG:GetDCSMissionTask(MissionGroup)
|
||||
------------------------------
|
||||
-- FREIGHTTRANSPORT Mission --
|
||||
------------------------------
|
||||
|
||||
local statics=self.engageTarget:GetObjects()
|
||||
|
||||
local x=nil; local y=nil; local unitIdTransport=nil
|
||||
if MissionGroup then
|
||||
local vec2=MissionGroup:GetVec2()
|
||||
x=vec2.x
|
||||
y=vec2.y
|
||||
unitIdTransport=MissionGroup:GetFirstUnit():GetID()
|
||||
for _, StaticObject in pairs(statics) do
|
||||
local static=StaticObject --Wrapper.Static#STATIC
|
||||
|
||||
self:T(static)
|
||||
|
||||
-- Task to unload the cargo
|
||||
local TaskCargoUnload={
|
||||
["id"] = "CargoUnloadPlane",
|
||||
["params"] =
|
||||
{
|
||||
["groupId"] = static:GetID(),
|
||||
["unitId"] = static:GetID(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
table.insert(DCStasks, TaskCargoUnload)
|
||||
|
||||
end
|
||||
|
||||
local static=self.engageTarget:GetObject() --Wrapper.Static#STATIC
|
||||
|
||||
-- Task to transport cargo.
|
||||
local TaskCargoTransportation={
|
||||
id = "CargoTransportationPlane",
|
||||
params = {
|
||||
x=x,
|
||||
y=y,
|
||||
unitIdTransport=nil,
|
||||
groupId=static:GetID(),
|
||||
unitId=static:GetID(),
|
||||
}
|
||||
}
|
||||
|
||||
table.insert(DCStasks, TaskCargoTransportation)
|
||||
|
||||
elseif self.type==AUFTRAG.Type.RESCUEHELO then
|
||||
|
||||
|
||||
@@ -5946,6 +5946,9 @@ function OPSGROUP:RouteToMission(mission, delay)
|
||||
|
||||
-- Debug info.
|
||||
self:T(self.lid..string.format("Route To Mission"))
|
||||
|
||||
-- Delay in seconds before cruise or updateroute is called.
|
||||
local delayGo=-1
|
||||
|
||||
-- Catch dead or stopped groups.
|
||||
if self:IsDead() or self:IsStopped() then
|
||||
@@ -6164,13 +6167,51 @@ function OPSGROUP:RouteToMission(mission, delay)
|
||||
-- The only way to ensure the cargo is delivered there, because when the task is executed, the cargo is delivered to the closest airbase.
|
||||
-- Hopefully, ED will change the behaviour of this task but at the moment, it is what it is.
|
||||
waypointcoord=destination:GetCoordinate()
|
||||
|
||||
-- Get additional parameters
|
||||
mission.DCStask.params.destination=destination --Wrapper.Airbase#AIRBASE
|
||||
mission.DCStask.params.cargo=cargo --Core.Set#SET_STATIC
|
||||
|
||||
-- Refresh DCS task with the known controllable.
|
||||
mission.DCStask=mission:GetDCSMissionTask(self.group)
|
||||
-- Get transport unit
|
||||
local unit=self.group:GetFirstUnit()
|
||||
local unitIdTransport=unit:GetID()
|
||||
local vec2=unit:GetVec2()
|
||||
|
||||
mission.DCStask.params.destination=destination
|
||||
mission.DCStask.params.cargo=cargo
|
||||
-- Create tasks to load/transport statics cargos
|
||||
local tasks={}
|
||||
for StaticName, StaticObject in pairs(cargo:GetSet()) do
|
||||
local static=StaticObject --Wrapper.Static#STATIC
|
||||
|
||||
-- Task to transport cargo.
|
||||
local TaskCargoTransportation={
|
||||
id = "CargoTransportationPlane",
|
||||
params = {
|
||||
x=vec2.x,
|
||||
y=vec2.y,
|
||||
unitIdTransport=unitIdTransport,
|
||||
groupId=static:GetID(),
|
||||
unitId=static:GetID(),
|
||||
}
|
||||
}
|
||||
|
||||
table.insert(tasks, TaskCargoTransportation)
|
||||
end
|
||||
|
||||
-- If we have multiple tasks, we create a combo task
|
||||
local TaskCargo=nil
|
||||
if #tasks==1 then
|
||||
TaskCargo=tasks[1]
|
||||
else
|
||||
TaskCargo=CONTROLLABLE.TaskCombo(nil, tasks)
|
||||
end
|
||||
|
||||
-- We set the task to load the cargo into the aircraft.
|
||||
-- We must be careful when calling updateroute because there the task is overwritten.
|
||||
-- We also clear present "UpdateRoute" FSM events
|
||||
self:_ClearFSMEvent( "UpdateRoute" )
|
||||
delayGo=-30
|
||||
self.group:SetTask(TaskCargo)
|
||||
|
||||
elseif mission.type==AUFTRAG.Type.ARTY then
|
||||
|
||||
---
|
||||
@@ -6329,7 +6370,7 @@ function OPSGROUP:RouteToMission(mission, delay)
|
||||
elseif self:IsNavygroup() then
|
||||
self:Cruise(SpeedToMission)
|
||||
elseif self:IsFlightgroup() then
|
||||
self:UpdateRoute()
|
||||
self:__UpdateRoute(delayGo)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user