diff --git a/Moose Development/Moose/Functional/Warehouse.lua b/Moose Development/Moose/Functional/Warehouse.lua index 1c571b93c..e352dce84 100644 --- a/Moose Development/Moose/Functional/Warehouse.lua +++ b/Moose Development/Moose/Functional/Warehouse.lua @@ -2647,6 +2647,25 @@ function WAREHOUSE:_CheckParkingValid(spot) return false end +--- Check parking ID for an asset. +-- @param #WAREHOUSE self +-- @param Wrapper.Airbase#AIRBASE.ParkingSpot spot Parking spot. +-- @return #boolean If true, parking is valid. +function WAREHOUSE:_CheckParkingAsset(spot, asset) + + if asset.parkingIDs==nil then + return true + end + + for _,id in pairs(asset.parkingIDs or {}) do + if spot.TerminalID==id then + return true + end + end + + return false +end + --- Enable auto save of warehouse assets at mission end event. -- @param #WAREHOUSE self @@ -7848,7 +7867,7 @@ function WAREHOUSE:_FindParkingForAssets(airbase, assets) local parkingspot=_parkingspot --Wrapper.Airbase#AIRBASE.ParkingSpot -- Check correct terminal type for asset. We don't want helos in shelters etc. - if AIRBASE._CheckTerminalType(parkingspot.TerminalType, terminaltype) and self:_CheckParkingValid(parkingspot) and airbase:_CheckParkingLists(parkingspot.TerminalID) then + if AIRBASE._CheckTerminalType(parkingspot.TerminalType, terminaltype) and self:_CheckParkingValid(parkingspot) and self:_CheckParkingAsset(parkingspot, asset) and airbase:_CheckParkingLists(parkingspot.TerminalID) then -- Coordinate of the parking spot. local _spot=parkingspot.Coordinate -- Core.Point#COORDINATE diff --git a/Moose Development/Moose/Ops/AirWing.lua b/Moose Development/Moose/Ops/AirWing.lua index 5e702896b..58e8ebb95 100644 --- a/Moose Development/Moose/Ops/AirWing.lua +++ b/Moose Development/Moose/Ops/AirWing.lua @@ -155,7 +155,7 @@ AIRWING = { --- AIRWING class version. -- @field #string version -AIRWING.version="0.6.0" +AIRWING.version="0.7.0" ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -- ToDo list @@ -745,6 +745,11 @@ end -- @return #AIRWING.PatrolData Patrol point table. function AIRWING:NewPatrolPoint(Type, Coordinate, Altitude, Speed, Heading, LegLength, RefuelSystem) + -- Check if a zone was passed instead of a coordinate. + if Coordinate:IsInstanceOf("ZONE_BASE") then + Coordinate=Coordinate:GetCoordinate() + end + local patrolpoint={} --#AIRWING.PatrolData patrolpoint.type=Type or "Unknown" patrolpoint.coord=Coordinate or self:GetCoordinate():Translate(UTILS.NMToMeters(math.random(10, 15)), math.random(360)) @@ -994,7 +999,7 @@ function AIRWING:CheckTANKER() for _,_mission in pairs(self.missionqueue) do local mission=_mission --Ops.Auftrag#AUFTRAG - if mission:IsNotOver() and mission.type==AUFTRAG.Type.TANKER then + if mission:IsNotOver() and mission.type==AUFTRAG.Type.TANKER and mission.patroldata then if mission.refuelSystem==Unit.RefuelingSystem.BOOM_AND_RECEPTACLE then Nboom=Nboom+1 elseif mission.refuelSystem==Unit.RefuelingSystem.PROBE_AND_DROGUE then @@ -1566,6 +1571,9 @@ function AIRWING:onafterNewAsset(From, Event, To, asset, assignment) -- Set takeoff type. asset.takeoffType=squad.takeoffType + + -- Set parking IDs. + asset.parkingIDs=squad.parkingIDs -- Create callsign and modex (needs to be after grouping). squad:GetCallsign(asset) @@ -2032,6 +2040,23 @@ function AIRWING:CountAssets() return N end + +--- Count total number of assets that are in the warehouse stock (not spawned). +-- @param #AIRWING self +-- @param #table MissionTypes (Optional) Count only assest that can perform certain mission type(s). Default is all types. +-- @return #number Amount of asset groups in stock. +function AIRWING:CountAssetsInStock(MissionTypes) + + local N=0 + + for _,_squad in pairs(self.squadrons) do + local squad=_squad --Ops.Squadron#SQUADRON + N=N+squad:CountAssetsInStock(MissionTypes) + end + + return N +end + --- Count assets on mission. -- @param #AIRWING self -- @param #table MissionTypes Types on mission to be checked. Default all. diff --git a/Moose Development/Moose/Ops/Airboss.lua b/Moose Development/Moose/Ops/Airboss.lua index e0cff612e..d49d52b6f 100644 --- a/Moose Development/Moose/Ops/Airboss.lua +++ b/Moose Development/Moose/Ops/Airboss.lua @@ -3601,36 +3601,39 @@ function AIRBOSS:_CheckAIStatus() -- Unit local unit=element.unit - -- Get lineup and distance to carrier. - local lineup=self:_Lineup(unit, true) + if unit and unit:IsAlive() then - local unitcoord=unit:GetCoord() + -- Get lineup and distance to carrier. + local lineup=self:_Lineup(unit, true) - local dist=unitcoord:Get2DDistance(self:GetCoord()) + local unitcoord=unit:GetCoord() - -- Distance in NM. - local distance=UTILS.MetersToNM(dist) + local dist=unitcoord:Get2DDistance(self:GetCoord()) - -- Altitude in ft. - local alt=UTILS.MetersToFeet(unitcoord.y) + -- Distance in NM. + local distance=UTILS.MetersToNM(dist) - -- Check if parameters are right and flight is in the groove. - if lineup<2 and distance<=0.75 and alt<500 and not element.ballcall then + -- Altitude in ft. + local alt=UTILS.MetersToFeet(unitcoord.y) - -- Paddles: Call the ball! - self:RadioTransmission(self.LSORadio, self.LSOCall.CALLTHEBALL, nil, nil, nil, true) + -- Check if parameters are right and flight is in the groove. + if lineup<2 and distance<=0.75 and alt<500 and not element.ballcall then - -- Pilot: "405, Hornet Ball, 3.2" - self:_LSOCallAircraftBall(element.onboard,self:_GetACNickname(unit:GetTypeName()), self:_GetFuelState(unit)/1000) + -- Paddles: Call the ball! + self:RadioTransmission(self.LSORadio, self.LSOCall.CALLTHEBALL, nil, nil, nil, true) - -- Paddles: Roger ball after 0.5 seconds. - self:RadioTransmission(self.LSORadio, self.LSOCall.ROGERBALL, nil, nil, 0.5, true) + -- Pilot: "405, Hornet Ball, 3.2" + self:_LSOCallAircraftBall(element.onboard,self:_GetACNickname(unit:GetTypeName()), self:_GetFuelState(unit)/1000) - -- Flight element called the ball. - element.ballcall=true + -- Paddles: Roger ball after 0.5 seconds. + self:RadioTransmission(self.LSORadio, self.LSOCall.ROGERBALL, nil, nil, 0.5, true) - -- This is for the whole flight. Maybe we need it. - flight.ballcall=true + -- Flight element called the ball. + element.ballcall=true + + -- This is for the whole flight. Maybe we need it. + flight.ballcall=true + end end end diff --git a/Moose Development/Moose/Ops/Auftrag.lua b/Moose Development/Moose/Ops/Auftrag.lua index c9bd4ca98..de8f0e82b 100644 --- a/Moose Development/Moose/Ops/Auftrag.lua +++ b/Moose Development/Moose/Ops/Auftrag.lua @@ -53,8 +53,9 @@ -- @field #number dTevaluate Time interval in seconds before the mission result is evaluated after mission is over. -- @field #number Tover Mission abs. time stamp, when mission was over. -- @field #table conditionStart Condition(s) that have to be true, before the mission will be started. --- @field #table conditionSuccess If all stop conditions are true, the mission is cancelled. --- @field #table conditionFailure If all stop conditions are true, the mission is cancelled. +-- @field #table conditionSuccess If all conditions are true, the mission is cancelled. +-- @field #table conditionFailure If all conditions are true, the mission is cancelled. +-- @field #table conditionPush If all conditions are true, the mission is executed. Before, the group(s) wait at the mission execution waypoint. -- -- @field #number orbitSpeed Orbit speed in m/s. -- @field #number orbitAltitude Orbit altitude in meters. @@ -288,6 +289,7 @@ AUFTRAG = { conditionStart = {}, conditionSuccess = {}, conditionFailure = {}, + conditionPush = {}, } --- Global mission counter. @@ -445,7 +447,7 @@ AUFTRAG.TargetType={ --- AUFTRAG class version. -- @field #string version -AUFTRAG.version="0.7.0" +AUFTRAG.version="0.7.1" ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -- TODO list @@ -1825,6 +1827,26 @@ function AUFTRAG:AddConditionFailure(ConditionFunction, ...) return self end +--- Add push condition. +-- @param #AUFTRAG self +-- @param #function ConditionFunction If this function returns `true`, the mission is executed. +-- @param ... Condition function arguments if any. +-- @return #AUFTRAG self +function AUFTRAG:AddConditionPush(ConditionFunction, ...) + + local condition={} --#AUFTRAG.Condition + + condition.func=ConditionFunction + condition.arg={} + if arg then + condition.arg=arg + end + + table.insert(self.conditionPush, condition) + + return self +end + --- Assign airwing squadron(s) to the mission. Only these squads will be considered for the job. -- @param #AUFTRAG self @@ -1983,12 +2005,12 @@ function AUFTRAG:IsReadyToGo() local Tnow=timer.getAbsTime() -- Start time did not pass yet. - if self.Tstart and Tnowself.Tstop or false then + if self.Tstop and Tnow>self.Tstop then return false end @@ -2014,7 +2036,7 @@ function AUFTRAG:IsReadyToCancel() local Tnow=timer.getAbsTime() -- Stop time already passed. - if self.Tstop and Tnow>self.Tstop then + if self.Tstop and Tnow>=self.Tstop then return true end @@ -2038,6 +2060,26 @@ function AUFTRAG:IsReadyToCancel() return false end +--- Check if mission is ready to be pushed. +-- * Mission push time already passed. +-- * All push conditions are true. +-- @param #AUFTRAG self +-- @return #boolean If true, mission groups can push. +function AUFTRAG:IsReadyToPush() + + local Tnow=timer.getAbsTime() + + -- Push time passed? + if self.Tpush and Tnow0) then + + if Mission:IsReadyToPush() then - if Mission.Tpush then + -- Not waiting any more. + self.Twaiting=nil + self.dTwait=nil - local Tnow=timer.getAbsTime() + else - -- Time to push - local dt=Mission.Tpush-Tnow - - -- Push time not reached. - if Tnow