diff --git a/Moose Development/Moose/Core/Point.lua b/Moose Development/Moose/Core/Point.lua index 79a274918..fe4863f54 100644 --- a/Moose Development/Moose/Core/Point.lua +++ b/Moose Development/Moose/Core/Point.lua @@ -1111,15 +1111,25 @@ do -- COORDINATE -- @param #number AngleRadians The angle in randians. -- @param #number Precision The precision. -- @param Core.Settings#SETTINGS Settings + -- @param #boolean MagVar If true, include magentic degrees -- @return #string The bearing text in degrees. - function COORDINATE:GetBearingText( AngleRadians, Precision, Settings, Language ) + function COORDINATE:GetBearingText( AngleRadians, Precision, Settings, MagVar ) local Settings = Settings or _SETTINGS -- Core.Settings#SETTINGS local AngleDegrees = UTILS.Round( UTILS.ToDegree( AngleRadians ), Precision ) local s = string.format( '%03d°', AngleDegrees ) - + + if MagVar then + local variation = UTILS.GetMagneticDeclination() or 0 + local AngleMagnetic = AngleDegrees - variation + + if AngleMagnetic < 0 then AngleMagnetic = 360-AngleMagnetic end + + s = string.format( '%03d°M|%03d°', AngleMagnetic,AngleDegrees ) + end + return s end @@ -1133,21 +1143,22 @@ do -- COORDINATE function COORDINATE:GetDistanceText( Distance, Settings, Language, Precision ) local Settings = Settings or _SETTINGS -- Core.Settings#SETTINGS - local Language = Language or "EN" + local Language = Language or Settings.Locale or _SETTINGS.Locale or "EN" + Language = string.lower(Language) local Precision = Precision or 0 local DistanceText if Settings:IsMetric() then - if Language == "EN" then + if Language == "en" then DistanceText = " for " .. UTILS.Round( Distance / 1000, Precision ) .. " km" - elseif Language == "RU" then + elseif Language == "ru" then DistanceText = " за " .. UTILS.Round( Distance / 1000, Precision ) .. " километров" end else - if Language == "EN" then + if Language == "en" then DistanceText = " for " .. UTILS.Round( UTILS.MetersToNM( Distance ), Precision ) .. " miles" - elseif Language == "RU" then + elseif Language == "ru" then DistanceText = " за " .. UTILS.Round( UTILS.MetersToNM( Distance ), Precision ) .. " миль" end end @@ -1161,19 +1172,21 @@ do -- COORDINATE function COORDINATE:GetAltitudeText( Settings, Language ) local Altitude = self.y local Settings = Settings or _SETTINGS - local Language = Language or "EN" - + local Language = Language or Settings.Locale or _SETTINGS.Locale or "EN" + + Language = string.lower(Language) + if Altitude ~= 0 then if Settings:IsMetric() then - if Language == "EN" then + if Language == "en" then return " at " .. UTILS.Round( self.y, -3 ) .. " meters" - elseif Language == "RU" then + elseif Language == "ru" then return " в " .. UTILS.Round( self.y, -3 ) .. " метры" end else - if Language == "EN" then + if Language == "en" then return " at " .. UTILS.Round( UTILS.MetersToFeet( self.y ), -3 ) .. " feet" - elseif Language == "RU" then + elseif Language == "ru" then return " в " .. UTILS.Round( self.y, -3 ) .. " ноги" end end @@ -1220,12 +1233,14 @@ do -- COORDINATE -- @param #number AngleRadians The angle in randians -- @param #number Distance The distance -- @param Core.Settings#SETTINGS Settings + -- @param #string Language (Optional) Language "en" or "ru" + -- @param #boolean MagVar If true, also state angle in magnetic -- @return #string The BR Text - function COORDINATE:GetBRText( AngleRadians, Distance, Settings, Language ) + function COORDINATE:GetBRText( AngleRadians, Distance, Settings, Language, MagVar ) local Settings = Settings or _SETTINGS -- Core.Settings#SETTINGS - local BearingText = self:GetBearingText( AngleRadians, 0, Settings, Language ) + local BearingText = self:GetBearingText( AngleRadians, 0, Settings, MagVar ) local DistanceText = self:GetDistanceText( Distance, Settings, Language, 0 ) local BRText = BearingText .. DistanceText @@ -1238,12 +1253,14 @@ do -- COORDINATE -- @param #number AngleRadians The angle in randians -- @param #number Distance The distance -- @param Core.Settings#SETTINGS Settings + -- @param #string Language (Optional) Language "en" or "ru" + -- @param #boolean MagVar If true, also state angle in magnetic -- @return #string The BRA Text - function COORDINATE:GetBRAText( AngleRadians, Distance, Settings, Language ) + function COORDINATE:GetBRAText( AngleRadians, Distance, Settings, Language, MagVar ) local Settings = Settings or _SETTINGS -- Core.Settings#SETTINGS - local BearingText = self:GetBearingText( AngleRadians, 0, Settings, Language ) + local BearingText = self:GetBearingText( AngleRadians, 0, Settings, MagVar ) local DistanceText = self:GetDistanceText( Distance, Settings, Language, 0 ) local AltitudeText = self:GetAltitudeText( Settings, Language ) @@ -2755,25 +2772,27 @@ do -- COORDINATE -- @param #COORDINATE self -- @param #COORDINATE FromCoordinate The coordinate to measure the distance and the bearing from. -- @param Core.Settings#SETTINGS Settings (optional) The settings. Can be nil, and in this case the default settings are used. If you want to specify your own settings, use the _SETTINGS object. + -- @param #boolean MagVar If true, also get angle in MagVar for BR/BRA -- @return #string The BR text. - function COORDINATE:ToStringBR( FromCoordinate, Settings ) + function COORDINATE:ToStringBR( FromCoordinate, Settings, MagVar ) local DirectionVec3 = FromCoordinate:GetDirectionVec3( self ) local AngleRadians = self:GetAngleRadians( DirectionVec3 ) local Distance = self:Get2DDistance( FromCoordinate ) - return "BR, " .. self:GetBRText( AngleRadians, Distance, Settings ) + return "BR, " .. self:GetBRText( AngleRadians, Distance, Settings, nil, MagVar ) end --- Return a BRA string from a COORDINATE to the COORDINATE. -- @param #COORDINATE self -- @param #COORDINATE FromCoordinate The coordinate to measure the distance and the bearing from. -- @param Core.Settings#SETTINGS Settings (optional) The settings. Can be nil, and in this case the default settings are used. If you want to specify your own settings, use the _SETTINGS object. + -- @param #boolean MagVar If true, also get angle in MagVar for BR/BRA -- @return #string The BR text. - function COORDINATE:ToStringBRA( FromCoordinate, Settings, Language ) + function COORDINATE:ToStringBRA( FromCoordinate, Settings, MagVar ) local DirectionVec3 = FromCoordinate:GetDirectionVec3( self ) local AngleRadians = self:GetAngleRadians( DirectionVec3 ) local Distance = FromCoordinate:Get2DDistance( self ) local Altitude = self:GetAltitudeText() - return "BRA, " .. self:GetBRAText( AngleRadians, Distance, Settings, Language ) + return "BRA, " .. self:GetBRAText( AngleRadians, Distance, Settings, nil, MagVar ) end --- Create a BRAA NATO call string to this COORDINATE from the FromCOORDINATE. Note - BRA delivered if no aspect can be obtained and "Merged" if range < 3nm @@ -2868,14 +2887,15 @@ do -- COORDINATE -- @param #COORDINATE self -- @param DCS#coalition.side Coalition The coalition. -- @param Core.Settings#SETTINGS Settings (optional) The settings. Can be nil, and in this case the default settings are used. If you want to specify your own settings, use the _SETTINGS object. + -- @param #boolean MagVar If true, als get angle in magnetic -- @return #string The BR text. - function COORDINATE:ToStringBULLS( Coalition, Settings ) + function COORDINATE:ToStringBULLS( Coalition, Settings, MagVar ) local BullsCoordinate = COORDINATE:NewFromVec3( coalition.getMainRefPoint( Coalition ) ) local DirectionVec3 = BullsCoordinate:GetDirectionVec3( self ) local AngleRadians = self:GetAngleRadians( DirectionVec3 ) local Distance = self:Get2DDistance( BullsCoordinate ) local Altitude = self:GetAltitudeText() - return "BULLS, " .. self:GetBRText( AngleRadians, Distance, Settings ) + return "BULLS, " .. self:GetBRText( AngleRadians, Distance, Settings, nil, MagVar ) end --- Return an aspect string from a COORDINATE to the Angle of the object. @@ -2939,7 +2959,7 @@ do -- COORDINATE -- @param #COORDINATE self -- @param Core.Settings#SETTINGS Settings (optional) The settings. Can be nil, and in this case the default settings are used. If you want to specify your own settings, use the _SETTINGS object. -- @return #string The MGRS Text - function COORDINATE:ToStringMGRS( Settings ) --R2.1 Fixes issue #424. + function COORDINATE:ToStringMGRS( Settings ) local MGRS_Accuracy = Settings and Settings.MGRS_Accuracy or _SETTINGS.MGRS_Accuracy local lat, lon = coord.LOtoLL( self:GetVec3() ) @@ -2955,8 +2975,9 @@ do -- COORDINATE -- @param #string ReferenceName The reference name. -- @param Wrapper.Controllable#CONTROLLABLE Controllable -- @param Core.Settings#SETTINGS Settings (optional) The settings. Can be nil, and in this case the default settings are used. If you want to specify your own settings, use the _SETTINGS object. + -- @param #boolean MagVar If true also show angle in magnetic -- @return #string The coordinate Text in the configured coordinate system. - function COORDINATE:ToStringFromRP( ReferenceCoord, ReferenceName, Controllable, Settings ) + function COORDINATE:ToStringFromRP( ReferenceCoord, ReferenceName, Controllable, Settings, MagVar ) self:F2( { ReferenceCoord = ReferenceCoord, ReferenceName = ReferenceName } ) @@ -2968,12 +2989,12 @@ do -- COORDINATE local DirectionVec3 = ReferenceCoord:GetDirectionVec3( self ) local AngleRadians = self:GetAngleRadians( DirectionVec3 ) local Distance = self:Get2DDistance( ReferenceCoord ) - return "Targets are the last seen " .. self:GetBRText( AngleRadians, Distance, Settings ) .. " from " .. ReferenceName + return "Targets are the last seen " .. self:GetBRText( AngleRadians, Distance, Settings, nil, MagVar ) .. " from " .. ReferenceName else local DirectionVec3 = ReferenceCoord:GetDirectionVec3( self ) local AngleRadians = self:GetAngleRadians( DirectionVec3 ) local Distance = self:Get2DDistance( ReferenceCoord ) - return "Target are located " .. self:GetBRText( AngleRadians, Distance, Settings ) .. " from " .. ReferenceName + return "Target are located " .. self:GetBRText( AngleRadians, Distance, Settings, nil, MagVar ) .. " from " .. ReferenceName end return nil @@ -2988,8 +3009,9 @@ do -- COORDINATE -- @param #string ReferenceName The reference name. -- @param Wrapper.Controllable#CONTROLLABLE Controllable -- @param Core.Settings#SETTINGS Settings (optional) The settings. Can be nil, and in this case the default settings are used. If you want to specify your own settings, use the _SETTINGS object. + -- @param #boolean MagVar If true also get the angle as magnetic -- @return #string The coordinate Text in the configured coordinate system. - function COORDINATE:ToStringFromRPShort( ReferenceCoord, ReferenceName, Controllable, Settings ) + function COORDINATE:ToStringFromRPShort( ReferenceCoord, ReferenceName, Controllable, Settings, MagVar ) self:F2( { ReferenceCoord = ReferenceCoord, ReferenceName = ReferenceName } ) @@ -3001,12 +3023,12 @@ do -- COORDINATE local DirectionVec3 = ReferenceCoord:GetDirectionVec3( self ) local AngleRadians = self:GetAngleRadians( DirectionVec3 ) local Distance = self:Get2DDistance( ReferenceCoord ) - return self:GetBRText( AngleRadians, Distance, Settings ) .. " from " .. ReferenceName + return self:GetBRText( AngleRadians, Distance, Settings, nil, MagVar ) .. " from " .. ReferenceName else local DirectionVec3 = ReferenceCoord:GetDirectionVec3( self ) local AngleRadians = self:GetAngleRadians( DirectionVec3 ) local Distance = self:Get2DDistance( ReferenceCoord ) - return self:GetBRText( AngleRadians, Distance, Settings ) .. " from " .. ReferenceName + return self:GetBRText( AngleRadians, Distance, Settings, nil, MagVar ) .. " from " .. ReferenceName end return nil @@ -3017,8 +3039,9 @@ do -- COORDINATE -- @param #COORDINATE self -- @param Wrapper.Controllable#CONTROLLABLE Controllable -- @param Core.Settings#SETTINGS Settings (optional) The settings. Can be nil, and in this case the default settings are used. If you want to specify your own settings, use the _SETTINGS object. + -- @param #boolean MagVar If true, also get angle in MagVar for BR/BRA -- @return #string The coordinate Text in the configured coordinate system. - function COORDINATE:ToStringA2G( Controllable, Settings ) + function COORDINATE:ToStringA2G( Controllable, Settings, MagVar ) self:F2( { Controllable = Controllable and Controllable:GetName() } ) @@ -3028,7 +3051,7 @@ do -- COORDINATE -- If no Controllable is given to calculate the BR from, then MGRS will be used!!! if Controllable then local Coordinate = Controllable:GetCoordinate() - return Controllable and self:ToStringBR( Coordinate, Settings ) or self:ToStringMGRS( Settings ) + return Controllable and self:ToStringBR( Coordinate, Settings, MagVar ) or self:ToStringMGRS( Settings ) else return self:ToStringMGRS( Settings ) end @@ -3052,33 +3075,34 @@ do -- COORDINATE -- @param #COORDINATE self -- @param Wrapper.Controllable#CONTROLLABLE Controllable -- @param Core.Settings#SETTINGS Settings (optional) The settings. Can be nil, and in this case the default settings are used. If you want to specify your own settings, use the _SETTINGS object. + -- @param #boolean MagVar If true, also get angle in MagVar for BR/BRA -- @return #string The coordinate Text in the configured coordinate system. - function COORDINATE:ToStringA2A( Controllable, Settings, Language ) -- R2.2 + function COORDINATE:ToStringA2A( Controllable, Settings, MagVar ) self:F2( { Controllable = Controllable and Controllable:GetName() } ) local Settings = Settings or ( Controllable and _DATABASE:GetPlayerSettings( Controllable:GetPlayerName() ) ) or _SETTINGS - if Settings:IsA2A_BRAA() then + if Settings:IsA2A_BRAA() then if Controllable then local Coordinate = Controllable:GetCoordinate() - return self:ToStringBRA( Coordinate, Settings, Language ) + return self:ToStringBRA( Coordinate, Settings, MagVar ) else - return self:ToStringMGRS( Settings, Language ) + return self:ToStringMGRS( Settings ) end end if Settings:IsA2A_BULLS() then local Coalition = Controllable:GetCoalition() - return self:ToStringBULLS( Coalition, Settings, Language ) + return self:ToStringBULLS( Coalition, Settings, MagVar ) end if Settings:IsA2A_LL_DMS() then - return self:ToStringLLDMS( Settings, Language ) + return self:ToStringLLDMS( Settings ) end if Settings:IsA2A_LL_DDM() then - return self:ToStringLLDDM( Settings, Language ) + return self:ToStringLLDDM( Settings ) end if Settings:IsA2A_MGRS() then - return self:ToStringMGRS( Settings, Language ) + return self:ToStringMGRS( Settings ) end return nil @@ -3146,7 +3170,7 @@ do -- COORDINATE -- @param Wrapper.Controllable#CONTROLLABLE Controllable -- @param Core.Settings#SETTINGS Settings (optional) The settings. Can be nil, and in this case the default settings are used. If you want to specify your own settings, use the _SETTINGS object. -- @return #string The pressure text in the configured measurement system. - function COORDINATE:ToStringPressure( Controllable, Settings ) -- R2.3 + function COORDINATE:ToStringPressure( Controllable, Settings ) self:F2( { Controllable = Controllable and Controllable:GetName() } ) diff --git a/Moose Development/Moose/Functional/Range.lua b/Moose Development/Moose/Functional/Range.lua index 1826185b3..20d879ee0 100644 --- a/Moose Development/Moose/Functional/Range.lua +++ b/Moose Development/Moose/Functional/Range.lua @@ -2259,7 +2259,7 @@ function RANGE:onafterImpact( From, Event, To, result, player ) end -- Send message to player. - local text = string.format( "%s, impact %03d° for %d ft", player.playername, result.radial, UTILS.MetersToFeet( result.distance ) ) + local text = string.format( "%s, impact %03d° for %d ft (%d m)", player.playername, result.radial, UTILS.MetersToFeet( result.distance ), result.distance ) if targetname then text = text .. string.format( " from bulls of target %s.", targetname ) else diff --git a/Moose Development/Moose/Functional/Scoring.lua b/Moose Development/Moose/Functional/Scoring.lua index 70e5de975..2a7ef471a 100644 --- a/Moose Development/Moose/Functional/Scoring.lua +++ b/Moose Development/Moose/Functional/Scoring.lua @@ -12,7 +12,7 @@ -- * Score the hits and destroys of units. -- * Score the hits and destroys of statics. -- * Score the hits and destroys of scenery. --- * Log scores into a CSV file. +-- * (optional) Log scores into a CSV file. -- * Connect to a remote server using JSON and IP. -- -- === @@ -225,6 +225,7 @@ SCORING = { ClassName = "SCORING", ClassID = 0, Players = {}, + AutoSave = true, } local _SCORINGCoalition = { @@ -306,6 +307,7 @@ function SCORING:New( GameName ) end ) -- Create the CSV file. + self.AutoSave = true self:OpenCSV( GameName ) return self @@ -1748,7 +1750,7 @@ end function SCORING:OpenCSV( ScoringCSV ) self:F( ScoringCSV ) - if lfs and io and os then + if lfs and io and os and self.AutoSave then if ScoringCSV then self.ScoringCSV = ScoringCSV local fdir = lfs.writedir() .. [[Logs\]] .. self.ScoringCSV .. " " .. os.date( "%Y-%m-%d %H-%M-%S" ) .. ".csv" @@ -1828,7 +1830,7 @@ function SCORING:ScoreCSV( PlayerName, TargetPlayerName, ScoreType, ScoreTimes, TargetUnitType = TargetUnitType or "" TargetUnitName = TargetUnitName or "" - if lfs and io and os then + if lfs and io and os and self.AutoSave then self.CSVFile:write( '"' .. self.GameName .. '"' .. ',' .. '"' .. self.RunTime .. '"' .. ',' .. @@ -1852,9 +1854,20 @@ function SCORING:ScoreCSV( PlayerName, TargetPlayerName, ScoreType, ScoreTimes, end end +--- Close CSV file +-- @param #SCORING self +-- @return #SCORING self function SCORING:CloseCSV() - if lfs and io and os then + if lfs and io and os and self.AutoSave then self.CSVFile:close() end end +--- Registers a score for a player. +-- @param #SCORING self +-- @param #boolean OnOff Switch saving to CSV on = true or off = false +-- @return #SCORING self +function SCORING:SwitchAutoSave(OnOff) + self.AutoSave = OnOff + return self +end diff --git a/Moose Development/Moose/Ops/Awacs.lua b/Moose Development/Moose/Ops/Awacs.lua index 14ccb5922..565fa451a 100644 --- a/Moose Development/Moose/Ops/Awacs.lua +++ b/Moose Development/Moose/Ops/Awacs.lua @@ -17,7 +17,7 @@ -- === -- -- ### Author: **applevangelist** --- @date Last Update September 2022 +-- @date Last Update November 2022 -- @module Ops.AWACS -- @image OPS_AWACS.jpg @@ -497,7 +497,7 @@ do -- @field #AWACS AWACS = { ClassName = "AWACS", -- #string - version = "0.2.46", -- #string + version = "0.2.47", -- #string lid = "", -- #string coalition = coalition.side.BLUE, -- #number coalitiontxt = "blue", -- #string @@ -1980,22 +1980,16 @@ function AWACS:_MessageVector(GID,Tag,Coordinate,Angels) local group = managedgroup.Group local groupposition = group:GetCoordinate() - --local BRtext = Coordinate:ToStringBR(groupposition) local BRtext,BRtextTTS = self:_ToStringBR(groupposition,Coordinate) local vector = self.gettext:GetEntry("VECTORTO",self.locale) local vectortts = self.gettext:GetEntry("VECTORTOTTS",self.locale) local angelstxt = self.gettext:GetEntry("ANGELS",self.locale) - --local text = string.format("%s, %s. Vector%s %s",tocallsign, self.callsigntxt,Tag,BRtextTTS) - --local textScreen = string.format("%s, %s, Vector%s %s",tocallsign, self.callsigntxt,Tag,BRtext) - local text = string.format(vectortts,tocallsign, self.callsigntxt,Tag,BRtextTTS) local textScreen = string.format(vector,tocallsign, self.callsigntxt,Tag,BRtext) if Angels then - --text = text .. ". Angels "..tostring(Angels).."." - --textScreen = textScreen .. ". Angels "..tostring(Angels).."." text = text .. angelstxt ..tostring(Angels).."." textScreen = textScreen ..angelstxt..tostring(Angels).."." end @@ -2215,7 +2209,7 @@ end -- @param #AWACS self -- @param Wrapper.Group#GROUP Group Group to use -- @param #number GID GID to use --- @param #booean IsPlayer Check in player if true +-- @param #boolean IsPlayer Check in player if true -- @return #string Callsign function AWACS:_GetCallSign(Group,GID, IsPlayer) self:T(self.lid.."_GetCallSign - GID "..tostring(GID)) @@ -2326,14 +2320,13 @@ function AWACS:_CleanUpContacts() self.Contacts:ForEach( function (Contact) local contact = Contact -- #AWACS.ManagedContact - if not contact.Contact.group:IsAlive() or contact.Target:IsDead() then + if not contact.Contact.group:IsAlive() or contact.Target:IsDead() or contact.Target:IsDestroyed() or contact.Target:CountTargets() == 0 then deadcontacts:Push(contact,contact.CID) self:T("DEAD contact CID="..contact.CID) end end ) - - --local aliveclusters = FIFO:New() + -- announce VANISHED if deadcontacts:Count() > 0 and (not self.NoGroupTags) then @@ -2460,16 +2453,12 @@ function AWACS:_TargetSelectionProcess(Untargeted) self:T(self.lid..string.format("Looking at group %s type %s",contactname,typename)) local contactcoord = contact.Cluster.coordinate or contact.Contact.position or contact.Contact.group:GetCoordinate() local contactvec2 = contactcoord:GetVec2() - -- self:T({contactcoord:ToStringMGRS()}) - -- self:T({contactvec2}) -- Bucket 0 - NOT in Rejection Zone :) if self.RejectZone then local isinrejzone = self.RejectZone:IsVec2InZone(contactvec2) - --local distance = self.OpsZone:Get2DDistance(contactcoord) if isinrejzone then self:T(self.lid.."Across Border = YES - ignore") - --targettable:Push(contact,distance) checked = true end end @@ -2517,7 +2506,6 @@ function AWACS:_TargetSelectionProcess(Untargeted) if (AOdist2 < 75) or (aspect == "Hot") then local text = string.format("In AO(Adj) dist = %d(%d) NM",AOdist,AOdist2) self:T(self.lid..text) - --if sizing > 2 then distance = math.floor(distance / sizing)+1 end targettable:Push(contact,distance) checked = true end @@ -2602,7 +2590,7 @@ function AWACS:_CreatePicture(AO,Callsign,GID,MaxEntries,IsGeneral) local contact = fifo:Pull() -- #AWACS.ManagedContact self:T({contact}) if contact and contact.Contact.group and contact.Contact.group:IsAlive() then - --local coordinate = contact.Contact.group:GetCoordinate() + local coordinate = contact.Cluster.coordinate or contact.Contact.position or contact.Contact.group:GetCoordinate() -- Core.Point#COORDINATE if not coordinate then self:E(self.lid.."NO Coordinate for this cluster! CID="..contact.CID) @@ -2633,9 +2621,7 @@ function AWACS:_CreatePicture(AO,Callsign,GID,MaxEntries,IsGeneral) local alt = contact.Contact.group:GetAltitude() or 8000 alt = UTILS.Round(UTILS.MetersToFeet(alt)/1000,0) -- Alpha Group. Bulls eye 0 2 1, 16 miles, 25 thousand. - --text = text .. " "..refBRAATTS.." miles, "..alt.." thousand." -- Alpha Group. Bulls eye 0 2 1, 16 miles, 25 thousand. text = string.format("%s %s %s, %d %s.",text,refBRAATTS,milestxt,alt,thsdtxt) - --textScreen = textScreen .. " "..refBRAA.." miles, "..alt.." thousand." -- Alpha Group, Bullseye 021, 16 miles, 25 thousand, textScreen = string.format("%s %s %s, %d %s.",textScreen,refBRAA,milestxt,alt,thsdtxt) else -- pilot reference @@ -2705,7 +2691,6 @@ function AWACS:_CreateBogeyDope(Callsign,GID) local groupcoord = group:GetCoordinate() local fifo = self.ContactsAO -- Utilities.FiFo#FIFO - --local maxentries = self.maxspeakentries local maxentries = 1 local counter = 0 @@ -2745,7 +2730,6 @@ function AWACS:_Picture(Group,IsGeneral) local textScreen = text local general = IsGeneral local GID, Outcome, gcallsign = self:_GetManagedGrpID(Group) - --local gcallsign = "" if general then local allst = self.gettext:GetEntry("ALLSTATIONS",self.locale) @@ -2772,7 +2756,6 @@ function AWACS:_Picture(Group,IsGeneral) -- get clusters from Intel local contactstable = self.Contacts:GetDataTable() - --local clustertable = self.intel:GetClusterTable() or {} -- sort into buckets for _,_contact in pairs(contactstable) do @@ -2824,15 +2807,11 @@ function AWACS:_Picture(Group,IsGeneral) local grptxt = self.gettext:GetEntry("GROUP",self.locale) local groupstxt = self.gettext:GetEntry("GROUPMULTI",self.locale) if clustersAO == 1 then - --text = text .. "One group. " text = string.format("%s%s %s. ",text,onetxt,grptxt) - --textScreen = textScreen .. "One group.\n" textScreen = string.format("%s%s %s.\n",textScreen,onetxt,grptxt) else text = string.format("%s%d %s. ",text,clustersAO,groupstxt) - --text = text .. clustersAO .. " groups. " textScreen = string.format("%s%d %s.\n",textScreen,clustersAO,groupstxt) - --textScreen = textScreen .. clustersAO .. " groups.\n" end self:_NewRadioEntry(text,textScreen,GID,Outcome,true,true,false) @@ -2917,28 +2896,15 @@ function AWACS:_BogeyDope(Group) if contactsAO > 0 then local dope = self.gettext:GetEntry("DOPE",self.locale) text = string.format(dope,self:_GetCallSign(Group,GID) or "Ghost 1", self.callsigntxt) - --[[ - if contactsAO == 1 then - text = text .. "One group. " - textScreen = text .. "\n" - else - text = text .. contactsAO .. " groups. " - textScreen = textScreen .. contactsAO .. " groups.\n" - end - --]] local onetxt = self.gettext:GetEntry("ONE",self.locale) local grptxt = self.gettext:GetEntry("GROUP",self.locale) local groupstxt = self.gettext:GetEntry("GROUPMULTI",self.locale) if contactsAO == 1 then - --text = text .. "One group. " text = string.format("%s%s %s. ",text,onetxt,grptxt) - --textScreen = textScreen .. "One group.\n" textScreen = string.format("%s%s %s.\n",textScreen,onetxt,grptxt) else text = string.format("%s%d %s. ",text,contactsAO,groupstxt) - --text = text .. clustersAO .. " groups. " textScreen = string.format("%s%d %s.\n",textScreen,contactsAO,groupstxt) - --textScreen = textScreen .. clustersAO .. " groups.\n" end self:_NewRadioEntry(text,textScreen,GID,Outcome,true,true,false,true) @@ -2949,7 +2915,6 @@ function AWACS:_BogeyDope(Group) elseif self.AwacsFG then -- no, unknown - --text = string.format("%s. %s. Negative. You are not checked in.",self:_GetCallSign(Group,GID) or "Ghost 1", self.callsigntxt) local nocheckin = self.gettext:GetEntry("NOTCHECKEDIN",self.locale) text = string.format(nocheckin,self:_GetCallSign(Group,GID) or "Ghost 1", self.callsigntxt) self:_NewRadioEntry(text,text,GID,Outcome,true,true,false) @@ -3248,7 +3213,6 @@ function AWACS:_Unable(Group) if managedtask.Status == AWACS.TaskStatus.REQUESTED then -- ok let's commit this one managedtask = self.ManagedTasks:PullByID(currtaskid) - --managedtask.AssignedGroupID = 0 managedtask.IsUnassigned = true managedtask.Status = AWACS.TaskStatus.FAILED self.ManagedTasks:Push(managedtask,currtaskid) @@ -3284,7 +3248,6 @@ end -- @return #AWACS self function AWACS:_TaskAbort(Group) self:T(self.lid.."_TaskAbort") - --local GID, Outcome = self:_GetManagedGrpID(Group) local Outcome,GID = self:_GetGIDFromGroupOrName(Group) local text = "" if Outcome then @@ -3300,7 +3263,6 @@ function AWACS:_TaskAbort(Group) -- ok let's un-commit this one managedtask = self.ManagedTasks:PullByID(currtaskid) managedtask.Status = AWACS.TaskStatus.FAILED - --managedtask.AssignedGroupID = 0 managedtask.IsUnassigned = true self.ManagedTasks:Push(managedtask,currtaskid) -- unlink group @@ -3431,8 +3393,7 @@ function AWACS:_CheckIn(Group) local alphacheckbulls = self:_ToStringBULLS(Group:GetCoordinate()) local alphacheckbullstts = self:_ToStringBULLS(Group:GetCoordinate(),false,true) - - --self.ManagedGrps[self.ManagedGrpID]=managedgroup + local alpha = self.gettext:GetEntry("ALPHACHECK",self.locale) text = string.format("%s. %s. %s. %s",managedgroup.CallSign,self.callsigntxt,alpha,alphacheckbulls) textTTS = text @@ -3555,11 +3516,9 @@ function AWACS:_CheckOut(Group,GID,dead) local Angels = managedgroup.AnchorStackAngels -- remove menus if managedgroup.IsPlayer then - -- DONE Move to FIFO if self.clientmenus:HasUniqueID(managedgroup.GroupName) then local menus = self.clientmenus:PullByID(managedgroup.GroupName) --#AWACS.MenuStructure menus.basemenu:Remove() - --self.clientmenus[AnchorAssigned.GroupName] = nil end end -- delete open tasks @@ -3591,7 +3550,6 @@ function AWACS:_SetClientMenus() self:T(self.lid.."_SetClientMenus") local clientset = self.clientset -- Core.Set#SET_CLIENT local aliveset = clientset:GetSetObjects() or {}-- #table of #CLIENT objects - --local clientmenus = {} local clientcount = 0 local clientcheckedin = 0 for _,_group in pairs(aliveset) do @@ -3603,7 +3561,6 @@ function AWACS:_SetClientMenus() cgrpname = cgrp:GetName() self:T(cgrpname) end - --cgrpname = string.match(cgrpname,"([%a%s]+)#") if self.MenuStrict then -- check if pilot has checked in if cgrp and cgrp:IsAlive() then @@ -3612,9 +3569,7 @@ function AWACS:_SetClientMenus() if checkedin then -- full menu minus checkin clientcheckedin = clientcheckedin + 1 - --self.clientmenus:Flush() local hasclientmenu = self.clientmenus:ReadByID(cgrpname) -- #AWACS.MenuStructure - --self:T({hasclientmenu}) local basemenu = hasclientmenu.basemenu -- Core.Menu#MENU_GROUP if hasclientmenu and (not hasclientmenu.menuset) then @@ -3622,7 +3577,6 @@ function AWACS:_SetClientMenus() self:T(self.lid.."Setting Menus for "..cgrpname) basemenu:RemoveSubMenus() - --basemenu:Refresh() local bogeydope = MENU_GROUP_COMMAND:New(cgrp,"Bogey Dope",basemenu,self._BogeyDope,self,cgrp) local picture = MENU_GROUP_COMMAND:New(cgrp,"Picture",basemenu,self._Picture,self,cgrp) local declare = MENU_GROUP_COMMAND:New(cgrp,"Declare",basemenu,self._Declare,self,cgrp) @@ -3665,10 +3619,8 @@ function AWACS:_SetClientMenus() elseif not self.clientmenus:HasUniqueID(cgrpname) then -- check in only local basemenu = MENU_GROUP:New(cgrp,self.Name,nil) - --basemenu:RemoveSubMenus() local checkin = MENU_GROUP_COMMAND:New(cgrp,"Check In",basemenu,self._CheckIn,self,cgrp) checkin:SetTag(cgrp:GetName()) - --basemenu:Set() basemenu:Refresh() local menus = { -- #AWACS.MenuStructure groupname = cgrpname, @@ -3682,8 +3634,6 @@ function AWACS:_SetClientMenus() else if cgrp and cgrp:IsAlive() and not self.clientmenus:HasUniqueID(cgrpname) then local basemenu = MENU_GROUP:New(cgrp,self.Name,nil) - --basemenu:RemoveSubMenus() - --basemenu:Refresh() local picture = MENU_GROUP_COMMAND:New(cgrp,"Picture",basemenu,self._Picture,self,cgrp) local bogeydope = MENU_GROUP_COMMAND:New(cgrp,"Bogey Dope",basemenu,self._BogeyDope,self,cgrp) local declare = MENU_GROUP_COMMAND:New(cgrp,"Declare",basemenu,self._Declare,self,cgrp) @@ -3885,7 +3835,6 @@ function AWACS:_CreateAnchorStack() AnchorStackOne.StationName = newname --push to AnchorStacks if self.debug then - --self.AnchorStacks:Flush() AnchorStackOne.StationZone:DrawZone(self.coalition,{0,0,1},1,{0,0,1},0.2,5,true) local stationtag = string.format("Station: %s\nCoordinate: %s",newname,self.StationZone:GetCoordinate():ToStringLLDDM()) AnchorStackOne.AnchorMarker=MARKER:New(AnchorStackOne.StationZone:GetCoordinate(),stationtag):ToCoalition(self.coalition) @@ -4023,7 +3972,6 @@ function AWACS:_StartIntel(awacs) acceptzoneset:AddZone(self.BorderZone) end - --self.AwacsInZone intel:SetAcceptZones(acceptzoneset) if self.NoHelos then @@ -4475,8 +4423,8 @@ function AWACS:_CheckTaskQueue() end elseif entry.IsPlayerTask then -- Player task - -- TODO - if entry.Target:IsDead() or entry.Target:IsDestroyed() then + -- DONE + if entry.Target:IsDead() or entry.Target:IsDestroyed() or entry.Target:CountTargets() == 0 then -- success! entry.Status = AWACS.TaskStatus.SUCCESS elseif entry.Target:IsAlive() then @@ -4593,7 +4541,7 @@ function AWACS:_CheckTaskQueue() end -- target dead or out of bounds? - if entry.Target:IsDead() or entry.Target:IsDestroyed() then + if entry.Target:IsDead() or entry.Target:IsDestroyed() or entry.Target:CountTargets() == 0 then -- success! entry.Status = AWACS.TaskStatus.SUCCESS elseif entry.Target:IsAlive() then @@ -4819,7 +4767,6 @@ function AWACS:AddCAPAirWing(AirWing,Zone) AnchorStackOne.StationName = newname --push to AnchorStacks if self.debug then - --self.AnchorStacks:Flush() AnchorStackOne.StationZone:DrawZone(self.coalition,{0,0,1},1,{0,0,1},0.2,5,true) local stationtag = string.format("Station: %s\nCoordinate: %s",newname,self.StationZone:GetCoordinate():ToStringLLDDM()) AnchorStackOne.AnchorMarker=MARKER:New(AnchorStackOne.StationZone:GetCoordinate(),stationtag):ToCoalition(self.coalition) @@ -4914,24 +4861,16 @@ function AWACS:_AnnounceContact(Contact,IsNew,Group,IsBogeyDope,Tag,IsPopup,Repo local popup = self.gettext:GetEntry("POPUP",self.locale) if IsNew and self.PlayerGuidance then - --BRAText = BRAText .. " New group." BRAText = string.format("%s %s.",BRAText,newgrp) - --TextScreen = TextScreen .. " New group." TextScreen = string.format("%s %s.",TextScreen,newgrp) elseif IsPopup then - --BRAText = BRAText .. " Pop-up group." BRAText = string.format("%s %s %s.",BRAText,popup,grptxt) - --TextScreen = TextScreen .. " Pop-up group." TextScreen = string.format("%s %s %s.",TextScreen,popup,grptxt) elseif IsBogeyDope and Tag and Tag ~= "" then - --BRAText = BRAText .. " "..Tag.." group." BRAText = string.format("%s %s %s.",BRAText,Tag,grptxt) - --TextScreen = TextScreen .. " "..Tag.." group." TextScreen = string.format("%s %s %s.",TextScreen,Tag,grptxt) else - --BRAText = BRAText .. " Group." BRAText = string.format("%s %s.",BRAText,GRPtxt) - --TextScreen = TextScreen .. " Group." TextScreen = string.format("%s %s.",TextScreen,GRPtxt) end @@ -5205,7 +5144,6 @@ function AWACS:_CheckAICAPOnStation() local OpsGroup = self:_GetAliveOpsGroupFromTable(OpsGroups) -- Ops.OpsGroup#OPSGROUP if OpsGroup then local OpsName = OpsGroup:GetName() or "Unknown" - --local OpsCallSign = OpsGroup:GetCallsignName() or "Unknown" local found,GID,OpsCallSign = self:_GetGIDFromGroupOrName(OpsGroup) report:Add(string.format("Mission FG %s",OpsName)) report:Add(string.format("Callsign %s",OpsCallSign)) @@ -5485,7 +5423,7 @@ function AWACS:_AssignPilotToTarget(Pilots,Targets) -- BASE:I("AUFTRAG Condition Succes Eval Running") local success = true local target = target -- Ops.Target#TARGET - if target:IsDestroyed() then return true end + if target:IsDestroyed() or target:IsDead() or target:CountTargets() == 0 then return true end local tgtcoord = target:GetCoordinate() local tgtvec2 = nil if tgtcoord then @@ -5496,7 +5434,6 @@ function AWACS:_AssignPilotToTarget(Pilots,Targets) if tgtvec2 then zones:ForEachZone( function(zone) - -- BASE:I("AUFTRAG Condition Succes ZONE Eval Running") if zone:IsVec2InZone(tgtvec2) then success = false end @@ -5504,7 +5441,6 @@ function AWACS:_AssignPilotToTarget(Pilots,Targets) ) rzones:ForEachZone( function(zone) - -- BASE:I("AUFTRAG Condition Succes REJECT ZONE Eval Running") if zone:IsVec2InZone(tgtvec2) then success = true end @@ -5603,7 +5539,6 @@ function AWACS:onafterStart(From, Event, To) self.ControlZone = ZONE_RADIUS:New(controlzonename,self.OpsZone:GetVec2(),UTILS.NMToMeters(self.ControlZoneRadius)) if self.debug then self.ControlZone:DrawZone(self.coalition,{0,1,0},1,{1,0,0},0.05,3,true) - --MARKER:New(self.ControlZone:GetCoordinate(),"Radar Zone"):ToAll() self.OpsZone:DrawZone(self.coalition,{1,0,0},1,{1,0,0},0.2,5,true) local AOCoordString = self.AOCoordinate:ToStringLLDDM() local Rocktag = string.format("FEZ: %s\nBulls Coordinate: %s",self.AOName,AOCoordString) @@ -5658,7 +5593,6 @@ function AWACS:onafterStart(From, Event, To) return self end - --self.AwacsFG:SetSRS(self.PathToSRS,self.Gender,self.Culture,self.Voice,self.Port,self.PathToGoogleKey,"AWACS",self.Volume) self.callsigntxt = string.format("%s",self.CallSignClear[self.CallSign]) self:__CheckRadioQueue(-10) @@ -5717,17 +5651,14 @@ function AWACS:onafterStart(From, Event, To) -- Event functions function MarkerOps:OnAfterMarkAdded(From,Event,To,Text,Keywords,Coord) - --local m = MESSAGE:New(string.format("AWACS %s Mark Added.", self.Tag),10,"Info",true):ToAllIf(self.debug) Handler(Keywords,Coord,Text) end function MarkerOps:OnAfterMarkChanged(From,Event,To,Text,Keywords,Coord) - --BASE:I(string.format("%s Mark Changed.", self.Tag)) Handler(Keywords,Coord,Text) end function MarkerOps:OnAfterMarkDeleted(From,Event,To) - --BASE:I(string.format("%s Mark Deleted.", self.Tag)) end self.MarkerOps = MarkerOps @@ -5788,7 +5719,6 @@ function AWACS:_CheckAwacsStatus() local sunrise = self.gettext:GetEntry("SUNRISE",self.locale) local text = string.format(sunrise,self.callsigntxt,self.callsigntxt) self:_NewRadioEntry(text,text,0,false,false,false,false,true) - --self.AwacsFG:RadioTransmission(text,1,false) self:T(self.lid..text) self.sunrisedone = true end @@ -5925,13 +5855,10 @@ function AWACS:_CheckAwacsStatus() local ESTOSLeft = UTILS.Round((((self.EscortsTimeOnStation+self.ShiftChangeTime)*3600) - ESmissiontime),0) -- seconds ESTOSLeft = UTILS.Round(ESTOSLeft/60,0) -- minutes local ChangeTime = UTILS.Round(((self.ShiftChangeTime * 3600)/60),0) - --local Changedue = "No" - - --report:Add("====================") + report:Add("ESCORTS REPLACEMENT:") report:Add(string.format("Auftrag Status: %s",esstatus)) report:Add(string.format("TOS Left: %d min",ESTOSLeft)) - --report:Add(string.format("Needs ShiftChange: %s",Changedue)) local OpsGroups = ESmission:GetOpsGroups() local OpsGroup = self:_GetAliveOpsGroupFromTable(OpsGroups) -- Ops.OpsGroup#OPSGROUP @@ -6016,17 +5943,13 @@ function AWACS:onafterStatus(From, Event, To) self:_CheckMerges() - if self.debug then - --local outcome, targets = self:_TargetSelectionProcess() -- TODO for debug ATM - end - local outcome, targets = self:_TargetSelectionProcess(true) self:_CheckTaskQueue() local AI, Humans = self:_GetIdlePilots() -- assign Pilot if there are targets and available Pilots, prefer Humans to AI - -- TODO - Implemented AI First, Humans laters - need to work out how to loop the targets to assign a pilot + -- DONE - Implemented AI First, Humans laters - need to work out how to loop the targets to assign a pilot if outcome and #Humans > 0 and self.PlayerCapAssigment then -- add a task for AI self:_AssignPilotToTarget(Humans,targets) @@ -6163,7 +6086,6 @@ function AWACS:onafterAssignedAnchor(From, Event, To, GID, Anchor, AnchorStackNo local isAI = managedgroup.IsAI local Group = managedgroup.Group local CallSign = managedgroup.CallSign or "Ghost 1" - --local AnchorName = Anchor.StationZone:GetName() or "unknown" local AnchorName = Anchor.StationName or "unknown" local AnchorCoordTxt = Anchor.StationZoneCoordinateText or "unknown" local Angels = AnchorAngels or 25 @@ -6345,7 +6267,6 @@ end -- @return #AWACS self function AWACS:onafterLostContact(From,Event,To,Contact) self:T({From, Event, To, Contact}) - --self:_CleanUpContacts() return self end @@ -6359,7 +6280,6 @@ end -- @return #AWACS self function AWACS:onafterLostCluster(From,Event,To,Cluster,Mission) self:T({From, Event, To}) - --self:_CleanUpContacts() return self end @@ -6396,10 +6316,8 @@ function AWACS:onafterCheckRadioQueue(From,Event,To) if self.PathToGoogleKey then local gtext = RadioEntry.TextTTS gtext = string.format("%s",gtext) - --self.AwacsFG:RadioTransmission(gtext,1,false) self.AwacsSRS:PlayTextExt(gtext,nil,self.MultiFrequency,self.MultiModulation,self.Gender,self.Culture,self.Voice,self.Volume,"AWACS") else - --self.AwacsFG:RadioTransmission(RadioEntry.TextTTS,1,false) self.AwacsSRS:PlayTextExt(RadioEntry.TextTTS,nil,self.MultiFrequency,self.MultiModulation,self.Gender,self.Culture,self.Voice,self.Volume,"AWACS") end self:T(RadioEntry.TextTTS) @@ -6647,9 +6565,6 @@ function AWACS:onafterReAnchor(From, Event, To, GID) local lastknown = UTILS.DeepCopy(managedgroup.LastKnownPosition) local brtext = self:_ToStringBULLS(lastknown) local brtexttts = self:_ToStringBULLS(lastknown,false,true) - --if self.PathToGoogleKey then - --brtexttts = self:_ToStringBULLS(lastknown,true) - --end text = text .. " "..brtexttts.." "..milestxt.."." textScreen = textScreen .. " "..brtext.." "..milestxt.."." diff --git a/Moose Development/Moose/Ops/CTLD.lua b/Moose Development/Moose/Ops/CTLD.lua index bd52b2742..bb5a86982 100644 --- a/Moose Development/Moose/Ops/CTLD.lua +++ b/Moose Development/Moose/Ops/CTLD.lua @@ -1072,11 +1072,12 @@ CTLD.UnitTypes = { --Actually it's longer, but the center coord is off-center of the model. ["UH-60L"] = {type="UH-60L", crates=true, troops=true, cratelimit = 2, trooplimit = 20, length = 16, cargoweightlimit = 3500}, -- 4t cargo, 20 (unsec) seats ["AH-64D_BLK_II"] = {type="AH-64D_BLK_II", crates=false, troops=true, cratelimit = 0, trooplimit = 2, length = 17, cargoweightlimit = 200}, -- 2 ppl **outside** the helo + ["Bronco-OV-10A"] = {type="Bronco-OV-10A", crates= false, troops=true, cratelimit = 0, trooplimit = 5, length = 13, cargoweightlimit = 1450}, } --- CTLD class version. -- @field #string version -CTLD.version="1.0.17" +CTLD.version="1.0.18" --- Instantiate a new CTLD. -- @param #CTLD self @@ -1518,7 +1519,7 @@ function CTLD:_EventHandler(EventData) self:_RefreshF10Menus() end -- Herc support - if _unit:GetTypeName() == "Hercules" and self.enableHercules then + if self:IsHercules(_unit) and self.enableHercules then local unitname = event.IniUnitName or "none" self.Loaded_Cargo[unitname] = nil self:_RefreshF10Menus() @@ -2523,7 +2524,7 @@ end -- @param Wrapper.Unit#UNIT Unit -- @return #boolean Outcome function CTLD:IsHercules(Unit) - if Unit:GetTypeName() == "Hercules" then + if Unit:GetTypeName() == "Hercules" or string.find(Unit:GetTypeName(),"Bronco") then return true else return false @@ -2732,8 +2733,7 @@ end function CTLD:_BuildCrates(Group, Unit,Engineering) self:T(self.lid .. " _BuildCrates") -- avoid users trying to build from flying Hercs - local type = Unit:GetTypeName() - if type == "Hercules" and self.enableHercules and not Engineering then + if self:IsHercules(Unit) and self.enableHercules and not Engineering then local speed = Unit:GetVelocityKMH() if speed > 1 then self:_SendMessage("You need to land / stop to build something, Pilot!", 10, false, Group) @@ -3046,7 +3046,7 @@ function CTLD:_RefreshF10Menus() local _unit = _group:GetUnit(1) -- Wrapper.Unit#UNIT Asume that there is only one unit in the flight for players if _unit then if _unit:IsAlive() and _unit:IsPlayer() then - if _unit:IsHelicopter() or (_unit:GetTypeName() == "Hercules" and self.enableHercules) then --ensure no stupid unit entries here + if _unit:IsHelicopter() or (self:IsHercules(_unit) and self.enableHercules) then --ensure no stupid unit entries here local unitName = _unit:GetName() _UnitList[unitName] = unitName end @@ -3145,7 +3145,7 @@ function CTLD:_RefreshF10Menus() local buildmenu = MENU_GROUP_COMMAND:New(_group,"Build crates",topcrates, self._BuildCrates, self, _group, _unit) local repairmenu = MENU_GROUP_COMMAND:New(_group,"Repair",topcrates, self._RepairCrates, self, _group, _unit):Refresh() end - if unittype == "Hercules" then + if self:IsHercules(_unit) then local hoverpars = MENU_GROUP_COMMAND:New(_group,"Show flight parameters",topmenu, self._ShowFlightParams, self, _group, _unit):Refresh() else local hoverpars = MENU_GROUP_COMMAND:New(_group,"Show hover parameters",topmenu, self._ShowHoverParams, self, _group, _unit):Refresh() @@ -3422,11 +3422,19 @@ function CTLD:AddCTLDZone(Name, Type, Color, Active, HasBeacon, Shiplength, Ship self:T(self.lid .. " AddCTLDZone") local zone = ZONE:FindByName(Name) - if not zone then + if not zone and Type ~= CTLD.CargoZoneType.SHIP then self:E(self.lid.."**** Zone does not exist: "..Name) return self end + if Type == CTLD.CargoZoneType.SHIP then + local Ship = UNIT:FindByName(Name) + if not Ship then + self:E(self.lid.."**** Ship does not exist: "..Name) + return self + end + end + local ctldzone = {} -- #CTLD.CargoZone ctldzone.active = Active or false ctldzone.color = Color or SMOKECOLOR.Red @@ -3684,21 +3692,22 @@ function CTLD:IsUnitInZone(Unit,Zonetype) local zonewidth = 20 if Zonetype == CTLD.CargoZoneType.SHIP then self:T("Checking Type Ship: "..zonename) - zone = UNIT:FindByName(zonename) - zonecoord = zone:GetCoordinate() + local ZoneUNIT = UNIT:FindByName(zonename) + zonecoord = ZoneUNIT:GetCoordinate() zoneradius = czone.shiplength zonewidth = czone.shipwidth + zone = ZONE_UNIT:New( ZoneUNIT:GetName(), ZoneUNIT, zoneradius/2) elseif ZONE:FindByName(zonename) then zone = ZONE:FindByName(zonename) self:T("Checking Zone: "..zonename) zonecoord = zone:GetCoordinate() - zoneradius = 1500 + --zoneradius = 1500 zonewidth = zoneradius elseif AIRBASE:FindByName(zonename) then zone = AIRBASE:FindByName(zonename):GetZone() self:T("Checking Zone: "..zonename) zonecoord = zone:GetCoordinate() - zoneradius = 2500 + zoneradius = 2000 zonewidth = zoneradius end local distance = self:_GetDistance(zonecoord,unitcoord) @@ -3956,7 +3965,7 @@ end function CTLD:IsUnitInAir(Unit) -- get speed and height local minheight = self.minimumHoverHeight - if self.enableHercules and Unit:GetTypeName() == "Hercules" then + if self.enableHercules and self:IsHercules(Unit) then minheight = 5.1 -- herc is 5m AGL on the ground end local uheight = Unit:GetHeight() diff --git a/Moose Development/Moose/Ops/PlayerTask.lua b/Moose Development/Moose/Ops/PlayerTask.lua index e98bcf67b..69327de47 100644 --- a/Moose Development/Moose/Ops/PlayerTask.lua +++ b/Moose Development/Moose/Ops/PlayerTask.lua @@ -21,7 +21,7 @@ -- === -- @module Ops.PlayerTask -- @image OPS_PlayerTask.jpg --- @date Last Update October 2022 +-- @date Last Update November 2022 do @@ -95,7 +95,7 @@ PLAYERTASK = { --- PLAYERTASK class version. -- @field #string version -PLAYERTASK.version="0.1.9" +PLAYERTASK.version="0.1.10" --- Generic task condition. -- @type PLAYERTASK.Condition @@ -654,11 +654,14 @@ function PLAYERTASK:onafterStatus(From, Event, To) -- Check Target status local targetdead = false - if self.Target:IsDead() or self.Target:IsDestroyed() or self.Target:CountTargets() == 0 then - targetdead = true - self:__Success(-2) - status = "Success" - return self + + if self.Type ~= AUFTRAG.Type.CTLD and self.Type ~= AUFTRAG.Type.CSAR then + if self.Target:IsDead() or self.Target:IsDestroyed() or self.Target:CountTargets() == 0 then + targetdead = true + self:__Success(-2) + status = "Success" + return self + end end if status == "Executing" then @@ -919,6 +922,7 @@ do -- @field Ops.PlayerRecce#PLAYERRECCE PlayerRecce -- @field #number Coalition -- @field Core.Menu#MENU_MISSION MenuParent +-- @field #boolean ShowMagnetic Also show magnetic angles -- @extends Core.Fsm#FSM --- @@ -1231,6 +1235,7 @@ PLAYERTASKCONTROLLER = { PlayerRecce = nil, Coalition = nil, MenuParent = nil, + ShowMagnetic = true, } --- @@ -1397,7 +1402,7 @@ PLAYERTASKCONTROLLER.Messages = { --- PLAYERTASK class version. -- @field #string version -PLAYERTASKCONTROLLER.version="0.1.45" +PLAYERTASKCONTROLLER.version="0.1.46" --- Create and run a new TASKCONTROLLER instance. -- @param #PLAYERTASKCONTROLLER self @@ -1453,6 +1458,8 @@ function PLAYERTASKCONTROLLER:New(Name, Coalition, Type, ClientFilter) self.CallsignTranslations = nil self.noflaresmokemenu = false + + self.ShowMagnetic = true if ClientFilter then self.ClientSet = SET_CLIENT:New():FilterCoalitions(string.lower(self.CoalitionName)):FilterActive(true):FilterPrefixes(ClientFilter):FilterStart() @@ -2013,6 +2020,20 @@ function PLAYERTASKCONTROLLER:SwitchUseGroupNames(OnOff) return self end +--- [User] Switch showing additional magnetic angles +-- @param #PLAYERTASKCONTROLLER self +-- @param #boolean OnOff If true, set to on (default), if nil or false, set to off +-- @return #PLAYERTASKCONTROLLER self +function PLAYERTASKCONTROLLER:SwitchMagenticAngles(OnOff) + self:T(self.lid.."SwitchMagenticAngles") + if OnOff then + self.ShowMagnetic = true + else + self.ShowMagnetic = false + end + return self +end + --- [Internal] Get task types for the menu -- @param #PLAYERTASKCONTROLLER self -- @return #table TaskTypes @@ -2678,9 +2699,9 @@ function PLAYERTASKCONTROLLER:_FlashInfo() local Coordinate = task.Target:GetCoordinate() local CoordText = "" if self.Type ~= PLAYERTASKCONTROLLER.Type.A2A then - CoordText = Coordinate:ToStringA2G(_client) + CoordText = Coordinate:ToStringA2G(_client, nil, self.ShowMagnetic) else - CoordText = Coordinate:ToStringA2A(_client) + CoordText = Coordinate:ToStringA2A(_client, nil, self.ShowMagnetic) end local targettxt = self.gettext:GetEntry("TARGET",self.locale) local text = "Target: "..CoordText @@ -2713,9 +2734,9 @@ function PLAYERTASKCONTROLLER:_ActiveTaskInfo(Group, Client, Task) local Coordinate = task.Target:GetCoordinate() local CoordText = "" if self.Type ~= PLAYERTASKCONTROLLER.Type.A2A then - CoordText = Coordinate:ToStringA2G(Client) + CoordText = Coordinate:ToStringA2G(Client,nil,self.ShowMagnetic) else - CoordText = Coordinate:ToStringA2A(Client) + CoordText = Coordinate:ToStringA2A(Client,nil,self.ShowMagnetic) end -- Threat Level local ThreatLevel = task.Target:GetThreatLevelMax() @@ -2819,6 +2840,9 @@ function PLAYERTASKCONTROLLER:_ActiveTaskInfo(Group, Client, Task) if string.find(CoordText," BR, ") then CoordText = string.gsub(CoordText," BR, "," Bee, Arr, ") end + if self.ShowMagnetic then + text=string.gsub(text,"°M|","° magnetic, ") + end local ThreatLocaleTextTTS = self.gettext:GetEntry("THREATTEXTTTS",self.locale) local ttstext = string.format(ThreatLocaleTextTTS,self.MenuName or self.Name,ttsplayername,ttstaskname,ThreatLevelText, targets, CoordText) -- POINTERTARGETLASINGTTS = ". Pointer over target and lasing." diff --git a/Moose Development/Moose/Sound/SRS.lua b/Moose Development/Moose/Sound/SRS.lua index 52ed609b0..268b4e60c 100644 --- a/Moose Development/Moose/Sound/SRS.lua +++ b/Moose Development/Moose/Sound/SRS.lua @@ -94,8 +94,6 @@ -- For more information on setting up a cloud account, visit: https://cloud.google.com/text-to-speech -- Google's supported SSML reference: https://cloud.google.com/text-to-speech/docs/ssml -- --- **NOTE on using GOOGLE TTS with SRS:** You need to have the C# library installed in your SRS folder for Google to work. --- You can obtain it e.g. here: [NuGet](https://www.nuget.org/packages/Grpc.Core) -- -- **Pro-Tipp** - use the command line with power shell to call DCS-SR-ExternalAudio.exe - it will tell you what is missing. -- and also the Google Console error, in case you have missed a step in setting up your Google TTS. @@ -104,10 +102,14 @@ -- -- ## Set Voice -- --- Use a specifc voice with the @{#MSRS.SetVoice} function, e.g, `:SetVoice("Microsoft Hedda Desktop")`. +-- Use a specific voice with the @{#MSRS.SetVoice} function, e.g, `:SetVoice("Microsoft Hedda Desktop")`. -- Note that this must be installed on your windows system. -- If enabling SetGoogle(), you can use voices provided by Google -- Google's supported voices: https://cloud.google.com/text-to-speech/docs/voices +-- For voices there are enumerators in this class to help you out on voice names: +-- +-- MSRS.Voices.Microsoft -- e.g. MSRS.Voices.Microsoft.Hedda - the Microsoft enumerator contains all voices known to work with SRS +-- MSRS.Voices.Google -- e.g. MSRS.Voices.Google.Standard.en_AU_Standard_A or MSRS.Voices.Google.Wavenet.de_DE_Wavenet_C - The Google enumerator contains voices for EN, DE, IT, FR and ES. -- -- ## Set Coordinate -- @@ -141,7 +143,7 @@ MSRS = { --- MSRS class version. -- @field #string version -MSRS.version="0.1.0" +MSRS.version="0.1.1" --- Voices -- @type Voices @@ -248,7 +250,7 @@ MSRS.Voices = { -- TODO list ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --- TODO: Add functions to add/remove freqs and modulations. +-- TODO: Add functions to remove freqs and modulations. -- DONE: Add coordinate. -- DONE: Add google. @@ -410,6 +412,24 @@ function MSRS:SetFrequencies(Frequencies) return self end +--- Add frequencies. +-- @param #MSRS self +-- @param #table Frequencies Frequencies in MHz. Can also be given as a #number if only one frequency should be used. +-- @return #MSRS self +function MSRS:AddFrequencies(Frequencies) + + -- Ensure table. + if type(Frequencies)~="table" then + Frequencies={Frequencies} + end + + for _,_freq in pairs(Frequencies) do + table.insert(self.frequencies,_freq) + end + + return self +end + --- Get frequencies. -- @param #MSRS self -- @param #table Frequencies in MHz. @@ -434,6 +454,24 @@ function MSRS:SetModulations(Modulations) return self end +--- Add modulations. +-- @param #MSRS self +-- @param #table Modulations Modulations. Can also be given as a #number if only one modulation should be used. +-- @return #MSRS self +function MSRS:AddModulations(Modulations) + + -- Ensure table. + if type(Modulations)~="table" then + Modulations={Modulations} + end + + for _,_mod in pairs(Modulations) do + table.insert(self.modulations,_mod) + end + + return self +end + --- Get modulations. -- @param #MSRS self -- @param #table Modulations.