From 2b0fcd342679eea89b9bacca7e190d79128520af Mon Sep 17 00:00:00 2001 From: FlightControl Date: Sat, 20 May 2017 22:04:44 +0200 Subject: [PATCH] Progress --- Moose Development/Moose/Actions/Act_Route.lua | 4 +-- Moose Development/Moose/Core/Point.lua | 11 ++++---- .../Moose/Functional/Detection.lua | 27 +++++++++++++++++-- .../Moose/Tasking/Task_A2A_Dispatcher.lua | 8 ++++-- .../Moose/Wrapper/Controllable.lua | 4 +-- 5 files changed, 40 insertions(+), 14 deletions(-) diff --git a/Moose Development/Moose/Actions/Act_Route.lua b/Moose Development/Moose/Actions/Act_Route.lua index 953a526fe..a336dffea 100644 --- a/Moose Development/Moose/Actions/Act_Route.lua +++ b/Moose Development/Moose/Actions/Act_Route.lua @@ -161,13 +161,13 @@ do -- ACT_ROUTE local RouteText = "" if self.Coordinate then - RouteText = "Route to " .. self.Coordinate:ToString( Controllable ) + RouteText = self.Coordinate:ToString( Controllable ) end if self.Zone then local Coordinate = self.Zone:GetPointVec3( self.Altitude ) Coordinate:SetHeading( self.Heading ) - RouteText = "Route to zone " .. Coordinate:ToString( Controllable ) + RouteText = Coordinate:ToString( Controllable ) end return RouteText diff --git a/Moose Development/Moose/Core/Point.lua b/Moose Development/Moose/Core/Point.lua index ccf65dd4b..5fe8c6363 100644 --- a/Moose Development/Moose/Core/Point.lua +++ b/Moose Development/Moose/Core/Point.lua @@ -709,7 +709,7 @@ do -- COORDINATE local DirectionVec3 = self:GetDirectionVec3( FromCoordinate ) local AngleRadians = self:GetAngleRadians( DirectionVec3 ) local Distance = self:Get2DDistance( FromCoordinate ) - return "BR: " .. self:GetBRText( AngleRadians, Distance, Settings ) + return "BR, " .. self:GetBRText( AngleRadians, Distance, Settings ) end --- Return a BRAA string from a COORDINATE to the COORDINATE. @@ -721,8 +721,7 @@ do -- COORDINATE local AngleRadians = self:GetAngleRadians( DirectionVec3 ) local Distance = FromCoordinate:Get2DDistance( self ) local Altitude = self:GetAltitudeText() - local AspectText = self:ToStringAspect( FromCoordinate ) - return "BRAA: " .. self:GetBRText( AngleRadians, Distance, Settings ) .. ( AspectText and ", " .. AspectText or "" ) + return "BRA, " .. self:GetBRText( AngleRadians, Distance, Settings ) end --- Return a BULLS string from a COORDINATE to the BULLS of the coalition. @@ -735,7 +734,7 @@ do -- COORDINATE local AngleRadians = self:GetAngleRadians( DirectionVec3 ) local Distance = self:Get2DDistance( TargetCoordinate ) local Altitude = self:GetAltitudeText() - return "BULLS: " .. self:GetBRText( AngleRadians, Distance, Settings ) + return "BULLS, " .. self:GetBRText( AngleRadians, Distance, Settings ) end --- Return an aspect string from a COORDINATE to the Angle of the object. @@ -774,7 +773,7 @@ do -- COORDINATE 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 ) + return "LL, " .. UTILS.tostringLL( lat, lon, LL_Accuracy, LL_DMS ) end --- Provides a MGRS string @@ -786,7 +785,7 @@ do -- COORDINATE 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 ) + return "MGRS, " .. UTILS.tostringMGRS( MGRS, MGRS_Accuracy ) end --- Provides a coordinate string of the point, based on a coordinate format system: diff --git a/Moose Development/Moose/Functional/Detection.lua b/Moose Development/Moose/Functional/Detection.lua index c9659b1af..6e7cb4df6 100644 --- a/Moose Development/Moose/Functional/Detection.lua +++ b/Moose Development/Moose/Functional/Detection.lua @@ -239,6 +239,11 @@ do -- DETECTION_BASE -- -- -- Start the Detection. -- Detection:Start() + -- + -- ## Detection of Friendlies Nearby + -- + -- Use the method @{Detection#DETECTION_BASE.SetFriendliesRange}() to set the range what will indicate when friendlies are nearby + -- a DetectedItem. The default range is 6000 meters. For air detections, it is advisory to use about 30.000 meters. -- -- ## DETECTION_BASE is a Finite State Machine -- @@ -329,6 +334,8 @@ do -- DETECTION_BASE Unit.Category.SHIP, Unit.Category.STRUCTURE } ) + + self:SetFriendlesRange( 6000 ) -- Create FSM transitions. @@ -879,6 +886,22 @@ do -- DETECTION_BASE end end + + do -- Friendlies Radius + + --- Set the radius in meters to validate if friendlies are nearby. + -- @param #DETECTION_BASE self + -- @param #number FriendliesRange Radius to use when checking if Friendlies are nearby. + -- @return #DETECTION_BASE self + function DETECTION_BASE:SetFriendlesRange( FriendliesRange ) --R2.2 Friendlies range + self:F2() + + self.FriendliesRange = FriendliesRange + + return self + end + + end do -- Accept / Reject detected units @@ -1071,7 +1094,7 @@ do -- DETECTION_BASE id = world.VolumeType.SPHERE, params = { point = DetectedUnit:GetVec3(), - radius = 6000, + radius = self.FriendliesRadius, } } @@ -1411,7 +1434,7 @@ end do -- DETECTION_UNITS - --- # 2) DETECTION_UNITS class, extends @{Detection#DETECTION_BASE} + --- # DETECTION_UNITS class, extends @{Detection#DETECTION_BASE} -- -- The DETECTION_UNITS class will detect units within the battle zone. -- It will build a DetectedItems list filled with DetectedItems. Each DetectedItem will contain a field Set, which contains a @{Set#SET_UNIT} containing ONE @{UNIT} object reference. diff --git a/Moose Development/Moose/Tasking/Task_A2A_Dispatcher.lua b/Moose Development/Moose/Tasking/Task_A2A_Dispatcher.lua index 4cacccd39..82ed5f576 100644 --- a/Moose Development/Moose/Tasking/Task_A2A_Dispatcher.lua +++ b/Moose Development/Moose/Tasking/Task_A2A_Dispatcher.lua @@ -105,8 +105,9 @@ do -- TASK_A2A_DISPATCHER local DetectedZone = DetectedItem.Zone -- Put here the intercept logic.... + local FriendliesNearBy = self.Detection:IsFriendliesNearBy( DetectedItem ) - if true then + if not FriendliesNearBy == true then -- Here we're doing something advanced... We're copying the DetectedSet, but making a new Set only with SEADable Radar units in it. local TargetSetUnit = SET_UNIT:New() @@ -130,8 +131,11 @@ do -- TASK_A2A_DISPATCHER -- @return Tasking.Task#TASK function TASK_A2A_DISPATCHER:EvaluateRemoveTask( Mission, Task, DetectedItemID, DetectedItemChanged ) + if Task then - if Task:IsStatePlanned() and DetectedItemChanged == true then + local FriendliesNearBy = self.Detection:IsFriendliesNearBy( DetectedItemID ) + + if Task:IsStatePlanned() and DetectedItemChanged == true and FriendliesNearBy then self:E( "Removing Tasking: " .. Task:GetTaskName() ) Mission:RemoveTask( Task ) self.Tasks[DetectedItemID] = nil diff --git a/Moose Development/Moose/Wrapper/Controllable.lua b/Moose Development/Moose/Wrapper/Controllable.lua index 1160ef81d..a1e05db0d 100644 --- a/Moose Development/Moose/Wrapper/Controllable.lua +++ b/Moose Development/Moose/Wrapper/Controllable.lua @@ -2226,8 +2226,8 @@ function CONTROLLABLE:IsAirPlane() local DCSObject = self:GetDCSObject() if DCSObject then - local Category = DCSObject:getCategory() - self:T2( Category ) + local Category = DCSObject:getDesc().category + self:T( Category ) return Category == Unit.Category.AIRPLANE end