This commit is contained in:
Frank 2020-07-08 00:07:30 +02:00
parent 71733babf8
commit 80b22a8444
7 changed files with 45 additions and 48 deletions

View File

@ -70,12 +70,12 @@ __Moose.Include( 'Scripts/Moose/Ops/Airboss.lua' )
__Moose.Include( 'Scripts/Moose/Ops/RecoveryTanker.lua' ) __Moose.Include( 'Scripts/Moose/Ops/RecoveryTanker.lua' )
__Moose.Include( 'Scripts/Moose/Ops/RescueHelo.lua' ) __Moose.Include( 'Scripts/Moose/Ops/RescueHelo.lua' )
__Moose.Include( 'Scripts/Moose/Ops/ATIS.lua' ) __Moose.Include( 'Scripts/Moose/Ops/ATIS.lua' )
__Moose.Include( 'Scripts/Moose/Ops/AirWing.lua' )
__Moose.Include( 'Scripts/Moose/Ops/Auftrag.lua' ) __Moose.Include( 'Scripts/Moose/Ops/Auftrag.lua' )
__Moose.Include( 'Scripts/Moose/Ops/OpsGroup.lua' ) __Moose.Include( 'Scripts/Moose/Ops/OpsGroup.lua' )
__Moose.Include( 'Scripts/Moose/Ops/FlightGroup.lua' ) __Moose.Include( 'Scripts/Moose/Ops/FlightGroup.lua' )
__Moose.Include( 'Scripts/Moose/Ops/NavyGroup.lua' ) __Moose.Include( 'Scripts/Moose/Ops/NavyGroup.lua' )
__Moose.Include( 'Scripts/Moose/Ops/Squadron.lua' ) __Moose.Include( 'Scripts/Moose/Ops/Squadron.lua' )
__Moose.Include( 'Scripts/Moose/Ops/AirWing.lua' )
__Moose.Include( 'Scripts/Moose/AI/AI_Balancer.lua' ) __Moose.Include( 'Scripts/Moose/AI/AI_Balancer.lua' )
__Moose.Include( 'Scripts/Moose/AI/AI_Air.lua' ) __Moose.Include( 'Scripts/Moose/AI/AI_Air.lua' )

View File

