mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2026-08-21 02:31:39 +00:00
AUFTRAG
- improved FREIGHTTRANSPORT mission type
This commit is contained in:
@@ -834,6 +834,16 @@ do -- FSM
|
|||||||
end
|
end
|
||||||
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.
|
--- Go sub.
|
||||||
-- @param #FSM self
|
-- @param #FSM self
|
||||||
-- @param #string ParentFrom Parent from state.
|
-- @param #string ParentFrom Parent from state.
|
||||||
|
|||||||
@@ -2175,12 +2175,37 @@ function AUFTRAG:NewCARGOTRANSPORT(StaticCargo, DropZone)
|
|||||||
end
|
end
|
||||||
|
|
||||||
--- **[AIR]** Create a FREIGHT TRANSPORT mission.
|
--- **[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 #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.
|
-- @param Wrapper.Airbase#AIRBASE Destination Destination airbase, where the cargo is unloaded.
|
||||||
-- @return #AUFTRAG self
|
-- @return #AUFTRAG self
|
||||||
function AUFTRAG:NewFREIGHTTRANSPORT(StaticCargo, Destination)
|
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)
|
local mission=AUFTRAG:New(AUFTRAG.Type.FREIGHTTRANSPORT)
|
||||||
|
|
||||||
mission:_TargetFromObject(StaticCargo)
|
mission:_TargetFromObject(StaticCargo)
|
||||||
@@ -2195,7 +2220,6 @@ function AUFTRAG:NewFREIGHTTRANSPORT(StaticCargo, Destination)
|
|||||||
|
|
||||||
mission.DCStask=mission:GetDCSMissionTask()
|
mission.DCStask=mission:GetDCSMissionTask()
|
||||||
|
|
||||||
mission.DCStask.params.groupId=StaticCargo:GetID()
|
|
||||||
mission.DCStask.params.cargo=StaticCargo
|
mission.DCStask.params.cargo=StaticCargo
|
||||||
mission.DCStask.params.destination=Destination
|
mission.DCStask.params.destination=Destination
|
||||||
|
|
||||||
@@ -6582,29 +6606,27 @@ function AUFTRAG:GetDCSMissionTask(MissionGroup)
|
|||||||
-- FREIGHTTRANSPORT Mission --
|
-- FREIGHTTRANSPORT Mission --
|
||||||
------------------------------
|
------------------------------
|
||||||
|
|
||||||
local x=nil; local y=nil; local unitIdTransport=nil
|
local statics=self.engageTarget:GetObjects()
|
||||||
if MissionGroup then
|
|
||||||
local vec2=MissionGroup:GetVec2()
|
|
||||||
x=vec2.x
|
|
||||||
y=vec2.y
|
|
||||||
unitIdTransport=MissionGroup:GetFirstUnit():GetID()
|
|
||||||
end
|
|
||||||
|
|
||||||
local static=self.engageTarget:GetObject() --Wrapper.Static#STATIC
|
for _, StaticObject in pairs(statics) do
|
||||||
|
local static=StaticObject --Wrapper.Static#STATIC
|
||||||
|
|
||||||
-- Task to transport cargo.
|
self:T(static)
|
||||||
local TaskCargoTransportation={
|
|
||||||
id = "CargoTransportationPlane",
|
-- Task to unload the cargo
|
||||||
params = {
|
local TaskCargoUnload={
|
||||||
x=x,
|
["id"] = "CargoUnloadPlane",
|
||||||
y=y,
|
["params"] =
|
||||||
unitIdTransport=nil,
|
{
|
||||||
groupId=static:GetID(),
|
["groupId"] = static:GetID(),
|
||||||
unitId=static:GetID(),
|
["unitId"] = static:GetID(),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
table.insert(DCStasks, TaskCargoTransportation)
|
|
||||||
|
table.insert(DCStasks, TaskCargoUnload)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
elseif self.type==AUFTRAG.Type.RESCUEHELO then
|
elseif self.type==AUFTRAG.Type.RESCUEHELO then
|
||||||
|
|
||||||
|
|||||||
@@ -5947,6 +5947,9 @@ function OPSGROUP:RouteToMission(mission, delay)
|
|||||||
-- Debug info.
|
-- Debug info.
|
||||||
self:T(self.lid..string.format("Route To Mission"))
|
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.
|
-- Catch dead or stopped groups.
|
||||||
if self:IsDead() or self:IsStopped() then
|
if self:IsDead() or self:IsStopped() then
|
||||||
self:T(self.lid..string.format("Route To Mission: I am DEAD or STOPPED! Ooops..."))
|
self:T(self.lid..string.format("Route To Mission: I am DEAD or STOPPED! Ooops..."))
|
||||||
@@ -6165,11 +6168,49 @@ function OPSGROUP:RouteToMission(mission, delay)
|
|||||||
-- Hopefully, ED will change the behaviour of this task but at the moment, it is what it is.
|
-- Hopefully, ED will change the behaviour of this task but at the moment, it is what it is.
|
||||||
waypointcoord=destination:GetCoordinate()
|
waypointcoord=destination:GetCoordinate()
|
||||||
|
|
||||||
-- Refresh DCS task with the known controllable.
|
-- Get additional parameters
|
||||||
mission.DCStask=mission:GetDCSMissionTask(self.group)
|
mission.DCStask.params.destination=destination --Wrapper.Airbase#AIRBASE
|
||||||
|
mission.DCStask.params.cargo=cargo --Core.Set#SET_STATIC
|
||||||
|
|
||||||
mission.DCStask.params.destination=destination
|
-- Get transport unit
|
||||||
mission.DCStask.params.cargo=cargo
|
local unit=self.group:GetFirstUnit()
|
||||||
|
local unitIdTransport=unit:GetID()
|
||||||
|
local vec2=unit:GetVec2()
|
||||||
|
|
||||||
|
-- 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
|
elseif mission.type==AUFTRAG.Type.ARTY then
|
||||||
|
|
||||||
@@ -6329,7 +6370,7 @@ function OPSGROUP:RouteToMission(mission, delay)
|
|||||||
elseif self:IsNavygroup() then
|
elseif self:IsNavygroup() then
|
||||||
self:Cruise(SpeedToMission)
|
self:Cruise(SpeedToMission)
|
||||||
elseif self:IsFlightgroup() then
|
elseif self:IsFlightgroup() then
|
||||||
self:UpdateRoute()
|
self:__UpdateRoute(delayGo)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user