Nearest distance for Designate is 12.000 meters

This commit is contained in:
FlightControl_Master 2017-08-11 16:44:58 +02:00
parent 0aa92372bf
commit b1e7951a47
2 changed files with 56 additions and 42 deletions

View File

@ -389,10 +389,10 @@ do -- DESIGNATE
self:SetThreatLevelPrioritization( false ) -- self.ThreatLevelPrioritization, default is threat level priorization off self:SetThreatLevelPrioritization( false ) -- self.ThreatLevelPrioritization, default is threat level priorization off
self:SetMaximumDesignations( 5 ) -- Sets the maximum designations. The default is 5 designations. self:SetMaximumDesignations( 5 ) -- Sets the maximum designations. The default is 5 designations.
self:SetMaximumDistanceDesignations( 12000 ) -- Sets the maximum distance on which designations can be accepted. The default is 8000 meters.
self.LaserCodesUsed = {} self.LaserCodesUsed = {}
self.Detection:__Start( 2 ) self.Detection:__Start( 2 )
self:__Detect( -15 ) self:__Detect( -15 )
@ -429,6 +429,36 @@ do -- DESIGNATE
return self return self
end end
--- Set the maximum ground designation distance.
-- @param #DESIGNATE self
-- @param #number MaximumDistanceGroundDesignation Maximum ground designation distance in meters.
-- @return #DESIGNATE
function DESIGNATE:SetMaximumDistanceGroundDesignation( MaximumDistanceGroundDesignation )
self.MaximumDistanceGroundDesignation = MaximumDistanceGroundDesignation
return self
end
--- Set the maximum air designation distance.
-- @param #DESIGNATE self
-- @param #number MaximumDistanceAirDesignation Maximum air designation distance in meters.
-- @return #DESIGNATE
function DESIGNATE:SetMaximumDistanceAirDesignation( MaximumDistanceAirDesignation )
self.MaximumDistanceAirDesignation = MaximumDistanceAirDesignation
return self
end
--- Set the overall maximum distance when designations can be accepted.
-- @param #DESIGNATE self
-- @param #number MaximumDistanceDesignations Maximum distance in meters to accept designations.
-- @return #DESIGNATE
function DESIGNATE:SetMaximumDistanceDesignations( MaximumDistanceDesignations )
self.MaximumDistanceDesignations = MaximumDistanceDesignations
return self
end
--- Set an array of possible laser codes. --- Set an array of possible laser codes.
-- Each new lase will select a code from this table. -- Each new lase will select a code from this table.
@ -599,16 +629,19 @@ do -- DESIGNATE
for DesignateIndex, DetectedItem in pairs( DetectedItems ) do for DesignateIndex, DetectedItem in pairs( DetectedItems ) do
local IsDetected = self.Detection:IsDetectedItemDetected( DetectedItem ) local IsDetected = self.Detection:IsDetectedItemDetected( DetectedItem )
if IsDetected == true then if IsDetected == true then
if self.Designating[DesignateIndex] == nil then self:F( { DistanceRecce = DetectedItem.DistanceRecce } )
-- ok, we added one item to the designate scope. if DetectedItem.DistanceRecce <= self.MaximumDistanceDesignations then
self.AttackSet:ForEachGroup( if self.Designating[DesignateIndex] == nil then
function( AttackGroup ) -- ok, we added one item to the designate scope.
local DetectionText = self.Detection:DetectedItemReportSummary( DesignateIndex, AttackGroup ):Text( ", " ) self.AttackSet:ForEachGroup(
self.CC:GetPositionable():MessageToGroup( "Targets detected at \n" .. DetectionText, 10, AttackGroup, "Designate" ) function( AttackGroup )
end local DetectionText = self.Detection:DetectedItemReportSummary( DesignateIndex, AttackGroup ):Text( ", " )
) self.CC:GetPositionable():MessageToGroup( "Targets detected at \n" .. DetectionText, 10, AttackGroup, "Designate" )
self.Designating[DesignateIndex] = "" end
break )
self.Designating[DesignateIndex] = ""
break
end
end end
end end
end end
@ -735,8 +768,6 @@ do -- DESIGNATE
local DetectedItems = self.Detection:GetDetectedItems() local DetectedItems = self.Detection:GetDetectedItems()
local DetectedItemCount = 0
for DesignateIndex, Designating in pairs( self.Designating ) do for DesignateIndex, Designating in pairs( self.Designating ) do
local DetectedItem = DetectedItems[DesignateIndex] local DetectedItem = DetectedItems[DesignateIndex]

View File

@ -1548,22 +1548,6 @@ do -- DETECTION_BASE
end end
--- Has the detected item LOS (Line Of Sight) with one of the Recce?
-- @param #DETECTION_BASE self
-- @param Index
-- @return #boolean true is LOS, false if no LOS.
function DETECTION_BASE:HasDetectedItemLOS( Index )
self:F( { Index = Index } )
local DetectedItem = self:GetDetectedItem( Index )
if DetectedItem then
return DetectedItem.LOS
end
return nil
end
--- Menu of a detected item using a given numeric index. --- Menu of a detected item using a given numeric index.
-- @param #DETECTION_BASE self -- @param #DETECTION_BASE self
-- @param Index -- @param Index
@ -2410,25 +2394,24 @@ do -- DETECTION_AREAS
-- @return Wrapper.Unit#UNIT The nearest FAC unit -- @return Wrapper.Unit#UNIT The nearest FAC unit
function DETECTION_AREAS:NearestFAC( DetectedItem ) function DETECTION_AREAS:NearestFAC( DetectedItem )
local NearestFAC = nil local NearestRecce = nil
local MinDistance = 1000000000 -- Units are not further than 1000000 km away from an area :-) local DistanceRecce = 1000000000 -- Units are not further than 1000000 km away from an area :-)
for FACGroupName, FACGroupData in pairs( self.DetectionSetGroup:GetSet() ) do for RecceGroupName, RecceGroup in pairs( self.DetectionSetGroup:GetSet() ) do
for FACUnit, FACUnitData in pairs( FACGroupData:GetUnits() ) do for RecceUnit, RecceUnit in pairs( RecceGroup:GetUnits() ) do
local FACUnit = FACUnitData -- Wrapper.Unit#UNIT if RecceUnit:IsActive() then
if FACUnit:IsActive() then local RecceUnitCoord = RecceUnit:GetCoordinate()
local Vec3 = FACUnit:GetVec3() local Distance = RecceUnitCoord:Get2DDistance( self:GetDetectedItemCoordinate( DetectedItem.Index ) )
local PointVec3 = POINT_VEC3:NewFromVec3( Vec3 ) if Distance < DistanceRecce then
local Distance = PointVec3:Get2DDistance(POINT_VEC3:NewFromVec3( FACUnit:GetVec3() ) ) DistanceRecce = Distance
if Distance < MinDistance then NearestRecce = RecceUnit
MinDistance = Distance
NearestFAC = FACUnit
end end
end end
end end
end end
DetectedItem.NearestFAC = NearestFAC DetectedItem.NearestFAC = NearestRecce
DetectedItem.DistanceRecce = DistanceRecce
end end