@ -1864,22 +1864,20 @@ function AUFTRAG:Evaluate()
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). --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).
--self:I(self.lid..string.format("Evaluating mission: Initial Targets=%d, current targets=%d ==> success=%s", self.Ntargets, Ntargets, tostring(not failed)))
if failureCondition then if failureCondition then
failed=true failed=true
elseif successCondition then elseif successCondition then
failed=false failed=false
end end
-- Debug text.
local text=string.format("Evaluating mission:\n") local text=string.format("Evaluating mission:\n")
text=text..string.format("Targets = %d/%d\n", self.Ntargets, Ntargets) text=text..string.format("Targets = %d/%d\n", self.Ntargets, Ntargets)
text=text..string.format("Damage = %.1f %%\n", targetdamage) text=text..string.format("Damage = %.1f %%\n", targetdamage)
text=text..string.format("Success Cond = %s\n", tostring(successCondition)) text=text..string.format("Success Cond = %s\n", tostring(successCondition))
text=text..string.format("Failure Cond = %s", tostring(failureCondition)) text=text..string.format("Failure Cond = %s", tostring(failureCondition))
self:I(self.lid..text) self:I(self.lid..text)
if failed then if failed then
self:Failed() self:Failed()
@ -1930,9 +1928,8 @@ end
-- @param Ops.OpsGroup#OPSGROUP opsgroup The flight group. -- @param Ops.OpsGroup#OPSGROUP opsgroup The flight group.
-- @param #string status New status. -- @param #string status New status.
function AUFTRAG:SetGroupStatus(opsgroup, status) function AUFTRAG:SetGroupStatus(opsgroup, status)
self:I(self.lid..string.format("Setting flight %s to status %s", opsgroup and opsgroup.groupname or "nil", tostring(status))) self:T(self.lid..string.format("Setting flight %s to status %s", opsgroup and opsgroup.groupname or "nil", tostring(status)))
--env.info("FF trying to get flight status in AUFTRAG:GetGroupStatus")
if self:GetGroupStatus(opsgroup)==AUFTRAG.GroupStatus.CANCELLED and status==AUFTRAG.GroupStatus.DONE then if self:GetGroupStatus(opsgroup)==AUFTRAG.GroupStatus.CANCELLED and status==AUFTRAG.GroupStatus.DONE then
-- Do not overwrite a CANCELLED status with a DONE status. -- Do not overwrite a CANCELLED status with a DONE status.
else else
@ -1945,11 +1942,11 @@ function AUFTRAG:SetGroupStatus(opsgroup, status)
end end
-- Debug info. -- Debug info.
self:I(self.lid..string.format("Setting flight %s status to %s. IsNotOver=%s CheckGroupsDone=%s", opsgroup.groupname, self:GetGroupStatus(opsgroup), tostring(self:IsNotOver()), tostring(self:CheckGroupsDone()))) self:T2(self.lid..string.format("Setting flight %s status to %s. IsNotOver=%s CheckGroupsDone=%s", opsgroup.groupname, self:GetGroupStatus(opsgroup), tostring(self:IsNotOver()), tostring(self:CheckGroupsDone())))
-- Check if ALL flights are done with their mission. -- Check if ALL flights are done with their mission.
if self:IsNotOver() and self:CheckGroupsDone() then if self:IsNotOver() and self:CheckGroupsDone() then
self:I(self.lid.."All flights done ==> mission DONE!") self:T3(self.lid.."All flights done ==> mission DONE!")
self:Done() self:Done()
else else
self:T3(self.lid.."Mission NOT DONE yet!") self:T3(self.lid.."Mission NOT DONE yet!")
@ -2842,7 +2839,6 @@ function AUFTRAG:GetMissionWaypointCoord(group)
if self.missionAltitude then if self.missionAltitude then
waypointcoord:SetAltitude(self.missionAltitude, true) waypointcoord:SetAltitude(self.missionAltitude, true)
end end
env.info(string.format("FF mission alt=%d meters", waypointcoord.y))
return waypointcoord return waypointcoord
end end
@ -3137,7 +3133,8 @@ function AUFTRAG:GetDCSMissionTask(TaskControllable)
end end
self:I({missiontask=DCStasks}) -- Debug info.
self:T3({missiontask=DCStasks})
-- Return the task. -- Return the task.
if #DCStasks==1 then if #DCStasks==1 then

View File

