diff --git a/Moose Development/Moose/Ops/Auftrag.lua b/Moose Development/Moose/Ops/Auftrag.lua index bdc45fdad..a180d4d9d 100644 --- a/Moose Development/Moose/Ops/Auftrag.lua +++ b/Moose Development/Moose/Ops/Auftrag.lua @@ -533,7 +533,6 @@ function AUFTRAG:New(Type) self:SetStartState(self.status) -- PLANNED --> (QUEUED) --> (REQUESTED) --> SCHEDULED --> STARTED --> EXECUTING --> DONE - self:AddTransition("*", "Planned", AUFTRAG.Status.PLANNED) -- Mission is in planning stage. self:AddTransition(AUFTRAG.Status.PLANNED, "Queued", AUFTRAG.Status.QUEUED) -- Mission is in queue of an AIRWING. self:AddTransition(AUFTRAG.Status.QUEUED, "Requested", AUFTRAG.Status.REQUESTED) -- Mission assets have been requested from the warehouse. @@ -1728,6 +1727,13 @@ function AUFTRAG:SetOpsTransport(OpsTransport) return self end +--- Get the attach OPS transport of the mission. +-- @param #AUFTRAG self +-- @return Ops.OpsTransport#OPSTRANSPORT The OPS transport assignment attached to the mission. +function AUFTRAG:GetOpsTransport() + return self.opstransport +end + --- Attach OPS transport to the mission. Mission assets will be transported before the mission is started at the OPSGROUP level. -- @param #AUFTRAG self -- @param Core.Zone#ZONE PickupZone Zone where assets are picked up. @@ -2182,6 +2188,15 @@ function AUFTRAG:IsReadyToGo() return false end + -- Ops transport at + if self.opstransport then + if #self.legions>0 then + end + if self.opstransport:IsPlanned() or self.opstransport:IsQueued() or self.opstransport:IsRequested() then + return false + end + end + -- All start conditions true? local startme=self:EvalConditionsAll(self.conditionStart) diff --git a/Moose Development/Moose/Ops/Legion.lua b/Moose Development/Moose/Ops/Legion.lua index 06e63f37b..4154ca1c7 100644 --- a/Moose Development/Moose/Ops/Legion.lua +++ b/Moose Development/Moose/Ops/Legion.lua @@ -157,6 +157,12 @@ function LEGION:AddMission(Mission) -- Add legion to mission. Mission:AddLegion(self) + + if Mission.opstransport then + Mission.opstransport:SetPickupZone(self.spawnzone) + Mission.opstransport:SetEmbarkZone(self.spawnzone) + self:AddOpsTransport(Mission.opstransport) + end -- Add mission to queue. table.insert(self.missionqueue, Mission) @@ -333,6 +339,9 @@ function LEGION:_GetNextMission() -- Check that mission is still scheduled, time has passed and enough assets are available. if can then + + -- Number of required assets. + local Nassets=mission:GetRequiredAssets(self) -- Optimize the asset selection. Most useful assets will come first. We do not include the payload as some assets have and some might not. self:_OptimizeAssetSelection(assets, mission, false) @@ -384,7 +393,7 @@ function LEGION:_GetNextMission() --mission.assets={} -- Assign assets to mission. - for i=1,mission.Nassets[self.alias] do + for i=1,Nassets do local asset=assets[i] --Functional.Warehouse#WAREHOUSE.Assetitem -- Should not happen as we just checked! @@ -398,7 +407,7 @@ function LEGION:_GetNextMission() -- Now return the remaining payloads. if self:IsAirwing() then - for i=mission.Nassets[self.alias]+1,#assets do + for i=Nassets+1,#assets do local asset=assets[i] --Functional.Warehouse#WAREHOUSE.Assetitem for _,uid in pairs(gotpayload) do if uid==asset.uid then @@ -997,9 +1006,14 @@ function LEGION:onafterAssetSpawned(From, Event, To, group, asset, request) if Tacan then --mission:SetTACAN(Tacan, Morse, UnitName, Band) end + + -- Transport for mission assets. + if mission.opstransport then + mission.opstransport:AddCargoGroups(self) + end -- Add mission to flightgroup queue. - flightgroup:AddMission(mission) + flightgroup:AddMission(mission) -- Trigger event. self:__OpsOnMission(5, flightgroup, mission) diff --git a/Moose Development/Moose/Ops/NavyGroup.lua b/Moose Development/Moose/Ops/NavyGroup.lua index 46202c0ed..2b8cec8ba 100644 --- a/Moose Development/Moose/Ops/NavyGroup.lua +++ b/Moose Development/Moose/Ops/NavyGroup.lua @@ -133,16 +133,16 @@ function NAVYGROUP:New(group) self:AddTransition("*", "FullStop", "Holding") -- Hold position. self:AddTransition("*", "Cruise", "Cruising") -- Hold position. - self:AddTransition("*", "TurnIntoWind", "IntoWind") -- Command the group to turn into the wind. - self:AddTransition("IntoWind", "TurnedIntoWind", "IntoWind") -- Group turned into wind. - self:AddTransition("IntoWind", "TurnIntoWindStop", "IntoWind") -- Stop a turn into wind. - self:AddTransition("IntoWind", "TurnIntoWindOver", "Cruising") -- Turn into wind is over. + self:AddTransition("*", "TurnIntoWind", "Cruising") -- Command the group to turn into the wind. + self:AddTransition("*", "TurnedIntoWind", "*") -- Group turned into wind. + self:AddTransition("*", "TurnIntoWindStop", "*") -- Stop a turn into wind. + self:AddTransition("*", "TurnIntoWindOver", "*") -- Turn into wind is over. self:AddTransition("*", "TurningStarted", "*") -- Group started turning. self:AddTransition("*", "TurningStopped", "*") -- Group stopped turning. - self:AddTransition("*", "Detour", "OnDetour") -- Make a detour to a coordinate and resume route afterwards. - self:AddTransition("OnDetour", "DetourReached", "Cruising") -- Group reached the detour coordinate. + self:AddTransition("*", "Detour", "Cruising") -- Make a detour to a coordinate and resume route afterwards. + self:AddTransition("*", "DetourReached", "*") -- Group reached the detour coordinate. self:AddTransition("*", "CollisionWarning", "*") -- Collision warning. self:AddTransition("*", "ClearAhead", "*") -- Clear ahead. @@ -701,9 +701,6 @@ function NAVYGROUP:onafterSpawned(From, Event, To) else self:FullStop() end - - -- Update status. - self:__Status(-0.1) end @@ -938,8 +935,12 @@ function NAVYGROUP:onafterTurnIntoWindOver(From, Event, To, IntoWindData) -- Detour to where we left the route. self:T(self.lid.."FF Turn Into Wind Over ==> Uturn!") - self:Detour(self.intowind.Coordinate, self:GetSpeedCruise(), 0, true) - + + -- ID of current waypoint. + local uid=self:GetWaypointCurrent().uid + + self:AddWaypoint(self.intowind.Coordinate, self:GetSpeedCruise(), uid) + else --- diff --git a/Moose Development/Moose/Ops/OpsGroup.lua b/Moose Development/Moose/Ops/OpsGroup.lua index ebbc98861..8e45f7a07 100644 --- a/Moose Development/Moose/Ops/OpsGroup.lua +++ b/Moose Development/Moose/Ops/OpsGroup.lua @@ -5732,6 +5732,9 @@ end -- @return #OPSGROUP self function OPSGROUP:AddOpsTransport(OpsTransport) + -- Scheduled. + OpsTransport:Scheduled() + -- Add this group as carrier for the transport. OpsTransport:_AddCarrier(self) diff --git a/Moose Development/Moose/Ops/OpsTransport.lua b/Moose Development/Moose/Ops/OpsTransport.lua index 6cdbf7430..0bd288cea 100644 --- a/Moose Development/Moose/Ops/OpsTransport.lua +++ b/Moose Development/Moose/Ops/OpsTransport.lua @@ -186,12 +186,13 @@ function OPSTRANSPORT:New(GroupSet, Pickupzone, Deployzone) -- Set some string id for output to DCS.log file. self.lid=string.format("OPSTRANSPORT [UID=%d] | ", _OPSTRANSPORTID) - -- Defaults. + -- UID of this transport. self.uid=_OPSTRANSPORTID - self.pickupzone=Pickupzone - self.deployzone=Deployzone - self.embarkzone=Pickupzone + -- Defaults. + self:SetPickupZone(Pickupzone) + self:SetDeployZone(Deployzone) + self:SetEmbarkZone() -- Default is pickup zone. self.cargos={} self.carriers={} self.Ncargo=0 @@ -214,7 +215,7 @@ function OPSTRANSPORT:New(GroupSet, Pickupzone, Deployzone) self:AddTransition("*", "Planned", OPSTRANSPORT.Status.PLANNED) -- Cargo transport was planned. self:AddTransition(OPSTRANSPORT.Status.PLANNED, "Queued", OPSTRANSPORT.Status.QUEUED) -- Cargo is queued at at least one carrier. self:AddTransition(OPSTRANSPORT.Status.QUEUED, "Requested", OPSTRANSPORT.Status.REQUESTED) -- Transport assets have been requested from a warehouse. - self:AddTransition(OPSTRANSPORT.Status.QUEUED, "Scheduled", OPSTRANSPORT.Status.SCHEDULED) -- Cargo is queued at at least one carrier. + self:AddTransition(OPSTRANSPORT.Status.REQUESTED, "Scheduled", OPSTRANSPORT.Status.SCHEDULED) -- Cargo is queued at at least one carrier. self:AddTransition(OPSTRANSPORT.Status.PLANNED, "Scheduled", OPSTRANSPORT.Status.SCHEDULED) -- Cargo is queued at at least one carrier. self:AddTransition(OPSTRANSPORT.Status.SCHEDULED, "Executing", OPSTRANSPORT.Status.EXECUTING) -- Cargo is being transported. self:AddTransition("*", "Delivered", OPSTRANSPORT.Status.DELIVERED) -- Cargo was delivered. @@ -290,6 +291,24 @@ function OPSTRANSPORT:AddCargoGroups(GroupSet) return self end +--- Set pickup zone. +-- @param #OPSTRANSPORT self +-- @param Core.Zone#ZONE PickupZone Zone where the troops are picked up. +-- @return #OPSTRANSPORT self +function OPSTRANSPORT:SetPickupZone(PickupZone) + self.pickupzone=PickupZone + return self +end + +--- Set deploy zone. +-- @param #OPSTRANSPORT self +-- @param Core.Zone#ZONE DeployZone Zone where the troops are deployed. +-- @return #OPSTRANSPORT self +function OPSTRANSPORT:SetDeployZone(DeployZone) + self.deployzone=DeployZone + return self +end + --- Set embark zone. -- @param #OPSTRANSPORT self -- @param Core.Zone#ZONE EmbarkZone Zone where the troops are embarked. @@ -792,6 +811,16 @@ function OPSTRANSPORT:IsReadyToGo() -- Current abs time. local Tnow=timer.getAbsTime() + + -- Pickup and deploy zones must be set. + if not self.pickupzone then + text=text.."No, pickup zone not defined!" + return false + end + if not self.deployzone then + text=text.."No, deploy zone not defined!" + return false + end -- Start time did not pass yet. if self.Tstart and Tnow=1 then + if self.verbose>=1 then - -- Info text. - local text=string.format("%s [%s --> %s]: Ncargo=%d/%d, Ncarrier=%d/%d", fsmstate:upper(), self.pickupzone:GetName(), self.deployzone:GetName(), self.Ncargo, self.Ndelivered, #self.carriers,self.Ncarrier) + -- Info text. + local pickupname=self.pickupzone and self.pickupzone:GetName() or "Unknown" + local deployname=self.deployzone and self.deployzone:GetName() or "Unknown" + local text=string.format("%s [%s --> %s]: Ncargo=%d/%d, Ncarrier=%d/%d", fsmstate:upper(), pickupname, deployname, self.Ncargo, self.Ndelivered, #self.carriers, self.Ncarrier) -- Info about cargo and carrier. if self.verbose>=2 then