Fixes DETECTION_UNITS and DETECTION_TYPES again.

This commit is contained in:
FlightControl_Master 2018-03-14 06:57:47 +01:00
parent 92d4bad63f
commit e57d05fc91
3 changed files with 72 additions and 35 deletions

View File

@ -647,7 +647,13 @@ end
-- @usage
-- -- RU Su-34 - AI Ship Attack
-- -- Re-SPAWN the Group(s) after each landing and Engine Shut-Down automatically.
-- SpawnRU_SU34 = SPAWN:New( 'TF1 RU Su-34 Krymsk@AI - Attack Ships' ):Schedule( 2, 3, 1800, 0.4 ):SpawnUncontrolled():InitRandomizeRoute( 1, 1, 3000 ):RepeatOnEngineShutDown()
-- SpawnRU_SU34 = SPAWN
-- :New( 'Su-34' )
-- :Schedule( 2, 3, 1800, 0.4 )
-- :SpawnUncontrolled()
-- :InitRandomizeRoute( 1, 1, 3000 )
-- :InitRepeatOnEngineShutDown()
--
function SPAWN:InitRepeat()
self:F( { self.SpawnTemplatePrefix, self.SpawnIndex } )
@ -661,6 +667,16 @@ end
--- Respawn group after landing.
-- @param #SPAWN self
-- @return #SPAWN self
-- @usage
-- -- RU Su-34 - AI Ship Attack
-- -- Re-SPAWN the Group(s) after each landing and Engine Shut-Down automatically.
-- SpawnRU_SU34 = SPAWN
-- :New( 'Su-34' )
-- :Schedule( 2, 3, 1800, 0.4 )
-- :SpawnUncontrolled()
-- :InitRandomizeRoute( 1, 1, 3000 )
-- :InitRepeatOnLanding()
--
function SPAWN:InitRepeatOnLanding()
self:F( { self.SpawnTemplatePrefix } )
@ -675,6 +691,16 @@ end
--- Respawn after landing when its engines have shut down.
-- @param #SPAWN self
-- @return #SPAWN self
-- @usage
-- -- RU Su-34 - AI Ship Attack
-- -- Re-SPAWN the Group(s) after each landing and Engine Shut-Down automatically.
-- SpawnRU_SU34 = SPAWN
-- :New( 'Su-34' )
-- :Schedule( 2, 3, 1800, 0.4 )
-- :SpawnUncontrolled()
-- :InitRandomizeRoute( 1, 1, 3000 )
-- :InitRepeatOnEngineShutDown()
--
function SPAWN:InitRepeatOnEngineShutDown()
self:F( { self.SpawnTemplatePrefix } )
@ -691,7 +717,8 @@ end
-- @param #SPAWN self
-- @param #string SpawnCleanUpInterval The interval to check for inactive groups within seconds.
-- @return #SPAWN self
-- @usage Spawn_Helicopter:CleanUp( 20 ) -- CleanUp the spawning of the helicopters every 20 seconds when they become inactive.
-- @usage
-- Spawn_Helicopter:InitCleanUp( 20 ) -- CleanUp the spawning of the helicopters every 20 seconds when they become inactive.
function SPAWN:InitCleanUp( SpawnCleanUpInterval )
self:F( { self.SpawnTemplatePrefix, SpawnCleanUpInterval } )
@ -718,7 +745,11 @@ end
-- @return #SPAWN self
-- @usage
-- -- Define an array of Groups.
-- Spawn_BE_Ground = SPAWN:New( 'BE Ground' ):InitLimit( 2, 24 ):InitArray( 90, "Diamond", 10, 100, 50 )
-- Spawn_BE_Ground = SPAWN
-- :New( 'BE Ground' )
-- :InitLimit( 2, 24 )
-- :InitArray( 90, 10, 100, 50 )
--
function SPAWN:InitArray( SpawnAngle, SpawnWidth, SpawnDeltaX, SpawnDeltaY )
self:F( { self.SpawnTemplatePrefix, SpawnAngle, SpawnWidth, SpawnDeltaX, SpawnDeltaY } )

View File

@ -802,6 +802,10 @@ do -- DESIGNATE
end
)
self.Designating[DesignateIndex] = ""
-- When we found an item for designation, we stop the loop.
-- So each iteration over the detected items, a new detected item will be selected to be designated.
-- Until all detected items were found or until there are about 5 designations allocated.
break
end
end

View File