@ -191,7 +191,7 @@ FLIGHTGROUP.Attribute = {
--- FLIGHTGROUP class version. --- FLIGHTGROUP class version.
-- @field #string version -- @field #string version
FLIGHTGROUP.version="0.5.0" FLIGHTGROUP.version="0.6.0"
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- TODO list -- TODO list
@ -1738,7 +1738,7 @@ function FLIGHTGROUP:onafterUpdateRoute(From, Event, To, n)
--- ---
if self:IsAirborne() then if self:IsAirborne() then
env.info("FF no waypoints left ==> CheckGroupDone") self:T2(self.lid.."No waypoints left ==> CheckGroupDone")
self:_CheckGroupDone() self:_CheckGroupDone()
end end
@ -2033,16 +2033,12 @@ function FLIGHTGROUP:onafterRTB(From, Event, To, airbase, SpeedTo, SpeedHold, Sp
-- Respawn? -- Respawn?
if routeto then if routeto then
--self:I(self.lid.."FF route (not repawn)") -- Just route the group. Respawn might happen when going from holding to final.
-- Just route the group. Respawn might happen when going from holding to final.
self:Route(wp, 1) self:Route(wp, 1)
else else
--self:I(self.lid.."FF respawn (not route)")
-- Get group template. -- Get group template.
local Template=self.group:GetTemplate() local Template=self.group:GetTemplate()

View File

@ -20,6 +20,7 @@
-- @field #NAVYGROUP.IntoWind intowind Into wind info. -- @field #NAVYGROUP.IntoWind intowind Into wind info.
-- @field #table Qintowind Queue of "into wind" turns. -- @field #table Qintowind Queue of "into wind" turns.
-- @field #boolean adinfinitum Resume route at first waypoint when final waypoint is reached. -- @field #boolean adinfinitum Resume route at first waypoint when final waypoint is reached.
-- @field #number depth Ordered depth in meters.
-- @extends Ops.OpsGroup#OPSGROUP -- @extends Ops.OpsGroup#OPSGROUP
--- *Something must be left to chance; nothing is sure in a sea fight above all.* -- Horatio Nelson --- *Something must be left to chance; nothing is sure in a sea fight above all.* -- Horatio Nelson
@ -35,7 +36,6 @@
-- @field #NAVYGROUP -- @field #NAVYGROUP
NAVYGROUP = { NAVYGROUP = {
ClassName = "NAVYGROUP", ClassName = "NAVYGROUP",
verbose = 2,
turning = false, turning = false,
intowind = nil, intowind = nil,
intowindcounter = 0, intowindcounter = 0,
@ -63,7 +63,7 @@ NAVYGROUP = {
--- NavyGroup version. --- NavyGroup version.
-- @field #string version -- @field #string version
NAVYGROUP.version="0.0.1" NAVYGROUP.version="0.1.0"
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- TODO list -- TODO list
@ -464,6 +464,8 @@ function NAVYGROUP:onafterSpawned(From, Event, To)
-- Get orientation. -- Get orientation.
self.Corientlast=self.group:GetUnit(1):GetOrientationX() self.Corientlast=self.group:GetUnit(1):GetOrientationX()
self.depth=self.group:GetHeight()
-- Update route. -- Update route.
self:Cruise() self:Cruise()
@ -551,7 +553,7 @@ function NAVYGROUP:onafterUpdateRoute(From, Event, To, n, Speed, Depth)
if #self.waypoints>1 then if #self.waypoints>1 then
self:I(self.lid..string.format("Resuming route at first waypoint")) self:I(self.lid..string.format("Resuming route at first waypoint"))
self:__UpdateRoute(-1, 1) self:__UpdateRoute(-1, 1, nil, self.depth)
end end
end end
@ -568,8 +570,6 @@ end
-- @param #number Depth Depth in meters. Default 0 meters. -- @param #number Depth Depth in meters. Default 0 meters.
-- @param #number ResumeRoute If true, resume route after detour point was reached. -- @param #number ResumeRoute If true, resume route after detour point was reached.
function NAVYGROUP:onafterDetour(From, Event, To, Coordinate, Speed, Depth, ResumeRoute) function NAVYGROUP:onafterDetour(From, Event, To, Coordinate, Speed, Depth, ResumeRoute)
env.info("FF detour")
-- Waypoints. -- Waypoints.
local waypoints={} local waypoints={}
@ -616,7 +616,7 @@ function NAVYGROUP._DetourReached(group, navygroup, resume)
if resume then if resume then
local indx=navygroup:GetWaypointIndexNext(true) local indx=navygroup:GetWaypointIndexNext(true)
local speed=navygroup:GetSpeedToWaypoint(indx) local speed=navygroup:GetSpeedToWaypoint(indx)
navygroup:UpdateRoute(indx, speed) navygroup:UpdateRoute(indx, speed, navygroup.depth)
end end
navygroup:DetourReached() navygroup:DetourReached()
@ -676,7 +676,7 @@ function NAVYGROUP:onafterTurnIntoWindOver(From, Event, To)
else else
local indx=self:GetWaypointIndexNext(self.adinfinitum) local indx=self:GetWaypointIndexNext(self.adinfinitum)
local speed=self:GetWaypointSpeed(indx) local speed=self:GetWaypointSpeed(indx)
self:UpdateRoute(indx, speed) self:UpdateRoute(indx, speed, self.depth)
end end
self.intowind=nil self.intowind=nil
@ -709,7 +709,7 @@ end
-- @param #number Speed Speed in knots. -- @param #number Speed Speed in knots.
function NAVYGROUP:onafterCruise(From, Event, To, Speed) function NAVYGROUP:onafterCruise(From, Event, To, Speed)
self:UpdateRoute(nil, Speed) self:UpdateRoute(nil, Speed, self.depth)
end end
@ -718,11 +718,16 @@ end
-- @param #string From From state. -- @param #string From From state.
-- @param #string Event Event. -- @param #string Event Event.
-- @param #string To To state. -- @param #string To To state.
-- @param #number Depth Dive depth in meters. -- @param #number Depth Dive depth in meters. Default 50 meters.
function NAVYGROUP:onafterDive(From, Event, To, Depth) function NAVYGROUP:onafterDive(From, Event, To, Depth)
env.info("FF Diving") Depth=Depth or 50
self:UpdateRoute(nil, nil, Depth)
self:I(self.lid..string.format("Diving to %d meters", Depth))
self.depth=Depth
self:UpdateRoute(nil, nil, self.depth)
end end
@ -734,7 +739,9 @@ end
-- @param #number Depth Dive depth in meters. -- @param #number Depth Dive depth in meters.
function NAVYGROUP:onafterSurface(From, Event, To) function NAVYGROUP:onafterSurface(From, Event, To)
self:UpdateRoute(nil, nil, 0) self.depth=0
self:UpdateRoute(nil, nil, self.depth)
end end
@ -1090,13 +1097,13 @@ function NAVYGROUP:_CheckGroupDone(delay)
local speed=self:GetSpeedToWaypoint(1) local speed=self:GetSpeedToWaypoint(1)
-- Start route at first waypoint. -- Start route at first waypoint.
self:__UpdateRoute(-1, 1, speed) self:__UpdateRoute(-1, 1, speed, self.depth)
end end
else else
self:UpdateRoute() self:UpdateRoute(nil, nil, self.depth)
end end
@ -1166,12 +1173,8 @@ end
-- @return #number Speed to next waypoint (>0) in knots. -- @return #number Speed to next waypoint (>0) in knots.
function NAVYGROUP:GetSpeedToWaypoint(indx) function NAVYGROUP:GetSpeedToWaypoint(indx)
self:I(self.lid..string.format("Index=%s", tostring(indx)))
local speed=self:GetWaypointSpeed(indx) local speed=self:GetWaypointSpeed(indx)
self:I(self.lid..string.format("Speed=%s", tostring(speed)))
if speed<=0.1 then if speed<=0.1 then
speed=self:GetSpeedCruise() speed=self:GetSpeedCruise()
end end

View File

@ -203,7 +203,7 @@ OPSGROUP.TaskType={
--- NavyGroup version. --- NavyGroup version.
-- @field #string version -- @field #string version
OPSGROUP.version="0.0.1" OPSGROUP.version="0.1.0"
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- TODO list -- TODO list
@ -649,6 +649,7 @@ function OPSGROUP:RemoveWaypoint(wpindex)
-- Number of waypoints after delete. -- Number of waypoints after delete.
local n=#self.waypoints local n=#self.waypoints
-- Debug info.
self:I(self.lid..string.format("Removing waypoint %d. N %d-->%d", wpindex, N, n)) self:I(self.lid..string.format("Removing waypoint %d. N %d-->%d", wpindex, N, n))
-- Shift all waypoint tasks after the removed waypoint. -- Shift all waypoint tasks after the removed waypoint.
@ -681,7 +682,6 @@ function OPSGROUP:RemoveWaypoint(wpindex)
self.passedfinalwp=true self.passedfinalwp=true
end end
env.info("FF update route -1 after waypoint removed")
self:_CheckGroupDone() self:_CheckGroupDone()
else else
@ -1287,13 +1287,13 @@ function OPSGROUP:onafterTaskDone(From, Event, To, Task)
local status=Mission:GetGroupStatus(self) local status=Mission:GetGroupStatus(self)
if status~=AUFTRAG.GroupStatus.PAUSED then if status~=AUFTRAG.GroupStatus.PAUSED then
self:I(self.lid.."FF Task Done ==> Mission Done!") self:T(self.lid.."Task Done ==> Mission Done!")
self:MissionDone(Mission) self:MissionDone(Mission)
else else
--Mission paused. Do nothing! --Mission paused. Do nothing!
end end
else else
self:I(self.lid.."FF Task Done but NO mission found ==> _CheckGroupDone in 1 sec") self:T(self.lid.."Task Done but NO mission found ==> _CheckGroupDone in 1 sec")
self:_CheckGroupDone(1) self:_CheckGroupDone(1)
end end
@ -1574,7 +1574,7 @@ function OPSGROUP:onafterPauseMission(From, Event, To)
local Task=Mission:GetGroupWaypointTask(self) local Task=Mission:GetGroupWaypointTask(self)
-- Debug message. -- Debug message.
self:I(self.lid..string.format("FF pausing current mission %s. Task=%s", tostring(Mission.name), tostring(Task and Task.description or "WTF"))) self:I(self.lid..string.format("Pausing current mission %s. Task=%s", tostring(Mission.name), tostring(Task and Task.description or "WTF")))
-- Cancelling the mission is actually cancelling the current task. -- Cancelling the mission is actually cancelling the current task.
self:TaskCancel(Task) self:TaskCancel(Task)
@ -1623,7 +1623,7 @@ function OPSGROUP:onafterMissionCancel(From, Event, To, Mission)
local Task=Mission:GetGroupWaypointTask(self) local Task=Mission:GetGroupWaypointTask(self)
-- Debug info. -- Debug info.
self:I(self.lid..string.format("FF Cancel current mission %s. Task=%s", tostring(Mission.name), tostring(Task and Task.description or "WTF"))) self:I(self.lid..string.format("Cancel current mission %s. Task=%s", tostring(Mission.name), tostring(Task and Task.description or "WTF")))
-- Cancelling the mission is actually cancelling the current task. -- Cancelling the mission is actually cancelling the current task.
-- Note that two things can happen. -- Note that two things can happen.
@ -1850,7 +1850,7 @@ end
-- @param #number N Total number of waypoints. -- @param #number N Total number of waypoints.
function OPSGROUP:onafterPassingWaypoint(From, Event, To, n, N) function OPSGROUP:onafterPassingWaypoint(From, Event, To, n, N)
local text=string.format("Group passed waypoint %d/%d", n, N) local text=string.format("Group passed waypoint %d/%d", n, N)
self:I(self.lid..text) self:T(self.lid..text)
MESSAGE:New(text, 30, "DEBUG"):ToAllIf(self.Debug) MESSAGE:New(text, 30, "DEBUG"):ToAllIf(self.Debug)
-- Get all waypoint tasks. -- Get all waypoint tasks.

View File

@ -84,7 +84,7 @@ SQUADRON = {
--- SQUADRON class version. --- SQUADRON class version.
-- @field #string version -- @field #string version
SQUADRON.version="0.0.7" SQUADRON.version="0.1.0"
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- TODO list -- TODO list

View File

@ -65,11 +65,12 @@ Ops/Airboss.lua
Ops/RecoveryTanker.lua Ops/RecoveryTanker.lua
Ops/RescueHelo.lua Ops/RescueHelo.lua
Ops/ATIS.lua Ops/ATIS.lua
Ops/AirWing.lua
Ops/Auftrag.lua Ops/Auftrag.lua
Ops/OpsGroup.lua
Ops/FlightGroup.lua Ops/FlightGroup.lua
Ops/NavyGroup.lua Ops/NavyGroup.lua
Ops/Squadron.lua Ops/Squadron.lua
Ops/AirWing.lua
AI/AI_Balancer.lua AI/AI_Balancer.lua
AI/AI_Air.lua AI/AI_Air.lua