Fixed DETECTION_AREAS, working again and complete with test missions.

This commit is contained in:
FlightControl
2017-03-06 13:56:34 +01:00
parent 8d73df48ce
commit 25bd0f8049
8 changed files with 94 additions and 16 deletions

View File

@@ -404,8 +404,9 @@ end
--- Bounds the zone with tires.
-- @param #ZONE_RADIUS self
-- @param #number Points (optional) The amount of points in the circle.
-- @param #boolean UnBound If true the tyres will be destroyed.
-- @return #ZONE_RADIUS self
function ZONE_RADIUS:BoundZone( Points )
function ZONE_RADIUS:BoundZone( Points, UnBound )
local Point = {}
local Vec2 = self:GetVec2()
@@ -434,7 +435,10 @@ function ZONE_RADIUS:BoundZone( Points )
["heading"] = 0,
} -- end of ["group"]
coalition.addStaticObject( country.id.USA, Tire )
local Group = coalition.addStaticObject( country.id.USA, Tire )
if UnBound and UnBound == true then
Group:destroy()
end
end
return self
@@ -867,8 +871,9 @@ end
--- Smokes the zone boundaries in a color.
-- @param #ZONE_POLYGON_BASE self
-- @param #boolean UnBound If true, the tyres will be destroyed.
-- @return #ZONE_POLYGON_BASE self
function ZONE_POLYGON_BASE:BoundZone( )
function ZONE_POLYGON_BASE:BoundZone( UnBound )
local i
local j
@@ -897,8 +902,11 @@ function ZONE_POLYGON_BASE:BoundZone( )
["name"] = string.format( "%s-Tire #%0d", self:GetName(), ((i - 1) * Segments) + Segment ),
["heading"] = 0,
} -- end of ["group"]
coalition.addStaticObject( country.id.USA, Tire )
local Group = coalition.addStaticObject( country.id.USA, Tire )
if UnBound and UnBound == true then
Group:destroy()
end
end
j = i

View File

@@ -934,8 +934,8 @@ do -- DETECTION_BASE
-- @param #number DetectedItemIndex The index or position in the DetectedItems list where the item needs to be removed.
function DETECTION_BASE:RemoveDetectedItem( DetectedItemIndex )
self.DetectedItemCount = self.DetectedItemCount + 1
self.DetectedItems[self.DetectedItemIndex] = nil
self.DetectedItemCount = self.DetectedItemCount - 1
self.DetectedItems[DetectedItemIndex] = nil
end
@@ -1734,21 +1734,26 @@ do -- DETECTION_AREAS
function DETECTION_AREAS:CreateDetectionSets()
self:F2()
self:T( "Checking Detected Items for new Detected Units ..." )
-- First go through all detected sets, and check if there are new detected units, match all existing detected units and identify undetected units.
-- Regroup when needed, split groups when needed.
for DetectedAreaID, DetectedAreaData in ipairs( self.DetectedItems ) do
for DetectedAreaID, DetectedAreaData in pairs( self.DetectedItems ) do
local DetectedArea = DetectedAreaData -- #DETECTION_AREAS.DetectedArea
if DetectedArea then
self:T( { "Detected Area ID:", DetectedAreaID } )
local DetectedSet = DetectedArea.Set
local AreaExists = false -- This flag will determine of the detected area is still existing.
-- First test if the center unit is detected in the detection area.
self:T3( DetectedArea.Zone.ZoneUNIT.UnitName )
self:T3( { "Zone Center Unit:", DetectedArea.Zone.ZoneUNIT.UnitName } )
local DetectedZoneObject = self:GetDetectedObject( DetectedArea.Zone.ZoneUNIT.UnitName )
self:T3( { "Detecting Zone Object", DetectedArea.AreaID, DetectedArea.Zone, DetectedZoneObject } )
self:T3( { "Detected Zone Object:", DetectedArea.Zone:GetName(), DetectedZoneObject } )
if DetectedZoneObject then
@@ -1776,6 +1781,8 @@ do -- DETECTION_AREAS
self:IdentifyDetectedObject( DetectedObject )
AreaExists = true
DetectedArea.Zone:BoundZone( 30, true)
-- Assign the Unit as the new center unit of the detected area.
DetectedArea.Zone = ZONE_UNIT:New( DetectedUnit:GetName(), DetectedUnit, self.DetectionZoneRange )
@@ -1827,7 +1834,8 @@ do -- DETECTION_AREAS
end
end
else
self:RemoveDetectedArea( DetectedAreaID )
DetectedArea.Zone:BoundZone( 30, true)
self:RemoveDetectedItem( DetectedAreaID )
self:AddChangeArea( DetectedArea, "RA" )
end
end
@@ -1851,7 +1859,7 @@ do -- DETECTION_AREAS
local AddedToDetectionArea = false
for DetectedAreaID, DetectedAreaData in ipairs( self.DetectedItems ) do
for DetectedAreaID, DetectedAreaData in pairs( self.DetectedItems ) do
local DetectedArea = DetectedAreaData -- #DETECTION_AREAS.DetectedArea
if DetectedArea then
@@ -1883,7 +1891,7 @@ do -- DETECTION_AREAS
-- Now all the tests should have been build, now make some smoke and flares...
-- We also report here the friendlies within the detected areas.
for DetectedAreaID, DetectedAreaData in ipairs( self.DetectedItems ) do
for DetectedAreaID, DetectedAreaData in pairs( self.DetectedItems ) do
local DetectedArea = DetectedAreaData -- #DETECTION_AREAS.DetectedArea
local DetectedSet = DetectedArea.Set