mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
OPS
Strange version buggy
This commit is contained in:
parent
eba6e3f5f1
commit
c6ebbc6122
@ -2596,6 +2596,12 @@ function WAREHOUSE:SetSpawnZone(zone, maxdist)
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Get the spawn zone.
|
||||||
|
-- @param #WAREHOUSE self
|
||||||
|
-- @return Core.Zone#ZONE The spawn zone.
|
||||||
|
function WAREHOUSE:GetSpawnZone()
|
||||||
|
return self.spawnzone
|
||||||
|
end
|
||||||
|
|
||||||
--- Set a warehouse zone. If this zone is captured, the warehouse and all its assets fall into the hands of the enemy.
|
--- Set a warehouse zone. If this zone is captured, the warehouse and all its assets fall into the hands of the enemy.
|
||||||
-- @param #WAREHOUSE self
|
-- @param #WAREHOUSE self
|
||||||
@ -6332,8 +6338,16 @@ function WAREHOUSE:_OnEventBirth(EventData)
|
|||||||
-- Set born to true.
|
-- Set born to true.
|
||||||
request.born=true
|
request.born=true
|
||||||
|
|
||||||
-- Birth is triggered for each unit. We need to make sure not to call this too often!
|
|
||||||
if not asset.spawned then
|
if not asset.spawned then
|
||||||
|
asset.spawned=1
|
||||||
|
else
|
||||||
|
asset.spawned=asset.spawned+1
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Birth is triggered for each unit. We need to make sure not to call this too often!
|
||||||
|
if asset.spawned==asset.nunits then
|
||||||
|
|
||||||
-- Remove asset from stock.
|
-- Remove asset from stock.
|
||||||
self:_DeleteStockItem(asset)
|
self:_DeleteStockItem(asset)
|
||||||
@ -6355,9 +6369,9 @@ function WAREHOUSE:_OnEventBirth(EventData)
|
|||||||
group:SetState(group, "WAREHOUSE", self)
|
group:SetState(group, "WAREHOUSE", self)
|
||||||
|
|
||||||
-- Asset spawned FSM function.
|
-- Asset spawned FSM function.
|
||||||
--self:__AssetSpawned(1, group, asset, request)
|
-- This needs to be delayed a bit for all units to be present. Especially, since MOOSE needs a birth event for UNITs to be added to the _DATABASE.
|
||||||
--env.info(string.format("FF asset spawned %s, %s", asset.spawngroupname, EventData.IniUnitName))
|
self:__AssetSpawned(0.1, group, asset, request)
|
||||||
self:AssetSpawned(group, asset, request)
|
--self:AssetSpawned(group, asset, request)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -840,6 +840,21 @@ function AIRWING:onafterStatus(From, Event, To)
|
|||||||
self:I(self.lid..text)
|
self:I(self.lid..text)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
----------------
|
||||||
|
-- Transport ---
|
||||||
|
----------------
|
||||||
|
|
||||||
|
-- Check if any transports should be cancelled.
|
||||||
|
--self:_CheckTransports()
|
||||||
|
|
||||||
|
-- Get next mission.
|
||||||
|
local transport=self:_GetNextTransport()
|
||||||
|
|
||||||
|
-- Request mission execution.
|
||||||
|
if transport then
|
||||||
|
self:TransportRequest(transport)
|
||||||
|
end
|
||||||
|
|
||||||
--------------
|
--------------
|
||||||
-- Mission ---
|
-- Mission ---
|
||||||
--------------
|
--------------
|
||||||
|
|||||||
@ -350,10 +350,9 @@ function ARMYGROUP:Status()
|
|||||||
-- FSM state.
|
-- FSM state.
|
||||||
local fsmstate=self:GetState()
|
local fsmstate=self:GetState()
|
||||||
|
|
||||||
|
-- Is group alive?
|
||||||
local alive=self:IsAlive()
|
local alive=self:IsAlive()
|
||||||
|
|
||||||
env.info(self.lid.."FF status="..fsmstate)
|
|
||||||
|
|
||||||
if alive then
|
if alive then
|
||||||
|
|
||||||
---
|
---
|
||||||
@ -1228,20 +1227,36 @@ function ARMYGROUP:_InitGroup(Template)
|
|||||||
-- Units of the group.
|
-- Units of the group.
|
||||||
local units=self.group:GetUnits()
|
local units=self.group:GetUnits()
|
||||||
|
|
||||||
|
-- DCS group.
|
||||||
|
local dcsgroup=Group.getByName(self.groupname)
|
||||||
|
local size0=dcsgroup:getInitialSize()
|
||||||
|
|
||||||
|
-- Quick check.
|
||||||
|
if #units~=size0 then
|
||||||
|
self:E(self.lid..string.format("ERROR: Got #units=%d but group consists of %d units!", #units, size0))
|
||||||
|
end
|
||||||
|
|
||||||
-- Add elemets.
|
-- Add elemets.
|
||||||
for _,unit in pairs(units) do
|
for _,unit in pairs(units) do
|
||||||
self:_AddElementByName(unit:GetName())
|
self:_AddElementByName(unit:GetName())
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Get first unit. This is used to extract other parameters.
|
||||||
|
local unit=units[1] --Wrapper.Unit#UNIT
|
||||||
|
|
||||||
|
if unit then
|
||||||
|
|
||||||
-- Get Descriptors.
|
-- Get Descriptors.
|
||||||
self.descriptors=units[1]:GetDesc()
|
self.descriptors=unit:GetDesc()
|
||||||
|
|
||||||
-- Set type name.
|
-- Set type name.
|
||||||
self.actype=units[1]:GetTypeName()
|
self.actype=unit:GetTypeName()
|
||||||
|
|
||||||
-- Init done.
|
-- Init done.
|
||||||
self.groupinitialized=true
|
self.groupinitialized=true
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -960,7 +960,7 @@ end
|
|||||||
--- Check if a mission type is contained in a list of possible capabilities.
|
--- Check if a mission type is contained in a list of possible capabilities.
|
||||||
-- @param #COHORT self
|
-- @param #COHORT self
|
||||||
-- @param #table MissionTypes The requested mission type. Can also be passed as a single mission type `#string`.
|
-- @param #table MissionTypes The requested mission type. Can also be passed as a single mission type `#string`.
|
||||||
-- @param #table Capabilities A table with possible capabilities.
|
-- @param #table Capabilities (Optional) A table with possible capabilities `Ops.Auftrag#AUFTRAG.Capability`. Default is capabilities of the cohort.
|
||||||
-- @return #boolean If true, the requested mission type is part of the possible mission types.
|
-- @return #boolean If true, the requested mission type is part of the possible mission types.
|
||||||
function COHORT:CheckMissionCapability(MissionTypes, Capabilities)
|
function COHORT:CheckMissionCapability(MissionTypes, Capabilities)
|
||||||
|
|
||||||
@ -968,6 +968,8 @@ function COHORT:CheckMissionCapability(MissionTypes, Capabilities)
|
|||||||
MissionTypes={MissionTypes}
|
MissionTypes={MissionTypes}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Capabilities=Capabilities or self.missiontypes
|
||||||
|
|
||||||
for _,cap in pairs(Capabilities) do
|
for _,cap in pairs(Capabilities) do
|
||||||
local capability=cap --Ops.Auftrag#AUFTRAG.Capability
|
local capability=cap --Ops.Auftrag#AUFTRAG.Capability
|
||||||
for _,MissionType in pairs(MissionTypes) do
|
for _,MissionType in pairs(MissionTypes) do
|
||||||
|
|||||||
@ -1984,6 +1984,13 @@ function FLIGHTGROUP:onbeforeUpdateRoute(From, Event, To, n)
|
|||||||
allowed=false
|
allowed=false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if self:IsUncontrolled() then
|
||||||
|
-- Not airborne yet. Try again in 5 sec.
|
||||||
|
self:T(self.lid.."Update route denied. Group is UNCONTROLLED ==> checking back in 5 sec")
|
||||||
|
trepeat=-5
|
||||||
|
allowed=false
|
||||||
|
end
|
||||||
|
|
||||||
if n and n<1 then
|
if n and n<1 then
|
||||||
self:E(self.lid.."Update route denied because waypoint n<1!")
|
self:E(self.lid.."Update route denied because waypoint n<1!")
|
||||||
allowed=false
|
allowed=false
|
||||||
@ -2065,13 +2072,16 @@ function FLIGHTGROUP:onafterUpdateRoute(From, Event, To, n)
|
|||||||
|
|
||||||
-- Waypoint type.
|
-- Waypoint type.
|
||||||
local waypointType=COORDINATE.WaypointType.TurningPoint
|
local waypointType=COORDINATE.WaypointType.TurningPoint
|
||||||
|
local waypointAction=COORDINATE.WaypointAction.TurningPoint
|
||||||
if self:IsLanded() or self:IsLandedAt() or self:IsAirborne()==false then
|
if self:IsLanded() or self:IsLandedAt() or self:IsAirborne()==false then
|
||||||
-- Had some issues with passing waypoint function of the next WP called too ealy when the type is TurningPoint. Setting it to TakeOff solved it!
|
-- Had some issues with passing waypoint function of the next WP called too ealy when the type is TurningPoint. Setting it to TakeOff solved it!
|
||||||
waypointType=COORDINATE.WaypointType.TakeOff
|
waypointType=COORDINATE.WaypointType.TakeOff
|
||||||
|
env.info("FF takeoff type waypoint")
|
||||||
|
--waypointAction=COORDINATE.WaypointAction.FromParkingArea
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Set current waypoint or we get problem that the _PassingWaypoint function is triggered too early, i.e. right now and not when passing the next WP.
|
-- Set current waypoint or we get problem that the _PassingWaypoint function is triggered too early, i.e. right now and not when passing the next WP.
|
||||||
local current=self.group:GetCoordinate():WaypointAir(COORDINATE.WaypointAltType.BARO, waypointType, COORDINATE.WaypointAction.TurningPoint, speed, true, nil, {}, "Current")
|
local current=self.group:GetCoordinate():WaypointAir(COORDINATE.WaypointAltType.BARO, waypointType, waypointAction, speed, true, nil, {}, "Current")
|
||||||
table.insert(wp, current)
|
table.insert(wp, current)
|
||||||
|
|
||||||
local Nwp=self.waypoints and #self.waypoints or 0
|
local Nwp=self.waypoints and #self.waypoints or 0
|
||||||
@ -2084,7 +2094,13 @@ function FLIGHTGROUP:onafterUpdateRoute(From, Event, To, n)
|
|||||||
-- Debug info.
|
-- Debug info.
|
||||||
local hb=self.homebase and self.homebase:GetName() or "unknown"
|
local hb=self.homebase and self.homebase:GetName() or "unknown"
|
||||||
local db=self.destbase and self.destbase:GetName() or "unknown"
|
local db=self.destbase and self.destbase:GetName() or "unknown"
|
||||||
self:T(self.lid..string.format("Updating route for WP #%d-%d homebase=%s destination=%s", n, #wp, hb, db))
|
self:T(self.lid..string.format("Updating route for WP #%d-%d [%s], homebase=%s destination=%s", n, #wp, self:GetState(), hb, db))
|
||||||
|
|
||||||
|
-- Print waypoints.
|
||||||
|
for i,w in pairs(wp) do
|
||||||
|
env.info("FF waypoint index="..i)
|
||||||
|
self:I(w)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
if #wp>1 then
|
if #wp>1 then
|
||||||
@ -2243,7 +2259,7 @@ function FLIGHTGROUP:_CheckGroupDone(delay, waittime)
|
|||||||
self:T(self.lid..string.format("Flight (status=%s) did NOT pass the final waypoint yet ==> update route", self:GetState()))
|
self:T(self.lid..string.format("Flight (status=%s) did NOT pass the final waypoint yet ==> update route", self:GetState()))
|
||||||
|
|
||||||
-- Update route.
|
-- Update route.
|
||||||
self:__UpdateRoute(-1)
|
self:__UpdateRoute(-0.01)
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -3086,13 +3102,25 @@ function FLIGHTGROUP:_InitGroup(Template)
|
|||||||
self.menu.atc.root=self.menu.atc.root or MENU_GROUP:New(self.group, "ATC")
|
self.menu.atc.root=self.menu.atc.root or MENU_GROUP:New(self.group, "ATC")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Units of the group.
|
||||||
|
local units=self.group:GetUnits()
|
||||||
|
|
||||||
|
-- DCS group.
|
||||||
|
local dcsgroup=Group.getByName(self.groupname)
|
||||||
|
local size0=dcsgroup:getInitialSize()
|
||||||
|
|
||||||
|
-- Quick check.
|
||||||
|
if #units~=size0 then
|
||||||
|
self:E(self.lid..string.format("ERROR: Got #units=%d but group consists of %d units!", #units, size0))
|
||||||
|
end
|
||||||
|
|
||||||
-- Add elemets.
|
-- Add elemets.
|
||||||
for _,unit in pairs(self.group:GetUnits()) do
|
for _,unit in pairs(units) do
|
||||||
self:_AddElementByName(unit:GetName())
|
self:_AddElementByName(unit:GetName())
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Get first unit. This is used to extract other parameters.
|
-- Get first unit. This is used to extract other parameters.
|
||||||
local unit=self.group:GetUnit(1)
|
local unit=units[1] --Wrapper.Unit#UNIT
|
||||||
|
|
||||||
if unit then
|
if unit then
|
||||||
|
|
||||||
@ -3469,7 +3497,7 @@ function FLIGHTGROUP:AddWaypoint(Coordinate, Speed, AfterWaypointWithID, Altitud
|
|||||||
|
|
||||||
-- Update route.
|
-- Update route.
|
||||||
if Updateroute==nil or Updateroute==true then
|
if Updateroute==nil or Updateroute==true then
|
||||||
self:__UpdateRoute(-1)
|
self:__UpdateRoute(-0.01)
|
||||||
end
|
end
|
||||||
|
|
||||||
return waypoint
|
return waypoint
|
||||||
|
|||||||
@ -158,11 +158,13 @@ function LEGION:AddMission(Mission)
|
|||||||
-- Add legion to mission.
|
-- Add legion to mission.
|
||||||
Mission:AddLegion(self)
|
Mission:AddLegion(self)
|
||||||
|
|
||||||
|
--[[
|
||||||
if Mission.opstransport then
|
if Mission.opstransport then
|
||||||
Mission.opstransport:SetPickupZone(self.spawnzone)
|
Mission.opstransport:SetPickupZone(self.spawnzone)
|
||||||
Mission.opstransport:SetEmbarkZone(self.spawnzone)
|
Mission.opstransport:SetEmbarkZone(self.spawnzone)
|
||||||
self:AddOpsTransport(Mission.opstransport)
|
self:AddOpsTransport(Mission.opstransport)
|
||||||
end
|
end
|
||||||
|
]]
|
||||||
|
|
||||||
-- Add mission to queue.
|
-- Add mission to queue.
|
||||||
table.insert(self.missionqueue, Mission)
|
table.insert(self.missionqueue, Mission)
|
||||||
@ -1007,12 +1009,7 @@ function LEGION:onafterAssetSpawned(From, Event, To, group, asset, request)
|
|||||||
--mission:SetTACAN(Tacan, Morse, UnitName, Band)
|
--mission:SetTACAN(Tacan, Morse, UnitName, Band)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Transport for mission assets.
|
-- Add mission to flightgroup queue. If mission has an OPSTRANSPORT attached, all added OPSGROUPS are added as CARGO for a transport.
|
||||||
if mission.opstransport then
|
|
||||||
mission.opstransport:AddCargoGroups(self)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Add mission to flightgroup queue.
|
|
||||||
flightgroup:AddMission(mission)
|
flightgroup:AddMission(mission)
|
||||||
|
|
||||||
-- Trigger event.
|
-- Trigger event.
|
||||||
|
|||||||
@ -462,7 +462,10 @@ function NAVYGROUP:Status(From, Event, To)
|
|||||||
-- FSM state.
|
-- FSM state.
|
||||||
local fsmstate=self:GetState()
|
local fsmstate=self:GetState()
|
||||||
|
|
||||||
if self:IsAlive() then
|
-- Is group alive?
|
||||||
|
local alive=self:IsAlive()
|
||||||
|
|
||||||
|
if alive then
|
||||||
|
|
||||||
---
|
---
|
||||||
-- Detection
|
-- Detection
|
||||||
@ -520,6 +523,10 @@ function NAVYGROUP:Status(From, Event, To)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
if alive~=nil then
|
||||||
|
|
||||||
if self.verbose>=1 then
|
if self.verbose>=1 then
|
||||||
|
|
||||||
-- Get number of tasks and missions.
|
-- Get number of tasks and missions.
|
||||||
@ -549,18 +556,6 @@ function NAVYGROUP:Status(From, Event, To)
|
|||||||
fsmstate, roe, als, nTaskTot, nMissions, wpidxCurr, wpuidCurr, wpidxNext, wpuidNext, #self.waypoints or 0, wpDist, wpETA, speed, speedExpected, alt, self.heading, turning, freepath, intowind)
|
fsmstate, roe, als, nTaskTot, nMissions, wpidxCurr, wpuidCurr, wpidxNext, wpuidNext, #self.waypoints or 0, wpDist, wpETA, speed, speedExpected, alt, self.heading, turning, freepath, intowind)
|
||||||
self:I(self.lid..text)
|
self:I(self.lid..text)
|
||||||
|
|
||||||
if false then
|
|
||||||
local text="Waypoints:"
|
|
||||||
for i,wp in pairs(self.waypoints) do
|
|
||||||
local waypoint=wp --Ops.OpsGroup#OPSGROUP.Waypoint
|
|
||||||
text=text..string.format("\n%d. UID=%d", i, waypoint.uid)
|
|
||||||
if i==self.currentwp then
|
|
||||||
text=text.." current!"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
env.info(text)
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
@ -575,7 +570,7 @@ function NAVYGROUP:Status(From, Event, To)
|
|||||||
-- Recovery Windows
|
-- Recovery Windows
|
||||||
---
|
---
|
||||||
|
|
||||||
if self.verbose>=2 and #self.Qintowind>0 then
|
if alive and self.verbose>=2 and #self.Qintowind>0 then
|
||||||
|
|
||||||
-- Debug output:
|
-- Debug output:
|
||||||
local text=string.format(self.lid.."Turn into wind time windows:")
|
local text=string.format(self.lid.."Turn into wind time windows:")
|
||||||
@ -1191,20 +1186,36 @@ function NAVYGROUP:_InitGroup(Template)
|
|||||||
-- Get all units of the group.
|
-- Get all units of the group.
|
||||||
local units=self.group:GetUnits()
|
local units=self.group:GetUnits()
|
||||||
|
|
||||||
|
-- DCS group.
|
||||||
|
local dcsgroup=Group.getByName(self.groupname)
|
||||||
|
local size0=dcsgroup:getInitialSize()
|
||||||
|
|
||||||
|
-- Quick check.
|
||||||
|
if #units~=size0 then
|
||||||
|
self:E(self.lid..string.format("ERROR: Got #units=%d but group consists of %d units!", #units, size0))
|
||||||
|
end
|
||||||
|
|
||||||
-- Add elemets.
|
-- Add elemets.
|
||||||
for _,unit in pairs(units) do
|
for _,unit in pairs(units) do
|
||||||
self:_AddElementByName(unit:GetName())
|
self:_AddElementByName(unit:GetName())
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Get first unit. This is used to extract other parameters.
|
||||||
|
local unit=units[1] --Wrapper.Unit#UNIT
|
||||||
|
|
||||||
|
if unit then
|
||||||
|
|
||||||
-- Get Descriptors.
|
-- Get Descriptors.
|
||||||
self.descriptors=units[1]:GetDesc()
|
self.descriptors=unit:GetDesc()
|
||||||
|
|
||||||
-- Set type name.
|
-- Set type name.
|
||||||
self.actype=units[1]:GetTypeName()
|
self.actype=unit:GetTypeName()
|
||||||
|
|
||||||
-- Init done.
|
-- Init done.
|
||||||
self.groupinitialized=true
|
self.groupinitialized=true
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -1414,7 +1414,7 @@ function OPSGROUP:DestroyUnit(UnitName, Delay)
|
|||||||
-- Create a "Unit Lost" event.
|
-- Create a "Unit Lost" event.
|
||||||
local EventTime=timer.getTime()
|
local EventTime=timer.getTime()
|
||||||
|
|
||||||
if self.isAircraft then
|
if self:IsFlightgroup() then
|
||||||
self:CreateEventUnitLost(EventTime, unit)
|
self:CreateEventUnitLost(EventTime, unit)
|
||||||
else
|
else
|
||||||
self:CreateEventDead(EventTime, unit)
|
self:CreateEventDead(EventTime, unit)
|
||||||
@ -2469,8 +2469,8 @@ function OPSGROUP:OnEventBirth(EventData)
|
|||||||
|
|
||||||
if element and element.status~=OPSGROUP.ElementStatus.SPAWNED then
|
if element and element.status~=OPSGROUP.ElementStatus.SPAWNED then
|
||||||
|
|
||||||
-- Set element to spawned state.
|
-- Set element to spawned state. We need to delay this.
|
||||||
self:ElementSpawned(element)
|
self:__ElementSpawned(0.05, element)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -2646,12 +2646,11 @@ end
|
|||||||
|
|
||||||
--- Clear DCS tasks.
|
--- Clear DCS tasks.
|
||||||
-- @param #OPSGROUP self
|
-- @param #OPSGROUP self
|
||||||
-- @param #table DCSTask DCS task structure.
|
|
||||||
-- @return #OPSGROUP self
|
-- @return #OPSGROUP self
|
||||||
function OPSGROUP:ClearTasks()
|
function OPSGROUP:ClearTasks()
|
||||||
if self:IsAlive() then
|
if self:IsAlive() then
|
||||||
self.group:ClearTasks()
|
|
||||||
self:I(self.lid..string.format("CLEARING Tasks"))
|
self:I(self.lid..string.format("CLEARING Tasks"))
|
||||||
|
self.group:ClearTasks()
|
||||||
end
|
end
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
@ -3166,8 +3165,8 @@ function OPSGROUP:onafterTaskExecute(From, Event, To, Task)
|
|||||||
-- NOTE: I am pushing the task instead of setting it as it seems to keep the mission task alive.
|
-- NOTE: I am pushing the task instead of setting it as it seems to keep the mission task alive.
|
||||||
-- There were issues that flights did not proceed to a later waypoint because the task did not finish until the fired missiles
|
-- There were issues that flights did not proceed to a later waypoint because the task did not finish until the fired missiles
|
||||||
-- impacted (took rather long). Then the flight flew to the nearest airbase and one lost completely the control over the group.
|
-- impacted (took rather long). Then the flight flew to the nearest airbase and one lost completely the control over the group.
|
||||||
self:PushTask(TaskFinal)
|
--self:PushTask(TaskFinal)
|
||||||
--self:SetTask(TaskFinal)
|
self:SetTask(TaskFinal)
|
||||||
|
|
||||||
|
|
||||||
elseif Task.type==OPSGROUP.TaskType.WAYPOINT then
|
elseif Task.type==OPSGROUP.TaskType.WAYPOINT then
|
||||||
@ -3307,14 +3306,16 @@ function OPSGROUP:onafterTaskDone(From, Event, To, Task)
|
|||||||
else
|
else
|
||||||
--Mission paused. Do nothing!
|
--Mission paused. Do nothing!
|
||||||
end
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
if Task.description=="Engage_Target" then
|
if Task.description=="Engage_Target" then
|
||||||
self:Disengage()
|
self:Disengage()
|
||||||
end
|
end
|
||||||
|
|
||||||
self:T(self.lid.."Task Done but NO mission found ==> _CheckGroupDone in 1 sec")
|
--
|
||||||
self:_CheckGroupDone(1)
|
self:T(self.lid.."Task Done but NO mission found ==> _CheckGroupDone in 0 sec")
|
||||||
|
self:_CheckGroupDone()
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@ -3575,7 +3576,7 @@ function OPSGROUP:onbeforeMissionStart(From, Event, To, Mission)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Startup group if it is uncontrolled.
|
-- Startup group if it is uncontrolled.
|
||||||
if self.isAircraft and self:IsUncontrolled() then
|
if self:IsFlightgroup() and self:IsUncontrolled() then
|
||||||
self:StartUncontrolled(delay)
|
self:StartUncontrolled(delay)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -3966,7 +3967,7 @@ function OPSGROUP:RouteToMission(mission, delay)
|
|||||||
self:SwitchAlarmstate(mission.optionAlarm)
|
self:SwitchAlarmstate(mission.optionAlarm)
|
||||||
end
|
end
|
||||||
-- Formation
|
-- Formation
|
||||||
if mission.optionFormation and self.isAircraft then
|
if mission.optionFormation and self:IsFlightgroup() then
|
||||||
self:SwitchFormation(mission.optionFormation)
|
self:SwitchFormation(mission.optionFormation)
|
||||||
end
|
end
|
||||||
-- Radio frequency and modulation.
|
-- Radio frequency and modulation.
|
||||||
@ -4036,7 +4037,7 @@ function OPSGROUP:_QueueUpdate()
|
|||||||
local ready=true
|
local ready=true
|
||||||
|
|
||||||
-- For aircraft check airborne.
|
-- For aircraft check airborne.
|
||||||
if self.isAircraft then
|
if self:IsFlightgroup() then
|
||||||
ready=self:IsAirborne()
|
ready=self:IsAirborne()
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -4219,8 +4220,8 @@ function OPSGROUP:onafterPassingWaypoint(From, Event, To, Waypoint)
|
|||||||
|
|
||||||
-- Check if all tasks/mission are done?
|
-- Check if all tasks/mission are done?
|
||||||
-- Note, we delay it for a second to let the OnAfterPassingwaypoint function to be executed in case someone wants to add another waypoint there.
|
-- Note, we delay it for a second to let the OnAfterPassingwaypoint function to be executed in case someone wants to add another waypoint there.
|
||||||
if ntasks==0 then
|
if ntasks==0 and self:HasPassedFinalWaypoint() then
|
||||||
self:_CheckGroupDone(0.1)
|
self:_CheckGroupDone(0.01)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Debug info.
|
-- Debug info.
|
||||||
@ -5356,7 +5357,10 @@ function OPSGROUP:_CheckCargoTransport()
|
|||||||
local text=""
|
local text=""
|
||||||
for i,_transport in pairs(self.cargoqueue) do
|
for i,_transport in pairs(self.cargoqueue) do
|
||||||
local transport=_transport --#Ops.OpsTransport#OPSTRANSPORT
|
local transport=_transport --#Ops.OpsTransport#OPSTRANSPORT
|
||||||
text=text..string.format("\n[%d] UID=%d Status=%s: %s --> %s", i, transport.uid, transport:GetState(), transport.pickupzone:GetName(), transport.deployzone:GetName())
|
|
||||||
|
local pickupname=transport.pickupzone and transport.pickupzone:GetName() or "unknown"
|
||||||
|
local deployname=transport.deployzone and transport.deployzone:GetName() or "unknown"
|
||||||
|
text=text..string.format("\n[%d] UID=%d Status=%s: %s --> %s", i, transport.uid, transport:GetState(), pickupname, deployname)
|
||||||
for j,_cargo in pairs(transport.cargos) do
|
for j,_cargo in pairs(transport.cargos) do
|
||||||
local cargo=_cargo --#OPSGROUP.CargoGroup
|
local cargo=_cargo --#OPSGROUP.CargoGroup
|
||||||
local state=cargo.opsgroup:GetState()
|
local state=cargo.opsgroup:GetState()
|
||||||
@ -5386,7 +5390,9 @@ function OPSGROUP:_CheckCargoTransport()
|
|||||||
|
|
||||||
-- Debug info.
|
-- Debug info.
|
||||||
if self.verbose>=2 then
|
if self.verbose>=2 then
|
||||||
local text=string.format("Carrier [%s]: %s --> %s", self.carrierStatus, self.cargoTransport.pickupzone:GetName(), self.cargoTransport.deployzone:GetName())
|
local pickupname=self.cargoTransport.pickupzone and self.cargoTransport.pickupzone:GetName() or "unknown"
|
||||||
|
local deployname=self.cargoTransport.deployzone and self.cargoTransport.deployzone:GetName() or "unknown"
|
||||||
|
local text=string.format("Carrier [%s]: %s --> %s", self.carrierStatus, pickupname, deployname)
|
||||||
for _,_cargo in pairs(self.cargoTransport.cargos) do
|
for _,_cargo in pairs(self.cargoTransport.cargos) do
|
||||||
local cargo=_cargo --Ops.OpsGroup#OPSGROUP.CargoGroup
|
local cargo=_cargo --Ops.OpsGroup#OPSGROUP.CargoGroup
|
||||||
local name=cargo.opsgroup:GetName()
|
local name=cargo.opsgroup:GetName()
|
||||||
@ -6483,7 +6489,7 @@ function OPSGROUP:onafterLoaded(From, Event, To)
|
|||||||
-- Cancel landedAt task.
|
-- Cancel landedAt task.
|
||||||
if self:IsFlightgroup() and self:IsLandedAt() then
|
if self:IsFlightgroup() and self:IsLandedAt() then
|
||||||
local Task=self:GetTaskCurrent()
|
local Task=self:GetTaskCurrent()
|
||||||
self:TaskCancel(Task)
|
self:__TaskCancel(1, Task)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Order group to transport.
|
-- Order group to transport.
|
||||||
@ -6552,7 +6558,7 @@ function OPSGROUP:onafterTransport(From, Event, To)
|
|||||||
self:FullStop()
|
self:FullStop()
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Start loading.
|
-- Start unloading.
|
||||||
self:__UnLoading(-5)
|
self:__UnLoading(-5)
|
||||||
|
|
||||||
else
|
else
|
||||||
@ -6598,8 +6604,9 @@ function OPSGROUP:onafterTransport(From, Event, To)
|
|||||||
---
|
---
|
||||||
|
|
||||||
-- If this is a helo and no ZONE_AIRBASE was given, we make the helo land in the pickup zone.
|
-- If this is a helo and no ZONE_AIRBASE was given, we make the helo land in the pickup zone.
|
||||||
Coordinate:SetAltitude(200)
|
Coordinate:MarkToAll("landing",ReadOnly,Text)
|
||||||
local waypoint=FLIGHTGROUP.AddWaypoint(self, Coordinate) ; waypoint.detour=1
|
env.info("FF helo add waypoint detour")
|
||||||
|
local waypoint=FLIGHTGROUP.AddWaypoint(self, Coordinate, nil, self:GetWaypointCurrent().uid, 200) ; waypoint.detour=1
|
||||||
|
|
||||||
else
|
else
|
||||||
self:E(self.lid.."ERROR: Carrier aircraft cannot land in Deploy zone! Specify a ZONE_AIRBASE as deploy zone")
|
self:E(self.lid.."ERROR: Carrier aircraft cannot land in Deploy zone! Specify a ZONE_AIRBASE as deploy zone")
|
||||||
@ -7818,6 +7825,8 @@ function OPSGROUP:Route(waypoints, delay)
|
|||||||
-- DCS task combo.
|
-- DCS task combo.
|
||||||
local Tasks={}
|
local Tasks={}
|
||||||
|
|
||||||
|
self:ClearTasks(DCSTask)
|
||||||
|
|
||||||
-- Route (Mission) task.
|
-- Route (Mission) task.
|
||||||
local TaskRoute=self.group:TaskRoute(waypoints)
|
local TaskRoute=self.group:TaskRoute(waypoints)
|
||||||
table.insert(Tasks, TaskRoute)
|
table.insert(Tasks, TaskRoute)
|
||||||
@ -7914,7 +7923,8 @@ function OPSGROUP._PassingWaypoint(group, opsgroup, uid)
|
|||||||
|
|
||||||
if wpnext and (opsgroup.currentwp<#opsgroup.waypoints or opsgroup.adinfinitum or wpistemp) then
|
if wpnext and (opsgroup.currentwp<#opsgroup.waypoints or opsgroup.adinfinitum or wpistemp) then
|
||||||
|
|
||||||
opsgroup:I(opsgroup.lid..string.format("Next waypoint UID=%d index=%d", wpnext.uid, opsgroup:GetWaypointIndex(wpnext.uid)))
|
-- Debug info.
|
||||||
|
opsgroup:T(opsgroup.lid..string.format("Next waypoint UID=%d index=%d", wpnext.uid, opsgroup:GetWaypointIndex(wpnext.uid)))
|
||||||
|
|
||||||
-- Set formation.
|
-- Set formation.
|
||||||
if opsgroup.isGround then
|
if opsgroup.isGround then
|
||||||
@ -7930,8 +7940,6 @@ function OPSGROUP._PassingWaypoint(group, opsgroup, uid)
|
|||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
env.info(opsgroup.lid.."FF 300")
|
|
||||||
|
|
||||||
-- Set passed final waypoint.
|
-- Set passed final waypoint.
|
||||||
opsgroup:_PassedFinalWaypoint(true, "_PassingWaypoint No next Waypoint found")
|
opsgroup:_PassedFinalWaypoint(true, "_PassingWaypoint No next Waypoint found")
|
||||||
|
|
||||||
@ -7972,6 +7980,7 @@ function OPSGROUP._PassingWaypoint(group, opsgroup, uid)
|
|||||||
if opsgroup.isFlightgroup then
|
if opsgroup.isFlightgroup then
|
||||||
|
|
||||||
-- Land at current pos and wait for 60 min max.
|
-- Land at current pos and wait for 60 min max.
|
||||||
|
env.info("FF LandAt for Pickup")
|
||||||
opsgroup:LandAt(opsgroup:GetCoordinate(), 60*60)
|
opsgroup:LandAt(opsgroup:GetCoordinate(), 60*60)
|
||||||
|
|
||||||
else
|
else
|
||||||
@ -7985,6 +7994,7 @@ function OPSGROUP._PassingWaypoint(group, opsgroup, uid)
|
|||||||
if opsgroup.isFlightgroup then
|
if opsgroup.isFlightgroup then
|
||||||
|
|
||||||
-- Land at current pos and wait for 60 min max.
|
-- Land at current pos and wait for 60 min max.
|
||||||
|
env.info("FF LandAt for Transporting")
|
||||||
opsgroup:LandAt(opsgroup:GetCoordinate(), 60*60)
|
opsgroup:LandAt(opsgroup:GetCoordinate(), 60*60)
|
||||||
|
|
||||||
else
|
else
|
||||||
@ -8271,7 +8281,7 @@ function OPSGROUP:SetDefaultTACAN(Channel, Morse, UnitName, Band, OffSwitch)
|
|||||||
self.tacanDefault.Morse=Morse or "XXX"
|
self.tacanDefault.Morse=Morse or "XXX"
|
||||||
self.tacanDefault.BeaconName=UnitName
|
self.tacanDefault.BeaconName=UnitName
|
||||||
|
|
||||||
if self.isAircraft then
|
if self:IsFlightgroup() then
|
||||||
Band=Band or "Y"
|
Band=Band or "Y"
|
||||||
else
|
else
|
||||||
Band=Band or "X"
|
Band=Band or "X"
|
||||||
@ -8356,7 +8366,7 @@ function OPSGROUP:SwitchTACAN(Channel, Morse, UnitName, Band)
|
|||||||
|
|
||||||
-- System
|
-- System
|
||||||
local System=BEACON.System.TACAN
|
local System=BEACON.System.TACAN
|
||||||
if self.isAircraft then
|
if self:IsFlightgroup() then
|
||||||
System=BEACON.System.TACAN_TANKER_Y
|
System=BEACON.System.TACAN_TANKER_Y
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -8592,7 +8602,7 @@ function OPSGROUP:SwitchRadio(Frequency, Modulation)
|
|||||||
Frequency=Frequency or self.radioDefault.Freq
|
Frequency=Frequency or self.radioDefault.Freq
|
||||||
Modulation=Modulation or self.radioDefault.Modu
|
Modulation=Modulation or self.radioDefault.Modu
|
||||||
|
|
||||||
if self.isAircraft and not self.radio.On then
|
if self:IsFlightgroup() and not self.radio.On then
|
||||||
self.group:SetOption(AI.Option.Air.id.SILENCE, false)
|
self.group:SetOption(AI.Option.Air.id.SILENCE, false)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -8621,7 +8631,7 @@ function OPSGROUP:TurnOffRadio()
|
|||||||
|
|
||||||
if self:IsAlive() then
|
if self:IsAlive() then
|
||||||
|
|
||||||
if self.isAircraft then
|
if self:IsFlightgroup() then
|
||||||
|
|
||||||
-- Set group to be silient.
|
-- Set group to be silient.
|
||||||
self.group:SetOption(AI.Option.Air.id.SILENCE, true)
|
self.group:SetOption(AI.Option.Air.id.SILENCE, true)
|
||||||
@ -8662,7 +8672,7 @@ function OPSGROUP:SwitchFormation(Formation)
|
|||||||
|
|
||||||
Formation=Formation or self.optionDefault.Formation
|
Formation=Formation or self.optionDefault.Formation
|
||||||
|
|
||||||
if self.isAircraft then
|
if self:IsFlightgroup() then
|
||||||
|
|
||||||
self.group:SetOption(AI.Option.Air.id.FORMATION, Formation)
|
self.group:SetOption(AI.Option.Air.id.FORMATION, Formation)
|
||||||
|
|
||||||
@ -9556,7 +9566,7 @@ end
|
|||||||
function OPSGROUP:_PassedFinalWaypoint(final, comment)
|
function OPSGROUP:_PassedFinalWaypoint(final, comment)
|
||||||
|
|
||||||
-- Debug info.
|
-- Debug info.
|
||||||
self:I(self.lid..string.format("Passed final waypoint=%s [from %s]: comment \"%s\"", tostring(final), tostring(self.passedfinalwp), tostring(comment)))
|
self:T(self.lid..string.format("Passed final waypoint=%s [from %s]: comment \"%s\"", tostring(final), tostring(self.passedfinalwp), tostring(comment)))
|
||||||
|
|
||||||
-- Set value.
|
-- Set value.
|
||||||
self.passedfinalwp=final
|
self.passedfinalwp=final
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user