diff --git a/Moose Development/Moose/Modules.lua b/Moose Development/Moose/Modules.lua index 9ca9bce74..48b13adee 100644 --- a/Moose Development/Moose/Modules.lua +++ b/Moose Development/Moose/Modules.lua @@ -70,12 +70,12 @@ __Moose.Include( 'Scripts/Moose/Ops/Airboss.lua' ) __Moose.Include( 'Scripts/Moose/Ops/RecoveryTanker.lua' ) __Moose.Include( 'Scripts/Moose/Ops/RescueHelo.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/OpsGroup.lua' ) __Moose.Include( 'Scripts/Moose/Ops/FlightGroup.lua' ) __Moose.Include( 'Scripts/Moose/Ops/NavyGroup.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_Air.lua' ) diff --git a/Moose Development/Moose/Ops/Auftrag.lua b/Moose Development/Moose/Ops/Auftrag.lua index f848c9da5..816bba0e9 100644 --- a/Moose Development/Moose/Ops/Auftrag.lua +++ b/Moose Development/Moose/Ops/Auftrag.lua @@ -1864,22 +1864,20 @@ function AUFTRAG:Evaluate() 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). - - --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 failed=true elseif successCondition then failed=false end + -- Debug text. local text=string.format("Evaluating mission:\n") text=text..string.format("Targets = %d/%d\n", self.Ntargets, Ntargets) text=text..string.format("Damage = %.1f %%\n", targetdamage) text=text..string.format("Success Cond = %s\n", tostring(successCondition)) text=text..string.format("Failure Cond = %s", tostring(failureCondition)) - self:I(self.lid..text) - + self:I(self.lid..text) if failed then self:Failed() @@ -1930,9 +1928,8 @@ end -- @param Ops.OpsGroup#OPSGROUP opsgroup The flight group. -- @param #string status New 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 -- Do not overwrite a CANCELLED status with a DONE status. else @@ -1945,11 +1942,11 @@ function AUFTRAG:SetGroupStatus(opsgroup, status) end -- 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. 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() else self:T3(self.lid.."Mission NOT DONE yet!") @@ -2842,7 +2839,6 @@ function AUFTRAG:GetMissionWaypointCoord(group) if self.missionAltitude then waypointcoord:SetAltitude(self.missionAltitude, true) end - env.info(string.format("FF mission alt=%d meters", waypointcoord.y)) return waypointcoord end @@ -3137,7 +3133,8 @@ function AUFTRAG:GetDCSMissionTask(TaskControllable) end - self:I({missiontask=DCStasks}) + -- Debug info. + self:T3({missiontask=DCStasks}) -- Return the task. if #DCStasks==1 then diff --git a/Moose Development/Moose/Ops/FlightGroup.lua b/Moose Development/Moose/Ops/FlightGroup.lua index b201ca95a..5562f6de7 100644 --- a/Moose Development/Moose/Ops/FlightGroup.lua +++ b/Moose Development/Moose/Ops/FlightGroup.lua @@ -191,7 +191,7 @@ FLIGHTGROUP.Attribute = { --- FLIGHTGROUP class version. -- @field #string version -FLIGHTGROUP.version="0.5.0" +FLIGHTGROUP.version="0.6.0" ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -- TODO list @@ -1738,7 +1738,7 @@ function FLIGHTGROUP:onafterUpdateRoute(From, Event, To, n) --- if self:IsAirborne() then - env.info("FF no waypoints left ==> CheckGroupDone") + self:T2(self.lid.."No waypoints left ==> CheckGroupDone") self:_CheckGroupDone() end @@ -2033,16 +2033,12 @@ function FLIGHTGROUP:onafterRTB(From, Event, To, airbase, SpeedTo, SpeedHold, Sp -- Respawn? 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) else - - --self:I(self.lid.."FF respawn (not route)") - + -- Get group template. local Template=self.group:GetTemplate() diff --git a/Moose Development/Moose/Ops/NavyGroup.lua b/Moose Development/Moose/Ops/NavyGroup.lua index 107d063ff..e50fb94db 100644 --- a/Moose Development/Moose/Ops/NavyGroup.lua +++ b/Moose Development/Moose/Ops/NavyGroup.lua @@ -20,6 +20,7 @@ -- @field #NAVYGROUP.IntoWind intowind Into wind info. -- @field #table Qintowind Queue of "into wind" turns. -- @field #boolean adinfinitum Resume route at first waypoint when final waypoint is reached. +-- @field #number depth Ordered depth in meters. -- @extends Ops.OpsGroup#OPSGROUP --- *Something must be left to chance; nothing is sure in a sea fight above all.* -- Horatio Nelson @@ -35,7 +36,6 @@ -- @field #NAVYGROUP NAVYGROUP = { ClassName = "NAVYGROUP", - verbose = 2, turning = false, intowind = nil, intowindcounter = 0, @@ -63,7 +63,7 @@ NAVYGROUP = { --- NavyGroup version. -- @field #string version -NAVYGROUP.version="0.0.1" +NAVYGROUP.version="0.1.0" ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -- TODO list @@ -464,6 +464,8 @@ function NAVYGROUP:onafterSpawned(From, Event, To) -- Get orientation. self.Corientlast=self.group:GetUnit(1):GetOrientationX() + self.depth=self.group:GetHeight() + -- Update route. self:Cruise() @@ -551,7 +553,7 @@ function NAVYGROUP:onafterUpdateRoute(From, Event, To, n, Speed, Depth) if #self.waypoints>1 then self:I(self.lid..string.format("Resuming route at first waypoint")) - self:__UpdateRoute(-1, 1) + self:__UpdateRoute(-1, 1, nil, self.depth) end end @@ -568,8 +570,6 @@ end -- @param #number Depth Depth in meters. Default 0 meters. -- @param #number ResumeRoute If true, resume route after detour point was reached. function NAVYGROUP:onafterDetour(From, Event, To, Coordinate, Speed, Depth, ResumeRoute) - - env.info("FF detour") -- Waypoints. local waypoints={} @@ -616,7 +616,7 @@ function NAVYGROUP._DetourReached(group, navygroup, resume) if resume then local indx=navygroup:GetWaypointIndexNext(true) local speed=navygroup:GetSpeedToWaypoint(indx) - navygroup:UpdateRoute(indx, speed) + navygroup:UpdateRoute(indx, speed, navygroup.depth) end navygroup:DetourReached() @@ -676,7 +676,7 @@ function NAVYGROUP:onafterTurnIntoWindOver(From, Event, To) else local indx=self:GetWaypointIndexNext(self.adinfinitum) local speed=self:GetWaypointSpeed(indx) - self:UpdateRoute(indx, speed) + self:UpdateRoute(indx, speed, self.depth) end self.intowind=nil @@ -709,7 +709,7 @@ end -- @param #number Speed Speed in knots. function NAVYGROUP:onafterCruise(From, Event, To, Speed) - self:UpdateRoute(nil, Speed) + self:UpdateRoute(nil, Speed, self.depth) end @@ -718,11 +718,16 @@ end -- @param #string From From state. -- @param #string Event Event. -- @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) - env.info("FF Diving") - self:UpdateRoute(nil, nil, Depth) + Depth=Depth or 50 + + self:I(self.lid..string.format("Diving to %d meters", Depth)) + + self.depth=Depth + + self:UpdateRoute(nil, nil, self.depth) end @@ -734,7 +739,9 @@ end -- @param #number Depth Dive depth in meters. function NAVYGROUP:onafterSurface(From, Event, To) - self:UpdateRoute(nil, nil, 0) + self.depth=0 + + self:UpdateRoute(nil, nil, self.depth) end @@ -1090,13 +1097,13 @@ function NAVYGROUP:_CheckGroupDone(delay) local speed=self:GetSpeedToWaypoint(1) -- Start route at first waypoint. - self:__UpdateRoute(-1, 1, speed) + self:__UpdateRoute(-1, 1, speed, self.depth) end else - self:UpdateRoute() + self:UpdateRoute(nil, nil, self.depth) end @@ -1166,12 +1173,8 @@ end -- @return #number Speed to next waypoint (>0) in knots. function NAVYGROUP:GetSpeedToWaypoint(indx) - self:I(self.lid..string.format("Index=%s", tostring(indx))) - local speed=self:GetWaypointSpeed(indx) - self:I(self.lid..string.format("Speed=%s", tostring(speed))) - if speed<=0.1 then speed=self:GetSpeedCruise() end diff --git a/Moose Development/Moose/Ops/OpsGroup.lua b/Moose Development/Moose/Ops/OpsGroup.lua index 0895b65cd..e99ae114c 100644 --- a/Moose Development/Moose/Ops/OpsGroup.lua +++ b/Moose Development/Moose/Ops/OpsGroup.lua @@ -203,7 +203,7 @@ OPSGROUP.TaskType={ --- NavyGroup version. -- @field #string version -OPSGROUP.version="0.0.1" +OPSGROUP.version="0.1.0" ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -- TODO list @@ -649,6 +649,7 @@ function OPSGROUP:RemoveWaypoint(wpindex) -- Number of waypoints after delete. local n=#self.waypoints + -- Debug info. self:I(self.lid..string.format("Removing waypoint %d. N %d-->%d", wpindex, N, n)) -- Shift all waypoint tasks after the removed waypoint. @@ -681,7 +682,6 @@ function OPSGROUP:RemoveWaypoint(wpindex) self.passedfinalwp=true end - env.info("FF update route -1 after waypoint removed") self:_CheckGroupDone() else @@ -1287,13 +1287,13 @@ function OPSGROUP:onafterTaskDone(From, Event, To, Task) local status=Mission:GetGroupStatus(self) 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) else --Mission paused. Do nothing! end 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) end @@ -1574,7 +1574,7 @@ function OPSGROUP:onafterPauseMission(From, Event, To) local Task=Mission:GetGroupWaypointTask(self) -- 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. self:TaskCancel(Task) @@ -1623,7 +1623,7 @@ function OPSGROUP:onafterMissionCancel(From, Event, To, Mission) local Task=Mission:GetGroupWaypointTask(self) -- 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. -- Note that two things can happen. @@ -1850,7 +1850,7 @@ end -- @param #number N Total number of waypoints. function OPSGROUP:onafterPassingWaypoint(From, Event, To, 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) -- Get all waypoint tasks. diff --git a/Moose Development/Moose/Ops/Squadron.lua b/Moose Development/Moose/Ops/Squadron.lua index 8f65cf1d5..5ca14eec4 100644 --- a/Moose Development/Moose/Ops/Squadron.lua +++ b/Moose Development/Moose/Ops/Squadron.lua @@ -84,7 +84,7 @@ SQUADRON = { --- SQUADRON class version. -- @field #string version -SQUADRON.version="0.0.7" +SQUADRON.version="0.1.0" ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -- TODO list diff --git a/Moose Setup/Moose.files b/Moose Setup/Moose.files index f74007e69..994ee660e 100644 --- a/Moose Setup/Moose.files +++ b/Moose Setup/Moose.files @@ -65,11 +65,12 @@ Ops/Airboss.lua Ops/RecoveryTanker.lua Ops/RescueHelo.lua Ops/ATIS.lua -Ops/AirWing.lua Ops/Auftrag.lua +Ops/OpsGroup.lua Ops/FlightGroup.lua Ops/NavyGroup.lua Ops/Squadron.lua +Ops/AirWing.lua AI/AI_Balancer.lua AI/AI_Air.lua