diff --git a/Moose Development/Moose/Ops/AirWing.lua b/Moose Development/Moose/Ops/AirWing.lua index 6b9d51128..55f8cf555 100644 --- a/Moose Development/Moose/Ops/AirWing.lua +++ b/Moose Development/Moose/Ops/AirWing.lua @@ -21,6 +21,12 @@ -- @field #table missionqueue Mission queue table. -- @field #table payloads Playloads for specific aircraft and mission types. -- @field #number payloadcounter Running index of payloads. +-- @field Core.Set#SET_ZONE zonesetCAP Set of CAP zones. +-- @field Core.Set#SET_ZONE zonesetTANKER Set of TANKER zones. +-- @field Core.Set#SET_ZONE zonesetAWACS Set of AWACS zones. +-- @field #number nflightsCAP Number of CAP flights constantly in the air. +-- @field #number nflightsTANKER Number of TANKER flights constantly in the air. +-- @field #number nflightsAWACS Number of AWACS flights constantly in the air. -- @extends Functional.Warehouse#WAREHOUSE --- Be surprised! @@ -42,6 +48,7 @@ AIRWING = { squadrons = {}, missionqueue = {}, payloads = {}, + cappoints = {}, } --- Squadron data. @@ -56,7 +63,6 @@ AIRWING = { --- Squadron asset. -- @type AIRWING.SquadronAsset -- @field #AIRWING.Payload payload The payload of the asset. --- @field Ops.Auftrag#AUFTRAG mission The assigned mission. -- @field Ops.FlightGroup#FLIGHTGROUP flightgroup The flightgroup object. -- @extends Functional.Warehouse#WAREHOUSE.Assetitem @@ -69,10 +75,17 @@ AIRWING = { -- @field #number navail Number of available payloads of this type. -- @field #boolean unlimited If true, this payload is unlimited and does not get consumed. +--- CAP data. +-- @type AIRWING.PatrolData +-- @field Core.Point#COORDINATE coord CAP coordinate. +-- @field #number heading heading +-- @field #number leg Leg. +-- @field #number speed Speed. +-- @field #boolean occupied Is currently occupied. --- AIRWING class version. -- @field #string version -AIRWING.version="0.1.3" +AIRWING.version="0.1.4" ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -- ToDo list @@ -82,11 +95,13 @@ AIRWING.version="0.1.3" -- TODO: Make special request to transfer squadrons to anther airwing (or warehouse). -- DONE: Build mission queue. -- DONE: Find way to start missions. --- TODO: Check if missions are accomplished. +-- TODO: Check if missions are done/cancelled. -- DONE: Payloads as resources. -- TODO: Spawn in air or hot. -- TODO: Define CAP zones. -- TODO: Define TANKER zones for refuelling. +-- TODO: Border zone or even multiple zones. +-- TODO: Check that airbase has enough parking spots if a request is BIG. Alternatively, split requests. ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -- Constructor @@ -112,7 +127,6 @@ function AIRWING:New(warehousename, airwingname) -- Add FSM transitions. -- From State --> Event --> To State - self:AddTransition("*", "MissionNew", "*") -- Add a new mission. self:AddTransition("*", "MissionRequest", "*") -- Add a (mission) request to the warehouse. self:AddTransition("*", "MissionDone", "*") -- Mission is over. self:AddTransition("*", "MissionCancel", "*") -- Mission is over. @@ -190,7 +204,7 @@ end -- @param Wrapper.Unit#UNIT Unit The unit, the payload is extracted from. Can also be given as *#string* name of the unit. -- @param #table MissionTypes Mission types this payload can be used for. -- @param #number Npayloads Number of payloads to add to the airwing resources. Default 99 (which should be enough for most scenarios). --- @param #boolan Unlimited If true, this payload is unlimited. +-- @param #boolean Unlimited If true, this payload is unlimited. -- @return #AIRWING.Payload The payload table or nil if the unit does not exist. function AIRWING:NewPayload(Unit, MissionTypes, Npayloads, Unlimited) @@ -323,31 +337,52 @@ end --- Add mission to queue. -- @param #AIRWING self -- @param Ops.Auftrag#AUFTRAG Mission for this group. --- @param #number Nassets Number of required assets for this mission. Default 1. --- @param Core.Point#COORDINATE WaypointCoordinate Coordinate of the mission waypoint. -- @return #AIRWING self -function AIRWING:AddMission(Mission, Nassets, WaypointCoordinate) - - -- Number of assets. - Mission.nassets=Mission.nassets and Mission.nassets or (Nassets or 1) - - Mission.waypointcoord=WaypointCoordinate - Mission.waypointindex=nil +function AIRWING:AddMission(Mission) -- Set status to QUEUED. Mission:Queued() + + -- Set airwing. + Mission.airwing=self -- Add mission to queue. table.insert(self.missionqueue, Mission) -- Info text. - local text=string.format("Added %s mission %s at waypoint #%s. Starting at %s. Stopping at %s", - tostring(Mission.type), tostring(Mission.name), tostring(Mission.waypointindex), UTILS.SecondsToClock(Mission.Tstart, true), Mission.Tstop and UTILS.SecondsToClock(Mission.Tstop, true) or "never") + local text=string.format("Added %s mission %s. Starting at %s. Stopping at %s", + tostring(Mission.type), tostring(Mission.name), UTILS.SecondsToClock(Mission.Tstart, true), Mission.Tstop and UTILS.SecondsToClock(Mission.Tstop, true) or "never") self:I(self.lid..text) return self end +--- Set CAP zones. +-- @param #AIRWING self +-- @param #number n Number of flights. Default 1. +-- @return #AIRWING self +function AIRWING:SetCAPflights(n) + self.nflightsCAP=n + return self +end + +--- Add a CAP zone. +-- @param #AIRWING self +-- @param Core.Zone#ZONE AcceptZone Add a zone to the CAP zone set. +-- @return #AIRWING self +function AIRWING:AddCAPPoint(Coordinate, Heading, Leg, Speed) + + local cappoint={} --#AIRWING.PatrolData + cappoint.coord=Coordinate + cappoint.heading=Heading or 090 + cappoint.leg=Leg or 15 + cappoint.speed=Speed or 350 + + table.insert(self.cappoints, cappoint) + + return self +end + ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -- Start & Status ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- @@ -362,12 +397,17 @@ function AIRWING:onafterStart(From, Event, To) -- Info. self:I(self.lid..string.format("Starting AIRWING v%s", AIRWING.version)) - -- Add F10 radio menu. - self:_SetMenuCoalition() + -- Menu. + if false then - for _,_squadron in pairs(self.squadrons) do - local squadron=_squadron --#AIRWING.Squadron - self:_AddSquadonMenu(squadron) + -- Add F10 radio menu. + self:_SetMenuCoalition() + + for _,_squadron in pairs(self.squadrons) do + local squadron=_squadron --#AIRWING.Squadron + self:_AddSquadonMenu(squadron) + end + end end @@ -422,6 +462,8 @@ function AIRWING:onafterStatus(From, Event, To) end self:I(self.lid..text) + + -------------- -- Mission --- -------------- @@ -471,7 +513,7 @@ function AIRWING:_GetNextMission() local can, assets=self:CanMission(mission.type, mission.nassets) -- Debug output. - self:T3({self.lid.."Mission check:", MissionStatusScheduled=mission.status==AUFTRAG.Status.SCHEDULED, TstartPassed=time>=mission.Tstart, CanMission=can, Nassets=#assets}) + self:T3({self.lid.."Mission check:", TstartPassed=time>=mission.Tstart, CanMission=can, Nassets=#assets}) -- Check that mission is still scheduled, time has passed and enough assets are available. if can then @@ -494,8 +536,6 @@ function AIRWING:_GetNextMission() end table.insert(mission.assets, asset) - - asset.mission=mission end return mission @@ -609,7 +649,7 @@ function AIRWING:onafterMissionCancel(From, Event, To, Mission) end ---- On after "MissionRequest" event. Performs a self request to the warehouse for the mission assets. Sets mission status to ASSIGNED. +--- On after "MissionRequest" event. Performs a self request to the warehouse for the mission assets. Sets mission status to REQUESTED. -- @param #AIRWING self -- @param #string From From state. -- @param #string Event Event. @@ -617,12 +657,14 @@ end -- @param Ops.Auftrag#AUFTRAG Mission The requested mission. function AIRWING:onafterMissionRequest(From, Event, To, Mission) - -- Set mission status to ASSIGNED. + -- Set mission status from QUEUED to REQUESTED. Ensures that it is not considered in the next selection. Mission:Requested() + --- -- Some assets might already be spawned and even on a different mission (orbit). -- Need to dived to set into spawned and instock assets and handle the other - + --- + -- Assets to be requested local Assetlist={} @@ -633,7 +675,7 @@ function AIRWING:onafterMissionRequest(From, Event, To, Mission) if asset.flightgroup then --TODO: cancel current mission if there is any! - asset.flightgroup:AddMission(Mission, Mission.waypointcoord, Mission.waypointindex) + asset.flightgroup:AddMission(Mission) else self:E(self.lid.."ERROR: flight group for asset does NOT exist!") end @@ -646,12 +688,18 @@ function AIRWING:onafterMissionRequest(From, Event, To, Mission) -- Add request to airwing warehouse. if #Assetlist>0 then + + -- Add request to airwing warehouse. + -- TODO: better Assignment string. self:AddRequest(self, WAREHOUSE.Descriptor.ASSETLIST, Assetlist, #Assetlist, nil, nil, Mission.prio, tostring(Mission.auftragsnummer)) + + -- The queueid has been increased in the onafterAddRequest function. So we can simply use it here. + Mission.requestID=self.queueid end end ---- On after "Request" event. Spawns the necessary cargo and transport assets. +--- On after "Request" event. -- @param #AIRWING self -- @param #string From From state. -- @param #string Event Event. @@ -702,7 +750,7 @@ function AIRWING:onafterAssetSpawned(From, Event, To, group, asset, request) if mission then -- Add mission to flightgroup queue. - asset.flightgroup:AddMission(mission, mission.waypointcoord, mission.waypointindex) + asset.flightgroup:AddMission(mission) end end diff --git a/Moose Development/Moose/Ops/Auftrag.lua b/Moose Development/Moose/Ops/Auftrag.lua index 6d6f6569d..098f6a7ea 100644 --- a/Moose Development/Moose/Ops/Auftrag.lua +++ b/Moose Development/Moose/Ops/Auftrag.lua @@ -20,8 +20,6 @@ -- @field #number auftragsnummer Auftragsnummer. -- @field #string type Mission type. -- @field #string status Mission status. --- @field #table flightstatus Status of flight missions. --- @field #table flightgroups Flight groups of this mission. -- @field #table flightdata Flight specific data. -- @field #string name Mission name. -- @field #number prio Mission priority. @@ -33,8 +31,6 @@ -- @field #table DCStask DCS task structure. -- -- @field Core.Point#COORDINATE waypointcoord Coordinate of the waypoint task. --- @field #number waypointindex Waypoint number at which the task is executed. --- @field Ops.FlightGroup#FLIGHTGROUP.Task waypointtask Waypoint task. -- -- @field Core.Point#COORDINATE orbitCoord Coordinate where to orbit. -- @field #number orbitSpeed Orbit speed in m/s. @@ -61,6 +57,7 @@ -- @field #string squadname Name of the assigned Airwing squadron. -- @field #table assets Airwing Assets assigned for this mission. -- @field #number nassets Number of required assets by the Airwing. +-- @field #number requestID The ID of the queued warehouse request. Necessary to cancel the request if the mission was cancelled before the request is processed. -- -- @field #number optionROE ROE. -- @field #number optionROT ROT. @@ -98,8 +95,6 @@ AUFTRAG = { Debug = false, lid = nil, auftragsnummer = nil, - flightgroups = {}, - flightstatus = {}, flightdata = {}, } @@ -177,14 +172,16 @@ AUFTRAG.Status={ -- @field #string STARTED Flightgroup started this mission but it is not executed yet. -- @field #string EXECUTING Flightgroup is executing this mission. -- @field #string DONE Mission task of the flightgroup is done. +-- @field #string CANCELLED Mission was cancelled. AUFTRAG.FlightStatus={ SCHEDULED="scheduled", STARTED="started", EXECUTING="executing", DONE="done", + CANCELLED="cancelled", } ---- Flight specific data. +--- Flight specific data. Each flight subscribed to this mission has different data for this. -- @type AUFTRAG.FlightData -- @field Ops.FlightGroup#FLIGHTGROUP flightgroup The flight group. -- @field Core.Point#COORDINATE waypointcoordinate Waypoint coordinate. @@ -195,7 +192,7 @@ AUFTRAG.FlightStatus={ --- AUFTRAG class version. -- @field #string version -AUFTRAG.version="0.0.3" +AUFTRAG.version="0.0.4" ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -- TODO list @@ -204,6 +201,8 @@ AUFTRAG.version="0.0.3" -- TODO: Mission ROE and ROT -- TODO: Mission formation, etc. -- TODO: FSM events. +-- TODO: F10 marker functions that are updated on Status event. +-- TODO: Evaluate mission result ==> SUCCESS/FAILURE ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -- Constructor @@ -505,17 +504,45 @@ end function AUFTRAG:AddFlightGroup(FlightGroup) self:I(self.lid..string.format("Adding flight group %s", FlightGroup.groupname)) - --table.insert(self.flightgroups, FlightGroup) - local flightdata={} --#AUFTRAG.FlightData flightdata.flightgroup=FlightGroup flightdata.status=AUFTRAG.FlightStatus.SCHEDULED flightdata.waypointcoordinate=nil + flightdata.waypointindex=nil + flightdata.waypointtask=nil self.flightdata[FlightGroup.groupname]=flightdata end +--- Check if mission is PLANNED. +-- @param #AUFTRAG self +-- @return #boolean If true, mission is in the planning state. +function AUFTRAG:IsPlanned() + return self.status==AUFTRAG.Status.PLANNED +end + +--- Check if mission is QUEUED at an AIRWING mission queue. +-- @param #AUFTRAG self +-- @return #boolean If true, mission is queued. +function AUFTRAG:IsQueued() + return self.status==AUFTRAG.Status.QUEUED +end + +--- Check if mission is REQUESTED, i.e. request for WAREHOUSE assets is done. +-- @param #AUFTRAG self +-- @return #boolean If true, mission is requested. +function AUFTRAG:IsRequested() + return self.status==AUFTRAG.Status.REQUESTED +end + +--- Check if mission is SCHEDULED, i.e. request for WAREHOUSE assets is done. +-- @param #AUFTRAG self +-- @return #boolean If true, mission is queued. +function AUFTRAG:IsScheduled() + return self.status==AUFTRAG.Status.SCHEDULED +end + --- Check if mission is executing. -- @param #AUFTRAG self -- @return #boolean If true, mission is currently executing. @@ -523,6 +550,20 @@ function AUFTRAG:IsExecuting() return self.status==AUFTRAG.Status.EXECUTING end +--- Check if mission was cancelled. +-- @param #AUFTRAG self +-- @return #boolean If true, mission was cancelled. +function AUFTRAG:IsCancelled() + return self.status==AUFTRAG.Status.CANCELLED +end + +--- Check if mission is done. +-- @param #AUFTRAG self +-- @return #boolean If true, mission is done. +function AUFTRAG:IsCancelled() + return self.status==AUFTRAG.Status.DONE +end + --- Check if mission is over. This could be state DONE or CANCELLED. -- @param #AUFTRAG self -- @return #boolean If true, mission is currently executing. @@ -544,8 +585,14 @@ end function AUFTRAG:onafterStatus(From, Event, To) local fsmstate=self:GetState() + + local Ntargets=self:CountMissionTargets() + + local Cstart=UTILS.SecondsToClock(self.Tstart, true) + local Cstop=self.Tstop and UTILS.SecondsToClock(self.Tstop, true) or "INF" - self:I(self.lid..string.format("FSM status %s, mission status=%s, flightgroups=%d", fsmstate, self.status, #self.flightdata)) + -- Info message. + self:I(self.lid..string.format("FSM state %s (Mstatus=%s): T=%s-%s flights=%d, targets=%d", fsmstate, self.status, Cstart, Cstop, #self.flightdata, Ntargets)) self:__Status(-30) end @@ -605,10 +652,16 @@ end -- @return #boolean If true, all flights are done with the mission. function AUFTRAG:CheckFlightsDone() + -- These are early stages, where we might not even have a flightgroup defined to be checked. + if self:IsPlanned() or self:IsQueued() or self:IsRequested() then + return false + end + local done=true - for groupname,status in pairs(self.flightstatus) do - if status~=AUFTRAG.Status.DONE then + for groupname,data in pairs(self.flightdata) do + local flightdata=data --#AUFTRAG.FlightData + if flightdata.status~=AUFTRAG.FlightStatus.DONE and flightdata.status~=AUFTRAG.FlightStatus.CANCELLED then done=false end end @@ -703,16 +756,16 @@ function AUFTRAG:onafterCancel(From, Event, To) self.status=AUFTRAG.Status.CANCELLED self:I(self.lid..string.format("New mission status=%s", self.status)) - --[[ - for _,_asset in pairs(self.assets or {}) do - local asset=_asset --Ops.AirWing#AIRWING.SquadronAsset - asset.flightgroup:MissionCancel(self) - end - ]] + if self.airwing then - for _,_flightdata in pairs(self.flightdata) do - local flightdata=_flightdata --#AUFTRAG.FlightData - flightdata.flightgroup:MissionCancel(self) + self.airwing:MissionCancel(self) + + else + + for _,_flightdata in pairs(self.flightdata) do + local flightdata=_flightdata --#AUFTRAG.FlightData + flightdata.flightgroup:MissionCancel(self) + end end end @@ -723,7 +776,7 @@ end --- Count alive mission targets. -- @param #AUFTRAG self --- @param #number Number of alive targets. +-- @return #number Number of alive targets. function AUFTRAG:CountMissionTargets() local N=0 diff --git a/Moose Development/Moose/Ops/FlightGroup.lua b/Moose Development/Moose/Ops/FlightGroup.lua index c903c1100..0d0244814 100644 --- a/Moose Development/Moose/Ops/FlightGroup.lua +++ b/Moose Development/Moose/Ops/FlightGroup.lua @@ -656,18 +656,16 @@ end --- Add mission to queue. -- @param #FLIGHTGROUP self -- @param Ops.Auftrag#AUFTRAG Mission Mission for this group. --- @param Core.Point#COORDINATE WaypointCoordinate Coordinate of the mission waypoint --- @param #number WaypointIndex The waypoint number. Default is after all current air waypoints. -- @return #FLIGHTGROUP self -function FLIGHTGROUP:AddMission(Mission, WaypointCoordinate) - - Mission.waypointcoord=WaypointCoordinate +function FLIGHTGROUP:AddMission(Mission) -- Add flight group to mission. Mission:AddFlightGroup(self) - -- Set status to scheduled. + -- Set flight status to SCHEDULED.. Mission:SetFlightStatus(self, AUFTRAG.FlightStatus.SCHEDULED) + + -- Set mission status to SCHEDULED. Mission:Scheduled() -- Add mission to queue. @@ -2539,7 +2537,7 @@ function FLIGHTGROUP:onafterRTB(From, Event, To, airbase, SpeedTo, SpeedHold, Sp wp[#wp+1]=pland:WaypointAirLanding(UTILS.KnotsToKmph(SpeedLand), airbase, {}, "Landing") -- Respawn? - if fc then + if fc or world.event.S_EVENT_KILL then -- Just route the group. Respawn will happen when going from holding to final. self:Route(wp, 1) @@ -3004,6 +3002,7 @@ function FLIGHTGROUP:onafterTaskCancel(From, Event, To, Task) -- Get current task. local currenttask=self:GetTaskCurrent() + -- If no task, we take the current task. But this could also be *nil*! Task=Task or currenttask if Task then @@ -3020,12 +3019,20 @@ function FLIGHTGROUP:onafterTaskCancel(From, Event, To, Task) Task.stopflag:Set(1) else - - self:I(self.lid..string.format("TaskCancel: Setting task %s ID=%d to DONE", Task.description, Task.id)) + + -- Set task status to DONE (we have no CANCELLED defined yet). Task.status=FLIGHTGROUP.TaskStatus.DONE + -- Debug info. + self:I(self.lid..string.format("TaskCancel: Setting task %s ID=%d to DONE", Task.description, Task.id)) + + -- Is this a waypoint task? if Task.type==FLIGHTGROUP.TaskType.WAYPOINT and Task.waypoint then - self:RemoveWaypoint(Task.waypoint) + + -- Check that this is a mission waypoint and no other tasks are defined here. + if self:GetMissionByTaskID(Task.id) and #self:GetTasksWaypoint(Task.waypoint) then + self:RemoveWaypoint(Task.waypoint) + end end end @@ -3136,9 +3143,10 @@ function FLIGHTGROUP:onafterMissionStart(From, Event, To, Mission) -- Set current mission. self.currentmission=Mission.auftragsnummer - -- Set mission status. + -- Set flight mission status to STARTED. Mission:SetFlightStatus(self, AUFTRAG.FlightStatus.STARTED) + -- Set mission status to STARTED. Mission:Started() -- Route flight to mission zone. @@ -3158,8 +3166,10 @@ function FLIGHTGROUP:onafterMissionExecute(From, Event, To, Mission) self:I(self.lid..text) MESSAGE:New(text, 120, "DEBUG"):ToAllIf(true) - -- Set mission status. + -- Set flight mission status to EXECUTING. Mission:SetFlightStatus(self, AUFTRAG.FlightStatus.EXECUTING) + + -- Set mission status to EXECUTING. Mission:Executing() end @@ -3174,25 +3184,30 @@ function FLIGHTGROUP:onafterMissionCancel(From, Event, To, Mission) if self.currentmission and Mission.auftragsnummer==self.currentmission then + -- Get mission waypoint task. local Task=Mission:GetFlightWaypointTask(self) env.info(string.format("FF 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. This will trigger the task done. + -- Cancelling the mission is actually cancelling the current task. + -- Note that two things can happen. + -- 1.) Flight is still on the way to the waypoint (status should be STARTED). In this case there would not be a current task! + -- 2.) Flight already passed the mission waypoint (status should be EXECUTING). self:TaskCancel(Task) + -- Set current mission to nil. self.currentmission=nil else - -- Not the current mission. So set status in queue. + -- Not the current mission. -- TODO: remove mission from queue? end -- Set missin flight status. env.info("FF setting mission to cancelled") - Mission:SetFlightStatus(self, AUFTRAG.Status.CANCELLED) + Mission:SetFlightStatus(self, AUFTRAG.FlightStatus.CANCELLED) end @@ -3207,14 +3222,6 @@ function FLIGHTGROUP:onafterMissionDone(From, Event, To, Mission) -- Set Flight status. Mission:SetFlightStatus(self, AUFTRAG.FlightStatus.DONE) - -- TODO: This has to be done in AUFTRAG. - --[[ - local airwing=self:GetAirWing() - if airwing then - airwing:MissionDone(Mission) - end - ]] - -- Set current mission to nil. self.currentmission=nil @@ -3233,9 +3240,14 @@ function FLIGHTGROUP:RouteToMission(mission, delay) -- Next waypoint. local nextwaypoint=self.currentwp+1 + + -- Create waypoint coordinate half way between us and the target. + local targetcoord=mission:GetTargetCoordinate() + local flightcoord=self.group:GetCoordinate() + local waypointcoord=flightcoord:GetIntermediateCoordinate(targetcoord, 0.5) -- Add waypoint. - self:AddWaypointAir(mission.waypointcoord, nextwaypoint, self.speedmax*0.8, false) + self:AddWaypointAir(waypointcoord, nextwaypoint, self.speedmax*0.8, false) -- Add waypoint task. UpdateRoute is called inside. local waypointtask=self:AddTaskWaypoint(mission.DCStask, nextwaypoint, mission.name, mission.prio, mission.duration) @@ -3244,7 +3256,7 @@ function FLIGHTGROUP:RouteToMission(mission, delay) mission:SetFlightWaypointTask(self, waypointtask) -- TODO: better marker text, mission.maker - mission.marker=mission.waypointcoord:MarkToCoalition(mission.name, self:GetCoalition(), true) + mission.marker=waypointcoord:MarkToCoalition(mission.name, self:GetCoalition(), true) --self:SetROE(mission.optionROE) @@ -3781,7 +3793,7 @@ function FLIGHTGROUP:GetMissionByTaskID(taskid) for _,_mission in pairs(self.missionqueue) do local mission=_mission --Ops.Auftrag#AUFTRAG - local task=mission.waypointtask + local task=mission:GetFlightWaypointTask(self) if task and task.id and task.id==taskid then return mission diff --git a/Moose Development/Moose/Ops/Intelligence.lua b/Moose Development/Moose/Ops/Intelligence.lua index 1431469ec..10ae18dba 100644 --- a/Moose Development/Moose/Ops/Intelligence.lua +++ b/Moose Development/Moose/Ops/Intelligence.lua @@ -232,12 +232,14 @@ function INTEL:onafterStatus(From, Event, To) -- FSM state. local fsmstate=self:GetState() + -- Fresh arrays. self.ContactsLost={} self.ContactsUnknown={} -- Check if group has detected any units. self:UpdateIntel() + -- Number of total contacts. local Ncontacts=#self.Contacts -- Short info. diff --git a/Moose Development/Moose/Ops/WingCommander.lua b/Moose Development/Moose/Ops/WingCommander.lua index 4d1c7bbc2..e062c9139 100644 --- a/Moose Development/Moose/Ops/WingCommander.lua +++ b/Moose Development/Moose/Ops/WingCommander.lua @@ -54,7 +54,7 @@ WINGCOMMANDER = { --- WINGCOMMANDER class version. -- @field #string version -WINGCOMMANDER.version="0.0.1" +WINGCOMMANDER.version="0.0.2" ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -- TODO list @@ -79,13 +79,6 @@ function WINGCOMMANDER:New(AgentSet) -- Set some string id for output to DCS.log file. self.lid=string.format("WINGCOMMANDER | ") - -- Start State. - --self:SetStartState("Stopped") - - -- Add FSM transitions. - -- From State --> Event --> To State - --self:AddTransition("Stopped", "Start", "Running") -- Start FSM. - ------------------------ --- Pseudo Functions --- @@ -192,7 +185,7 @@ function WINGCOMMANDER:onafterStatus(From, Event, To) if contact.mission and contact.mission.airwing then -- Cancel this mission. - contact.mission.airwing:MissionCancel(contact.mission) + contact.mission:Cancel() end @@ -314,14 +307,11 @@ function WINGCOMMANDER:CheckMissionQueue() end table.sort(airwings, sortdist) + -- This is the closest airwing to the target. local airwing=airwings[1].airwing --Ops.AirWing#AIRWING - local targetcoord=airwings[1].targetcoord --Core.Point#COORDINATE - - -- Get waypoint coordinate. This is where the mission is actually executed. - local WaypointCoordinate=airwing:GetCoordinate():GetIntermediateCoordinate(targetcoord, 0.5) -- Add mission to airwing. - airwing:AddMission(mission, Nassets, WaypointCoordinate) + airwing:AddMission(mission) return end