@ -760,7 +760,6 @@ do -- DETECTION_BASE
-- @param #DETECTION_BASE self
-- @return #DETECTION_BASE
function DETECTION_BASE:CleanDetectionItem( DetectedItem, DetectedItemID )
self:F2()
-- We clean all DetectedItems.
-- if there are any remaining DetectedItems with no Set Objects then the Item in the DetectedItems must be deleted.
@ -768,6 +767,7 @@ do -- DETECTION_BASE
local DetectedSet = DetectedItem.Set
if DetectedSet:Count() == 0 then
self:F3( { DetectedItemID = DetectedItemID } )
self:RemoveDetectedItem( DetectedItemID )
end
@ -1750,6 +1750,36 @@ do -- DETECTION_BASE
return DetectionSetGroup
end
--- Find the nearest Recce of the DetectedItem.
-- @param #DETECTION_BASE self
-- @param #DETECTION_BASE.DetectedItem DetectedItem
-- @return Wrapper.Unit#UNIT The nearest FAC unit
function DETECTION_BASE:NearestRecce( DetectedItem )
local NearestRecce = nil
local DistanceRecce = 1000000000 -- Units are not further than 1000000 km away from an area :-)
for RecceGroupName, RecceGroup in pairs( self.DetectionSetGroup:GetSet() ) do
if RecceGroup and RecceGroup:IsAlive() then
for RecceUnit, RecceUnit in pairs( RecceGroup:GetUnits() ) do
if RecceUnit:IsActive() then
local RecceUnitCoord = RecceUnit:GetCoordinate()
local Distance = RecceUnitCoord:Get2DDistance( self:GetDetectedItemCoordinate( DetectedItem.Index ) )
if Distance < DistanceRecce then
DistanceRecce = Distance
NearestRecce = RecceUnit
end
end
end
end
end
DetectedItem.NearestFAC = NearestRecce
DetectedItem.DistanceRecce = DistanceRecce
end
--- Schedule the DETECTION construction.
-- @param #DETECTION_BASE self
@ -1930,7 +1960,7 @@ do -- DETECTION_UNITS
self:SetDetectedItemCoordinate( DetectedItem, DetectedFirstUnitCoord, DetectedFirstUnit )
self:ReportFriendliesNearBy( { DetectedItem = DetectedItem, ReportSetGroup = self.DetectionSetGroup } ) -- Fill the Friendlies table
--self:NearestFAC( DetectedItem )
self:NearestRecce( DetectedItem )
end
@ -2188,7 +2218,7 @@ do -- DETECTION_TYPES
self:SetDetectedItemCoordinate( DetectedItem, DetectedUnitCoord, DetectedFirstUnit )
self:ReportFriendliesNearBy( { DetectedItem = DetectedItem, ReportSetGroup = self.DetectionSetGroup } ) -- Fill the Friendlies table
--self:NearestFAC( DetectedItem )
self:NearestRecce( DetectedItem )
end
@ -2452,34 +2482,6 @@ do -- DETECTION_AREAS
end
--- Find the nearest FAC of the DetectedItem.
-- @param #DETECTION_AREAS self
-- @param #DETECTION_BASE.DetectedItem DetectedItem
-- @return Wrapper.Unit#UNIT The nearest FAC unit
function DETECTION_AREAS:NearestFAC( DetectedItem )
local NearestRecce = nil
local DistanceRecce = 1000000000 -- Units are not further than 1000000 km away from an area :-)
for RecceGroupName, RecceGroup in pairs( self.DetectionSetGroup:GetSet() ) do
if RecceGroup and RecceGroup:IsAlive() then
for RecceUnit, RecceUnit in pairs( RecceGroup:GetUnits() ) do
if RecceUnit:IsActive() then
local RecceUnitCoord = RecceUnit:GetCoordinate()
local Distance = RecceUnitCoord:Get2DDistance( self:GetDetectedItemCoordinate( DetectedItem.Index ) )
if Distance < DistanceRecce then
DistanceRecce = Distance
NearestRecce = RecceUnit
end
end
end
end
end
DetectedItem.NearestFAC = NearestRecce
DetectedItem.DistanceRecce = DistanceRecce
end
--- Smoke the detected units
-- @param #DETECTION_AREAS self
@ -2784,7 +2786,7 @@ do -- DETECTION_AREAS
end
self:SetDetectedItemThreatLevel( DetectedItem ) -- Calculate A2G threat level
self:NearestFAC( DetectedItem )
self:NearestRecce( DetectedItem )
if DETECTION_AREAS._SmokeDetectedUnits or self._SmokeDetectedUnits then