diff --git a/Moose Development/Moose/Ops/Auftrag.lua b/Moose Development/Moose/Ops/Auftrag.lua index cae2c17c4..e2e94d412 100644 --- a/Moose Development/Moose/Ops/Auftrag.lua +++ b/Moose Development/Moose/Ops/Auftrag.lua @@ -397,6 +397,7 @@ AUFTRAG = { conditionPush = {}, conditionSuccessSet = false, conditionFailureSet = false, + repeatDelay = 1, } --- Global mission counter. @@ -3002,6 +3003,16 @@ function AUFTRAG:SetRepeat(Nrepeat) return self end + +--- **[LEGION, COMMANDER, CHIEF]** Set the repeat delay in seconds after a mission is successful/failed. Only valid if the mission is handled by a LEGION (AIRWING, BRIGADE, FLEET) or higher level. +-- @param #AUFTRAG self +-- @param #number Nrepeat Repeat delay in seconds. Default 1. +-- @return #AUFTRAG self +function AUFTRAG:SetRepeatDelay(RepeatDelay) + self.repeatDelay = RepeatDelay + return self +end + --- **[LEGION, COMMANDER, CHIEF]** Set how many times the mission is repeated if it fails. Only valid if the mission is handled by a LEGION (AIRWING, BRIGADE, FLEET) or higher level. -- @param #AUFTRAG self -- @param #number Nrepeat Number of repeats. Default 0. @@ -5203,7 +5214,7 @@ function AUFTRAG:onafterSuccess(From, Event, To) -- Repeat mission. self:T(self.lid..string.format("Mission SUCCESS! Repeating mission for the %d time (max %d times) ==> Repeat mission!", self.repeated+1, N)) - self:Repeat() + self:__Repeat(self.repeatDelay) else @@ -5245,7 +5256,7 @@ function AUFTRAG:onafterFailed(From, Event, To) -- Repeat mission. self:T(self.lid..string.format("Mission FAILED! Repeating mission for the %d time (max %d times) ==> Repeat mission!", self.repeated+1, N)) - self:Repeat() + self:__Repeat(self.repeatDelay) else diff --git a/Moose Development/Moose/Ops/Commander.lua b/Moose Development/Moose/Ops/Commander.lua index a29b2538b..22a198b0e 100644 --- a/Moose Development/Moose/Ops/Commander.lua +++ b/Moose Development/Moose/Ops/Commander.lua @@ -136,6 +136,7 @@ COMMANDER = { awacsZones = {}, tankerZones = {}, limitMission = {}, + MaxMissionsAssignPerCycle = 1, } --- COMMANDER class version. @@ -1535,6 +1536,8 @@ function COMMANDER:CheckMissionQueue() end end + local missionsAssigned = 0 + -- Loop over missions in queue. for _,_mission in pairs(self.missionqueue) do local mission=_mission --Ops.Auftrag#AUFTRAG @@ -1594,9 +1597,12 @@ function COMMANDER:CheckMissionQueue() -- Recruited assets but no requested escort available. Unrecruit assets! LEGION.UnRecruitAssets(assets, mission) end - - -- Only ONE mission is assigned. - return + + missionsAssigned = missionsAssigned + 1 + if missionsAssigned >= self.maxMissionsAssignPerCycle then + return + end + end else @@ -1611,6 +1617,16 @@ function COMMANDER:CheckMissionQueue() end +--- Set how many missions can be assigned in a single status iteration. (eg. This is useful for persistent missions where you need to load all AUFTRAGs on mission start and then change it back to default) +--- Warning: Increasing this value will increase the number of missions started per iteration and thus may lead to performance issues if too many missions are started at once. +-- @param #COMMANDER self +-- @param #number Number of missions assigned per status iteration. Default is 1. +-- @return #COMMANDER self. +function COMMANDER:SetMaxMissionsAssignPerCycle(MaxMissionsAssignPerCycle) + self.maxMissionsAssignPerCycle = MaxMissionsAssignPerCycle or 1 + return self +end + --- Get cohorts. -- @param #COMMANDER self -- @param #table Legions Special legions. diff --git a/Moose Development/Moose/Ops/FlightGroup.lua b/Moose Development/Moose/Ops/FlightGroup.lua index 33307d155..58aba8276 100644 --- a/Moose Development/Moose/Ops/FlightGroup.lua +++ b/Moose Development/Moose/Ops/FlightGroup.lua @@ -4497,6 +4497,11 @@ function FLIGHTGROUP:GetParkingSpot(element, maxdist, airbase) -- Airbase. airbase=airbase or self:GetClosestAirbase() + if airbase == nil then + self:T(self.lid.."No airbase found for element "..element.name) + return nil + end + -- Parking table of airbase. local parking=airbase.parking --:GetParkingSpotsTable()