From 13449cc9eedcb30eb964cb34421f155196c30762 Mon Sep 17 00:00:00 2001 From: FlightControl Date: Sat, 20 May 2017 08:48:57 +0200 Subject: [PATCH] Progress designing system settings --- Moose Development/Moose/Actions/Act_Route.lua | 25 +- Moose Development/Moose/Core/Point.lua | 1366 ++++++++--------- Moose Development/Moose/Core/Settings.lua | 228 +++ .../Moose/Functional/Detection.lua | 7 +- Moose Development/Moose/Moose.lua | 3 +- Moose Development/Moose/Tasking/Task.lua | 5 +- .../Moose/Tasking/Task_A2A_Dispatcher.lua | 8 +- Moose Mission Setup/Moose.files | 1 + Moose Mission Setup/Moose.lua | 3 +- 9 files changed, 924 insertions(+), 722 deletions(-) create mode 100644 Moose Development/Moose/Core/Settings.lua diff --git a/Moose Development/Moose/Actions/Act_Route.lua b/Moose Development/Moose/Actions/Act_Route.lua index 5a7b85d14..5e7f91381 100644 --- a/Moose Development/Moose/Actions/Act_Route.lua +++ b/Moose Development/Moose/Actions/Act_Route.lua @@ -154,29 +154,21 @@ do -- ACT_ROUTE --- Get the routing text to be displayed. -- The route mode determines the text displayed. -- @param #ACT_ROUTE self + -- @param Core.Point#COORDINATE FromCoordinate -- @return #string function ACT_ROUTE:GetRouteText( FromCoordinate ) local RouteText = "" - if self.Coordinate and self.RouteMode == "B" then - RouteText = "Route to " .. FromCoordinate:GetBRText( self.Coordinate ) .. " km." + + if self.Coordinate then + RouteText = "Route to " .. self.Coordinate:ToString( FromCoordinate ) end - if self.Coordinate and self.RouteMode == "C" then - RouteText = "Route to " .. self.Coordinate:ToString() - end - - if self.Zone and self.RouteMode == "B" then - local Coordinate = self.Zone:GetCoordinate() - RouteText = "Route to zone bearing " .. FromCoordinate:GetBRText( Coordinate ) .. " km." + if self.Zone then + RouteText = "Route to " .. self.Zone:GetCoordinate():ToString( FromCoordinate ) end - if self.Zone and self.RouteMode == "C" then - local Coordinate = self.Zone:GetCoordinate() - RouteText = "Route to zone at " .. Coordinate:ToString() - end - return RouteText end @@ -438,10 +430,7 @@ do -- ACT_ROUTE_ZONE -- @param #string To function ACT_ROUTE_ZONE:onafterReport( ProcessUnit, From, Event, To ) - local ZoneVec2 = self.Zone:GetVec2() - local ZoneCoordinate = COORDINATE:New( ZoneVec2.x, ZoneVec2.y ) - local TaskUnitVec2 = ProcessUnit:GetVec2() - local TaskUnitCoordinate = COORDINATE:New( TaskUnitVec2.x, TaskUnitVec2.y ) + local TaskUnitCoordinate = ProcessUnit:GetCoordinate() local RouteText = self:GetRouteText( TaskUnitCoordinate ) self:Message( RouteText ) end diff --git a/Moose Development/Moose/Core/Point.lua b/Moose Development/Moose/Core/Point.lua index f76caac96..75d44f6e1 100644 --- a/Moose Development/Moose/Core/Point.lua +++ b/Moose Development/Moose/Core/Point.lua @@ -53,6 +53,41 @@ -- -- @module Point + +--- @type COORDINATE +-- @extends Core.Base#BASE + +--- # COORDINATE class, extends @{Base#BASE} +-- +-- The COORDINATE class defines a 2D coordinate in the simulator. The height coordinate (if needed) will be the land height + an optional added height specified. +-- A COORDINATE can be expressed in LL or in MGRS. +-- +-- ## COORDINATE constructor +-- +-- A new COORDINATE instance can be created with: +-- +-- * @{Point#COORDINATE.New}(): a 2D point, taking an additional height parameter. +-- * @{Point#COORDINATE.NewFromVec2}(): a 2D point created from a @{DCSTypes#Vec2}. +-- +-- ## Manupulate the X, Altitude, Y coordinates of the 2D point +-- +-- A COORDINATE class works in 2D space, with an altitude setting. It contains internally an X, Altitude, Y coordinate. +-- Methods exist to manupulate these coordinates. +-- +-- The current X, Altitude, Y axis can be retrieved with the methods @{#COORDINATE.GetX}(), @{#COORDINATE.GetAlt}(), @{#COORDINATE.GetY}() respectively. +-- The methods @{#COORDINATE.SetX}(), @{#COORDINATE.SetAlt}(), @{#COORDINATE.SetY}() change the respective axis with a new value. +-- The current Lat(itude), Alt(itude), Lon(gitude) values can also be retrieved with the methods @{#COORDINATE.GetLat}(), @{#COORDINATE.GetAlt}(), @{#COORDINATE.GetLon}() respectively. +-- The current axis values can be changed by using the methods @{#COORDINATE.AddX}(), @{#COORDINATE.AddAlt}(), @{#COORDINATE.AddY}() +-- to add or substract a value from the current respective axis value. +-- Note that the Set and Add methods return the current COORDINATE object, so these manipulation methods can be chained... For example: +-- +-- local Vec2 = PointVec2:AddX( 100 ):AddY( 2000 ):GetVec2() +-- +-- @field #COORDINATE +COORDINATE = { + ClassName = "COORDINATE", +} + --- The POINT_VEC3 class -- @type POINT_VEC3 -- @field #number x The x coordinate in 3D space. @@ -63,9 +98,10 @@ -- @field #POINT_VEC3.RoutePointAltType RoutePointAltType -- @field #POINT_VEC3.RoutePointType RoutePointType -- @field #POINT_VEC3.RoutePointAction RoutePointAction --- @extends Core.Base#BASE +-- @extends Core.Point#COORDINATE ---- # POINT_VEC3 class, extends @{Base#BASE} + +--- # POINT_VEC3 class, extends @{Point#COORDINATE} -- -- POINT_VEC3 defines a 3D point in the simulator and with its methods, you can use or manipulate the point in 3D space. -- @@ -202,9 +238,10 @@ POINT_VEC3 = { --- @type POINT_VEC2 -- @field Dcs.DCSTypes#Distance x The x coordinate in meters. -- @field Dcs.DCSTypes#Distance y the y coordinate in meters. --- @extends Core.Point#POINT_VEC3 +-- @extends Core.Point#COORDINATE ---- # POINT_VEC2 class, extends @{Point#POINT_VEC3} + +--- # POINT_VEC2 class, extends @{Point#COORDINATE} -- -- The @{Point#POINT_VEC2} class defines a 2D point in the simulator. The height coordinate (if needed) will be the land height + an optional added height specified. -- @@ -235,48 +272,556 @@ POINT_VEC2 = { } ---- @type COORDINATE --- @field #number LL_Accuracy --- @field #boolean LL_DMS --- @field #number MGRS_Accuracy --- @field #string System --- @extends Core.Point#POINT_VEC2 ---- # COORDINATE class, extends @{Point#COORDINATE} --- --- The COORDINATE class defines a 2D coordinate in the simulator. The height coordinate (if needed) will be the land height + an optional added height specified. --- A COORDINATE can be expressed in LL or in MGRS. --- --- ## COORDINATE constructor --- --- A new COORDINATE instance can be created with: --- --- * @{Point#COORDINATE.New}(): a 2D point, taking an additional height parameter. --- * @{Point#COORDINATE.NewFromVec2}(): a 2D point created from a @{DCSTypes#Vec2}. --- --- ## Manupulate the X, Altitude, Y coordinates of the 2D point --- --- A COORDINATE class works in 2D space, with an altitude setting. It contains internally an X, Altitude, Y coordinate. --- Methods exist to manupulate these coordinates. --- --- The current X, Altitude, Y axis can be retrieved with the methods @{#COORDINATE.GetX}(), @{#COORDINATE.GetAlt}(), @{#COORDINATE.GetY}() respectively. --- The methods @{#COORDINATE.SetX}(), @{#COORDINATE.SetAlt}(), @{#COORDINATE.SetY}() change the respective axis with a new value. --- The current Lat(itude), Alt(itude), Lon(gitude) values can also be retrieved with the methods @{#COORDINATE.GetLat}(), @{#COORDINATE.GetAlt}(), @{#COORDINATE.GetLon}() respectively. --- The current axis values can be changed by using the methods @{#COORDINATE.AddX}(), @{#COORDINATE.AddAlt}(), @{#COORDINATE.AddY}() --- to add or substract a value from the current respective axis value. --- Note that the Set and Add methods return the current COORDINATE object, so these manipulation methods can be chained... For example: --- --- local Vec2 = PointVec2:AddX( 100 ):AddY( 2000 ):GetVec2() --- --- @field #COORDINATE -COORDINATE = { - ClassName = "COORDINATE", - LL_Accuracy = 2, - LL_DMS = true, - MGRS_Accuracy = 5, - System = "MGRS", -} +do -- COORDINATE + + --- COORDINATE constructor. + -- @param #COORDINATE self + -- @param Dcs.DCSTypes#Distance x The x coordinate of the Vec3 point, pointing to the North. + -- @param Dcs.DCSTypes#Distance y The y coordinate of the Vec3 point, pointing to the Right. + -- @param Dcs.DCSTypes#Distance z The z coordinate of the Vec3 point, pointing to the Right. + -- @return Core.Point#COORDINATE + function COORDINATE:New( x, y, z ) + + local self = BASE:Inherit( self, BASE:New() ) -- #COORDINATE + self.x = x + self.y = y + self.z = z + + self:SetModeA2G() + + return self + end + + --- Create a new COORDINATE object from Vec2 coordinates. + -- @param #COORDINATE self + -- @param Dcs.DCSTypes#Vec2 Vec2 The Vec2 point. + -- @param Dcs.DCSTypes#Distance LandHeightAdd (optional) The default height if required to be evaluated will be the land height of the x, y coordinate. You can specify an extra height to be added to the land height. + -- @return Core.Point#COORDINATE + function COORDINATE:NewFromVec2( Vec2, LandHeightAdd ) + + local LandHeight = land.getHeight( Vec2 ) + + LandHeightAdd = LandHeightAdd or 0 + LandHeight = LandHeight + LandHeightAdd + + local self = self:New( Vec2.x, LandHeight, Vec2.y ) -- #COORDINATE + + self:F2( self ) + + return self + + end + + --- Create a new COORDINATE object from Vec3 coordinates. + -- @param #COORDINATE self + -- @param Dcs.DCSTypes#Vec3 Vec3 The Vec3 point. + -- @return Core.Point#COORDINATE + function COORDINATE:NewFromVec3( Vec3 ) + + local self = self:New( Vec3.x, Vec3.y, Vec3.z ) + + --local self = BASE:Inherit( self, POINT_VEC3:NewFromVec3( Vec3 ) ) -- Core.Point#COORDINATE + self:F2( self ) + + return self + end + + + --- Return the coordinates of the COORDINATE in Vec3 format. + -- @param #COORDINATE self + -- @return Dcs.DCSTypes#Vec3 The Vec3 format coordinate. + function COORDINATE:GetVec3() + return { x = self.x, y = self.y, z = self.z } + end + + + --- Return the coordinates of the COORDINATE in Vec2 format. + -- @param #COORDINATE self + -- @return Dcs.DCSTypes#Vec2 The Vec2 format coordinate. + function COORDINATE:GetVec2() + return { x = self.x, y = self.z } + end + + + function COORDINATE:SetHeading( Heading ) + self.Heading = Heading + end + + + --- Return a direction vector Vec3 from COORDINATE to the COORDINATE. + -- @param #COORDINATE self + -- @param #COORDINATE TargetCoordinate The target COORDINATE. + -- @return Dcs.DCSTypes#Vec3 DirectionVec3 The direction vector in Vec3 format. + function COORDINATE:GetDirectionVec3( TargetCoordinate ) + return { x = TargetCoordinate.x - self.x, y = TargetCoordinate.y - self.y, z = TargetCoordinate.z - self.z } + end + + --- Get a correction in radians of the real magnetic north of the COORDINATE. + -- @param #COORDINATE self + -- @return #number CorrectionRadians The correction in radians. + function COORDINATE:GetNorthCorrectionRadians() + local TargetVec3 = self:GetVec3() + local lat, lon = coord.LOtoLL(TargetVec3) + local north_posit = coord.LLtoLO(lat + 1, lon) + return math.atan2( north_posit.z - TargetVec3.z, north_posit.x - TargetVec3.x ) + end + + + --- Return an angle in radians from the COORDINATE using a direction vector in Vec3 format. + -- @param #COORDINATE self + -- @param Dcs.DCSTypes#Vec3 DirectionVec3 The direction vector in Vec3 format. + -- @return #number DirectionRadians The angle in radians. + function COORDINATE:GetAngleRadians( DirectionVec3 ) + local DirectionRadians = math.atan2( DirectionVec3.z, DirectionVec3.x ) + --DirectionRadians = DirectionRadians + self:GetNorthCorrectionRadians() + if DirectionRadians < 0 then + DirectionRadians = DirectionRadians + 2 * math.pi -- put dir in range of 0 to 2*pi ( the full circle ) + end + return DirectionRadians + end + + --- Return an angle in degrees from the COORDINATE using a direction vector in Vec3 format. + -- @param #COORDINATE self + -- @param Dcs.DCSTypes#Vec3 DirectionVec3 The direction vector in Vec3 format. + -- @return #number DirectionRadians The angle in degrees. + function COORDINATE:GetAngleDegrees( DirectionVec3 ) + local AngleRadians = self:GetAngleRadians( DirectionVec3 ) + local Angle = UTILS.ToDegree( AngleRadians ) + return Angle + end + + + --- Return the 2D distance in meters between the target COORDINATE and the COORDINATE. + -- @param #COORDINATE self + -- @param #COORDINATE TargetCoordinate The target COORDINATE. + -- @return Dcs.DCSTypes#Distance Distance The distance in meters. + function COORDINATE:Get2DDistance( TargetCoordinate ) + local TargetVec3 = TargetCoordinate:GetVec3() + local SourceVec3 = self:GetVec3() + return ( ( TargetVec3.x - SourceVec3.x ) ^ 2 + ( TargetVec3.z - SourceVec3.z ) ^ 2 ) ^ 0.5 + end + + --- Return the 3D distance in meters between the target COORDINATE and the COORDINATE. + -- @param #COORDINATE self + -- @param #COORDINATE TargetCoordinate The target COORDINATE. + -- @return Dcs.DCSTypes#Distance Distance The distance in meters. + function COORDINATE:Get3DDistance( TargetCoordinate ) + local TargetVec3 = TargetCoordinate:GetVec3() + local SourceVec3 = self:GetVec3() + return ( ( TargetVec3.x - SourceVec3.x ) ^ 2 + ( TargetVec3.y - SourceVec3.y ) ^ 2 + ( TargetVec3.z - SourceVec3.z ) ^ 2 ) ^ 0.5 + end + + --- Provides a Bearing / Range string + -- @param #COORDINATE self + -- @param #number AngleRadians The angle in randians + -- @param #number Distance The distance + -- @return #string The BR Text + function COORDINATE:GetBRText( AngleRadians, Distance, Settings ) + + local Settings = Settings or _SETTINGS + + AngleRadians = UTILS.Round( UTILS.ToDegree( AngleRadians ), 0 ) + if Settings:IsMetric() then + Distance = UTILS.Round( Distance / 1000, 2 ) + else + Distance = UTILS.Round( UTILS.MetersToNM( Distance ), 2 ) + end + + local s = string.format( '%03d', AngleRadians ) .. ' for ' .. Distance + + s = s .. self:GetAltitudeText() -- When the POINT is a VEC2, there will be no altitude shown. + + return s + end + + + --- Return the altitude text of the COORDINATE. + -- @param #COORDINATE self + -- @return #string Altitude text. + function COORDINATE:GetAltitudeText( Settings ) + local Altitude = self.y + local Settings = Settings or _SETTINGS + if Altitude ~= 0 then + if Settings:IsMetric() then + return ' at ' .. UTILS.Round( self.y, -3 ) + else + return ' at ' .. UTILS.Round( UTILS.MetersToFeet( self.y ), -3 ) + end + end + end + + + --- Add a Distance in meters from the COORDINATE horizontal plane, with the given angle, and calculate the new COORDINATE. + -- @param #COORDINATE self + -- @param Dcs.DCSTypes#Distance Distance The Distance to be added in meters. + -- @param Dcs.DCSTypes#Angle Angle The Angle in degrees. + -- @return #COORDINATE The new calculated COORDINATE. + function COORDINATE:Translate( Distance, Angle ) + local SX = self.x + local SZ = self.z + local Radians = Angle / 180 * math.pi + local TX = Distance * math.cos( Radians ) + SX + local TZ = Distance * math.sin( Radians ) + SZ + + return COORDINATE:New( TX, self.y, TZ ) + end + + + + --- Build an air type route point. + -- @param #COORDINATE self + -- @param #COORDINATE.RoutePointAltType AltType The altitude type. + -- @param #COORDINATE.RoutePointType Type The route point type. + -- @param #COORDINATE.RoutePointAction Action The route point action. + -- @param Dcs.DCSTypes#Speed Speed Airspeed in km/h. + -- @param #boolean SpeedLocked true means the speed is locked. + -- @return #table The route point. + function COORDINATE:RoutePointAir( AltType, Type, Action, Speed, SpeedLocked ) + self:F2( { AltType, Type, Action, Speed, SpeedLocked } ) + + local RoutePoint = {} + RoutePoint.x = self.x + RoutePoint.y = self.z + RoutePoint.alt = self.y + RoutePoint.alt_type = AltType + + RoutePoint.type = Type + RoutePoint.action = Action + + RoutePoint.speed = Speed / 3.6 + RoutePoint.speed_locked = true + + -- ["task"] = + -- { + -- ["id"] = "ComboTask", + -- ["params"] = + -- { + -- ["tasks"] = + -- { + -- }, -- end of ["tasks"] + -- }, -- end of ["params"] + -- }, -- end of ["task"] + + + RoutePoint.task = {} + RoutePoint.task.id = "ComboTask" + RoutePoint.task.params = {} + RoutePoint.task.params.tasks = {} + + + return RoutePoint + end + + --- Build an ground type route point. + -- @param #COORDINATE self + -- @param Dcs.DCSTypes#Speed Speed Speed in km/h. + -- @param #COORDINATE.RoutePointAction Formation The route point Formation. + -- @return #table The route point. + function COORDINATE:RoutePointGround( Speed, Formation ) + self:F2( { Formation, Speed } ) + + local RoutePoint = {} + RoutePoint.x = self.x + RoutePoint.y = self.z + + RoutePoint.action = Formation or "" + + + RoutePoint.speed = Speed / 3.6 + RoutePoint.speed_locked = true + + -- ["task"] = + -- { + -- ["id"] = "ComboTask", + -- ["params"] = + -- { + -- ["tasks"] = + -- { + -- }, -- end of ["tasks"] + -- }, -- end of ["params"] + -- }, -- end of ["task"] + + + RoutePoint.task = {} + RoutePoint.task.id = "ComboTask" + RoutePoint.task.params = {} + RoutePoint.task.params.tasks = {} + + + return RoutePoint + end + + --- Creates an explosion at the point of a certain intensity. + -- @param #COORDINATE self + -- @param #number ExplosionIntensity + function COORDINATE:Explosion( ExplosionIntensity ) + self:F2( { ExplosionIntensity } ) + trigger.action.explosion( self:GetVec3(), ExplosionIntensity ) + end + + --- Creates an illumination bomb at the point. + -- @param #COORDINATE self + function COORDINATE:IlluminationBomb() + self:F2() + trigger.action.illuminationBomb( self:GetVec3() ) + end + + + --- Smokes the point in a color. + -- @param #COORDINATE self + -- @param Utilities.Utils#SMOKECOLOR SmokeColor + function COORDINATE:Smoke( SmokeColor ) + self:F2( { SmokeColor } ) + trigger.action.smoke( self:GetVec3(), SmokeColor ) + end + + --- Smoke the COORDINATE Green. + -- @param #COORDINATE self + function COORDINATE:SmokeGreen() + self:F2() + self:Smoke( SMOKECOLOR.Green ) + end + + --- Smoke the COORDINATE Red. + -- @param #COORDINATE self + function COORDINATE:SmokeRed() + self:F2() + self:Smoke( SMOKECOLOR.Red ) + end + + --- Smoke the COORDINATE White. + -- @param #COORDINATE self + function COORDINATE:SmokeWhite() + self:F2() + self:Smoke( SMOKECOLOR.White ) + end + + --- Smoke the COORDINATE Orange. + -- @param #COORDINATE self + function COORDINATE:SmokeOrange() + self:F2() + self:Smoke( SMOKECOLOR.Orange ) + end + + --- Smoke the COORDINATE Blue. + -- @param #COORDINATE self + function COORDINATE:SmokeBlue() + self:F2() + self:Smoke( SMOKECOLOR.Blue ) + end + + --- Flares the point in a color. + -- @param #COORDINATE self + -- @param Utilities.Utils#FLARECOLOR FlareColor + -- @param Dcs.DCSTypes#Azimuth (optional) Azimuth The azimuth of the flare direction. The default azimuth is 0. + function COORDINATE:Flare( FlareColor, Azimuth ) + self:F2( { FlareColor } ) + trigger.action.signalFlare( self:GetVec3(), FlareColor, Azimuth and Azimuth or 0 ) + end + + --- Flare the COORDINATE White. + -- @param #COORDINATE self + -- @param Dcs.DCSTypes#Azimuth (optional) Azimuth The azimuth of the flare direction. The default azimuth is 0. + function COORDINATE:FlareWhite( Azimuth ) + self:F2( Azimuth ) + self:Flare( FLARECOLOR.White, Azimuth ) + end + + --- Flare the COORDINATE Yellow. + -- @param #COORDINATE self + -- @param Dcs.DCSTypes#Azimuth (optional) Azimuth The azimuth of the flare direction. The default azimuth is 0. + function COORDINATE:FlareYellow( Azimuth ) + self:F2( Azimuth ) + self:Flare( FLARECOLOR.Yellow, Azimuth ) + end + + --- Flare the COORDINATE Green. + -- @param #COORDINATE self + -- @param Dcs.DCSTypes#Azimuth (optional) Azimuth The azimuth of the flare direction. The default azimuth is 0. + function COORDINATE:FlareGreen( Azimuth ) + self:F2( Azimuth ) + self:Flare( FLARECOLOR.Green, Azimuth ) + end + + --- Flare the COORDINATE Red. + -- @param #COORDINATE self + function COORDINATE:FlareRed( Azimuth ) + self:F2( Azimuth ) + self:Flare( FLARECOLOR.Red, Azimuth ) + end + + --- Returns if a Coordinate has Line of Sight (LOS) with the ToPointVec3. + -- @param #COORDINATE self + -- @param #COORDINATE ToCoordinate + -- @return #boolean true If the ToCoordinate has LOS with the Coordinate, otherwise false. + function COORDINATE:IsLOS( ToCoordinate ) + + -- Measurement of visibility should not be from the ground, so Adding a hypotethical 2 meters to each Coordinate. + local FromVec3 = self:GetVec3() + FromVec3.y = FromVec3.y + 2 + + local ToVec3 = ToCoordinate:GetVec3() + ToVec3.y = ToVec3.y + 2 + + local IsLOS = land.isVisible( FromVec3, ToVec3 ) + + return IsLOS + end + + + --- Set the mode to A2G + -- @param #COORDINATE self + -- @return #COORDINATE + function COORDINATE:SetModeA2G() + self.Mode = "A2G" + end + + --- Is the mode to A2G + -- @param #COORDINATE self + -- @return #boolean + function COORDINATE:IsModeA2G() + return self.Mode == "A2G" + end + + --- Set the mode to A2A + -- @param #COORDINATE self + -- @return #COORDINATE + function COORDINATE:SetModeA2A() + self.Mode = "A2A" + end + + --- Is the mode to A2A + -- @param #COORDINATE self + -- @return #boolean + function COORDINATE:IsModeA2A() + return self.Mode == "A2A" + end + + + --- Return a BR string from a COORDINATE to the COORDINATE. + -- @param #COORDINATE self + -- @param #COORDINATE TargetCoordinate The target COORDINATE. + -- @return #string The BR text. + function COORDINATE:ToStringBR( FromCoordinate, Settings ) + local DirectionVec3 = self:GetDirectionVec3( FromCoordinate ) + local AngleRadians = self:GetAngleRadians( DirectionVec3 ) + local Distance = self:Get2DDistance( FromCoordinate ) + return "BR: " .. self:GetBRText( AngleRadians, Distance, Settings ) + end + + --- Return a BRAA string from a COORDINATE to the COORDINATE. + -- @param #COORDINATE self + -- @param #COORDINATE TargetCoordinate The target COORDINATE. + -- @return #string The BR text. + function COORDINATE:ToStringBRAA( FromCoordinate, Settings ) + local DirectionVec3 = FromCoordinate:GetDirectionVec3( self ) + local AngleRadians = self:GetAngleRadians( DirectionVec3 ) + local Distance = FromCoordinate:Get2DDistance( self ) + local Altitude = self:GetAltitudeText() + return "BRAA: " .. self:GetBRText( AngleRadians, Distance, Settings ) + end + + --- Return a BULLS string from a COORDINATE to the BULLS of the coalition. + -- @param #COORDINATE self + -- @param Dcs.DCSCoalition#coalition.side Coalition The coalition. + -- @return #string The BR text. + function COORDINATE:ToStringBULLS( Coalition, Settings ) + local TargetCoordinate = COORDINATE:NewFromVec3( coalition.getMainRefPoint( Coalition ) ) + local DirectionVec3 = self:GetDirectionVec3( TargetCoordinate ) + local AngleRadians = self:GetAngleRadians( DirectionVec3 ) + local Distance = self:Get2DDistance( TargetCoordinate ) + local Altitude = self:GetAltitudeText() + return "BULLS: " .. self:GetBRText( AngleRadians, Distance, Settings ) + end + + --- Return an aspect string from a COORDINATE to the Angle of the object. + -- @param #COORDINATE self + -- @param #COORDINATE TargetCoordinate The target COORDINATE. + -- @return #string The Aspect string, which is Hot, Cold or Flanking. + function COORDINATE:ToStringAspect( TargetCoordinate ) + local Heading = self.Heading + local DirectionVec3 = self:GetDirectionVec3( TargetCoordinate ) + local Angle = self:GetAngleDegrees( DirectionVec3 ) + + if Heading then + local Aspect = Angle - Heading + if Aspect > -135 and Aspect <= -45 then + return "Flanking" + end + if Aspect > -45 and Aspect <= 45 then + return "Hot" + end + if Aspect > 45 and Aspect <= 135 then + return "Flanking" + end + if Aspect > 135 or Aspect <= -135 then + return "Cold" + end + end + return "" + end + + --- Provides a Lat Lon string + -- @param #COORDINATE self + -- @param Core.Settings#SETTINGS Settings (optional) Settings + -- @return #string The LL Text + function COORDINATE:ToStringLL( Settings ) --R2.1 Fixes issue #424. + + local LL_Accuracy = Settings and Settings.LL_Accuracy or _SETTINGS.LL_Accuracy + local LL_DMS = Settings and Settings.LL_DMS or _SETTINGS.LL_DMS + local lat, lon = coord.LOtoLL( self:GetVec3() ) + return "LL: " .. UTILS.tostringLL( lat, lon, LL_Accuracy, LL_DMS ) + end + + --- Provides a MGRS string + -- @param #COORDINATE self + -- @param Core.Settings#SETTINGS Settings (optional) Settings + -- @return #string The MGRS Text + function COORDINATE:ToStringMGRS( Settings ) --R2.1 Fixes issue #424. + + local MGRS_Accuracy = Settings and Settings.MGRS_Accuracy or _SETTINGS.MGRS_Accuracy + local lat, lon = coord.LOtoLL( self:GetVec3() ) + local MGRS = coord.LLtoMGRS( lat, lon ) + return "MGRS: " .. UTILS.tostringMGRS( MGRS, MGRS_Accuracy ) + end + + --- Provides a coordinate string of the point, based on a coordinate format system: + -- * Uses default settings in COORDINATE. + -- * Can be overridden if for a GROUP containing x clients, a menu was selected to override the default. + -- @param #COORDINATE self + -- @param #COORDINATE FromCoordinate + -- @param Core.Settings#SETTINGS Settings + -- @return #string The coordinate Text in the configured coordinate system. + function COORDINATE:ToString( FromCoordinate, Settings ) -- R2.2 + + local Settings = Settings or _SETTINGS + + if self:IsModeA2A() then + if Settings:IsA2A_BRA() then + return self:ToStringBRAA( FromCoordinate, Settings ) + end + + if Settings:IsA2A_BULLS() then + return self:ToStringBULLS( FromCoordinate, Settings ) + end + end + + if self:IsModeA2G() then + if Settings:IsA2G_LL() then + return self:ToStringLL( Settings ) + end + if Settings:IsA2G_MGRS() then + return self:ToStringMGRS( Settings ) + end + end + + return nil + + end + +end do -- POINT_VEC3 @@ -301,15 +846,11 @@ do -- POINT_VEC3 -- @param Dcs.DCSTypes#Distance x The x coordinate of the Vec3 point, pointing to the North. -- @param Dcs.DCSTypes#Distance y The y coordinate of the Vec3 point, pointing Upwards. -- @param Dcs.DCSTypes#Distance z The z coordinate of the Vec3 point, pointing to the Right. - -- @return Core.Point#POINT_VEC3 self + -- @return Core.Point#POINT_VEC3 function POINT_VEC3:New( x, y, z ) - local self = BASE:Inherit( self, BASE:New() ) - self.x = x - self.y = y - self.z = z - - self:SetMetric( true ) + local self = BASE:Inherit( self, COORDINATE:New( x, y, z ) ) -- Core.Point#POINT_VEC3 + self:F2( self ) return self end @@ -317,47 +858,30 @@ do -- POINT_VEC3 --- Create a new POINT_VEC3 object from Vec2 coordinates. -- @param #POINT_VEC3 self -- @param Dcs.DCSTypes#Vec2 Vec2 The Vec2 point. + -- @param Dcs.DCSTypes#Distance LandHeightAdd (optional) Add a landheight. -- @return Core.Point#POINT_VEC3 self function POINT_VEC3:NewFromVec2( Vec2, LandHeightAdd ) - local LandHeight = land.getHeight( Vec2 ) - - LandHeightAdd = LandHeightAdd or 0 - LandHeight = LandHeight + LandHeightAdd - - self = self:New( Vec2.x, LandHeight, Vec2.y ) - + local self = BASE:Inherit( self, COORDINATE:NewFromVec2( Vec2, LandHeightAdd ) ) -- Core.Point#POINT_VEC3 self:F2( self ) return self end + --- Create a new POINT_VEC3 object from Vec3 coordinates. -- @param #POINT_VEC3 self -- @param Dcs.DCSTypes#Vec3 Vec3 The Vec3 point. -- @return Core.Point#POINT_VEC3 self function POINT_VEC3:NewFromVec3( Vec3 ) - self = self:New( Vec3.x, Vec3.y, Vec3.z ) + local self = BASE:Inherit( self, COORDINATE:NewFromVec3( Vec3 ) ) -- Core.Point#POINT_VEC3 self:F2( self ) + return self end - --- Return the coordinates of the POINT_VEC3 in Vec3 format. - -- @param #POINT_VEC3 self - -- @return Dcs.DCSTypes#Vec3 The Vec3 coodinate. - function POINT_VEC3:GetVec3() - return { x = self.x, y = self.y, z = self.z } - end - - --- Return the coordinates of the POINT_VEC3 in Vec2 format. - -- @param #POINT_VEC3 self - -- @return Dcs.DCSTypes#Vec2 The Vec2 coodinate. - function POINT_VEC3:GetVec2() - return { x = self.x, y = self.z } - end - --- Return the x coordinate of the POINT_VEC3. -- @param #POINT_VEC3 self @@ -434,48 +958,6 @@ do -- POINT_VEC3 return self end - --- Return a random Vec2 within an Outer Radius and optionally NOT within an Inner Radius of the POINT_VEC3. - -- @param #POINT_VEC3 self - -- @param Dcs.DCSTypes#Distance OuterRadius - -- @param Dcs.DCSTypes#Distance InnerRadius - -- @return Dcs.DCSTypes#Vec2 Vec2 - function POINT_VEC3:GetRandomVec2InRadius( OuterRadius, InnerRadius ) - self:F2( { OuterRadius, InnerRadius } ) - - local Theta = 2 * math.pi * math.random() - local Radials = math.random() + math.random() - if Radials > 1 then - Radials = 2 - Radials - end - - local RadialMultiplier - if InnerRadius and InnerRadius <= OuterRadius then - RadialMultiplier = ( OuterRadius - InnerRadius ) * Radials + InnerRadius - else - RadialMultiplier = OuterRadius * Radials - end - - local RandomVec2 - if OuterRadius > 0 then - RandomVec2 = { x = math.cos( Theta ) * RadialMultiplier + self:GetX(), y = math.sin( Theta ) * RadialMultiplier + self:GetZ() } - else - RandomVec2 = { x = self:GetX(), y = self:GetZ() } - end - - return RandomVec2 - end - - --- Return a random POINT_VEC2 within an Outer Radius and optionally NOT within an Inner Radius of the POINT_VEC3. - -- @param #POINT_VEC3 self - -- @param Dcs.DCSTypes#Distance OuterRadius - -- @param Dcs.DCSTypes#Distance InnerRadius - -- @return #POINT_VEC2 - function POINT_VEC3:GetRandomPointVec2InRadius( OuterRadius, InnerRadius ) - self:F2( { OuterRadius, InnerRadius } ) - - return POINT_VEC2:NewFromVec2( self:GetRandomVec2InRadius( OuterRadius, InnerRadius ) ) - end - --- Return a random Vec3 within an Outer Radius and optionally NOT within an Inner Radius of the POINT_VEC3. -- @param #POINT_VEC3 self -- @param Dcs.DCSTypes#Distance OuterRadius @@ -500,335 +982,6 @@ do -- POINT_VEC3 return POINT_VEC3:NewFromVec3( self:GetRandomVec3InRadius( OuterRadius, InnerRadius ) ) end - - --- Return a direction vector Vec3 from POINT_VEC3 to the POINT_VEC3. - -- @param #POINT_VEC3 self - -- @param #POINT_VEC3 TargetPointVec3 The target POINT_VEC3. - -- @return Dcs.DCSTypes#Vec3 DirectionVec3 The direction vector in Vec3 format. - function POINT_VEC3:GetDirectionVec3( TargetPointVec3 ) - return { x = TargetPointVec3:GetX() - self:GetX(), y = TargetPointVec3:GetY() - self:GetY(), z = TargetPointVec3:GetZ() - self:GetZ() } - end - - --- Get a correction in radians of the real magnetic north of the POINT_VEC3. - -- @param #POINT_VEC3 self - -- @return #number CorrectionRadians The correction in radians. - function POINT_VEC3:GetNorthCorrectionRadians() - local TargetVec3 = self:GetVec3() - local lat, lon = coord.LOtoLL(TargetVec3) - local north_posit = coord.LLtoLO(lat + 1, lon) - return math.atan2( north_posit.z - TargetVec3.z, north_posit.x - TargetVec3.x ) - end - - - --- Return an angle in radians from the POINT_VEC3 using a direction vector in Vec3 format. - -- @param #POINT_VEC3 self - -- @param Dcs.DCSTypes#Vec3 DirectionVec3 The direction vector in Vec3 format. - -- @return #number DirectionRadians The angle in radians. - function POINT_VEC3:GetAngleRadians( DirectionVec3 ) - local DirectionRadians = math.atan2( DirectionVec3.z, DirectionVec3.x ) - --DirectionRadians = DirectionRadians + self:GetNorthCorrectionRadians() - if DirectionRadians < 0 then - DirectionRadians = DirectionRadians + 2 * math.pi -- put dir in range of 0 to 2*pi ( the full circle ) - end - return DirectionRadians - end - - --- Return an angle in degrees from the POINT_VEC3 using a direction vector in Vec3 format. - -- @param #POINT_VEC3 self - -- @param Dcs.DCSTypes#Vec3 DirectionVec3 The direction vector in Vec3 format. - -- @return #number DirectionRadians The angle in degrees. - function POINT_VEC3:GetAngleDegrees( DirectionVec3 ) - local AngleRadians = self:GetAngleRadians(DirectionVec3) - local Angle = UTILS.ToDegree( AngleRadians ) - return Angle - end - - - --- Return the 2D distance in meters between the target POINT_VEC3 and the POINT_VEC3. - -- @param #POINT_VEC3 self - -- @param #POINT_VEC3 TargetPointVec3 The target POINT_VEC3. - -- @return Dcs.DCSTypes#Distance Distance The distance in meters. - function POINT_VEC3:Get2DDistance( TargetPointVec3 ) - local TargetVec3 = TargetPointVec3:GetVec3() - local SourceVec3 = self:GetVec3() - return ( ( TargetVec3.x - SourceVec3.x ) ^ 2 + ( TargetVec3.z - SourceVec3.z ) ^ 2 ) ^ 0.5 - end - - --- Return the 3D distance in meters between the target POINT_VEC3 and the POINT_VEC3. - -- @param #POINT_VEC3 self - -- @param #POINT_VEC3 TargetPointVec3 The target POINT_VEC3. - -- @return Dcs.DCSTypes#Distance Distance The distance in meters. - function POINT_VEC3:Get3DDistance( TargetPointVec3 ) - local TargetVec3 = TargetPointVec3:GetVec3() - local SourceVec3 = self:GetVec3() - return ( ( TargetVec3.x - SourceVec3.x ) ^ 2 + ( TargetVec3.y - SourceVec3.y ) ^ 2 + ( TargetVec3.z - SourceVec3.z ) ^ 2 ) ^ 0.5 - end - - --- Provides a Bearing / Range string - -- @param #POINT_VEC3 self - -- @param #number AngleRadians The angle in randians - -- @param #number Distance The distance - -- @return #string The BR Text - function POINT_VEC3:GetBRText( AngleRadians, Distance ) - - AngleRadians = UTILS.Round( UTILS.ToDegree( AngleRadians ), 0 ) - if self:IsMetric() then - Distance = UTILS.Round( Distance / 1000, 2 ) - else - Distance = UTILS.Round( UTILS.MetersToNM( Distance ), 2 ) - end - - local s = string.format( '%03d', AngleRadians ) .. ' for ' .. Distance - - s = s .. self:GetAltitudeText() -- When the POINT is a VEC2, there will be no altitude shown. - - return s - end - - - --- Return the altitude text of the POINT_VEC3. - -- @param #POINT_VEC3 self - -- @return #string Altitude text. - function POINT_VEC3:GetAltitudeText() - if self:IsMetric() then - return ' at ' .. UTILS.Round( self:GetY(), -3 ) - else - return ' at ' .. UTILS.Round( UTILS.MetersToFeet( self:GetY() ), 0 ) - end - end - - --- Sets the POINT_VEC3 metric or NM. - -- @param #POINT_VEC3 self - -- @param #boolean Metric true means metric, false means NM. - function POINT_VEC3:SetMetric( Metric ) - self.Metric = Metric - end - - --- Gets if the POINT_VEC3 is metric or NM. - -- @param #POINT_VEC3 self - -- @return #boolean Metric true means metric, false means NM. - function POINT_VEC3:IsMetric() - return self.Metric - end - - --- Add a Distance in meters from the POINT_VEC3 horizontal plane, with the given angle, and calculate the new POINT_VEC3. - -- @param #POINT_VEC3 self - -- @param Dcs.DCSTypes#Distance Distance The Distance to be added in meters. - -- @param Dcs.DCSTypes#Angle Angle The Angle in degrees. - -- @return #POINT_VEC3 The new calculated POINT_VEC3. - function POINT_VEC3:Translate( Distance, Angle ) - local SX = self:GetX() - local SZ = self:GetZ() - local Radians = Angle / 180 * math.pi - local TX = Distance * math.cos( Radians ) + SX - local TZ = Distance * math.sin( Radians ) + SZ - - return POINT_VEC3:New( TX, self:GetY(), TZ ) - end - - - - --- Build an air type route point. - -- @param #POINT_VEC3 self - -- @param #POINT_VEC3.RoutePointAltType AltType The altitude type. - -- @param #POINT_VEC3.RoutePointType Type The route point type. - -- @param #POINT_VEC3.RoutePointAction Action The route point action. - -- @param Dcs.DCSTypes#Speed Speed Airspeed in km/h. - -- @param #boolean SpeedLocked true means the speed is locked. - -- @return #table The route point. - function POINT_VEC3:RoutePointAir( AltType, Type, Action, Speed, SpeedLocked ) - self:F2( { AltType, Type, Action, Speed, SpeedLocked } ) - - local RoutePoint = {} - RoutePoint.x = self.x - RoutePoint.y = self.z - RoutePoint.alt = self.y - RoutePoint.alt_type = AltType - - RoutePoint.type = Type - RoutePoint.action = Action - - RoutePoint.speed = Speed / 3.6 - RoutePoint.speed_locked = true - - -- ["task"] = - -- { - -- ["id"] = "ComboTask", - -- ["params"] = - -- { - -- ["tasks"] = - -- { - -- }, -- end of ["tasks"] - -- }, -- end of ["params"] - -- }, -- end of ["task"] - - - RoutePoint.task = {} - RoutePoint.task.id = "ComboTask" - RoutePoint.task.params = {} - RoutePoint.task.params.tasks = {} - - - return RoutePoint - end - - --- Build an ground type route point. - -- @param #POINT_VEC3 self - -- @param Dcs.DCSTypes#Speed Speed Speed in km/h. - -- @param #POINT_VEC3.RoutePointAction Formation The route point Formation. - -- @return #table The route point. - function POINT_VEC3:RoutePointGround( Speed, Formation ) - self:F2( { Formation, Speed } ) - - local RoutePoint = {} - RoutePoint.x = self.x - RoutePoint.y = self.z - - RoutePoint.action = Formation or "" - - - RoutePoint.speed = Speed / 3.6 - RoutePoint.speed_locked = true - - -- ["task"] = - -- { - -- ["id"] = "ComboTask", - -- ["params"] = - -- { - -- ["tasks"] = - -- { - -- }, -- end of ["tasks"] - -- }, -- end of ["params"] - -- }, -- end of ["task"] - - - RoutePoint.task = {} - RoutePoint.task.id = "ComboTask" - RoutePoint.task.params = {} - RoutePoint.task.params.tasks = {} - - - return RoutePoint - end - - --- Creates an explosion at the point of a certain intensity. - -- @param #POINT_VEC3 self - -- @param #number ExplosionIntensity - function POINT_VEC3:Explosion( ExplosionIntensity ) - self:F2( { ExplosionIntensity } ) - trigger.action.explosion( self:GetVec3(), ExplosionIntensity ) - end - - --- Creates an illumination bomb at the point. - -- @param #POINT_VEC3 self - function POINT_VEC3:IlluminationBomb() - self:F2() - trigger.action.illuminationBomb( self:GetVec3() ) - end - - - --- Smokes the point in a color. - -- @param #POINT_VEC3 self - -- @param Utilities.Utils#SMOKECOLOR SmokeColor - function POINT_VEC3:Smoke( SmokeColor ) - self:F2( { SmokeColor } ) - trigger.action.smoke( self:GetVec3(), SmokeColor ) - end - - --- Smoke the POINT_VEC3 Green. - -- @param #POINT_VEC3 self - function POINT_VEC3:SmokeGreen() - self:F2() - self:Smoke( SMOKECOLOR.Green ) - end - - --- Smoke the POINT_VEC3 Red. - -- @param #POINT_VEC3 self - function POINT_VEC3:SmokeRed() - self:F2() - self:Smoke( SMOKECOLOR.Red ) - end - - --- Smoke the POINT_VEC3 White. - -- @param #POINT_VEC3 self - function POINT_VEC3:SmokeWhite() - self:F2() - self:Smoke( SMOKECOLOR.White ) - end - - --- Smoke the POINT_VEC3 Orange. - -- @param #POINT_VEC3 self - function POINT_VEC3:SmokeOrange() - self:F2() - self:Smoke( SMOKECOLOR.Orange ) - end - - --- Smoke the POINT_VEC3 Blue. - -- @param #POINT_VEC3 self - function POINT_VEC3:SmokeBlue() - self:F2() - self:Smoke( SMOKECOLOR.Blue ) - end - - --- Flares the point in a color. - -- @param #POINT_VEC3 self - -- @param Utilities.Utils#FLARECOLOR FlareColor - -- @param Dcs.DCSTypes#Azimuth (optional) Azimuth The azimuth of the flare direction. The default azimuth is 0. - function POINT_VEC3:Flare( FlareColor, Azimuth ) - self:F2( { FlareColor } ) - trigger.action.signalFlare( self:GetVec3(), FlareColor, Azimuth and Azimuth or 0 ) - end - - --- Flare the POINT_VEC3 White. - -- @param #POINT_VEC3 self - -- @param Dcs.DCSTypes#Azimuth (optional) Azimuth The azimuth of the flare direction. The default azimuth is 0. - function POINT_VEC3:FlareWhite( Azimuth ) - self:F2( Azimuth ) - self:Flare( FLARECOLOR.White, Azimuth ) - end - - --- Flare the POINT_VEC3 Yellow. - -- @param #POINT_VEC3 self - -- @param Dcs.DCSTypes#Azimuth (optional) Azimuth The azimuth of the flare direction. The default azimuth is 0. - function POINT_VEC3:FlareYellow( Azimuth ) - self:F2( Azimuth ) - self:Flare( FLARECOLOR.Yellow, Azimuth ) - end - - --- Flare the POINT_VEC3 Green. - -- @param #POINT_VEC3 self - -- @param Dcs.DCSTypes#Azimuth (optional) Azimuth The azimuth of the flare direction. The default azimuth is 0. - function POINT_VEC3:FlareGreen( Azimuth ) - self:F2( Azimuth ) - self:Flare( FLARECOLOR.Green, Azimuth ) - end - - --- Flare the POINT_VEC3 Red. - -- @param #POINT_VEC3 self - function POINT_VEC3:FlareRed( Azimuth ) - self:F2( Azimuth ) - self:Flare( FLARECOLOR.Red, Azimuth ) - end - - --- Returns if a PointVec3 has Line of Sight (LOS) with the ToPointVec3. - -- @param #POINT_VEC3 self - -- @param #POINT_VEC3 ToPointVec3 - -- @return #boolean true If the ToPointVec3 has LOS with the PointVec3, otherwise false. - function POINT_VEC3:IsLOS( ToPointVec3 ) --R2.1 - - -- Measurement of visibility should not be from the ground, so Adding a hypotethical 2 meters to each PointVec3. - local FromVec3 = self:GetVec3() - FromVec3.y = FromVec3.y + 2 - - local ToVec3 = ToPointVec3:GetVec3() - ToVec3.y = ToVec3.y + 2 - - local IsLOS = land.isVisible( FromVec3, ToVec3 ) - - return IsLOS - end - - end do -- POINT_VEC2 @@ -848,7 +1001,7 @@ do -- POINT_VEC2 LandHeightAdd = LandHeightAdd or 0 LandHeight = LandHeight + LandHeightAdd - self = BASE:Inherit( self, POINT_VEC3:New( x, LandHeight, y ) ) + local self = BASE:Inherit( self, COORDINATE:New( x, LandHeight, y ) ) -- Core.Point#POINT_VEC2 self:F2( self ) return self @@ -865,7 +1018,7 @@ do -- POINT_VEC2 LandHeightAdd = LandHeightAdd or 0 LandHeight = LandHeight + LandHeightAdd - self = BASE:Inherit( self, POINT_VEC3:New( Vec2.x, LandHeight, Vec2.y ) ) + local self = BASE:Inherit( self, COORDINATE:New( Vec2.x, LandHeight, Vec2.y ) ) -- Core.Point#POINT_VEC2 self:F2( self ) return self @@ -879,7 +1032,7 @@ do -- POINT_VEC2 local self = BASE:Inherit( self, BASE:New() ) - self = BASE:Inherit( self, POINT_VEC3:New( Vec3.x, Vec3.y, Vec3.z ) ) + local self = BASE:Inherit( self, COORDINATE:New( Vec3.x, Vec3.y, Vec3.z ) ) -- Core.Point#POINT_VEC2 self:F2( self ) return self @@ -899,27 +1052,6 @@ do -- POINT_VEC2 return self.z end - --- Return the altitude (height) of the land at the POINT_VEC2. - -- @param #POINT_VEC2 self - -- @return #number The land altitude. - function POINT_VEC2:GetAlt() - return land.getHeight( { x = self.x, y = self.z } ) - end - - --- Return Return the Lat(itude) coordinate of the POINT_VEC2 (ie: (parent)POINT_VEC3.x). - -- @param #POINT_VEC2 self - -- @return #number The x coodinate. - function POINT_VEC2:GetLat() - return self.x - end - - --- Return the Lon(gitude) coordinate of the POINT_VEC2 (ie: (parent)POINT_VEC3.z). - -- @param #POINT_VEC2 self - -- @return #number The y coodinate. - function POINT_VEC2:GetLon() - return self.z - end - --- Set the x coordinate of the POINT_VEC2. -- @param #POINT_VEC2 self -- @param #number x The x coordinate. @@ -938,6 +1070,13 @@ do -- POINT_VEC2 return self end + --- Return Return the Lat(itude) coordinate of the POINT_VEC2 (ie: (parent)POINT_VEC3.x). + -- @param #POINT_VEC2 self + -- @return #number The x coodinate. + function POINT_VEC2:GetLat() + return self.x + end + --- Set the Lat(itude) coordinate of the POINT_VEC2 (ie: POINT_VEC3.x). -- @param #POINT_VEC2 self -- @param #number x The x coordinate. @@ -947,13 +1086,11 @@ do -- POINT_VEC2 return self end - --- Set the altitude of the POINT_VEC2. + --- Return the Lon(gitude) coordinate of the POINT_VEC2 (ie: (parent)POINT_VEC3.z). -- @param #POINT_VEC2 self - -- @param #number Altitude The land altitude. If nothing (nil) is given, then the current land altitude is set. - -- @return #POINT_VEC2 - function POINT_VEC2:SetAlt( Altitude ) - self.y = Altitude or land.getHeight( { x = self.x, y = self.z } ) - return self + -- @return #number The y coodinate. + function POINT_VEC2:GetLon() + return self.z end --- Set the Lon(gitude) coordinate of the POINT_VEC2 (ie: POINT_VEC3.z). @@ -965,6 +1102,22 @@ do -- POINT_VEC2 return self end + --- Return the altitude (height) of the land at the POINT_VEC2. + -- @param #POINT_VEC2 self + -- @return #number The land altitude. + function POINT_VEC2:GetAlt() + return self.y ~= 0 or land.getHeight( { x = self.x, y = self.z } ) + end + + --- Set the altitude of the POINT_VEC2. + -- @param #POINT_VEC2 self + -- @param #number Altitude The land altitude. If nothing (nil) is given, then the current land altitude is set. + -- @return #POINT_VEC2 + function POINT_VEC2:SetAlt( Altitude ) + self.y = Altitude or land.getHeight( { x = self.x, y = self.z } ) + return self + end + --- Add to the x coordinate of the POINT_VEC2. -- @param #POINT_VEC2 self -- @param #number x The x coordinate. @@ -992,8 +1145,50 @@ do -- POINT_VEC2 return self end + --- Return a random Vec2 within an Outer Radius and optionally NOT within an Inner Radius of the POINT_VEC2. + -- @param #POINT_VEC2 self + -- @param Dcs.DCSTypes#Distance OuterRadius + -- @param Dcs.DCSTypes#Distance InnerRadius + -- @return Dcs.DCSTypes#Vec2 Vec2 + function POINT_VEC2:GetRandomVec2InRadius( OuterRadius, InnerRadius ) + self:F2( { OuterRadius, InnerRadius } ) + + local Theta = 2 * math.pi * math.random() + local Radials = math.random() + math.random() + if Radials > 1 then + Radials = 2 - Radials + end + + local RadialMultiplier + if InnerRadius and InnerRadius <= OuterRadius then + RadialMultiplier = ( OuterRadius - InnerRadius ) * Radials + InnerRadius + else + RadialMultiplier = OuterRadius * Radials + end + + local RandomVec2 + if OuterRadius > 0 then + RandomVec2 = { x = math.cos( Theta ) * RadialMultiplier + self:GetX(), y = math.sin( Theta ) * RadialMultiplier + self:GetZ() } + else + RandomVec2 = { x = self:GetX(), y = self:GetZ() } + end + + return RandomVec2 + end + + --- Return a random POINT_VEC2 within an Outer Radius and optionally NOT within an Inner Radius of the POINT_VEC2. + -- @param #POINT_VEC2 self + -- @param Dcs.DCSTypes#Distance OuterRadius + -- @param Dcs.DCSTypes#Distance InnerRadius + -- @return #POINT_VEC2 + function POINT_VEC2:GetRandomPointVec2InRadius( OuterRadius, InnerRadius ) + self:F2( { OuterRadius, InnerRadius } ) + + return POINT_VEC2:NewFromVec2( self:GetRandomVec2InRadius( OuterRadius, InnerRadius ) ) + end +-- TODO: Check this to replace --- Calculate the distance from a reference @{#POINT_VEC2}. -- @param #POINT_VEC2 self -- @param #POINT_VEC2 PointVec2Reference The reference @{#POINT_VEC2}. @@ -1007,6 +1202,8 @@ do -- POINT_VEC2 return Distance end +--TODO: check this to replace + --- Calculate the distance from a reference @{DCSTypes#Vec2}. -- @param #POINT_VEC2 self -- @param Dcs.DCSTypes#Vec2 Vec2Reference The reference @{DCSTypes#Vec2}. @@ -1038,225 +1235,4 @@ do -- POINT_VEC2 end -do -- COORDINATE - --- COORDINATE constructor. - -- @param #COORDINATE self - -- @param Dcs.DCSTypes#Distance x The x coordinate of the Vec3 point, pointing to the North. - -- @param Dcs.DCSTypes#Distance y The y coordinate of the Vec3 point, pointing to the Right. - -- @param Dcs.DCSTypes#Distance LandHeightAdd (optional) The default height if required to be evaluated will be the land height of the x, y coordinate. You can specify an extra height to be added to the land height. - -- @return Core.Point#COORDINATE - function COORDINATE:New( x, y, LandHeightAdd ) --R2.1 Fixes issue #424. - - self = BASE:Inherit( self, POINT_VEC2:New( x, y, LandHeightAdd ) ) -- Core.Point#COORDINATE - self:F2( self ) - - return self - end - - --- Create a new COORDINATE object from Vec2 coordinates. - -- @param #COORDINATE self - -- @param Dcs.DCSTypes#Vec2 Vec2 The Vec2 point. - -- @param Dcs.DCSTypes#Distance LandHeightAdd (optional) The default height if required to be evaluated will be the land height of the x, y coordinate. You can specify an extra height to be added to the land height. - -- @return Core.Point#COORDINATE self - function COORDINATE:NewFromVec2( Vec2, LandHeightAdd ) --R2.1 Fixes issue #424. - - self = BASE:Inherit( self, POINT_VEC2:NewFromVec2( Vec2, LandHeightAdd ) ) -- Core.Point#COORDINATE - self:F2( self ) - - return self - end - - --- Create a new COORDINATE object from Vec3 coordinates. - -- @param #COORDINATE self - -- @param Dcs.DCSTypes#Vec3 Vec3 The Vec3 point. - -- @return Core.Point#COORDINATE self - function COORDINATE:NewFromVec3( Vec3 ) --R2.1 Fixes issue #424. - - self = BASE:Inherit( self, POINT_VEC3:NewFromVec3( Vec3 ) ) -- Core.Point#COORDINATE - self:F2( self ) - - return self - end - - function COORDINATE:SetHeading( Heading ) - self.Heading = Heading - end - - - --- Return a BR string from a COORDINATE to the COORDINATE. - -- @param #COORDINATE self - -- @param #COORDINATE TargetCoordinate The target COORDINATE. - -- @return #string The BR text. - function COORDINATE:ToStringBR( TargetCoordinate ) - local DirectionVec3 = self:GetDirectionVec3( TargetCoordinate ) - local AngleRadians = self:GetAngleRadians( DirectionVec3 ) - local Distance = self:Get2DDistance( TargetCoordinate ) - return "BR: " .. self:GetBRText( AngleRadians, Distance ) - end - - --- Return a BRAA string from a COORDINATE to the COORDINATE. - -- @param #COORDINATE self - -- @param #COORDINATE TargetCoordinate The target COORDINATE. - -- @return #string The BR text. - function COORDINATE:ToStringBRAA( TargetCoordinate ) - local DirectionVec3 = self:GetDirectionVec3( TargetCoordinate ) - local AngleRadians = self:GetAngleRadians( DirectionVec3 ) - local Distance = self:Get2DDistance( TargetCoordinate ) - local Altitude = self:GetAltitudeText() - return "BRAA: " .. self:GetBRText( AngleRadians, Distance ) - end - - --- Return a BULLS string from a COORDINATE to the BULLS of the coalition. - -- @param #COORDINATE self - -- @param Dcs.DCSCoalition#coalition.side Coalition The coalition. - -- @return #string The BR text. - function COORDINATE:ToStringBULLS( Coalition ) - local TargetCoordinate = COORDINATE:NewFromVec3( coalition.getMainRefPoint( Coalition ) ) - local DirectionVec3 = self:GetDirectionVec3( TargetCoordinate ) - local AngleRadians = self:GetAngleRadians( DirectionVec3 ) - local Distance = self:Get2DDistance( TargetCoordinate ) - local Altitude = self:GetAltitudeText() - return "BULLS: " .. self:GetBRText( AngleRadians, Distance ) - end - - --- Return an aspect string from a COORDINATE to the Angle of the object. - -- @param #COORDINATE self - -- @param #COORDINATE TargetCoordinate The target COORDINATE. - -- @return #string The Aspect string, which is Hot, Cold or Flanking. - function COORDINATE:ToStringAspect( TargetCoordinate ) - local Heading = self.Heading - local DirectionVec3 = self:GetDirectionVec3( TargetCoordinate ) - local Angle = self:GetAngleDegrees( DirectionVec3 ) - - if Heading then - local Aspect = Angle - Heading - if Aspect > -135 and Aspect <= -45 then - return "Flanking" - end - if Aspect > -45 and Aspect <= 45 then - return "Hot" - end - if Aspect > 45 and Aspect <= 135 then - return "Flanking" - end - if Aspect > 135 or Aspect <= -135 then - return "Cold" - end - end - return "" - end - - --- Provides a Lat Lon string - -- @param #COORDINATE self - -- @param #number LL_Accuracy The accurancy of significant numbers behind the comma... So Accurancy of 2 is 0.01. - -- @param #boolean LL_DMS true = Degrees, Minutes, Seconds; false = Degrees, Minutes - -- @return #string The LL Text - function COORDINATE:ToStringLL( LL_Accuracy, LL_DMS ) --R2.1 Fixes issue #424. - - LL_Accuracy = LL_Accuracy or self.LL_Accuracy - LL_DMS = LL_DMS or self.LL_DMS - local lat, lon = coord.LOtoLL( self:GetVec3() ) - return "LL: " .. UTILS.tostringLL( lat, lon, LL_Accuracy, LL_DMS ) - end - - --- Provides a MGRS string - -- @param #COORDINATE self - -- @param #number MGRS_Accuracy of the 5 digit code. - -- Precision depends on the Accuracy choosen: - -- * 0 = no digits - precision level 100 km - -- * 1 = 1 digits - precision level 10 km - -- * 2 = 2 digits - precision level 1 km - -- * 3 = 3 digits - precision level 100 m - -- * 4 = 4 digits - precision level 10 m. - -- @return #string The MGRS Text - function COORDINATE:ToStringMGRS( MGRS_Accuracy ) --R2.1 Fixes issue #424. - - MGRS_Accuracy = MGRS_Accuracy or self.MGRS_Accuracy - local lat, lon = coord.LOtoLL( self:GetVec3() ) - local MGRS = coord.LLtoMGRS( lat, lon ) - return "MGRS: " .. UTILS.tostringMGRS( MGRS, MGRS_Accuracy ) - end - - --- Provides a coordinate string of the point, based on a coordinate format system: - -- * Uses default settings in COORDINATE. - -- * Can be overridden if for a GROUP containing x clients, a menu was selected to override the default. - -- - -- @param #COORDINATE self - -- @return #string The coordinate Text in the configured coordinate system. - function COORDINATE:ToString() --R2.1 Fixes issue #424. - - local Coordinate = COORDINATE -- Core.Point#COORDINATE - - local CoordSystem = Coordinate.System - - if CoordSystem == "LL" then - return self:ToStringLL( Coordinate.LL_Accuracy, Coordinate.LL_DMS ) - end - - if CoordSystem == "MGRS" then - return self:ToStringMGRS( Coordinate.MGRS_Accuracy ) - end - - return nil - - end - - --- @param #COORDINATE self - -- @return #string The coordinate Text in the configured coordinate system. - function COORDINATE:CoordinateMenu( RootMenu ) --R2.1 Fixes issue #424. - - if self.SystemMenu then - self.SystemMenu:Remove() - self.SystemMenu = nil - end - - self.SystemMenu = MENU_MISSION:New( "System Settings" ) - local CoordinateMenu = MENU_MISSION:New( "Coordinates", self.SystemMenu ) - - local Coordinate = COORDINATE - - if Coordinate.System == "LL" then - MENU_MISSION_COMMAND:New( "Activate MGRS", CoordinateMenu, Coordinate.MenuSystem, Coordinate, "MGRS" ) - MENU_MISSION_COMMAND:New( "LL Accuracy 1", CoordinateMenu, Coordinate.MenuLL_Accuracy, Coordinate, 1 ) - MENU_MISSION_COMMAND:New( "LL Accuracy 2", CoordinateMenu, Coordinate.MenuLL_Accuracy, Coordinate, 2 ) - MENU_MISSION_COMMAND:New( "LL Accuracy 3", CoordinateMenu, Coordinate.MenuLL_Accuracy, Coordinate, 3 ) - MENU_MISSION_COMMAND:New( "LL Decimal On", CoordinateMenu, Coordinate.MenuLL_DMS, Coordinate, true ) - MENU_MISSION_COMMAND:New( "LL Decimal Off", CoordinateMenu, Coordinate.MenuLL_DMS, Coordinate, false ) - end - - if Coordinate.System == "MGRS" then - MENU_MISSION_COMMAND:New( "Activate LL", CoordinateMenu, Coordinate.MenuSystem, Coordinate, "LL" ) - MENU_MISSION_COMMAND:New( "MGRS Accuracy 1", CoordinateMenu, Coordinate.MenuMGRS_Accuracy, Coordinate, 1 ) - MENU_MISSION_COMMAND:New( "MGRS Accuracy 2", CoordinateMenu, Coordinate.MenuMGRS_Accuracy, Coordinate, 2 ) - MENU_MISSION_COMMAND:New( "MGRS Accuracy 3", CoordinateMenu, Coordinate.MenuMGRS_Accuracy, Coordinate, 3 ) - MENU_MISSION_COMMAND:New( "MGRS Accuracy 4", CoordinateMenu, Coordinate.MenuMGRS_Accuracy, Coordinate, 4 ) - MENU_MISSION_COMMAND:New( "MGRS Accuracy 5", CoordinateMenu, Coordinate.MenuMGRS_Accuracy, Coordinate, 5 ) - end - - end - - --- @param #COORDINATE self - function COORDINATE:MenuSystem( System ) --R2.1 Fixes issue #424. - self.System = System - self:CoordinateMenu() - end - - --- @param #COORDINATE self - function COORDINATE:MenuLL_Accuracy( LL_Accuracy ) --R2.1 Fixes issue #424. - self.LL_Accuracy = LL_Accuracy - self:CoordinateMenu() - end - - --- @param #COORDINATE self - function COORDINATE:MenuLL_DMS( LL_DMS ) --R2.1 Fixes issue #424. - self.LL_DMS = LL_DMS - self:CoordinateMenu() - end - --- @param #COORDINATE self - function COORDINATE:MenuMGRS_Accuracy( MGRS_Accuracy ) --R2.1 Fixes issue #424. - self.MGRS_Accuracy = MGRS_Accuracy - self:CoordinateMenu() - end - -end diff --git a/Moose Development/Moose/Core/Settings.lua b/Moose Development/Moose/Core/Settings.lua new file mode 100644 index 000000000..3e71bdf47 --- /dev/null +++ b/Moose Development/Moose/Core/Settings.lua @@ -0,0 +1,228 @@ +--- **Core** - **SETTINGS** classe defines the format settings management for measurement. +-- +-- ![Banner Image](..\Presentations\SETTINGS\Dia1.JPG) +-- +-- ==== +-- +-- # Demo Missions +-- +-- ### [SETTINGS Demo Missions source code]() +-- +-- ### [SETTINGS Demo Missions, only for beta testers]() +-- +-- ### [ALL Demo Missions pack of the last release](https://github.com/FlightControl-Master/MOOSE_MISSIONS/releases) +-- +-- ==== +-- +-- # YouTube Channel +-- +-- ### [SETTINGS YouTube Channel]() +-- +-- === +-- +-- ### Authors: +-- +-- * FlightControl : Design & Programming +-- +-- ### Contributions: +-- +-- @module Settings + + +--- @type SETTINGS +-- @field #number LL_Accuracy +-- @field #boolean LL_DMS +-- @field #number MGRS_Accuracy +-- @field #string A2GSystem +-- @field #string A2ASystem +-- @extends Core.Base#BASE + +--- # SETTINGS class, extends @{Base#BASE} +-- +-- @field #SETTINGS +SETTINGS = { + ClassName = "SETTINGS", + LL_Accuracy = 2, + LL_DMS = true, + MGRS_Accuracy = 5, + A2GSystem = "MGRS", + A2ASystem = "BRA", + +} + + + +do -- SETTINGS + + --- SETTINGS constructor. + -- @param #SETTINGS self + -- @return #SETTINGS + function SETTINGS:New() + + local self = BASE:Inherit( self, BASE:New() ) -- #SETTINGS + + self:SetMetric() -- Defaults + self:SetA2G_MGRS() -- Defaults + self:SetA2A_BRA() -- Defaults + + return self + end + + + --- Sets the SETTINGS metric. + -- @param #SETTINGS self + function SETTINGS:SetMetric() + self.Metric = true + end + + --- Gets if the SETTINGS is metric. + -- @param #SETTINGS self + -- @return #boolean true if metric. + function SETTINGS:IsMetric() + return self.Metric == true + end + + --- Sets the SETTINGS imperial. + -- @param #SETTINGS self + function SETTINGS:SetImperial() + self.Metric = false + end + + --- Gets if the SETTINGS is imperial. + -- @param #SETTINGS self + -- @return #boolean true if imperial. + function SETTINGS:IsImperial() + return self.Metric == false + end + + --- Sets A2G LL + -- @param #SETTINGS self + -- @return #SETTINGS + function SETTINGS:SetA2G_LL() + self.A2GSystem = "LL" + end + + --- Is LL + -- @param #SETTINGS self + -- @return #boolean true if LL + function SETTINGS:IsA2G_LL() + return self.A2GSystem == "LL" + end + + --- Sets A2G MGRS + -- @param #SETTINGS self + -- @return #SETTINGS + function SETTINGS:SetA2G_MGRS() + self.A2GSystem = "MGRS" + end + + --- Is MGRS + -- @param #SETTINGS self + -- @return #boolean true if MGRS + function SETTINGS:IsA2G_MGRS() + return self.A2GSystem == "MGRS" + end + + --- Sets A2A BRA + -- @param #SETTINGS self + -- @return #SETTINGS + function SETTINGS:SetA2A_BRA() + self.A2ASystem = "BRA" + end + + --- Is BRA + -- @param #SETTINGS self + -- @return #boolean true if BRA + function SETTINGS:IsA2A_BRA() + return self.A2ASystem == "BRA" + end + + --- Sets A2A BULLS + -- @param #SETTINGS self + -- @return #SETTINGS + function SETTINGS:SetA2A_BULLS() + self.A2ASystem = "BULLS" + end + + --- Is BULLS + -- @param #SETTINGS self + -- @return #boolean true if BULLS + function SETTINGS:IsA2A_BULLS() + return self.A2ASystem == "BULLS" + end + + --- @param #SETTINGS self + -- @return #SETTINGS + function SETTINGS:SettingsMenu( RootMenu ) + + if self.SystemMenu then + self.SystemMenu:Remove() + self.SystemMenu = nil + end + + self.SystemMenu = MENU_MISSION:New( "Coordinate Settings" ) + local A2GCoordinateMenu = MENU_MISSION:New( "A2G Coordinate System", self.SystemMenu ) + + if self:IsA2GLL() then + MENU_MISSION_COMMAND:New( "Activate MGRS", A2GCoordinateMenu, self.A2GMenuSystem, self, "MGRS" ) + MENU_MISSION_COMMAND:New( "LL Accuracy 1", A2GCoordinateMenu, self.MenuLL_Accuracy, self, 1 ) + MENU_MISSION_COMMAND:New( "LL Accuracy 2", A2GCoordinateMenu, self.MenuLL_Accuracy, self, 2 ) + MENU_MISSION_COMMAND:New( "LL Accuracy 3", A2GCoordinateMenu, self.MenuLL_Accuracy, self, 3 ) + MENU_MISSION_COMMAND:New( "LL Decimal On", A2GCoordinateMenu, self.MenuLL_DMS, self, true ) + MENU_MISSION_COMMAND:New( "LL Decimal Off", A2GCoordinateMenu, self.MenuLL_DMS, self, false ) + end + + if self:IsA2GMGRS() then + MENU_MISSION_COMMAND:New( "Activate LL", A2GCoordinateMenu, self.A2GMenuSystem, self, "LL" ) + MENU_MISSION_COMMAND:New( "MGRS Accuracy 1", A2GCoordinateMenu, self.MenuMGRS_Accuracy, self, 1 ) + MENU_MISSION_COMMAND:New( "MGRS Accuracy 2", A2GCoordinateMenu, self.MenuMGRS_Accuracy, self, 2 ) + MENU_MISSION_COMMAND:New( "MGRS Accuracy 3", A2GCoordinateMenu, self.MenuMGRS_Accuracy, self, 3 ) + MENU_MISSION_COMMAND:New( "MGRS Accuracy 4", A2GCoordinateMenu, self.MenuMGRS_Accuracy, self, 4 ) + MENU_MISSION_COMMAND:New( "MGRS Accuracy 5", A2GCoordinateMenu, self.MenuMGRS_Accuracy, self, 5 ) + end + + local A2ACoordinateMenu = MENU_MISSION:New( "A2A Coordinate System", self.SystemMenu ) + + if self:IsA2ABULLS() then + MENU_MISSION_COMMAND:New( "Activate BRA", A2GCoordinateMenu, self.A2AMenuSystem, self, "BRA" ) + end + + if self:IsA2ABRA() then + MENU_MISSION_COMMAND:New( "Activate BULLS", A2GCoordinateMenu, self.A2AMenuSystem, self, "BULLS" ) + end + + return self + end + + --- @param #SETTINGS self + function SETTINGS:A2GMenuSystem( A2GSystem ) + self.A2GSystem = A2GSystem + self:CoordinateMenu() + end + + --- @param #SETTINGS self + function SETTINGS:A2AMenuSystem( A2ASystem ) + self.A2ASystem = A2ASystem + self:CoordinateMenu() + end + + --- @param #SETTINGS self + function SETTINGS:MenuLL_Accuracy( LL_Accuracy ) + self.LL_Accuracy = LL_Accuracy + self:CoordinateMenu() + end + + --- @param #SETTINGS self + function SETTINGS:MenuLL_DMS( LL_DMS ) + self.LL_DMS = LL_DMS + self:CoordinateMenu() + end + --- @param #SETTINGS self + function SETTINGS:MenuMGRS_Accuracy( MGRS_Accuracy ) + self.MGRS_Accuracy = MGRS_Accuracy + self:CoordinateMenu() + end + +end + + diff --git a/Moose Development/Moose/Functional/Detection.lua b/Moose Development/Moose/Functional/Detection.lua index f75210006..6c92961e8 100644 --- a/Moose Development/Moose/Functional/Detection.lua +++ b/Moose Development/Moose/Functional/Detection.lua @@ -1308,7 +1308,7 @@ do -- DETECTION_BASE --- Get the COORDINATE of a detection item using a given numeric index. -- @param #DETECTION_BASE self -- @param #number Index - -- @return Core.Point#COORDINATE Coordinate + -- @return Core.Point#COORDINATE function DETECTION_BASE:GetDetectedItemCoordinate( Index ) -- If the Zone is set, return the coordinate of the Zone. @@ -1317,14 +1317,15 @@ do -- DETECTION_BASE local DetectedZone = self:GetDetectedItemZone( Index ) if DetectedZone then - local Coordinate = DetectedZone:GetCoordinate() + local Coordinate = DetectedZone:GetPointVec2() Coordinate:SetHeading(FirstUnit:GetHeading()) + Coordinate:SetAlt( FirstUnit:GetAltitude() ) return Coordinate end -- If no Zone is set, return the coordinate of the first unit in the Set if FirstUnit then - local Coordinate = FirstUnit:GetCoordinate() + local Coordinate = FirstUnit:GetPointVec3() FirstUnit:SetHeading(FirstUnit:GetHeading()) return Coordinate end diff --git a/Moose Development/Moose/Moose.lua b/Moose Development/Moose/Moose.lua index 46fdaa17c..194951078 100644 --- a/Moose Development/Moose/Moose.lua +++ b/Moose Development/Moose/Moose.lua @@ -9,4 +9,5 @@ _SCHEDULEDISPATCHER = SCHEDULEDISPATCHER:New() -- Core.Timer#SCHEDULEDISPATCHER --- Declare the main database object, which is used internally by the MOOSE classes. _DATABASE = DATABASE:New() -- Database#DATABASE ---COORDINATE:CoordinateMenu() +_SETTINGS = SETTINGS:New() +_SETTINGS:SettingsMenu(nil) diff --git a/Moose Development/Moose/Tasking/Task.lua b/Moose Development/Moose/Tasking/Task.lua index 5c95f5b8a..7b584a559 100644 --- a/Moose Development/Moose/Tasking/Task.lua +++ b/Moose Development/Moose/Tasking/Task.lua @@ -1403,9 +1403,10 @@ function TASK:ReportDetails( TaskGroup ) --R2.1 fixed report. Now nicely formatt elseif type(TaskInfo) == "table" then if TaskInfoID == "Coordinates" then local FromCoordinate = TaskGroup:GetUnit(1):GetCoordinate() + local ToCoordinate = TaskInfo -- Core.Point#COORDINATE Report:Add( TaskInfoIDText ) - Report:AddIndent( TaskInfo:ToStringBRAA( FromCoordinate ) .. ", " .. TaskInfo:ToStringAspect( FromCoordinate ) ) - Report:AddIndent( TaskInfo:ToStringBULLS( TaskGroup:GetCoalition() ) ) + Report:AddIndent( ToCoordinate:ToStringBRAA( FromCoordinate ) .. ", " .. TaskInfo:ToStringAspect( FromCoordinate ) ) + Report:AddIndent( ToCoordinate:ToStringBULLS( TaskGroup:GetCoalition() ) ) else end end diff --git a/Moose Development/Moose/Tasking/Task_A2A_Dispatcher.lua b/Moose Development/Moose/Tasking/Task_A2A_Dispatcher.lua index 04d8c7664..6b1bba3eb 100644 --- a/Moose Development/Moose/Tasking/Task_A2A_Dispatcher.lua +++ b/Moose Development/Moose/Tasking/Task_A2A_Dispatcher.lua @@ -72,7 +72,7 @@ do -- TASK_A2A_DISPATCHER self.Mission = Mission self.Detection:FilterCategories( Unit.Category.AIRPLANE, Unit.Category.HELICOPTER ) - self.Detection:InitDetectRadar( true ) + --self.Detection:InitDetectRadar( true ) self.Detection:SetDetectionInterval( 30 ) self:AddTransition( "Started", "Assign", "Started" ) @@ -190,7 +190,11 @@ do -- TASK_A2A_DISPATCHER local DetectedItemsCount = DetectedSet:Count() local DetectedItemsTypes = DetectedSet:GetTypeNames() Task:SetInfo( "Targets", string.format( "%d of %s", DetectedItemsCount, DetectedItemsTypes ) ) - Task:SetInfo( "Coordinates", Detection:GetDetectedItemCoordinate( DetectedIndex ) ) + + local Coordinate = Detection:GetDetectedItemCoordinate( DetectedIndex ) + Coordinate:SetModeA2A() + + Task:SetInfo( "Coordinates", Coordinate ) Task:SetInfo( "Object", DetectedSet:GetFirst() ) Mission:AddTask( Task ) else diff --git a/Moose Mission Setup/Moose.files b/Moose Mission Setup/Moose.files index 6b2abfad1..55aba83d6 100644 --- a/Moose Mission Setup/Moose.files +++ b/Moose Mission Setup/Moose.files @@ -5,6 +5,7 @@ Core/Base.lua Core/Scheduler.lua Core/ScheduleDispatcher.lua Core/Event.lua +Core/Settings.lua Core/Menu.lua Core/Zone.lua Core/Database.lua diff --git a/Moose Mission Setup/Moose.lua b/Moose Mission Setup/Moose.lua index 1010dac77..087866245 100644 --- a/Moose Mission Setup/Moose.lua +++ b/Moose Mission Setup/Moose.lua @@ -1,5 +1,5 @@ env.info( '*** MOOSE DYNAMIC INCLUDE START *** ' ) -env.info( 'Moose Generation Timestamp: 20170517_1856' ) +env.info( 'Moose Generation Timestamp: 20170520_0827' ) local base = _G @@ -27,6 +27,7 @@ __Moose.Include( 'Core/Base.lua' ) __Moose.Include( 'Core/Scheduler.lua' ) __Moose.Include( 'Core/ScheduleDispatcher.lua' ) __Moose.Include( 'Core/Event.lua' ) +__Moose.Include( 'Core/Settings.lua' ) __Moose.Include( 'Core/Menu.lua' ) __Moose.Include( 'Core/Zone.lua' ) __Moose.Include( 'Core/Database.lua' )