diff --git a/Moose Development/Moose/Functional/Detection.lua b/Moose Development/Moose/Functional/Detection.lua index 9fc086cd9..2ec01a349 100644 --- a/Moose Development/Moose/Functional/Detection.lua +++ b/Moose Development/Moose/Functional/Detection.lua @@ -39,7 +39,7 @@ do -- DETECTION_BASE - --- @type DETECTION_BASE + -- @type DETECTION_BASE -- @field Core.Set#SET_GROUP DetectionSetGroup The @{Core.Set} of GROUPs in the Forward Air Controller role. -- @field DCS#Distance DetectionRange The range till which targets are accepted to be detected. -- @field #DETECTION_BASE.DetectedObjects DetectedObjects The list of detected objects. @@ -269,10 +269,10 @@ do -- DETECTION_BASE DetectedItemsByIndex = {}, } - --- @type DETECTION_BASE.DetectedObjects + -- @type DETECTION_BASE.DetectedObjects -- @list <#DETECTION_BASE.DetectedObject> - --- @type DETECTION_BASE.DetectedObject + -- @type DETECTION_BASE.DetectedObject -- @field #string Name -- @field #boolean IsVisible -- @field #boolean KnowType @@ -284,7 +284,7 @@ do -- DETECTION_BASE -- @field #boolean LastPos -- @field #number LastVelocity - --- @type DETECTION_BASE.DetectedItems + -- @type DETECTION_BASE.DetectedItems -- @list <#DETECTION_BASE.DetectedItem> --- Detected item data structure. @@ -522,7 +522,7 @@ do -- DETECTION_BASE do -- State Transition Handling - --- @param #DETECTION_BASE self + -- @param #DETECTION_BASE self -- @param #string From The From State string. -- @param #string Event The Event string. -- @param #string To The To State string. @@ -530,7 +530,7 @@ do -- DETECTION_BASE self:__Detect( 1 ) end - --- @param #DETECTION_BASE self + -- @param #DETECTION_BASE self -- @param #string From The From State string. -- @param #string Event The Event string. -- @param #string To The To State string. @@ -570,7 +570,7 @@ do -- DETECTION_BASE end - --- @param #DETECTION_BASE self + -- @param #DETECTION_BASE self -- @param #number The amount of alive recce. function DETECTION_BASE:CountAliveRecce() @@ -578,7 +578,7 @@ do -- DETECTION_BASE end - --- @param #DETECTION_BASE self + -- @param #DETECTION_BASE self function DETECTION_BASE:ForEachAliveRecce( IteratorFunction, ... ) self:F2( arg ) @@ -587,7 +587,7 @@ do -- DETECTION_BASE return self end - --- @param #DETECTION_BASE self + -- @param #DETECTION_BASE self -- @param #string From The From State string. -- @param #string Event The Event string. -- @param #string To The To State string. @@ -712,6 +712,22 @@ do -- DETECTION_BASE end end + -- Calculate radar blue probability + + if self.RadarBlur then + local minheight = self.RadarBlurMinHeight or 250 -- meters + local thresheight = self.RadarBlurThresHeight or 90 -- 10% chance to find a low flying group + local thresblur = self.RadarBlurThresBlur or 85 -- 25% chance to escape the radar overall + local fheight = math.floor(math.random(1,10000)/100) + local fblur = math.floor(math.random(1,10000)/100) + local unit = UNIT:FindByName(DetectedObjectName) + if unit and unit:IsAlive() then + local AGL = unit:GetAltitude(true) + if AGL <= minheight and fheight > thresheight then DetectionAccepted = false end + if fblur > thresblur then DetectionAccepted = false end + end + end + -- Calculate additional probabilities if not self.DetectedObjects[DetectedObjectName] and TargetIsVisible and self.DistanceProbability then @@ -1011,7 +1027,21 @@ do -- DETECTION_BASE return self end - + + --- Method to make the radar detection less accurate, e.g. for WWII scenarios. + -- @param #DETECTION_BASE self + -- @param #number minheight Minimum flight height to be detected, in meters AGL (above ground) + -- @param #number thresheight Threshold to escape the radar if flying below minheight, defaults to 90 (90% escape chance) + -- @param #number thresblur Threshold to be detected by the radar overall, defaults to 85 (85% chance to be found) + -- @return #DETECTION_BASE self + function DETECTION_BASE:SetRadarBlur(minheight,thresheight,thresblur) + self.RadarBlur = true + self.RadarBlurMinHeight = minheight or 250 -- meters + self.RadarBlurThresHeight = thresheight or 90 -- 10% chance to find a low flying group + self.RadarBlurThresBlur = thresblur or 85 -- 25% chance to escape the radar overall + return self + end + end do @@ -1354,7 +1384,7 @@ do -- DETECTION_BASE } } - --- @param DCS#Unit FoundDCSUnit + -- @param DCS#Unit FoundDCSUnit -- @param Wrapper.Group#GROUP ReportGroup -- @param Core.Set#SET_GROUP ReportSetGroup local FindNearByFriendlies = function( FoundDCSUnit, ReportGroupData ) @@ -1419,7 +1449,7 @@ do -- DETECTION_BASE DetectedItem.PlayersNearBy = nil _DATABASE:ForEachPlayer( - --- @param Wrapper.Unit#UNIT PlayerUnit + -- @param Wrapper.Unit#UNIT PlayerUnit function( PlayerUnitName ) local PlayerUnit = UNIT:FindByName( PlayerUnitName ) @@ -1975,8 +2005,9 @@ do -- DETECTION_BASE end do -- DETECTION_UNITS - - --- @type DETECTION_UNITS + + --- + -- @type DETECTION_UNITS -- @field DCS#Distance DetectionRange The range till which targets are detected. -- @extends Functional.Detection#DETECTION_BASE @@ -2232,7 +2263,7 @@ end do -- DETECTION_TYPES - --- @type DETECTION_TYPES + -- @type DETECTION_TYPES -- @extends Functional.Detection#DETECTION_BASE --- Will detect units within the battle zone. @@ -2434,8 +2465,9 @@ do -- DETECTION_TYPES end do -- DETECTION_AREAS - - --- @type DETECTION_AREAS + + --- + -- @type DETECTION_AREAS -- @field DCS#Distance DetectionZoneRange The range till which targets are grouped upon the first detected target. -- @field #DETECTION_BASE.DetectedItems DetectedItems A list of areas containing the set of @{Wrapper.Unit}s, @{Core.Zone}s, the center @{Wrapper.Unit} within the zone, and ID of each area that was detected within a DetectionZoneRange. -- @extends Functional.Detection#DETECTION_BASE @@ -2961,7 +2993,7 @@ do -- DETECTION_AREAS -- DetectedSet:Flush( self ) - DetectedSet:ForEachUnit( --- @param Wrapper.Unit#UNIT DetectedUnit + DetectedSet:ForEachUnit( -- @param Wrapper.Unit#UNIT DetectedUnit function( DetectedUnit ) if DetectedUnit:IsAlive() then -- self:T( "Detected Set #" .. DetectedItem.ID .. ":" .. DetectedUnit:GetName() )