diff --git a/Moose Development/Moose/Core/Point.lua b/Moose Development/Moose/Core/Point.lua index fa8d58d65..57e2fc2cb 100644 --- a/Moose Development/Moose/Core/Point.lua +++ b/Moose Development/Moose/Core/Point.lua @@ -1215,11 +1215,11 @@ do -- COORDINATE -- @param #COORDINATE self -- @param #number Speed (optional) Speed in km/h. The default speed is 20 km/h. -- @param #string Formation (optional) The route point Formation, which is a text string that specifies exactly the Text in the Type of the route point, like "Vee", "Echelon Right". + -- @param #table DCSTasks A table of DCS tasks that are executed at the waypoints. Mind the curly brackets {}! -- @return #table The route point. - function COORDINATE:WaypointGround( Speed, Formation ) + function COORDINATE:WaypointGround( Speed, Formation, DCSTasks ) self:F2( { Formation, Speed } ) - local RoutePoint = {} RoutePoint.x = self.x RoutePoint.y = self.z @@ -1242,12 +1242,10 @@ do -- COORDINATE -- }, -- end of ["params"] -- }, -- end of ["task"] - RoutePoint.task = {} RoutePoint.task.id = "ComboTask" RoutePoint.task.params = {} - RoutePoint.task.params.tasks = {} - + RoutePoint.task.params.tasks = DCSTasks or {} return RoutePoint end diff --git a/Moose Development/Moose/Core/Zone.lua b/Moose Development/Moose/Core/Zone.lua index 802656890..1b55b5ba3 100644 --- a/Moose Development/Moose/Core/Zone.lua +++ b/Moose Development/Moose/Core/Zone.lua @@ -750,7 +750,7 @@ function ZONE_RADIUS:GetScannedUnits() end ---- Count the number of different coalitions inside the zone. +--- Get a set of scanned units. -- @param #ZONE_RADIUS self -- @return Core.Set#SET_UNIT Set of units and statics inside the zone. function ZONE_RADIUS:GetScannedSetUnit() @@ -949,7 +949,6 @@ function ZONE_RADIUS:SearchZone( EvaluateFunction, ObjectCategories ) local function EvaluateZone( ZoneDCSUnit ) - --env.info( ZoneDCSUnit:getName() ) local ZoneUnit = UNIT:Find( ZoneDCSUnit ) diff --git a/Moose Development/Moose/Functional/ZoneCaptureCoalition.lua b/Moose Development/Moose/Functional/ZoneCaptureCoalition.lua index 4b0801681..e6a07e323 100644 --- a/Moose Development/Moose/Functional/ZoneCaptureCoalition.lua +++ b/Moose Development/Moose/Functional/ZoneCaptureCoalition.lua @@ -874,16 +874,23 @@ do -- ZONE_CAPTURE_COALITION self:Capture() end - -- Get red and blue unit sets. - local unitsetRed=self:GetScannedSetUnit():FilterCoalitions(coalition.side.RED):FilterActive(true):FilterOnce() - local unitsetBlu=self:GetScannedSetUnit():FilterCoalitions(coalition.side.BLUE):FilterActive(true):FilterOnce() - - -- Count number of units. - local nRed=unitsetRed:Count() - local nBlu=unitsetBlu:Count() + -- Count stuff in zone. + local unitset=self:GetScannedSetUnit() + local nRed=0 + local nBlue=0 + for _,object in pairs(unitset:GetSet()) do + local coal=object:GetCoalition() + if object:IsAlive() then + if coal==coalition.side.RED then + nRed=nRed+1 + elseif coal==coalition.side.BLUE then + nBlue=nBlue+1 + end + end + end -- Status text. - local text=string.format("CAPTURE ZONE %s: Owner=%s (Previous=%s): #blue=%d, #red=%d, Status %s", self:GetZoneName(), self:GetCoalitionName(), UTILS.GetCoalitionName(self:GetPreviousCoalition()), nBlu, nRed, State) + local text=string.format("CAPTURE ZONE %s: Owner=%s (Previous=%s): #blue=%d, #red=%d, Status %s", self:GetZoneName(), self:GetCoalitionName(), UTILS.GetCoalitionName(self:GetPreviousCoalition()), nBlue, nRed, State) local NewState = self:GetState() if NewState~=State then text=text..string.format(" --> %s", NewState) diff --git a/Moose Development/Moose/Ops/ATIS.lua b/Moose Development/Moose/Ops/ATIS.lua index a1b5f4866..8c51087d4 100644 --- a/Moose Development/Moose/Ops/ATIS.lua +++ b/Moose Development/Moose/Ops/ATIS.lua @@ -82,6 +82,8 @@ -- @field #number runwaym2t Optional correction for magnetic to true runway heading conversion (and vice versa) in degrees. -- @field #boolean windtrue Report true (from) heading of wind. Default is magnetic. -- @field #boolean altimeterQNH Report altimeter QNH. +-- @field #boolean usemarker Use mark on the F10 map. +-- @field #number markerid Numerical ID of the F10 map mark point. -- @extends Core.Fsm#FSM --- *It is a very sad thing that nowadays there is so little useless information.* - Oscar Wilde @@ -241,6 +243,10 @@ -- ![Banner Image](..\Presentations\ATIS\ATIS_SoundFolder.png) -- -- **Note** that the default folder name is *ATIS Soundfiles/*. If you want to change it, you can use the @{#ATIS.SetSoundfilesPath}(*path*), where *path* is the path of the directory. This must end with a slash "/"! +-- +-- # Marks on the F10 Map +-- +-- You can place marks on the F10 map via the @{#ATIS.SetMapMarks}() function. These will contain info about the ATIS frequency, the currently active runway and some basic info about the weather (wind, pressure and temperature). -- -- # Examples -- @@ -309,6 +315,8 @@ ATIS = { runwaym2t = nil, windtrue = nil, altimeterQNH = nil, + usemarker = nil, + markerid = nil, } --- NATO alphabet. @@ -515,7 +523,7 @@ _ATIS={} --- ATIS class version. -- @field #string version -ATIS.version="0.6.1" +ATIS.version="0.6.2" ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -- TODO list @@ -570,6 +578,7 @@ function ATIS:New(airbasename, frequency, modulation) self:SetRunwayCorrectionMagnetic2True() self:SetRadioPower() self:SetAltimeterQNH(true) + self:SetMapMarks(false) -- Start State. self:SetStartState("Stopped") @@ -687,6 +696,19 @@ function ATIS:SetRadioPower(power) return self end +--- Use F10 map mark points. +-- @param #ATIS self +-- @param #boolean switch If *true* or *nil*, marks are placed on F10 map. If *false* this feature is set to off (default). +-- @return #ATIS self +function ATIS:SetMapMarks(switch) + if switch==nil or switch==true then + self.usemarker=true + else + self.usemarker=false + end + return self +end + --- Set magnetic runway headings as depicted on the runway, *e.g.* "13" for 130° or "25L" for the left runway with magnetic heading 250°. -- @param #ATIS self -- @param #table headings Magnetic headings. Inverse (-180°) headings are added automatically. You only need to specify one heading per runway direction. "L"eft and "R" right can also be appended. @@ -955,6 +977,12 @@ end -- @param #ATIS self function ATIS:onafterStart(From, Event, To) + -- Check that this is an airdrome. + if self.airbase:GetAirbaseCategory()~=Airbase.Category.AIRDROME then + self:E(self.lid..string.format("ERROR: Cannot start ATIS for airbase %s! Only AIRDROMES are supported but NOT FARPS or SHIPS.", self.airbasename)) + return + end + -- Info. self:I(self.lid..string.format("Starting ATIS v%s for airbase %s on %.3f MHz Modulation=%d", ATIS.version, self.airbasename, self.frequency, self.modulation)) @@ -1000,7 +1028,9 @@ function ATIS:onafterStatus(From, Event, To) local relayunitstatus="N/A" if self.relayunitname then local ru=UNIT:FindByName(self.relayunitname) - relayunitstatus=tostring(ru:IsAlive()) + if ru then + relayunitstatus=tostring(ru:IsAlive()) + end end -- Info text. @@ -1313,6 +1343,7 @@ function ATIS:onafterBroadcast(From, Event, To) -- Information tag subtitle=string.format("Information %s", NATO) + local _INFORMATION=subtitle self:Transmission(ATIS.Sound.Information, 0.5, subtitle) self.radioqueue:NewTransmission(string.format("NATO Alphabet/%s.ogg", NATO), 0.75, self.soundpath) @@ -1434,6 +1465,7 @@ function ATIS:onafterBroadcast(From, Event, To) subtitle=string.format("Altimeter QNH %s.%s, QFE %s.%s inHg", QNH[1], QNH[2], QFE[1], QFE[2]) end end + local _ALTIMETER=subtitle self:Transmission(ATIS.Sound.Altimeter, 1.0, subtitle) self:Transmission(ATIS.Sound.QNH, 0.5) self.radioqueue:Number2Transmission(QNH[1]) @@ -1467,6 +1499,7 @@ function ATIS:onafterBroadcast(From, Event, To) subtitle=string.format("Temperature %s °C", TEMPERATURE) end end + local _TEMPERATURE=subtitle self:Transmission(ATIS.Sound.Temperature, 1.0, subtitle) if temperature<0 then self:Transmission(ATIS.Sound.Minus, 0.2) @@ -1487,6 +1520,7 @@ function ATIS:onafterBroadcast(From, Event, To) if turbulence>0 then subtitle=subtitle..", gusting" end + local _WIND=subtitle self:Transmission(ATIS.Sound.WindFrom, 1.0, subtitle) self.radioqueue:Number2Transmission(WINDFROM) self:Transmission(ATIS.Sound.At, 0.2) @@ -1507,6 +1541,7 @@ function ATIS:onafterBroadcast(From, Event, To) elseif rwyLeft==false then subtitle=subtitle.." Right" end + local _RUNACT=subtitle self:Transmission(ATIS.Sound.ActiveRunway, 1.0, subtitle) self.radioqueue:Number2Transmission(runway) if rwyLeft==true then @@ -1534,7 +1569,7 @@ function ATIS:onafterBroadcast(From, Event, To) subtitle=subtitle.." feet" end - -- Transmitt. + -- Transmit. self:Transmission(ATIS.Sound.RunwayLength, 1.0, subtitle) if tonumber(L1000)>0 then self.radioqueue:Number2Transmission(L1000) @@ -1698,9 +1733,41 @@ function ATIS:onafterBroadcast(From, Event, To) subtitle=string.format("End of information %s", NATO) self:Transmission(ATIS.Sound.EndOfInformation, 0.5, subtitle) self.radioqueue:NewTransmission(string.format("NATO Alphabet/%s.ogg", NATO), 0.75, self.soundpath) + + -- Update F10 marker. + if self.usemarker then + self:UpdateMarker(_INFORMATION, _RUNACT, _WIND, _ALTIMETER, _TEMPERATURE) + end end +--- Update F10 map marker. +-- @param #ATIS self +-- @param #string information Information tag text. +-- @param #string runact Active runway text. +-- @param #string wind Wind text. +-- @param #string altimeter Altimeter text. +-- @param #string temperature Temperature text. +-- @return #number Marker ID. +function ATIS:UpdateMarker(information, runact, wind, altimeter, temperature) + + if self.markerid then + self.airbase:GetCoordinate():RemoveMark(self.markerid) + end + + local text=string.format("ATIS on %.3f %s, %s:\n", self.frequency, UTILS.GetModulationName(self.modulation), tostring(information)) + text=text..string.format("%s\n", tostring(runact)) + text=text..string.format("%s\n", tostring(wind)) + text=text..string.format("%s\n", tostring(altimeter)) + text=text..string.format("%s", tostring(temperature)) + -- More info is not displayed on the marker! + + -- Place new mark + self.markerid=self.airbase:GetCoordinate():MarkToAll(text, true) + + return self.markerid +end + ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -- Misc Functions ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/Moose Development/Moose/Wrapper/Controllable.lua b/Moose Development/Moose/Wrapper/Controllable.lua index 28eaff805..939345713 100644 --- a/Moose Development/Moose/Wrapper/Controllable.lua +++ b/Moose Development/Moose/Wrapper/Controllable.lua @@ -2136,8 +2136,10 @@ do -- Patrol methods -- @param #table ZoneList Table of zones. -- @param #number Speed Speed in km/h the group moves at. -- @param #string Formation (Optional) Formation the group should use. + -- @param #number DelayMin Delay in seconds before the group progresses to the next route point. Default 1 sec. + -- @param #number DelayMax Max. delay in seconds. Actual delay is randomly chosen between DelayMin and DelayMax. Default equal to DelayMin. -- @return #CONTROLLABLE - function CONTROLLABLE:PatrolZones( ZoneList, Speed, Formation ) + function CONTROLLABLE:PatrolZones( ZoneList, Speed, Formation, DelayMin, DelayMax ) if not type( ZoneList ) == "table" then ZoneList = { ZoneList } @@ -2148,14 +2150,18 @@ do -- Patrol methods if not self:IsInstanceOf( "GROUP" ) then PatrolGroup = self:GetGroup() -- Wrapper.Group#GROUP end + + DelayMin=DelayMin or 1 + if not DelayMax or DelayMax