diff --git a/Moose Development/Moose/Ops/Auftrag.lua b/Moose Development/Moose/Ops/Auftrag.lua index f8775e972..faed0e4f9 100644 --- a/Moose Development/Moose/Ops/Auftrag.lua +++ b/Moose Development/Moose/Ops/Auftrag.lua @@ -2076,6 +2076,9 @@ function AUFTRAG:SetRequiredEscorts(NescortMin, NescortMax) if self.NescortMax=8 then + NassetsMax=3 + elseif target.threatlevel0>=5 then + NassetsMax=2 + else + NassetsMax=1 + end for _,_mp in pairs(MissionPerformances) do local mp=_mp --#CHIEF.MissionPerformance diff --git a/Moose Development/Moose/Ops/Commander.lua b/Moose Development/Moose/Ops/Commander.lua index d3f478966..d3834fda3 100644 --- a/Moose Development/Moose/Ops/Commander.lua +++ b/Moose Development/Moose/Ops/Commander.lua @@ -668,7 +668,7 @@ function COMMANDER:onafterStatus(From, Event, To) state=asset.flightgroup:GetState() local mission=legion:GetAssetCurrentMission(asset) if mission then - state=state..string.format("Mission %s [%s]", mission:GetName(), mission:GetType()) + state=state..string.format(", Mission \"%s\" [%s]", mission:GetName(), mission:GetType()) end else if asset.spawned then @@ -1023,7 +1023,7 @@ end function COMMANDER:RecruitAssetsForMission(Mission) -- Debug info. - env.info(string.format("FF recruiting assets for mission %s [%s]", Mission:GetName(), Mission:GetType())) + self:T2(self.lid..string.format("Recruiting assets for mission \"%s\" [%s]", Mission:GetName(), Mission:GetType())) -- Cohorts. local Cohorts={} @@ -1102,7 +1102,7 @@ function COMMANDER:RecruitAssetsForEscort(Mission, Assets) -- Call LEGION function but provide COMMANDER as self. - local assigned=LEGION.AssignAssetsForEscort(self, Cohorts, Assets, Mission.NescortMin, Mission.NescortMin) + local assigned=LEGION.AssignAssetsForEscort(self, Cohorts, Assets, Mission.NescortMin, Mission.NescortMax) return assigned end diff --git a/Moose Development/Moose/Ops/FlightControl.lua b/Moose Development/Moose/Ops/FlightControl.lua index af0c700f6..54397657d 100644 --- a/Moose Development/Moose/Ops/FlightControl.lua +++ b/Moose Development/Moose/Ops/FlightControl.lua @@ -90,6 +90,7 @@ FLIGHTCONTROL = { --- Parking spot data. -- @type FLIGHTCONTROL.FlightStatus +-- @field #string UNKNOWN Flight state is unknown. -- @field #string INBOUND Flight is inbound. -- @field #string HOLDING Flight is holding. -- @field #string LANDING Flight is landing. @@ -99,6 +100,7 @@ FLIGHTCONTROL = { -- @field #string READYTO Flight is ready for takeoff. -- @field #string TAKEOFF Flight is taking off. FLIGHTCONTROL.FlightStatus={ + UNKNOWN="Unknown", INBOUND="Inbound", HOLDING="Holding", LANDING="Landing", @@ -923,8 +925,11 @@ function FLIGHTCONTROL:_RemoveFlightFromQueue(queue, flight, queuename) self:I(self.lid..string.format("Removing flight group %s from %s queue.", flight.groupname, queuename)) table.remove(queue, i) - if not flight.isAI then - flight:_UpdateMenu() + if not flight.isAI then + if flight.flightcontrol and flight.flightcontrol.airbasename==self.airbasename then + flight.flightcontrol=nil + end + flight:_UpdateMenu(0.1) end return true, i @@ -1413,7 +1418,7 @@ function FLIGHTCONTROL:_CreatePlayerMenu(flight, atcmenu) local airbaseName=airbasename local airbaseName2=airbaseName if gotcontrol then - airbaseName2=airbaseName2.." *" + --airbaseName2=airbaseName2.." *" end local Tag=airbasename local Tnow=timer.getTime() @@ -1466,6 +1471,10 @@ function FLIGHTCONTROL:_CreatePlayerMenu(flight, atcmenu) MENU_GROUP_COMMAND_DELAYED:New(group, "Holding", rootmenu, self._PlayerHolding, self, groupname):SetTime(Tnow):SetTag(Tag) end + + if flight:IsInbound() or flight:IsHolding() or flight:IsLanding() or flight:IsLanded() then + MENU_GROUP_COMMAND_DELAYED:New(group, "Abort Inbound", rootmenu, self._PlayerAbortInbound, self, groupname):SetTime(Tnow):SetTag(Tag) + end if flight:IsInbound() or flight:IsHolding() or flight:IsLanding() or flight:IsLanded() then MENU_GROUP_COMMAND_DELAYED:New(group, "Request Parking", rootmenu, self._PlayerRequestParking, self, groupname):SetTime(Tnow):SetTag(Tag) @@ -1692,7 +1701,7 @@ function FLIGHTCONTROL:_PlayerHolding(groupname) local text=string.format("Roger, you are added to the holding queue!") MESSAGE:New(text, 5):ToGroup(flight.group) - -- Call holding event. + -- Call holding event. Updates the menu. flight:Holding() else @@ -1841,6 +1850,40 @@ function FLIGHTCONTROL:_PlayerAbortTakeoff(groupname) end +--- Player wants to abort inbound. +-- @param #FLIGHTCONTROL self +-- @param #string groupname Name of the flight group. +function FLIGHTCONTROL:_PlayerAbortInbound(groupname) + + MESSAGE:New("Abort inbound", 5):ToAll() + + local flight=_DATABASE:GetOpsGroup(groupname) + + if flight then + + local flightstatus=self:GetFlightStatus(flight) + if flightstatus==FLIGHTCONTROL.FlightStatus.INBOUND or flightstatus==FLIGHTCONTROL.FlightStatus.HOLDING or flightstatus==FLIGHTCONTROL.FlightStatus.LANDING then + + MESSAGE:New("Afirm, You are removed from all queues queue", 5):ToAll() + + --TODO: what now? taxi inbound? or just another later attempt to takeoff. + self:SetFlightStatus(flight,FLIGHTCONTROL.FlightStatus.UNKNOWN) + + -- Remove flight. + self:_RemoveFlight(flight) + + -- Trigger cruise event. + flight:Cruise() + + + else + MESSAGE:New("Negative, You are NOT in the state INBOUND, HOLDING or LANDING!", 5):ToAll() + end + + end + +end + ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -- Flight and Element Functions ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/Moose Development/Moose/Ops/FlightGroup.lua b/Moose Development/Moose/Ops/FlightGroup.lua index 1c5e657cd..54e6e10d4 100644 --- a/Moose Development/Moose/Ops/FlightGroup.lua +++ b/Moose Development/Moose/Ops/FlightGroup.lua @@ -1544,6 +1544,8 @@ function FLIGHTGROUP:onafterSpawned(From, Event, To) self:__UpdateRoute(-0.5) else + + env.info("FF Spawned update menu") -- F10 other menu. self:_UpdateMenu() @@ -1695,7 +1697,7 @@ function FLIGHTGROUP:onafterCruise(From, Event, To) -- CLIENT --- - self:_UpdateMenu() + self:_UpdateMenu(0.1) end @@ -3218,7 +3220,7 @@ end -- @return #boolean Hot start? function FLIGHTGROUP:IsTakeoffHot() - local wp=self:GetWaypoint(1) + local wp=self.waypoints0 and self.waypoints0[1] or nil --self:GetWaypoint(1) if wp then @@ -3238,7 +3240,7 @@ end -- @return #boolean Cold start, i.e. engines off when spawned? function FLIGHTGROUP:IsTakeoffCold() - local wp=self:GetWaypoint(1) + local wp=self.waypoints0 and self.waypoints0[1] or nil --self:GetWaypoint(1) if wp then @@ -3258,7 +3260,7 @@ end -- @return #boolean Runway start? function FLIGHTGROUP:IsTakeoffRunway() - local wp=self:GetWaypoint(1) + local wp=self.waypoints0 and self.waypoints0[1] or nil --self:GetWaypoint(1) if wp then @@ -3278,7 +3280,7 @@ end -- @return #boolean Air start? function FLIGHTGROUP:IsTakeoffAir() - local wp=self:GetWaypoint(1) + local wp=self.waypoints0 and self.waypoints0[1] or nil --self:GetWaypoint(1) if wp then @@ -4009,19 +4011,28 @@ function FLIGHTGROUP:_UpdateMenu(delay) return a.dist0 or Mission.NescortMax>0) then -- Debug info. - self:I(self.lid..string.format("Reqested escort for mission %s [%s]. Required assets=%d-%d", Mission:GetName(), Mission:GetType(), Mission.NescortMin,Mission.NescortMax)) + self:I(self.lid..string.format("Requested escort for mission %s [%s]. Required assets=%d-%d", Mission:GetName(), Mission:GetType(), Mission.NescortMin,Mission.NescortMax)) -- Get special escort legions and/or cohorts. local Cohorts={} @@ -1855,7 +1855,7 @@ function LEGION:RecruitAssetsForEscort(Mission, Assets) end -- Call LEGION function but provide COMMANDER as self. - local assigned=LEGION.AssignAssetsForEscort(self, Cohorts, Assets, Mission.NescortMin, Mission.NescortMin) + local assigned=LEGION.AssignAssetsForEscort(self, Cohorts, Assets, Mission.NescortMin, Mission.NescortMax) return assigned end @@ -2083,7 +2083,7 @@ function LEGION:AssignAssetsForEscort(Cohorts, Assets, NescortMin, NescortMax) if NescortMin and NescortMax and (NescortMin>0 or NescortMax>0) then -- Debug info. - self:I(self.lid..string.format("Reqested escort for %d assets from %d cohorts. Required escort assets=%d-%d", #Assets, #Cohorts, NescortMin, NescortMax)) + self:T(self.lid..string.format("Requested escort for %d assets from %d cohorts. Required escort assets=%d-%d", #Assets, #Cohorts, NescortMin, NescortMax)) -- Escorts for each asset. local Escorts={} @@ -2153,14 +2153,14 @@ function LEGION:AssignAssetsForEscort(Cohorts, Assets, NescortMin, NescortMax) end -- Debug info. - self:I(self.lid..string.format("Recruited %d escort assets", N)) + self:T(self.lid..string.format("Recruited %d escort assets", N)) -- Yup! return true else -- Debug info. - self:I(self.lid..string.format("Could not get at least one escort!")) + self:T(self.lid..string.format("Could not get at least one escort!")) -- Could not get at least one escort. Unrecruit all recruited ones. for groupname,value in pairs(Escorts) do @@ -2174,6 +2174,7 @@ function LEGION:AssignAssetsForEscort(Cohorts, Assets, NescortMin, NescortMax) else -- No escort required. + self:T(self.lid..string.format("No escort required! NescortMin=%s, NescortMax=%s", tostring(NescortMin), tostring(NescortMax))) return true end @@ -2392,6 +2393,7 @@ function LEGION._OptimizeAssetSelection(assets, MissionType, TargetVec2, Include table.sort(assets, optimize) -- Remove distance parameter. + --[[ local text=string.format("Optimized %d assets for %s mission/transport (payload=%s):", #assets, MissionType, tostring(IncludePayload)) for i,Asset in pairs(assets) do local asset=Asset --Functional.Warehouse#WAREHOUSE.Assetitem @@ -2399,6 +2401,7 @@ function LEGION._OptimizeAssetSelection(assets, MissionType, TargetVec2, Include asset.score=nil end env.info(text) + ]] end diff --git a/Moose Development/Moose/Ops/OpsGroup.lua b/Moose Development/Moose/Ops/OpsGroup.lua index e74bd3147..7ab640d1b 100644 --- a/Moose Development/Moose/Ops/OpsGroup.lua +++ b/Moose Development/Moose/Ops/OpsGroup.lua @@ -3469,7 +3469,8 @@ function OPSGROUP:onbeforeTaskExecute(From, Event, To, Task) -- Group is already waiting else -- Wait indefinately. - self:Wait() + local alt=Mission.missionAltitude and UTILS.MetersToFeet(Mission.missionAltitude) or nil + self:Wait(nil, alt) end -- Time to for the next try. Best guess is when push time is reached or 20 sec when push conditions are not true yet. @@ -8762,7 +8763,7 @@ end function OPSGROUP:_InitWaypoints(WpIndexMin, WpIndexMax) -- Template waypoints. - self.waypoints0=self.group:GetTemplateRoutePoints() + self.waypoints0=UTILS.DeepCopy(_DATABASE:GetGroupTemplate(self.groupname).route.points) --self.group:GetTemplateRoutePoints() -- Waypoints empty! self.waypoints={} @@ -10904,7 +10905,7 @@ function OPSGROUP:_AddElementByName(unitname) local text=string.format("Adding element %s: status=%s, skill=%s, life=%.1f/%.1f category=%s (%d), type=%s, size=%.1f (L=%.1f H=%.1f W=%.1f), weight=%.1f/%.1f (cargo=%.1f/%.1f)", element.name, element.status, element.skill, element.life, element.life0, element.categoryname, element.category, element.typename, element.size, element.length, element.height, element.width, element.weight, element.weightMaxTotal, element.weightCargo, element.weightMaxCargo) - self:I(self.lid..text) + self:T(self.lid..text) -- Add element to table. if not self:_IsElement(unitname) then @@ -10930,7 +10931,7 @@ end function OPSGROUP:_SetTemplate(Template) -- Set the template. - self.template=Template or self.group:GetTemplate() + self.template=Template or UTILS.DeepCopy(_DATABASE:GetGroupTemplate(self.groupname)) --self.group:GetTemplate() -- Debug info. self:T3(self.lid.."Setting group template")