mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
First version
This commit is contained in:
parent
d558c5be21
commit
1cf2383dfd
@ -1579,12 +1579,12 @@ do -- AI_A2A_DISPATCHER
|
|||||||
local Variance = ( Cap.HighInterval - Cap.LowInterval ) / 2
|
local Variance = ( Cap.HighInterval - Cap.LowInterval ) / 2
|
||||||
local Median = Cap.LowInterval + Variance
|
local Median = Cap.LowInterval + Variance
|
||||||
local Randomization = Variance / Median
|
local Randomization = Variance / Median
|
||||||
|
local Start = math.random( 1, Cap.HighInterval )
|
||||||
|
|
||||||
if ScheduleID then
|
if ScheduleID then
|
||||||
Scheduler:Stop( ScheduleID )
|
Scheduler:Stop( ScheduleID )
|
||||||
end
|
end
|
||||||
|
|
||||||
Cap.ScheduleID = Scheduler:Schedule( self, self.SchedulerCAP, { SquadronName }, Median, Median, Randomization )
|
|
||||||
else
|
else
|
||||||
error( "This squadron does not exist:" .. SquadronName )
|
error( "This squadron does not exist:" .. SquadronName )
|
||||||
end
|
end
|
||||||
@ -1627,6 +1627,7 @@ do -- AI_A2A_DISPATCHER
|
|||||||
local Cap = DefenderSquadron.Cap
|
local Cap = DefenderSquadron.Cap
|
||||||
if Cap then
|
if Cap then
|
||||||
local CapCount = self:CountCapAirborne( SquadronName )
|
local CapCount = self:CountCapAirborne( SquadronName )
|
||||||
|
self:E( { CapCount = CapCount } )
|
||||||
if CapCount < Cap.CapLimit then
|
if CapCount < Cap.CapLimit then
|
||||||
local Probability = math.random()
|
local Probability = math.random()
|
||||||
if Probability <= Cap.Probability then
|
if Probability <= Cap.Probability then
|
||||||
|
|||||||
@ -871,9 +871,9 @@ function EVENT:onEvent( Event )
|
|||||||
-- Okay, we got the event from DCS. Now loop the SORTED self.EventSorted[] table for the received Event.id, and for each EventData registered, check if a function needs to be called.
|
-- Okay, we got the event from DCS. Now loop the SORTED self.EventSorted[] table for the received Event.id, and for each EventData registered, check if a function needs to be called.
|
||||||
for EventClass, EventData in pairs( self.Events[Event.id][EventPriority] ) do
|
for EventClass, EventData in pairs( self.Events[Event.id][EventPriority] ) do
|
||||||
|
|
||||||
if Event.IniObjectCategory ~= Object.Category.STATIC then
|
--if Event.IniObjectCategory ~= Object.Category.STATIC then
|
||||||
self:E( { "Evaluating: ", EventClass:GetClassNameAndID() } )
|
-- self:E( { "Evaluating: ", EventClass:GetClassNameAndID() } )
|
||||||
end
|
--end
|
||||||
|
|
||||||
Event.IniGroup = GROUP:FindByName( Event.IniDCSGroupName )
|
Event.IniGroup = GROUP:FindByName( Event.IniDCSGroupName )
|
||||||
Event.TgtGroup = GROUP:FindByName( Event.TgtDCSGroupName )
|
Event.TgtGroup = GROUP:FindByName( Event.TgtDCSGroupName )
|
||||||
|
|||||||
@ -1784,6 +1784,7 @@ end
|
|||||||
|
|
||||||
--- Calculate the maxium A2G threat level of the SET_UNIT.
|
--- Calculate the maxium A2G threat level of the SET_UNIT.
|
||||||
-- @param #SET_UNIT self
|
-- @param #SET_UNIT self
|
||||||
|
-- @return #number The maximum threatlevel
|
||||||
function SET_UNIT:CalculateThreatLevelA2G()
|
function SET_UNIT:CalculateThreatLevelA2G()
|
||||||
|
|
||||||
local MaxThreatLevelA2G = 0
|
local MaxThreatLevelA2G = 0
|
||||||
|
|||||||
@ -834,6 +834,20 @@ function ZONE_GROUP:GetRandomVec2()
|
|||||||
return Point
|
return Point
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Returns a @{Point#POINT_VEC2} object reflecting a random 2D location within the zone.
|
||||||
|
-- @param #ZONE_GROUP self
|
||||||
|
-- @param #number inner (optional) Minimal distance from the center of the zone. Default is 0.
|
||||||
|
-- @param #number outer (optional) Maximal distance from the outer edge of the zone. Default is the radius of the zone.
|
||||||
|
-- @return Core.Point#POINT_VEC2 The @{Point#POINT_VEC2} object reflecting the random 3D location within the zone.
|
||||||
|
function ZONE_GROUP:GetRandomPointVec2( inner, outer )
|
||||||
|
self:F( self.ZoneName, inner, outer )
|
||||||
|
|
||||||
|
local PointVec2 = POINT_VEC2:NewFromVec2( self:GetRandomVec2() )
|
||||||
|
|
||||||
|
self:T3( { PointVec2 } )
|
||||||
|
|
||||||
|
return PointVec2
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
--- @type ZONE_POLYGON_BASE
|
--- @type ZONE_POLYGON_BASE
|
||||||
|
|||||||
@ -797,11 +797,9 @@ do -- DESIGNATE
|
|||||||
MENU_GROUP_COMMAND:New( AttackGroup, "Flash Status Report On", StatusMenu, self.MenuFlashStatus, self, AttackGroup, true ):SetTime( MenuTime ):SetTag( self.DesignateName )
|
MENU_GROUP_COMMAND:New( AttackGroup, "Flash Status Report On", StatusMenu, self.MenuFlashStatus, self, AttackGroup, true ):SetTime( MenuTime ):SetTag( self.DesignateName )
|
||||||
end
|
end
|
||||||
|
|
||||||
local DetectedItems = self.Detection:GetDetectedItems()
|
|
||||||
|
|
||||||
for DesignateIndex, Designating in pairs( self.Designating ) do
|
for DesignateIndex, Designating in pairs( self.Designating ) do
|
||||||
|
|
||||||
local DetectedItem = DetectedItems[DesignateIndex]
|
local DetectedItem = self.Detection:GetDetectedItem( DesignateIndex )
|
||||||
|
|
||||||
if DetectedItem then
|
if DetectedItem then
|
||||||
|
|
||||||
|
|||||||
@ -305,7 +305,7 @@ do -- DETECTION_BASE
|
|||||||
-- @field #number ID -- The identifier of the detected area.
|
-- @field #number ID -- The identifier of the detected area.
|
||||||
-- @field #boolean FriendliesNearBy Indicates if there are friendlies within the detected area.
|
-- @field #boolean FriendliesNearBy Indicates if there are friendlies within the detected area.
|
||||||
-- @field Wrapper.Unit#UNIT NearestFAC The nearest FAC near the Area.
|
-- @field Wrapper.Unit#UNIT NearestFAC The nearest FAC near the Area.
|
||||||
|
-- @field Core.Point#COORDINATE Coordinate The last known coordinate of the DetectedItem.
|
||||||
|
|
||||||
--- DETECTION constructor.
|
--- DETECTION constructor.
|
||||||
-- @param #DETECTION_BASE self
|
-- @param #DETECTION_BASE self
|
||||||
@ -604,6 +604,14 @@ do -- DETECTION_BASE
|
|||||||
|
|
||||||
DetectionAccepted = self._.FilterCategories[DetectedUnitCategory] ~= nil and DetectionAccepted or false
|
DetectionAccepted = self._.FilterCategories[DetectedUnitCategory] ~= nil and DetectionAccepted or false
|
||||||
|
|
||||||
|
-- if Distance > 15000 then
|
||||||
|
-- if DetectedUnitCategory == Unit.Category.GROUND_UNIT or DetectedUnitCategory == Unit.Category.SHIP then
|
||||||
|
-- if DetectedObject:hasSensors( Unit.SensorType.RADAR, Unit.RadarType.AS ) == false then
|
||||||
|
-- DetectionAccepted = false
|
||||||
|
-- end
|
||||||
|
-- end
|
||||||
|
-- end
|
||||||
|
|
||||||
if self.AcceptRange and Distance > self.AcceptRange then
|
if self.AcceptRange and Distance > self.AcceptRange then
|
||||||
DetectionAccepted = false
|
DetectionAccepted = false
|
||||||
end
|
end
|
||||||
@ -1101,7 +1109,7 @@ do -- DETECTION_BASE
|
|||||||
DetectedItem.Changes[ChangeCode].ID = ID
|
DetectedItem.Changes[ChangeCode].ID = ID
|
||||||
DetectedItem.Changes[ChangeCode].ItemUnitType = ItemUnitType
|
DetectedItem.Changes[ChangeCode].ItemUnitType = ItemUnitType
|
||||||
|
|
||||||
self:T( { "Change on Detection Item:", DetectedItem.ID, ChangeCode, ItemUnitType } )
|
self:E( { "Change on Detection Item:", DetectedItem.ID, ChangeCode, ItemUnitType } )
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
@ -1124,7 +1132,7 @@ do -- DETECTION_BASE
|
|||||||
DetectedItem.Changes[ChangeCode][ChangeUnitType] = DetectedItem.Changes[ChangeCode][ChangeUnitType] + 1
|
DetectedItem.Changes[ChangeCode][ChangeUnitType] = DetectedItem.Changes[ChangeCode][ChangeUnitType] + 1
|
||||||
DetectedItem.Changes[ChangeCode].ID = ID
|
DetectedItem.Changes[ChangeCode].ID = ID
|
||||||
|
|
||||||
self:T( { "Change on Detection Item:", DetectedItem.ID, ChangeCode, ChangeUnitType } )
|
self:E( { "Change on Detection Item:", DetectedItem.ID, ChangeCode, ChangeUnitType } )
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
@ -1354,6 +1362,32 @@ do -- DETECTION_BASE
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Gets a detected unit type name, taking into account the detection results.
|
||||||
|
-- @param #DETECTION_BASE self
|
||||||
|
-- @param #Wrapper.Unit#UNIT DetectedUnit
|
||||||
|
-- @return #string The type name
|
||||||
|
function DETECTION_BASE:GetDetectedUnitTypeName( DetectedUnit )
|
||||||
|
--self:F2( ObjectName )
|
||||||
|
|
||||||
|
if DetectedUnit and DetectedUnit:IsAlive() then
|
||||||
|
local DetectedUnitName = DetectedUnit:GetName()
|
||||||
|
local DetectedObject = self.DetectedObjects[DetectedUnitName]
|
||||||
|
|
||||||
|
if DetectedObject then
|
||||||
|
if DetectedObject.KnowType then
|
||||||
|
return DetectedUnit:GetTypeName()
|
||||||
|
else
|
||||||
|
return "Unknown"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
return "Dead:" .. DetectedUnit:GetName()
|
||||||
|
end
|
||||||
|
|
||||||
|
return "Undetected:" .. DetectedUnit:GetName()
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Adds a new DetectedItem to the DetectedItems list.
|
--- Adds a new DetectedItem to the DetectedItems list.
|
||||||
-- The DetectedItem is a table and contains a SET_UNIT in the field Set.
|
-- The DetectedItem is a table and contains a SET_UNIT in the field Set.
|
||||||
-- @param #DETECTION_BASE self
|
-- @param #DETECTION_BASE self
|
||||||
@ -1538,15 +1572,78 @@ do -- DETECTION_BASE
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Set the detected item coordinate.
|
||||||
|
-- @param #DETECTION_BASE self
|
||||||
|
-- @param #DETECTION_BASE.DetectedItem The DetectedItem to set the coordinate at.
|
||||||
|
-- @param Core.Point#COORDINATE Coordinate The coordinate to set the last know detected position at.
|
||||||
|
-- @param Wrapper.Unit#UNIT DetectedItemUnit The unit to set the heading and altitude from.
|
||||||
|
-- @return #DETECTION_BASE
|
||||||
|
function DETECTION_BASE:SetDetectedItemCoordinate( DetectedItem, Coordinate, DetectedItemUnit )
|
||||||
|
self:F( { Coordinate = Coordinate } )
|
||||||
|
|
||||||
|
if DetectedItem then
|
||||||
|
if DetectedItemUnit then
|
||||||
|
DetectedItem.Coordinate = Coordinate
|
||||||
|
DetectedItem.Coordinate:SetHeading( DetectedItemUnit:GetHeading() )
|
||||||
|
DetectedItem.Coordinate.y = DetectedItemUnit:GetAltitude()
|
||||||
|
DetectedItem.Coordinate.Speed = DetectedItemUnit:GetVelocityMPS()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Get the detected item coordinate.
|
--- Get the detected item coordinate.
|
||||||
-- @param #DETECTION_BASE self
|
-- @param #DETECTION_BASE self
|
||||||
-- @param Index
|
-- @param #number Index
|
||||||
-- @return Core.Point#COORDINATE
|
-- @return Core.Point#COORDINATE
|
||||||
function DETECTION_BASE:GetDetectedItemCoordinate( Index )
|
function DETECTION_BASE:GetDetectedItemCoordinate( Index )
|
||||||
self:F( { Index = Index } )
|
self:F( { Index = Index } )
|
||||||
|
|
||||||
|
local DetectedItem = self:GetDetectedItem( Index )
|
||||||
|
|
||||||
|
if DetectedItem then
|
||||||
|
return DetectedItem.Coordinate
|
||||||
|
end
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Set the detected item threatlevel.
|
||||||
|
-- @param #DETECTION_BASE self
|
||||||
|
-- @param #DETECTION_BASE.DetectedItem The DetectedItem to calculate the threatlevel for.
|
||||||
|
-- @return #DETECTION_BASE
|
||||||
|
function DETECTION_BASE:SetDetectedItemThreatLevel( DetectedItem )
|
||||||
|
|
||||||
|
local DetectedSet = DetectedItem.Set
|
||||||
|
|
||||||
|
if DetectedItem then
|
||||||
|
DetectedItem.ThreatLevel = DetectedSet:CalculateThreatLevelA2G()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
--- Get the detected item coordinate.
|
||||||
|
-- @param #DETECTION_BASE self
|
||||||
|
-- @param #number Index
|
||||||
|
-- @return #number ThreatLevel
|
||||||
|
function DETECTION_BASE:GetDetectedItemThreatLevel( Index )
|
||||||
|
self:F( { Index = Index } )
|
||||||
|
|
||||||
|
local DetectedItem = self:GetDetectedItem( Index )
|
||||||
|
|
||||||
|
if DetectedItem then
|
||||||
|
return DetectedItem.ThreatLevel or 0
|
||||||
|
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
|
||||||
@ -1639,27 +1736,6 @@ do -- DETECTION_UNITS
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Get the detected item coordinate.
|
|
||||||
-- @param #DETECTION_UNITS self
|
|
||||||
-- @param Index
|
|
||||||
-- @return Core.Point#COORDINATE
|
|
||||||
function DETECTION_UNITS:GetDetectedItemCoordinate( Index )
|
|
||||||
self:F( { Index = Index } )
|
|
||||||
|
|
||||||
local DetectedItem = self:GetDetectedItem( Index )
|
|
||||||
local DetectedSet = self:GetDetectedSet( Index )
|
|
||||||
|
|
||||||
if DetectedSet then
|
|
||||||
local DetectedItemUnit = DetectedSet:GetFirst() -- Wrapper.Unit#UNIT
|
|
||||||
if DetectedItemUnit and DetectedItemUnit:IsAlive() then
|
|
||||||
local DetectedItemCoordinate = DetectedItemUnit:GetCoordinate()
|
|
||||||
DetectedItemCoordinate:SetHeading( DetectedItemUnit:GetHeading() )
|
|
||||||
return DetectedItemCoordinate
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
--- Make text documenting the changes of the detected zone.
|
--- Make text documenting the changes of the detected zone.
|
||||||
-- @param #DETECTION_UNITS self
|
-- @param #DETECTION_UNITS self
|
||||||
-- @param #DETECTION_UNITS.DetectedItem DetectedItem
|
-- @param #DETECTION_UNITS.DetectedItem DetectedItem
|
||||||
@ -1727,6 +1803,7 @@ do -- DETECTION_UNITS
|
|||||||
|
|
||||||
-- Update the detection with the new data provided.
|
-- Update the detection with the new data provided.
|
||||||
DetectedItem.TypeName = DetectedUnit:GetTypeName()
|
DetectedItem.TypeName = DetectedUnit:GetTypeName()
|
||||||
|
DetectedItem.CategoryName = DetectedUnit:GetCategoryName()
|
||||||
DetectedItem.Name = DetectedObject.Name
|
DetectedItem.Name = DetectedObject.Name
|
||||||
DetectedItem.IsVisible = DetectedObject.IsVisible
|
DetectedItem.IsVisible = DetectedObject.IsVisible
|
||||||
DetectedItem.LastTime = DetectedObject.LastTime
|
DetectedItem.LastTime = DetectedObject.LastTime
|
||||||
@ -1781,8 +1858,14 @@ do -- DETECTION_UNITS
|
|||||||
local DetectedItem = DetectedItemData -- #DETECTION_BASE.DetectedItem
|
local DetectedItem = DetectedItemData -- #DETECTION_BASE.DetectedItem
|
||||||
local DetectedSet = DetectedItem.Set
|
local DetectedSet = DetectedItem.Set
|
||||||
|
|
||||||
|
-- Set the last known coordinate.
|
||||||
|
local DetectedFirstUnit = DetectedSet:GetFirst()
|
||||||
|
local DetectedFirstUnitCoord = DetectedFirstUnit:GetCoordinate()
|
||||||
|
self:SetDetectedItemCoordinate( DetectedItem, DetectedFirstUnitCoord, DetectedFirstUnit )
|
||||||
|
|
||||||
self:ReportFriendliesNearBy( { DetectedItem = DetectedItem, ReportSetGroup = self.DetectionSetGroup } ) -- Fill the Friendlies table
|
self:ReportFriendliesNearBy( { DetectedItem = DetectedItem, ReportSetGroup = self.DetectionSetGroup } ) -- Fill the Friendlies table
|
||||||
--self:NearestFAC( DetectedItem )
|
--self:NearestFAC( DetectedItem )
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@ -1804,12 +1887,7 @@ do -- DETECTION_UNITS
|
|||||||
local UnitDistanceText = ""
|
local UnitDistanceText = ""
|
||||||
local UnitCategoryText = ""
|
local UnitCategoryText = ""
|
||||||
|
|
||||||
local DetectedItemUnit = DetectedSet:GetFirst() -- Wrapper.Unit#UNIT
|
local DetectedItemCoordinate = self:GetDetectedItemCoordinate( Index )
|
||||||
|
|
||||||
if DetectedItemUnit and DetectedItemUnit:IsAlive() then
|
|
||||||
self:T(DetectedItemUnit)
|
|
||||||
|
|
||||||
local DetectedItemCoordinate = DetectedItemUnit:GetCoordinate()
|
|
||||||
local DetectedItemCoordText = DetectedItemCoordinate:ToString( AttackGroup )
|
local DetectedItemCoordText = DetectedItemCoordinate:ToString( AttackGroup )
|
||||||
|
|
||||||
ReportSummary = string.format(
|
ReportSummary = string.format(
|
||||||
@ -1817,8 +1895,6 @@ do -- DETECTION_UNITS
|
|||||||
DetectedItemID,
|
DetectedItemID,
|
||||||
DetectedItemCoordText
|
DetectedItemCoordText
|
||||||
)
|
)
|
||||||
end
|
|
||||||
|
|
||||||
self:T( ReportSummary )
|
self:T( ReportSummary )
|
||||||
|
|
||||||
return ReportSummary
|
return ReportSummary
|
||||||
@ -1835,23 +1911,15 @@ do -- DETECTION_UNITS
|
|||||||
self:F( { Index, self.DetectedItems } )
|
self:F( { Index, self.DetectedItems } )
|
||||||
|
|
||||||
local DetectedItem = self:GetDetectedItem( Index )
|
local DetectedItem = self:GetDetectedItem( Index )
|
||||||
local DetectedSet = self:GetDetectedSet( Index )
|
|
||||||
local DetectedItemID = self:GetDetectedItemID( Index )
|
local DetectedItemID = self:GetDetectedItemID( Index )
|
||||||
|
|
||||||
self:T( DetectedSet )
|
if DetectedItem then
|
||||||
if DetectedSet then
|
|
||||||
local ReportSummary = ""
|
local ReportSummary = ""
|
||||||
local UnitDistanceText = ""
|
local UnitDistanceText = ""
|
||||||
local UnitCategoryText = ""
|
local UnitCategoryText = ""
|
||||||
|
|
||||||
local DetectedItemUnit = DetectedSet:GetFirst() -- Wrapper.Unit#UNIT
|
|
||||||
|
|
||||||
if DetectedItemUnit and DetectedItemUnit:IsAlive() then
|
|
||||||
self:T(DetectedItemUnit)
|
|
||||||
|
|
||||||
|
|
||||||
if DetectedItem.KnowType then
|
if DetectedItem.KnowType then
|
||||||
local UnitCategoryName = DetectedItemUnit:GetCategoryName()
|
local UnitCategoryName = DetectedItem.CategoryName
|
||||||
if UnitCategoryName then
|
if UnitCategoryName then
|
||||||
UnitCategoryText = UnitCategoryName
|
UnitCategoryText = UnitCategoryName
|
||||||
end
|
end
|
||||||
@ -1872,10 +1940,11 @@ do -- DETECTION_UNITS
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local DetectedItemCoordinate = DetectedItemUnit:GetCoordinate()
|
--TODO: solve Index reference
|
||||||
|
local DetectedItemCoordinate = self:GetDetectedItemCoordinate( Index )
|
||||||
local DetectedItemCoordText = DetectedItemCoordinate:ToString( AttackGroup, Settings )
|
local DetectedItemCoordText = DetectedItemCoordinate:ToString( AttackGroup, Settings )
|
||||||
|
|
||||||
local ThreatLevelA2G = DetectedItemUnit:GetThreatLevel( DetectedItem )
|
local ThreatLevelA2G = self:GetDetectedItemThreatLevel( DetectedItem )
|
||||||
|
|
||||||
local Report = REPORT:New()
|
local Report = REPORT:New()
|
||||||
Report:Add(DetectedItemID .. ", " .. DetectedItemCoordText)
|
Report:Add(DetectedItemID .. ", " .. DetectedItemCoordText)
|
||||||
@ -1883,7 +1952,6 @@ do -- DETECTION_UNITS
|
|||||||
Report:Add( string.format("Type: %s%s", UnitCategoryText, UnitDistanceText ) )
|
Report:Add( string.format("Type: %s%s", UnitCategoryText, UnitDistanceText ) )
|
||||||
return Report
|
return Report
|
||||||
end
|
end
|
||||||
end
|
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -1944,25 +2012,6 @@ do -- DETECTION_TYPES
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Get the detected item coordinate.
|
|
||||||
-- @param #DETECTION_TYPES self
|
|
||||||
-- @param DetectedTypeName
|
|
||||||
-- @return #Core.Point#COORDINATE
|
|
||||||
function DETECTION_TYPES:GetDetectedItemCoordinate( DetectedTypeName )
|
|
||||||
self:F( { DetectedTypeName = DetectedTypeName } )
|
|
||||||
|
|
||||||
local DetectedItem = self:GetDetectedItem( DetectedTypeName )
|
|
||||||
local DetectedSet = self:GetDetectedSet( DetectedTypeName )
|
|
||||||
|
|
||||||
if DetectedItem then
|
|
||||||
local DetectedItemUnit = DetectedSet:GetFirst()
|
|
||||||
local DetectedItemCoordinate = DetectedItemUnit:GetCoordinate()
|
|
||||||
DetectedItemCoordinate:SetHeading( DetectedItemUnit:GetHeading() )
|
|
||||||
return DetectedItemCoordinate
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
--- Make text documenting the changes of the detected zone.
|
--- Make text documenting the changes of the detected zone.
|
||||||
-- @param #DETECTION_TYPES self
|
-- @param #DETECTION_TYPES self
|
||||||
-- @param #DETECTION_TYPES.DetectedItem DetectedItem
|
-- @param #DETECTION_TYPES.DetectedItem DetectedItem
|
||||||
@ -2067,11 +2116,17 @@ do -- DETECTION_TYPES
|
|||||||
local DetectedItem = DetectedItemData -- #DETECTION_BASE.DetectedItem
|
local DetectedItem = DetectedItemData -- #DETECTION_BASE.DetectedItem
|
||||||
local DetectedSet = DetectedItem.Set
|
local DetectedSet = DetectedItem.Set
|
||||||
|
|
||||||
|
-- Set the last known coordinate.
|
||||||
|
local DetectedFirstUnit = DetectedSet:GetFirst()
|
||||||
|
local DetectedUnitCoord = DetectedFirstUnit:GetCoordinate()
|
||||||
|
self:SetDetectedItemCoordinate( DetectedItem, DetectedUnitCoord, DetectedFirstUnit )
|
||||||
|
|
||||||
self:ReportFriendliesNearBy( { DetectedItem = DetectedItem, ReportSetGroup = self.DetectionSetGroup } ) -- Fill the Friendlies table
|
self:ReportFriendliesNearBy( { DetectedItem = DetectedItem, ReportSetGroup = self.DetectionSetGroup } ) -- Fill the Friendlies table
|
||||||
--self:NearestFAC( DetectedItem )
|
--self:NearestFAC( DetectedItem )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Menu of a DetectedItem using a given numeric index.
|
--- Menu of a DetectedItem using a given numeric index.
|
||||||
@ -2082,20 +2137,13 @@ do -- DETECTION_TYPES
|
|||||||
self:F( DetectedTypeName )
|
self:F( DetectedTypeName )
|
||||||
|
|
||||||
local DetectedItem = self:GetDetectedItem( DetectedTypeName )
|
local DetectedItem = self:GetDetectedItem( DetectedTypeName )
|
||||||
local DetectedSet = self:GetDetectedSet( DetectedTypeName )
|
|
||||||
local DetectedItemID = self:GetDetectedItemID( DetectedTypeName )
|
local DetectedItemID = self:GetDetectedItemID( DetectedTypeName )
|
||||||
|
|
||||||
self:T( DetectedItem )
|
|
||||||
if DetectedItem then
|
if DetectedItem then
|
||||||
|
|
||||||
local DetectedItemUnit = DetectedSet:GetFirst()
|
local DetectedItemCoordinate = self:GetDetectedItemCoordinate( DetectedTypeName )
|
||||||
|
|
||||||
local DetectedItemCoordinate = DetectedItemUnit:GetCoordinate()
|
|
||||||
local DetectedItemCoordText = DetectedItemCoordinate:ToString( AttackGroup )
|
local DetectedItemCoordText = DetectedItemCoordinate:ToString( AttackGroup )
|
||||||
|
|
||||||
--self:E( { DetectedItemID,
|
|
||||||
-- DetectedItemCoordText } )
|
|
||||||
|
|
||||||
local ReportSummary = string.format(
|
local ReportSummary = string.format(
|
||||||
"%s - %s",
|
"%s - %s",
|
||||||
DetectedItemID,
|
DetectedItemID,
|
||||||
@ -2123,13 +2171,11 @@ do -- DETECTION_TYPES
|
|||||||
self:T( DetectedItem )
|
self:T( DetectedItem )
|
||||||
if DetectedItem then
|
if DetectedItem then
|
||||||
|
|
||||||
local ThreatLevelA2G = DetectedSet:CalculateThreatLevelA2G()
|
local ThreatLevelA2G = self:GetDetectedItemThreatLevel( DetectedTypeName )
|
||||||
local DetectedItemsCount = DetectedSet:Count()
|
local DetectedItemsCount = DetectedSet:Count()
|
||||||
local DetectedItemType = DetectedItem.TypeName
|
local DetectedItemType = DetectedItem.TypeName
|
||||||
|
|
||||||
local DetectedItemUnit = DetectedSet:GetFirst()
|
local DetectedItemCoordinate = self:GetDetectedItemCoordinate( DetectedTypeName )
|
||||||
|
|
||||||
local DetectedItemCoordinate = DetectedItemUnit:GetCoordinate()
|
|
||||||
local DetectedItemCoordText = DetectedItemCoordinate:ToString( AttackGroup, Settings )
|
local DetectedItemCoordText = DetectedItemCoordinate:ToString( AttackGroup, Settings )
|
||||||
|
|
||||||
local Report = REPORT:New()
|
local Report = REPORT:New()
|
||||||
@ -2228,32 +2274,6 @@ do -- DETECTION_AREAS
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Get the detected item coordinate.
|
|
||||||
-- In this case, the coordinate is the center of the zone of the area, not the center unit!
|
|
||||||
-- So if units move, the retrieved coordinate can be different from the units positions.
|
|
||||||
-- @param #DETECTION_AREAS self
|
|
||||||
-- @param Index
|
|
||||||
-- @return Core.Point#COORDINATE The coordinate.
|
|
||||||
function DETECTION_AREAS:GetDetectedItemCoordinate( Index )
|
|
||||||
self:F( { Index = Index } )
|
|
||||||
|
|
||||||
local DetectedItem = self:GetDetectedItem( Index )
|
|
||||||
local DetectedItemSet = self:GetDetectedSet( Index )
|
|
||||||
local FirstUnit = DetectedItemSet:GetFirst()
|
|
||||||
|
|
||||||
if DetectedItem then
|
|
||||||
local DetectedZone = self:GetDetectedItemZone( Index )
|
|
||||||
-- TODO: Rework to COORDINATE. Problem with SetAlt.
|
|
||||||
local DetectedItemCoordinate = DetectedZone:GetPointVec2()
|
|
||||||
-- These need to be done to understand the heading and altitude of the first unit in the zone.
|
|
||||||
DetectedItemCoordinate:SetHeading( FirstUnit:GetHeading() )
|
|
||||||
DetectedItemCoordinate:SetAlt( FirstUnit:GetAltitude() )
|
|
||||||
|
|
||||||
return DetectedItemCoordinate
|
|
||||||
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_AREAS self
|
-- @param #DETECTION_AREAS self
|
||||||
@ -2305,7 +2325,7 @@ do -- DETECTION_AREAS
|
|||||||
local DetectedItemCoordinate = DetectedZone:GetCoordinate()
|
local DetectedItemCoordinate = DetectedZone:GetCoordinate()
|
||||||
local DetectedItemCoordText = DetectedItemCoordinate:ToString( AttackGroup, Settings )
|
local DetectedItemCoordText = DetectedItemCoordinate:ToString( AttackGroup, Settings )
|
||||||
|
|
||||||
local ThreatLevelA2G = self:GetTreatLevelA2G( DetectedItem )
|
local ThreatLevelA2G = self:GetDetectedItemThreatLevel( Index )
|
||||||
local DetectedItemsCount = DetectedSet:Count()
|
local DetectedItemsCount = DetectedSet:Count()
|
||||||
local DetectedItemsTypes = DetectedSet:GetTypeNames()
|
local DetectedItemsTypes = DetectedSet:GetTypeNames()
|
||||||
|
|
||||||
@ -2341,25 +2361,6 @@ do -- DETECTION_AREAS
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Calculate the maxium A2G threat level of the DetectedItem.
|
|
||||||
-- @param #DETECTION_AREAS self
|
|
||||||
-- @param #DETECTION_BASE.DetectedItem DetectedItem
|
|
||||||
function DETECTION_AREAS:CalculateThreatLevelA2G( DetectedItem )
|
|
||||||
|
|
||||||
local MaxThreatLevelA2G = 0
|
|
||||||
for UnitName, UnitData in pairs( DetectedItem.Set:GetSet() ) do
|
|
||||||
local ThreatUnit = UnitData -- Wrapper.Unit#UNIT
|
|
||||||
local ThreatLevelA2G = ThreatUnit:GetThreatLevel()
|
|
||||||
if ThreatLevelA2G > MaxThreatLevelA2G then
|
|
||||||
MaxThreatLevelA2G = ThreatLevelA2G
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
self:T3( MaxThreatLevelA2G )
|
|
||||||
DetectedItem.MaxThreatLevelA2G = MaxThreatLevelA2G
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Calculate the optimal intercept point of the DetectedItem.
|
--- Calculate the optimal intercept point of the DetectedItem.
|
||||||
-- @param #DETECTION_AREAS self
|
-- @param #DETECTION_AREAS self
|
||||||
-- @param #DETECTION_BASE.DetectedItem DetectedItem
|
-- @param #DETECTION_BASE.DetectedItem DetectedItem
|
||||||
@ -2367,15 +2368,15 @@ do -- DETECTION_AREAS
|
|||||||
|
|
||||||
if self.Intercept then
|
if self.Intercept then
|
||||||
local DetectedSet = DetectedItem.Set
|
local DetectedSet = DetectedItem.Set
|
||||||
local DetectedUnit = DetectedSet:GetFirst() -- Wrapper.Unit#UNIT
|
|
||||||
if DetectedUnit then
|
if DetectedUnit then
|
||||||
local UnitSpeed = DetectedUnit:GetVelocityMPS()
|
-- todo: speed
|
||||||
local UnitHeading = DetectedUnit:GetHeading()
|
local DetectedSpeed = DetectedItem.Coordinate.Speed
|
||||||
local UnitCoord = DetectedUnit:GetCoordinate()
|
local DetectedHeading = DetectedItem.Coordinate.Heading
|
||||||
|
local DetectedCoord = DetectedItem.Coordinate
|
||||||
|
|
||||||
local TranslateDistance = UnitSpeed * self.InterceptDelay
|
local TranslateDistance = DetectedSpeed * self.InterceptDelay
|
||||||
|
|
||||||
local InterceptCoord = UnitCoord:Translate( TranslateDistance, UnitHeading )
|
local InterceptCoord = DetectedCoord:Translate( TranslateDistance, DetectedHeading )
|
||||||
|
|
||||||
DetectedItem.InterceptCoord = InterceptCoord
|
DetectedItem.InterceptCoord = InterceptCoord
|
||||||
else
|
else
|
||||||
@ -2415,18 +2416,6 @@ do -- DETECTION_AREAS
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Returns the A2G threat level of the units in the DetectedItem
|
|
||||||
-- @param #DETECTION_AREAS self
|
|
||||||
-- @param #DETECTION_BASE.DetectedItem DetectedItem
|
|
||||||
-- @return #number a scale from 0 to 10.
|
|
||||||
function DETECTION_AREAS:GetTreatLevelA2G( DetectedItem )
|
|
||||||
|
|
||||||
self:T3( DetectedItem.MaxThreatLevelA2G )
|
|
||||||
return DetectedItem.MaxThreatLevelA2G
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--- Smoke the detected units
|
--- Smoke the detected units
|
||||||
-- @param #DETECTION_AREAS self
|
-- @param #DETECTION_AREAS self
|
||||||
-- @return #DETECTION_AREAS self
|
-- @return #DETECTION_AREAS self
|
||||||
@ -2571,13 +2560,14 @@ do -- DETECTION_AREAS
|
|||||||
-- First remove the center unit from the set.
|
-- First remove the center unit from the set.
|
||||||
DetectedSet:RemoveUnitsByName( DetectedItem.Zone.ZoneUNIT.UnitName )
|
DetectedSet:RemoveUnitsByName( DetectedItem.Zone.ZoneUNIT.UnitName )
|
||||||
|
|
||||||
self:AddChangeItem( DetectedItem, 'RAU', "Dummy" )
|
self:AddChangeItem( DetectedItem, 'RAU', self:GetDetectedUnitTypeName( DetectedItem.Zone.ZoneUNIT ) )
|
||||||
|
|
||||||
-- Then search for a new center area unit within the set. Note that the new area unit candidate must be within the area range.
|
-- Then search for a new center area unit within the set. Note that the new area unit candidate must be within the area range.
|
||||||
for DetectedUnitName, DetectedUnitData in pairs( DetectedSet:GetSet() ) do
|
for DetectedUnitName, DetectedUnitData in pairs( DetectedSet:GetSet() ) do
|
||||||
|
|
||||||
local DetectedUnit = DetectedUnitData -- Wrapper.Unit#UNIT
|
local DetectedUnit = DetectedUnitData -- Wrapper.Unit#UNIT
|
||||||
local DetectedObject = self:GetDetectedObject( DetectedUnit.UnitName )
|
local DetectedObject = self:GetDetectedObject( DetectedUnit.UnitName )
|
||||||
|
local DetectedUnitTypeName = self:GetDetectedUnitTypeName( DetectedUnit )
|
||||||
|
|
||||||
-- The DetectedObject can be nil when the DetectedUnit is not alive anymore or it is not in the DetectedObjects map.
|
-- The DetectedObject can be nil when the DetectedUnit is not alive anymore or it is not in the DetectedObjects map.
|
||||||
-- If the DetectedUnit was already identified, DetectedObject will be nil.
|
-- If the DetectedUnit was already identified, DetectedObject will be nil.
|
||||||
@ -2590,13 +2580,13 @@ do -- DETECTION_AREAS
|
|||||||
-- Assign the Unit as the new center unit of the detected area.
|
-- Assign the Unit as the new center unit of the detected area.
|
||||||
DetectedItem.Zone = ZONE_UNIT:New( DetectedUnit:GetName(), DetectedUnit, self.DetectionZoneRange )
|
DetectedItem.Zone = ZONE_UNIT:New( DetectedUnit:GetName(), DetectedUnit, self.DetectionZoneRange )
|
||||||
|
|
||||||
self:AddChangeItem( DetectedItem, "AAU", DetectedItem.Zone.ZoneUNIT:GetTypeName() )
|
self:AddChangeItem( DetectedItem, "AAU", DetectedUnitTypeName )
|
||||||
|
|
||||||
-- We don't need to add the DetectedObject to the area set, because it is already there ...
|
-- We don't need to add the DetectedObject to the area set, because it is already there ...
|
||||||
break
|
break
|
||||||
else
|
else
|
||||||
DetectedSet:Remove( DetectedUnitName )
|
DetectedSet:Remove( DetectedUnitName )
|
||||||
self:AddChangeUnit( DetectedItem, "RU", DetectedUnit:GetTypeName() )
|
self:AddChangeUnit( DetectedItem, "RU", DetectedUnitTypeName )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -2612,6 +2602,8 @@ do -- DETECTION_AREAS
|
|||||||
for DetectedUnitName, DetectedUnitData in pairs( DetectedSet:GetSet() ) do
|
for DetectedUnitName, DetectedUnitData in pairs( DetectedSet:GetSet() ) do
|
||||||
|
|
||||||
local DetectedUnit = DetectedUnitData -- Wrapper.Unit#UNIT
|
local DetectedUnit = DetectedUnitData -- Wrapper.Unit#UNIT
|
||||||
|
local DetectedUnitTypeName = self:GetDetectedUnitTypeName( DetectedUnit )
|
||||||
|
|
||||||
local DetectedObject = nil
|
local DetectedObject = nil
|
||||||
if DetectedUnit:IsAlive() then
|
if DetectedUnit:IsAlive() then
|
||||||
--self:E(DetectedUnit:GetName())
|
--self:E(DetectedUnit:GetName())
|
||||||
@ -2628,7 +2620,7 @@ do -- DETECTION_AREAS
|
|||||||
else
|
else
|
||||||
-- No, the DetectedUnit is not within the DetectedItem.Zone, remove DetectedUnit from the Set.
|
-- No, the DetectedUnit is not within the DetectedItem.Zone, remove DetectedUnit from the Set.
|
||||||
DetectedSet:Remove( DetectedUnitName )
|
DetectedSet:Remove( DetectedUnitName )
|
||||||
self:AddChangeUnit( DetectedItem, "RU", DetectedUnit:GetTypeName() )
|
self:AddChangeUnit( DetectedItem, "RU", DetectedUnitTypeName )
|
||||||
end
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
@ -2665,6 +2657,7 @@ do -- DETECTION_AREAS
|
|||||||
|
|
||||||
-- We found an unidentified unit outside of any existing detection area.
|
-- We found an unidentified unit outside of any existing detection area.
|
||||||
local DetectedUnit = UNIT:FindByName( DetectedUnitName ) -- Wrapper.Unit#UNIT
|
local DetectedUnit = UNIT:FindByName( DetectedUnitName ) -- Wrapper.Unit#UNIT
|
||||||
|
local DetectedUnitTypeName = self:GetDetectedUnitTypeName( DetectedUnit )
|
||||||
|
|
||||||
local AddedToDetectionArea = false
|
local AddedToDetectionArea = false
|
||||||
|
|
||||||
@ -2678,7 +2671,7 @@ do -- DETECTION_AREAS
|
|||||||
self:IdentifyDetectedObject( DetectedObject )
|
self:IdentifyDetectedObject( DetectedObject )
|
||||||
DetectedSet:AddUnit( DetectedUnit )
|
DetectedSet:AddUnit( DetectedUnit )
|
||||||
AddedToDetectionArea = true
|
AddedToDetectionArea = true
|
||||||
self:AddChangeUnit( DetectedItem, "AU", DetectedUnit:GetTypeName() )
|
self:AddChangeUnit( DetectedItem, "AU", DetectedUnitTypeName )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -2692,7 +2685,7 @@ do -- DETECTION_AREAS
|
|||||||
)
|
)
|
||||||
--self:E( DetectedItem.Zone.ZoneUNIT.UnitName )
|
--self:E( DetectedItem.Zone.ZoneUNIT.UnitName )
|
||||||
DetectedItem.Set:AddUnit( DetectedUnit )
|
DetectedItem.Set:AddUnit( DetectedUnit )
|
||||||
self:AddChangeItem( DetectedItem, "AA", DetectedUnit:GetTypeName() )
|
self:AddChangeItem( DetectedItem, "AA", DetectedUnitTypeName )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -2704,14 +2697,20 @@ do -- DETECTION_AREAS
|
|||||||
|
|
||||||
local DetectedItem = DetectedItemData -- #DETECTION_BASE.DetectedItem
|
local DetectedItem = DetectedItemData -- #DETECTION_BASE.DetectedItem
|
||||||
local DetectedSet = DetectedItem.Set
|
local DetectedSet = DetectedItem.Set
|
||||||
|
local DetectedFirstUnit = DetectedSet:GetFirst()
|
||||||
local DetectedZone = DetectedItem.Zone
|
local DetectedZone = DetectedItem.Zone
|
||||||
|
|
||||||
|
-- Set the last known coordinate to the detection item.
|
||||||
|
local DetectedZoneCoord = DetectedZone:GetCoordinate()
|
||||||
|
self:SetDetectedItemCoordinate( DetectedItem, DetectedZoneCoord, DetectedFirstUnit )
|
||||||
|
|
||||||
self:CalculateIntercept( DetectedItem )
|
self:CalculateIntercept( DetectedItem )
|
||||||
|
|
||||||
self:ReportFriendliesNearBy( { DetectedItem = DetectedItem, ReportSetGroup = self.DetectionSetGroup } ) -- Fill the Friendlies table
|
self:ReportFriendliesNearBy( { DetectedItem = DetectedItem, ReportSetGroup = self.DetectionSetGroup } ) -- Fill the Friendlies table
|
||||||
self:CalculateThreatLevelA2G( DetectedItem ) -- Calculate A2G threat level
|
self:SetDetectedItemThreatLevel( DetectedItem ) -- Calculate A2G threat level
|
||||||
self:NearestFAC( DetectedItem )
|
self:NearestFAC( DetectedItem )
|
||||||
|
|
||||||
|
|
||||||
if DETECTION_AREAS._SmokeDetectedUnits or self._SmokeDetectedUnits then
|
if DETECTION_AREAS._SmokeDetectedUnits or self._SmokeDetectedUnits then
|
||||||
DetectedZone.ZoneUNIT:SmokeRed()
|
DetectedZone.ZoneUNIT:SmokeRed()
|
||||||
end
|
end
|
||||||
|
|||||||
@ -860,8 +860,9 @@ end
|
|||||||
|
|
||||||
--- Create a summary report of the Mission (one line).
|
--- Create a summary report of the Mission (one line).
|
||||||
-- @param #MISSION self
|
-- @param #MISSION self
|
||||||
|
-- @param Wrapper.Group#GROUP ReportGroup
|
||||||
-- @return #string
|
-- @return #string
|
||||||
function MISSION:ReportSummary()
|
function MISSION:ReportSummary( ReportGroup )
|
||||||
|
|
||||||
local Report = REPORT:New()
|
local Report = REPORT:New()
|
||||||
|
|
||||||
@ -874,9 +875,9 @@ function MISSION:ReportSummary()
|
|||||||
Report:Add( string.format( '%s - %s - Task Overview Report', Name, Status ) )
|
Report:Add( string.format( '%s - %s - Task Overview Report', Name, Status ) )
|
||||||
|
|
||||||
-- Determine how many tasks are remaining.
|
-- Determine how many tasks are remaining.
|
||||||
for TaskID, Task in pairs( self:GetTasks() ) do
|
for TaskID, Task in UTILS.spairs( self:GetTasks(), function( t, a, b ) return t[a]:ReportOrder( ReportGroup ) < t[b]:ReportOrder( ReportGroup ) end ) do
|
||||||
local Task = Task -- Tasking.Task#TASK
|
local Task = Task -- Tasking.Task#TASK
|
||||||
Report:Add( "- " .. Task:ReportSummary() )
|
Report:Add( "- " .. Task:ReportSummary( ReportGroup ) )
|
||||||
end
|
end
|
||||||
|
|
||||||
return Report:Text()
|
return Report:Text()
|
||||||
@ -898,13 +899,17 @@ function MISSION:ReportOverview( ReportGroup, TaskStatus )
|
|||||||
Report:Add( string.format( '%s - %s - %s Tasks Report', Name, Status, TaskStatus ) )
|
Report:Add( string.format( '%s - %s - %s Tasks Report', Name, Status, TaskStatus ) )
|
||||||
|
|
||||||
-- Determine how many tasks are remaining.
|
-- Determine how many tasks are remaining.
|
||||||
local TasksRemaining = 0
|
local Tasks = 0
|
||||||
for TaskID, Task in UTILS.spairs( self:GetTasks(), function( t, a, b ) return t[a]:ReportOrder( ReportGroup ) < t[b]:ReportOrder( ReportGroup ) end ) do
|
for TaskID, Task in UTILS.spairs( self:GetTasks(), function( t, a, b ) return t[a]:ReportOrder( ReportGroup ) < t[b]:ReportOrder( ReportGroup ) end ) do
|
||||||
local Task = Task -- Tasking.Task#TASK
|
local Task = Task -- Tasking.Task#TASK
|
||||||
if Task:Is( TaskStatus ) then
|
if Task:Is( TaskStatus ) then
|
||||||
Report:Add( string.rep( "-", 140 ) )
|
Report:Add( string.rep( "-", 140 ) )
|
||||||
Report:Add( " - " .. Task:ReportOverview( ReportGroup ) )
|
Report:Add( " - " .. Task:ReportOverview( ReportGroup ) )
|
||||||
end
|
end
|
||||||
|
Tasks = Tasks + 1
|
||||||
|
if Tasks >= 8 then
|
||||||
|
break
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return Report:Text()
|
return Report:Text()
|
||||||
@ -963,7 +968,7 @@ end
|
|||||||
-- @param Wrapper.Group#GROUP ReportGroup
|
-- @param Wrapper.Group#GROUP ReportGroup
|
||||||
function MISSION:MenuReportTasksSummary( ReportGroup )
|
function MISSION:MenuReportTasksSummary( ReportGroup )
|
||||||
|
|
||||||
local Report = self:ReportSummary()
|
local Report = self:ReportSummary( ReportGroup )
|
||||||
|
|
||||||
self:GetCommandCenter():MessageToGroup( Report, ReportGroup )
|
self:GetCommandCenter():MessageToGroup( Report, ReportGroup )
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1343,7 +1343,7 @@ function TASK:onbeforeTimeOut( From, Event, To )
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
do -- Dispatcher
|
do -- Links
|
||||||
|
|
||||||
--- Set dispatcher of a task
|
--- Set dispatcher of a task
|
||||||
-- @param #TASK self
|
-- @param #TASK self
|
||||||
@ -1353,6 +1353,19 @@ do -- Dispatcher
|
|||||||
self.Dispatcher = Dispatcher
|
self.Dispatcher = Dispatcher
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Set detection of a task
|
||||||
|
-- @param #TASK self
|
||||||
|
-- @param Function.Detection#DETECTION_BASE Detection
|
||||||
|
-- @param #number DetectedItemIndex
|
||||||
|
-- @return #TASK
|
||||||
|
function TASK:SetDetection( Detection, DetectedItemIndex )
|
||||||
|
|
||||||
|
self:E({DetectedItemIndex,Detection})
|
||||||
|
|
||||||
|
self.Detection = Detection
|
||||||
|
self.DetectedItemIndex = DetectedItemIndex
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
do -- Reporting
|
do -- Reporting
|
||||||
@ -1360,27 +1373,32 @@ do -- Reporting
|
|||||||
--- Create a summary report of the Task.
|
--- Create a summary report of the Task.
|
||||||
-- List the Task Name and Status
|
-- List the Task Name and Status
|
||||||
-- @param #TASK self
|
-- @param #TASK self
|
||||||
|
-- @param Wrapper.Group#GROUP ReportGroup
|
||||||
-- @return #string
|
-- @return #string
|
||||||
function TASK:ReportSummary() --R2.1 fixed report. Now nicely formatted and contains the info required.
|
function TASK:ReportSummary( ReportGroup )
|
||||||
|
|
||||||
local Report = REPORT:New()
|
local Report = REPORT:New()
|
||||||
|
|
||||||
-- List the name of the Task.
|
-- List the name of the Task.
|
||||||
local Name = self:GetName()
|
Report:Add( self:GetName() )
|
||||||
|
|
||||||
-- Determine the status of the Task.
|
-- Determine the status of the Task.
|
||||||
local Status = "<" .. self:GetState() .. ">"
|
Report:Add( "State: <" .. self:GetState() .. ">" )
|
||||||
|
|
||||||
Report:Add( 'Task ' .. Name .. ' - State ' .. Status )
|
if self.TaskInfo["Coordinates"] then
|
||||||
|
local TaskInfoIDText = string.format( "%s: ", "Coordinate" )
|
||||||
|
local TaskCoord = self.TaskInfo["Coordinates"].TaskInfoText -- Core.Point#COORDINATE
|
||||||
|
Report:Add( TaskInfoIDText .. TaskCoord:ToString( ReportGroup, nil, self ) )
|
||||||
|
end
|
||||||
|
|
||||||
return Report:Text()
|
return Report:Text( ', ' )
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Create an overiew report of the Task.
|
--- Create an overiew report of the Task.
|
||||||
-- List the Task Name and Status
|
-- List the Task Name and Status
|
||||||
-- @param #TASK self
|
-- @param #TASK self
|
||||||
-- @return #string
|
-- @return #string
|
||||||
function TASK:ReportOverview( ReportGroup ) --R2.1 fixed report. Now nicely formatted and contains the info required.
|
function TASK:ReportOverview( ReportGroup )
|
||||||
|
|
||||||
self:UpdateTaskInfo()
|
self:UpdateTaskInfo()
|
||||||
|
|
||||||
@ -1388,9 +1406,6 @@ function TASK:ReportOverview( ReportGroup ) --R2.1 fixed report. Now nicely form
|
|||||||
local TaskName = self:GetName()
|
local TaskName = self:GetName()
|
||||||
local Report = REPORT:New()
|
local Report = REPORT:New()
|
||||||
|
|
||||||
-- Determine the status of the Task.
|
|
||||||
local Status = "<" .. self:GetState() .. ">"
|
|
||||||
|
|
||||||
local Line = 0
|
local Line = 0
|
||||||
local LineReport = REPORT:New()
|
local LineReport = REPORT:New()
|
||||||
|
|
||||||
@ -1402,7 +1417,7 @@ function TASK:ReportOverview( ReportGroup ) --R2.1 fixed report. Now nicely form
|
|||||||
if Line ~= 0 then
|
if Line ~= 0 then
|
||||||
Report:AddIndent( LineReport:Text( ", " ) )
|
Report:AddIndent( LineReport:Text( ", " ) )
|
||||||
else
|
else
|
||||||
Report:Add( TaskName .. " - " .. LineReport:Text( ", " ) )
|
Report:Add( TaskName .. ", " .. LineReport:Text( ", " ) )
|
||||||
end
|
end
|
||||||
LineReport = REPORT:New()
|
LineReport = REPORT:New()
|
||||||
Line = math.floor( TaskInfo.TaskInfoOrder / 10 )
|
Line = math.floor( TaskInfo.TaskInfoOrder / 10 )
|
||||||
@ -1414,7 +1429,6 @@ function TASK:ReportOverview( ReportGroup ) --R2.1 fixed report. Now nicely form
|
|||||||
LineReport:Add( TaskInfoIDText .. TaskInfo.TaskInfoText )
|
LineReport:Add( TaskInfoIDText .. TaskInfo.TaskInfoText )
|
||||||
elseif type(TaskInfo) == "table" then
|
elseif type(TaskInfo) == "table" then
|
||||||
if TaskInfoID == "Coordinates" then
|
if TaskInfoID == "Coordinates" then
|
||||||
local FromCoordinate = ReportGroup:GetUnit(1):GetCoordinate()
|
|
||||||
local ToCoordinate = TaskInfo.TaskInfoText -- Core.Point#COORDINATE
|
local ToCoordinate = TaskInfo.TaskInfoText -- Core.Point#COORDINATE
|
||||||
--Report:Add( TaskInfoIDText )
|
--Report:Add( TaskInfoIDText )
|
||||||
LineReport:Add( TaskInfoIDText .. ToCoordinate:ToString( ReportGroup, nil, self ) )
|
LineReport:Add( TaskInfoIDText .. ToCoordinate:ToString( ReportGroup, nil, self ) )
|
||||||
@ -1422,8 +1436,6 @@ function TASK:ReportOverview( ReportGroup ) --R2.1 fixed report. Now nicely form
|
|||||||
else
|
else
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
Report:AddIndent( LineReport:Text( ", " ) )
|
Report:AddIndent( LineReport:Text( ", " ) )
|
||||||
|
|||||||
@ -328,17 +328,39 @@ do -- TASK_A2A_INTERCEPT
|
|||||||
"Intercept incoming intruders.\n"
|
"Intercept incoming intruders.\n"
|
||||||
)
|
)
|
||||||
|
|
||||||
local TargetCoordinate = TargetSetUnit:GetFirst():GetCoordinate()
|
self:UpdateTaskInfo()
|
||||||
self:SetInfo( "Coordinates", TargetCoordinate, 10 )
|
|
||||||
|
|
||||||
self:SetInfo( "Threat", "[" .. string.rep( "■", TargetSetUnit:CalculateThreatLevelA2G() ) .. "]", 11 )
|
|
||||||
local DetectedItemsCount = TargetSetUnit:Count()
|
|
||||||
local DetectedItemsTypes = TargetSetUnit:GetTypeNames()
|
|
||||||
self:SetInfo( "Targets", string.format( "%d of %s", DetectedItemsCount, DetectedItemsTypes ), 0 )
|
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function TASK_A2A_INTERCEPT:UpdateTaskInfo()
|
||||||
|
|
||||||
|
local TargetCoordinate = self.Detection and self.Detection:GetDetectedItemCoordinate( self.DetectedItemIndex ) or self.TargetSetUnit:GetFirst():GetCoordinate()
|
||||||
|
self:SetInfo( "Coordinates", TargetCoordinate, 0 )
|
||||||
|
|
||||||
|
self:SetInfo( "Threat", "[" .. string.rep( "■", self.Detection and self.Detection:GetDetectedItemThreatLevel( self.DetectedItemIndex ) or self.TargetSetUnit:CalculateThreatLevelA2G() ) .. "]", 11 )
|
||||||
|
|
||||||
|
if self.Detection then
|
||||||
|
local DetectedItemsCount = self.TargetSetUnit:Count()
|
||||||
|
local ReportTypes = REPORT:New()
|
||||||
|
local TargetTypes = {}
|
||||||
|
for TargetUnitName, TargetUnit in pairs( self.TargetSetUnit:GetSet() ) do
|
||||||
|
local TargetType = self.Detection:GetDetectedUnitTypeName( TargetUnit )
|
||||||
|
if not TargetTypes[TargetType] then
|
||||||
|
TargetTypes[TargetType] = TargetType
|
||||||
|
ReportTypes:Add( TargetType )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
self:SetInfo( "Targets", string.format( "%d of %s", DetectedItemsCount, ReportTypes:Text( ", " ) ), 10 )
|
||||||
|
else
|
||||||
|
local DetectedItemsCount = self.TargetSetUnit:Count()
|
||||||
|
local DetectedItemsTypes = self.TargetSetUnit:GetTypeNames()
|
||||||
|
self:SetInfo( "Targets", string.format( "%d of %s", DetectedItemsCount, DetectedItemsTypes ), 10 )
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
--- @param #TASK_A2A_INTERCEPT self
|
--- @param #TASK_A2A_INTERCEPT self
|
||||||
-- @param Wrapper.Group#GROUP ReportGroup
|
-- @param Wrapper.Group#GROUP ReportGroup
|
||||||
function TASK_A2A_INTERCEPT:ReportOrder( ReportGroup )
|
function TASK_A2A_INTERCEPT:ReportOrder( ReportGroup )
|
||||||
@ -461,17 +483,40 @@ do -- TASK_A2A_SWEEP
|
|||||||
"Perform a fighter sweep. Incoming intruders were detected and could be hiding at the location.\n"
|
"Perform a fighter sweep. Incoming intruders were detected and could be hiding at the location.\n"
|
||||||
)
|
)
|
||||||
|
|
||||||
local TargetCoordinate = TargetSetUnit:GetFirst():GetCoordinate()
|
self:UpdateTaskInfo()
|
||||||
self:SetInfo( "Coordinates", TargetCoordinate, 10 )
|
|
||||||
|
|
||||||
self:SetInfo( "Assumed Threat", "[" .. string.rep( "■", TargetSetUnit:CalculateThreatLevelA2G() ) .. "]", 11 )
|
|
||||||
local DetectedItemsCount = TargetSetUnit:Count()
|
|
||||||
local DetectedItemsTypes = TargetSetUnit:GetTypeNames()
|
|
||||||
self:SetInfo( "Lost Targets", string.format( "%d of %s", DetectedItemsCount, DetectedItemsTypes ), 0 )
|
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function TASK_A2A_SWEEP:UpdateTaskInfo()
|
||||||
|
|
||||||
|
local TargetCoordinate = self.Detection and self.Detection:GetDetectedItemCoordinate( self.DetectedItemIndex ) or self.TargetSetUnit:GetFirst():GetCoordinate()
|
||||||
|
self:SetInfo( "Coordinates", TargetCoordinate, 0 )
|
||||||
|
|
||||||
|
self:SetInfo( "Assumed Threat", "[" .. string.rep( "■", self.Detection and self.Detection:GetDetectedItemThreatLevel( self.DetectedItemIndex ) or self.TargetSetUnit:CalculateThreatLevelA2G() ) .. "]", 11 )
|
||||||
|
|
||||||
|
if self.Detection then
|
||||||
|
local DetectedItemsCount = self.TargetSetUnit:Count()
|
||||||
|
local ReportTypes = REPORT:New()
|
||||||
|
local TargetTypes = {}
|
||||||
|
for TargetUnitName, TargetUnit in pairs( self.TargetSetUnit:GetSet() ) do
|
||||||
|
local TargetType = self.Detection:GetDetectedUnitTypeName( TargetUnit )
|
||||||
|
if not TargetTypes[TargetType] then
|
||||||
|
TargetTypes[TargetType] = TargetType
|
||||||
|
ReportTypes:Add( TargetType )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
self:SetInfo( "Lost Targets", string.format( "%d of %s", DetectedItemsCount, ReportTypes:Text( ", " ) ), 10 )
|
||||||
|
else
|
||||||
|
local DetectedItemsCount = self.TargetSetUnit:Count()
|
||||||
|
local DetectedItemsTypes = self.TargetSetUnit:GetTypeNames()
|
||||||
|
self:SetInfo( "Lost Targets", string.format( "%d of %s", DetectedItemsCount, DetectedItemsTypes ), 10 )
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
function TASK_A2A_SWEEP:ReportOrder( ReportGroup )
|
function TASK_A2A_SWEEP:ReportOrder( ReportGroup )
|
||||||
local Coordinate = self.TaskInfo.Coordinates.TaskInfoText
|
local Coordinate = self.TaskInfo.Coordinates.TaskInfoText
|
||||||
local Distance = ReportGroup:GetCoordinate():Get2DDistance( Coordinate )
|
local Distance = ReportGroup:GetCoordinate():Get2DDistance( Coordinate )
|
||||||
@ -587,17 +632,39 @@ do -- TASK_A2A_ENGAGE
|
|||||||
"Bogeys are nearby! Players close by are ordered to ENGAGE the intruders!\n"
|
"Bogeys are nearby! Players close by are ordered to ENGAGE the intruders!\n"
|
||||||
)
|
)
|
||||||
|
|
||||||
local TargetCoordinate = TargetSetUnit:GetFirst():GetCoordinate()
|
self:UpdateTaskInfo()
|
||||||
self:SetInfo( "Coordinates", TargetCoordinate, 10 )
|
|
||||||
|
|
||||||
self:SetInfo( "Threat", "[" .. string.rep( "■", TargetSetUnit:CalculateThreatLevelA2G() ) .. "]", 11 )
|
|
||||||
local DetectedItemsCount = TargetSetUnit:Count()
|
|
||||||
local DetectedItemsTypes = TargetSetUnit:GetTypeNames()
|
|
||||||
self:SetInfo( "Targets", string.format( "%d of %s", DetectedItemsCount, DetectedItemsTypes ), 0 )
|
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function TASK_A2A_ENGAGE:UpdateTaskInfo()
|
||||||
|
|
||||||
|
local TargetCoordinate = self.Detection and self.Detection:GetDetectedItemCoordinate( self.DetectedItemIndex ) or self.TargetSetUnit:GetFirst():GetCoordinate()
|
||||||
|
self:SetInfo( "Coordinates", TargetCoordinate, 0 )
|
||||||
|
|
||||||
|
self:SetInfo( "Threat", "[" .. string.rep( "■", self.Detection and self.Detection:GetDetectedItemThreatLevel( self.DetectedItemIndex ) or self.TargetSetUnit:CalculateThreatLevelA2G() ) .. "]", 11 )
|
||||||
|
|
||||||
|
if self.Detection then
|
||||||
|
local DetectedItemsCount = self.TargetSetUnit:Count()
|
||||||
|
local ReportTypes = REPORT:New()
|
||||||
|
local TargetTypes = {}
|
||||||
|
for TargetUnitName, TargetUnit in pairs( self.TargetSetUnit:GetSet() ) do
|
||||||
|
local TargetType = self.Detection:GetDetectedUnitTypeName( TargetUnit )
|
||||||
|
if not TargetTypes[TargetType] then
|
||||||
|
TargetTypes[TargetType] = TargetType
|
||||||
|
ReportTypes:Add( TargetType )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
self:SetInfo( "Targets", string.format( "%d of %s", DetectedItemsCount, ReportTypes:Text( ", " ) ), 10 )
|
||||||
|
else
|
||||||
|
local DetectedItemsCount = self.TargetSetUnit:Count()
|
||||||
|
local DetectedItemsTypes = self.TargetSetUnit:GetTypeNames()
|
||||||
|
self:SetInfo( "Targets", string.format( "%d of %s", DetectedItemsCount, DetectedItemsTypes ), 10 )
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
function TASK_A2A_ENGAGE:ReportOrder( ReportGroup )
|
function TASK_A2A_ENGAGE:ReportOrder( ReportGroup )
|
||||||
local Coordinate = self.TaskInfo.Coordinates.TaskInfoText
|
local Coordinate = self.TaskInfo.Coordinates.TaskInfoText
|
||||||
local Distance = ReportGroup:GetCoordinate():Get2DDistance( Coordinate )
|
local Distance = ReportGroup:GetCoordinate():Get2DDistance( Coordinate )
|
||||||
|
|||||||
@ -382,9 +382,7 @@ do -- TASK_A2A_DISPATCHER
|
|||||||
end
|
end
|
||||||
|
|
||||||
if DetectedItemChanged == true or Remove then
|
if DetectedItemChanged == true or Remove then
|
||||||
--self:E( "Removing Tasking: " .. Task:GetTaskName() )
|
Task = self:RemoveTask( DetectedItemIndex )
|
||||||
Mission:RemoveTask( Task )
|
|
||||||
self.Tasks[DetectedItemIndex] = nil
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -482,6 +480,11 @@ do -- TASK_A2A_DISPATCHER
|
|||||||
return PlayersCount, PlayerTypesReport
|
return PlayersCount, PlayerTypesReport
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function TASK_A2A_DISPATCHER:RemoveTask( TaskIndex )
|
||||||
|
self.Mission:RemoveTask( self.Tasks[TaskIndex] )
|
||||||
|
self.Tasks[TaskIndex] = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Assigns tasks in relation to the detected items to the @{Set#SET_GROUP}.
|
--- Assigns tasks in relation to the detected items to the @{Set#SET_GROUP}.
|
||||||
-- @param #TASK_A2A_DISPATCHER self
|
-- @param #TASK_A2A_DISPATCHER self
|
||||||
@ -510,8 +513,7 @@ do -- TASK_A2A_DISPATCHER
|
|||||||
for TaskGroupID, TaskGroup in pairs( self.SetGroup:GetSet() ) do
|
for TaskGroupID, TaskGroup in pairs( self.SetGroup:GetSet() ) do
|
||||||
Mission:GetCommandCenter():MessageToGroup( string.format( "Obsolete A2A task %s for %s removed.", TaskText, Mission:GetName() ), TaskGroup )
|
Mission:GetCommandCenter():MessageToGroup( string.format( "Obsolete A2A task %s for %s removed.", TaskText, Mission:GetName() ), TaskGroup )
|
||||||
end
|
end
|
||||||
Mission:RemoveTask( Task )
|
Task = self:RemoveTask( TaskIndex )
|
||||||
self.Tasks[TaskIndex] = nil
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -538,21 +540,24 @@ do -- TASK_A2A_DISPATCHER
|
|||||||
local TargetSetUnit = self:EvaluateENGAGE( DetectedItem ) -- Returns a SetUnit if there are targets to be INTERCEPTed...
|
local TargetSetUnit = self:EvaluateENGAGE( DetectedItem ) -- Returns a SetUnit if there are targets to be INTERCEPTed...
|
||||||
if TargetSetUnit then
|
if TargetSetUnit then
|
||||||
Task = TASK_A2A_ENGAGE:New( Mission, self.SetGroup, string.format( "ENGAGE.%03d", DetectedID ), TargetSetUnit )
|
Task = TASK_A2A_ENGAGE:New( Mission, self.SetGroup, string.format( "ENGAGE.%03d", DetectedID ), TargetSetUnit )
|
||||||
|
Task:SetDetection( Detection, TaskIndex )
|
||||||
else
|
else
|
||||||
local TargetSetUnit = self:EvaluateINTERCEPT( DetectedItem ) -- Returns a SetUnit if there are targets to be INTERCEPTed...
|
local TargetSetUnit = self:EvaluateINTERCEPT( DetectedItem ) -- Returns a SetUnit if there are targets to be INTERCEPTed...
|
||||||
if TargetSetUnit then
|
if TargetSetUnit then
|
||||||
Task = TASK_A2A_INTERCEPT:New( Mission, self.SetGroup, string.format( "INTERCEPT.%03d", DetectedID ), TargetSetUnit )
|
Task = TASK_A2A_INTERCEPT:New( Mission, self.SetGroup, string.format( "INTERCEPT.%03d", DetectedID ), TargetSetUnit )
|
||||||
|
Task:SetDetection( Detection, TaskIndex )
|
||||||
else
|
else
|
||||||
local TargetSetUnit = self:EvaluateSWEEP( DetectedItem ) -- Returns a SetUnit
|
local TargetSetUnit = self:EvaluateSWEEP( DetectedItem ) -- Returns a SetUnit
|
||||||
if TargetSetUnit then
|
if TargetSetUnit then
|
||||||
Task = TASK_A2A_SWEEP:New( Mission, self.SetGroup, string.format( "SWEEP.%03d", DetectedID ), TargetSetUnit )
|
Task = TASK_A2A_SWEEP:New( Mission, self.SetGroup, string.format( "SWEEP.%03d", DetectedID ), TargetSetUnit )
|
||||||
|
Task:SetDetection( Detection, TaskIndex )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if Task then
|
if Task then
|
||||||
self.Tasks[TaskIndex] = Task
|
self.Tasks[TaskIndex] = Task
|
||||||
Task:SetTargetZone( DetectedZone, DetectedSet:GetFirst():GetAltitude(), DetectedSet:GetFirst():GetHeading() )
|
Task:SetTargetZone( DetectedZone, DetectedItem.Coordinate.y, DetectedItem.Coordinate.Heading )
|
||||||
Task:SetDispatcher( self )
|
Task:SetDispatcher( self )
|
||||||
Mission:AddTask( Task )
|
Mission:AddTask( Task )
|
||||||
|
|
||||||
|
|||||||
@ -335,13 +335,29 @@ do -- TASK_A2G_SEAD
|
|||||||
|
|
||||||
function TASK_A2G_SEAD:UpdateTaskInfo()
|
function TASK_A2G_SEAD:UpdateTaskInfo()
|
||||||
|
|
||||||
local TargetCoordinate = self.TargetSetUnit:GetFirst():GetCoordinate()
|
|
||||||
|
local TargetCoordinate = self.Detection and self.Detection:GetDetectedItemCoordinate( self.DetectedItemIndex ) or self.TargetSetUnit:GetFirst():GetCoordinate()
|
||||||
self:SetInfo( "Coordinates", TargetCoordinate, 0 )
|
self:SetInfo( "Coordinates", TargetCoordinate, 0 )
|
||||||
|
|
||||||
self:SetInfo( "Threat", "[" .. string.rep( "■", self.TargetSetUnit:CalculateThreatLevelA2G() ) .. "]", 11 )
|
self:SetInfo( "Threat", "[" .. string.rep( "■", self.Detection and self.Detection:GetDetectedItemThreatLevel( self.DetectedItemIndex ) or self.TargetSetUnit:CalculateThreatLevelA2G() ) .. "]", 11 )
|
||||||
|
|
||||||
|
if self.Detection then
|
||||||
|
local DetectedItemsCount = self.TargetSetUnit:Count()
|
||||||
|
local ReportTypes = REPORT:New()
|
||||||
|
local TargetTypes = {}
|
||||||
|
for TargetUnitName, TargetUnit in pairs( self.TargetSetUnit:GetSet() ) do
|
||||||
|
local TargetType = self.Detection:GetDetectedUnitTypeName( TargetUnit )
|
||||||
|
if not TargetTypes[TargetType] then
|
||||||
|
TargetTypes[TargetType] = TargetType
|
||||||
|
ReportTypes:Add( TargetType )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
self:SetInfo( "Targets", string.format( "%d of %s", DetectedItemsCount, ReportTypes:Text( ", " ) ), 10 )
|
||||||
|
else
|
||||||
local DetectedItemsCount = self.TargetSetUnit:Count()
|
local DetectedItemsCount = self.TargetSetUnit:Count()
|
||||||
local DetectedItemsTypes = self.TargetSetUnit:GetTypeNames()
|
local DetectedItemsTypes = self.TargetSetUnit:GetTypeNames()
|
||||||
self:SetInfo( "Targets", string.format( "%d of %s", DetectedItemsCount, DetectedItemsTypes ), 10 )
|
self:SetInfo( "Targets", string.format( "%d of %s", DetectedItemsCount, DetectedItemsTypes ), 10 )
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -462,13 +478,30 @@ do -- TASK_A2G_BAI
|
|||||||
|
|
||||||
function TASK_A2G_BAI:UpdateTaskInfo()
|
function TASK_A2G_BAI:UpdateTaskInfo()
|
||||||
|
|
||||||
local TargetCoordinate = self.TargetSetUnit:GetFirst():GetCoordinate()
|
self:E({self.Detection, self.DetectedItemIndex})
|
||||||
|
|
||||||
|
local TargetCoordinate = self.Detection and self.Detection:GetDetectedItemCoordinate( self.DetectedItemIndex ) or self.TargetSetUnit:GetFirst():GetCoordinate()
|
||||||
self:SetInfo( "Coordinates", TargetCoordinate, 0 )
|
self:SetInfo( "Coordinates", TargetCoordinate, 0 )
|
||||||
|
|
||||||
self:SetInfo( "Threat", "[" .. string.rep( "■", self.TargetSetUnit:CalculateThreatLevelA2G() ) .. "]", 11 )
|
self:SetInfo( "Threat", "[" .. string.rep( "■", self.Detection and self.Detection:GetDetectedItemThreatLevel( self.DetectedItemIndex ) or self.TargetSetUnit:CalculateThreatLevelA2G() ) .. "]", 11 )
|
||||||
|
|
||||||
|
if self.Detection then
|
||||||
|
local DetectedItemsCount = self.TargetSetUnit:Count()
|
||||||
|
local ReportTypes = REPORT:New()
|
||||||
|
local TargetTypes = {}
|
||||||
|
for TargetUnitName, TargetUnit in pairs( self.TargetSetUnit:GetSet() ) do
|
||||||
|
local TargetType = self.Detection:GetDetectedUnitTypeName( TargetUnit )
|
||||||
|
if not TargetTypes[TargetType] then
|
||||||
|
TargetTypes[TargetType] = TargetType
|
||||||
|
ReportTypes:Add( TargetType )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
self:SetInfo( "Targets", string.format( "%d of %s", DetectedItemsCount, ReportTypes:Text( ", " ) ), 10 )
|
||||||
|
else
|
||||||
local DetectedItemsCount = self.TargetSetUnit:Count()
|
local DetectedItemsCount = self.TargetSetUnit:Count()
|
||||||
local DetectedItemsTypes = self.TargetSetUnit:GetTypeNames()
|
local DetectedItemsTypes = self.TargetSetUnit:GetTypeNames()
|
||||||
self:SetInfo( "Targets", string.format( "%d of %s", DetectedItemsCount, DetectedItemsTypes ), 10 )
|
self:SetInfo( "Targets", string.format( "%d of %s", DetectedItemsCount, DetectedItemsTypes ), 10 )
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -590,13 +623,28 @@ do -- TASK_A2G_CAS
|
|||||||
|
|
||||||
function TASK_A2G_CAS:UpdateTaskInfo()
|
function TASK_A2G_CAS:UpdateTaskInfo()
|
||||||
|
|
||||||
local TargetCoordinate = self.TargetSetUnit:GetFirst():GetCoordinate()
|
local TargetCoordinate = self.Detection and self.Detection:GetDetectedItemCoordinate( self.DetectedItemIndex ) or self.TargetSetUnit:GetFirst():GetCoordinate()
|
||||||
self:SetInfo( "Coordinates", TargetCoordinate, 0 )
|
self:SetInfo( "Coordinates", TargetCoordinate, 0 )
|
||||||
|
|
||||||
self:SetInfo( "Threat", "[" .. string.rep( "■", self.TargetSetUnit:CalculateThreatLevelA2G() ) .. "]", 11 )
|
self:SetInfo( "Threat", "[" .. string.rep( "■", self.Detection and self.Detection:GetDetectedItemThreatLevel( self.DetectedItemIndex ) or self.TargetSetUnit:CalculateThreatLevelA2G() ) .. "]", 11 )
|
||||||
|
|
||||||
|
if self.Detection then
|
||||||
|
local DetectedItemsCount = self.TargetSetUnit:Count()
|
||||||
|
local ReportTypes = REPORT:New()
|
||||||
|
local TargetTypes = {}
|
||||||
|
for TargetUnitName, TargetUnit in pairs( self.TargetSetUnit:GetSet() ) do
|
||||||
|
local TargetType = self.Detection:GetDetectedUnitTypeName( TargetUnit )
|
||||||
|
if not TargetTypes[TargetType] then
|
||||||
|
TargetTypes[TargetType] = TargetType
|
||||||
|
ReportTypes:Add( TargetType )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
self:SetInfo( "Targets", string.format( "%d of %s", DetectedItemsCount, ReportTypes:Text( ", " ) ), 10 )
|
||||||
|
else
|
||||||
local DetectedItemsCount = self.TargetSetUnit:Count()
|
local DetectedItemsCount = self.TargetSetUnit:Count()
|
||||||
local DetectedItemsTypes = self.TargetSetUnit:GetTypeNames()
|
local DetectedItemsTypes = self.TargetSetUnit:GetTypeNames()
|
||||||
self:SetInfo( "Targets", string.format( "%d of %s", DetectedItemsCount, DetectedItemsTypes ), 10 )
|
self:SetInfo( "Targets", string.format( "%d of %s", DetectedItemsCount, DetectedItemsTypes ), 10 )
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -121,8 +121,9 @@ do -- TASK_A2G_DISPATCHER
|
|||||||
-- Determine if the set has radar targets. If it does, construct a SEAD task.
|
-- Determine if the set has radar targets. If it does, construct a SEAD task.
|
||||||
local GroundUnitCount = DetectedSet:HasGroundUnits()
|
local GroundUnitCount = DetectedSet:HasGroundUnits()
|
||||||
local FriendliesNearBy = self.Detection:IsFriendliesNearBy( DetectedItem )
|
local FriendliesNearBy = self.Detection:IsFriendliesNearBy( DetectedItem )
|
||||||
|
local RadarCount = DetectedSet:HasSEAD()
|
||||||
|
|
||||||
if GroundUnitCount > 0 and FriendliesNearBy == true then
|
if RadarCount == 0 and GroundUnitCount > 0 and FriendliesNearBy == true then
|
||||||
|
|
||||||
-- Copy the Set
|
-- Copy the Set
|
||||||
local TargetSetUnit = SET_UNIT:New()
|
local TargetSetUnit = SET_UNIT:New()
|
||||||
@ -150,8 +151,9 @@ do -- TASK_A2G_DISPATCHER
|
|||||||
-- Determine if the set has radar targets. If it does, construct a SEAD task.
|
-- Determine if the set has radar targets. If it does, construct a SEAD task.
|
||||||
local GroundUnitCount = DetectedSet:HasGroundUnits()
|
local GroundUnitCount = DetectedSet:HasGroundUnits()
|
||||||
local FriendliesNearBy = self.Detection:IsFriendliesNearBy( DetectedItem )
|
local FriendliesNearBy = self.Detection:IsFriendliesNearBy( DetectedItem )
|
||||||
|
local RadarCount = DetectedSet:HasSEAD()
|
||||||
|
|
||||||
if GroundUnitCount > 0 and FriendliesNearBy == false then
|
if RadarCount == 0 and GroundUnitCount > 0 and FriendliesNearBy == false then
|
||||||
|
|
||||||
-- Copy the Set
|
-- Copy the Set
|
||||||
local TargetSetUnit = SET_UNIT:New()
|
local TargetSetUnit = SET_UNIT:New()
|
||||||
@ -164,6 +166,12 @@ do -- TASK_A2G_DISPATCHER
|
|||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function TASK_A2G_DISPATCHER:RemoveTask( TaskIndex )
|
||||||
|
self.Mission:RemoveTask( self.Tasks[TaskIndex] )
|
||||||
|
self.Tasks[TaskIndex] = nil
|
||||||
|
end
|
||||||
|
|
||||||
--- Evaluates the removal of the Task from the Mission.
|
--- Evaluates the removal of the Task from the Mission.
|
||||||
-- Can only occur when the DetectedItem is Changed AND the state of the Task is "Planned".
|
-- Can only occur when the DetectedItem is Changed AND the state of the Task is "Planned".
|
||||||
-- @param #TASK_A2G_DISPATCHER self
|
-- @param #TASK_A2G_DISPATCHER self
|
||||||
@ -177,8 +185,7 @@ do -- TASK_A2G_DISPATCHER
|
|||||||
if Task then
|
if Task then
|
||||||
if ( Task:IsStatePlanned() and DetectedItemChanged == true ) or Task:IsStateCancelled() then
|
if ( Task:IsStatePlanned() and DetectedItemChanged == true ) or Task:IsStateCancelled() then
|
||||||
--self:E( "Removing Tasking: " .. Task:GetTaskName() )
|
--self:E( "Removing Tasking: " .. Task:GetTaskName() )
|
||||||
Mission:RemoveTask( Task )
|
self:RemoveTask( TaskIndex )
|
||||||
self.Tasks[TaskIndex] = nil
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -213,6 +220,7 @@ do -- TASK_A2G_DISPATCHER
|
|||||||
for TaskGroupID, TaskGroup in pairs( self.SetGroup:GetSet() ) do
|
for TaskGroupID, TaskGroup in pairs( self.SetGroup:GetSet() ) do
|
||||||
Mission:GetCommandCenter():MessageToGroup( string.format( "Obsolete A2G task %s for %s removed.", TaskText, Mission:GetName() ), TaskGroup )
|
Mission:GetCommandCenter():MessageToGroup( string.format( "Obsolete A2G task %s for %s removed.", TaskText, Mission:GetName() ), TaskGroup )
|
||||||
end
|
end
|
||||||
|
Task = self:RemoveTask( TaskIndex )
|
||||||
Mission:RemoveTask( Task )
|
Mission:RemoveTask( Task )
|
||||||
self.Tasks[TaskIndex] = nil
|
self.Tasks[TaskIndex] = nil
|
||||||
end
|
end
|
||||||
@ -232,10 +240,11 @@ do -- TASK_A2G_DISPATCHER
|
|||||||
local TaskIndex = DetectedItem.Index
|
local TaskIndex = DetectedItem.Index
|
||||||
local DetectedItemChanged = DetectedItem.Changed
|
local DetectedItemChanged = DetectedItem.Changed
|
||||||
|
|
||||||
|
self:E( { DetectedItemChanged = DetectedItemChanged, DetectedItemID = DetectedItemID, TaskIndex = TaskIndex } )
|
||||||
|
|
||||||
local Task = self.Tasks[TaskIndex] -- Tasking.Task_A2G#TASK_A2G
|
local Task = self.Tasks[TaskIndex] -- Tasking.Task_A2G#TASK_A2G
|
||||||
|
|
||||||
if Task then
|
if Task then
|
||||||
|
|
||||||
-- If there is a Task and the task was assigned, then we check if the task was changed ... If it was, we need to reevaluate the targets.
|
-- If there is a Task and the task was assigned, then we check if the task was changed ... If it was, we need to reevaluate the targets.
|
||||||
if Task:IsStateAssigned() then
|
if Task:IsStateAssigned() then
|
||||||
if DetectedItemChanged == true then -- The detection has changed, thus a new TargetSet is to be evaluated and set
|
if DetectedItemChanged == true then -- The detection has changed, thus a new TargetSet is to be evaluated and set
|
||||||
@ -254,24 +263,24 @@ do -- TASK_A2G_DISPATCHER
|
|||||||
if TargetSetUnit then
|
if TargetSetUnit then
|
||||||
if Task:IsInstanceOf( TASK_A2G_CAS ) then
|
if Task:IsInstanceOf( TASK_A2G_CAS ) then
|
||||||
Task:SetTargetSetUnit( TargetSetUnit )
|
Task:SetTargetSetUnit( TargetSetUnit )
|
||||||
|
Task:SetDetection( Detection, TaskIndex )
|
||||||
Task:UpdateTaskInfo()
|
Task:UpdateTaskInfo()
|
||||||
TargetsReport:Add( Detection:GetChangeText( DetectedItem ) )
|
TargetsReport:Add( Detection:GetChangeText( DetectedItem ) )
|
||||||
else
|
else
|
||||||
Task:Cancel()
|
Task:Cancel()
|
||||||
Task = nil
|
Task = self:RemoveTask( TaskIndex )
|
||||||
self.Tasks[TaskIndex] = nil
|
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
local TargetSetUnit = self:EvaluateBAI( DetectedItem ) -- Returns a SetUnit if there are targets to be BAIed...
|
local TargetSetUnit = self:EvaluateBAI( DetectedItem ) -- Returns a SetUnit if there are targets to be BAIed...
|
||||||
if TargetSetUnit then
|
if TargetSetUnit then
|
||||||
if Task:IsInstanceOf( TASK_A2G_BAI ) then
|
if Task:IsInstanceOf( TASK_A2G_BAI ) then
|
||||||
Task:SetTargetSetUnit( TargetSetUnit )
|
Task:SetTargetSetUnit( TargetSetUnit )
|
||||||
|
Task:SetDetection( Detection, TaskIndex )
|
||||||
Task:UpdateTaskInfo()
|
Task:UpdateTaskInfo()
|
||||||
TargetsReport:Add( Detection:GetChangeText( DetectedItem ) )
|
TargetsReport:Add( Detection:GetChangeText( DetectedItem ) )
|
||||||
else
|
else
|
||||||
Task:Cancel()
|
Task:Cancel()
|
||||||
Task = nil
|
Task = self:RemoveTask( TaskIndex )
|
||||||
self.Tasks[TaskIndex] = nil
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -288,14 +297,56 @@ do -- TASK_A2G_DISPATCHER
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if Task then
|
||||||
Task = self:EvaluateRemoveTask( Mission, Task, TaskIndex, DetectedItemChanged ) -- Task will be removed if it is planned and changed.
|
if Task:IsStatePlanned() then
|
||||||
|
if DetectedItemChanged == true then -- The detection has changed, thus a new TargetSet is to be evaluated and set
|
||||||
|
if Task:IsInstanceOf( TASK_A2G_SEAD ) then
|
||||||
|
local TargetSetUnit = self:EvaluateSEAD( DetectedItem ) -- Returns a SetUnit if there are targets to be SEADed...
|
||||||
|
if TargetSetUnit then
|
||||||
|
Task:SetTargetSetUnit( TargetSetUnit )
|
||||||
|
Task:UpdateTaskInfo()
|
||||||
|
else
|
||||||
|
Task:Cancel()
|
||||||
|
Task = self:RemoveTask( TaskIndex )
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if Task:IsInstanceOf( TASK_A2G_CAS ) then
|
||||||
|
local TargetSetUnit = self:EvaluateCAS( DetectedItem ) -- Returns a SetUnit if there are targets to be CASed...
|
||||||
|
if TargetSetUnit then
|
||||||
|
Task:SetTargetSetUnit( TargetSetUnit )
|
||||||
|
Task:SetDetection( Detection, TaskIndex )
|
||||||
|
Task:UpdateTaskInfo()
|
||||||
|
else
|
||||||
|
Task:Cancel()
|
||||||
|
Task = self:RemoveTask( TaskIndex )
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if Task:IsInstanceOf( TASK_A2G_BAI ) then
|
||||||
|
local TargetSetUnit = self:EvaluateBAI( DetectedItem ) -- Returns a SetUnit if there are targets to be BAIed...
|
||||||
|
if TargetSetUnit then
|
||||||
|
Task:SetTargetSetUnit( TargetSetUnit )
|
||||||
|
Task:SetDetection( Detection, TaskIndex )
|
||||||
|
Task:UpdateTaskInfo()
|
||||||
|
else
|
||||||
|
Task:Cancel()
|
||||||
|
Task = self:RemoveTask( TaskIndex )
|
||||||
|
end
|
||||||
|
else
|
||||||
|
Task:Cancel()
|
||||||
|
Task = self:RemoveTask( TaskIndex )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- Evaluate SEAD
|
-- Evaluate SEAD
|
||||||
if not Task then
|
if not Task then
|
||||||
local TargetSetUnit = self:EvaluateSEAD( DetectedItem ) -- Returns a SetUnit if there are targets to be SEADed...
|
local TargetSetUnit = self:EvaluateSEAD( DetectedItem ) -- Returns a SetUnit if there are targets to be SEADed...
|
||||||
if TargetSetUnit then
|
if TargetSetUnit then
|
||||||
Task = TASK_A2G_SEAD:New( Mission, self.SetGroup, string.format( "SEAD.%03d", DetectedItemID ), TargetSetUnit )
|
Task = TASK_A2G_SEAD:New( Mission, self.SetGroup, string.format( "SEAD.%03d", DetectedItemID ), TargetSetUnit )
|
||||||
|
Task:SetDetection( Detection, TaskIndex )
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Evaluate CAS
|
-- Evaluate CAS
|
||||||
@ -303,6 +354,7 @@ do -- TASK_A2G_DISPATCHER
|
|||||||
local TargetSetUnit = self:EvaluateCAS( DetectedItem ) -- Returns a SetUnit if there are targets to be CASed...
|
local TargetSetUnit = self:EvaluateCAS( DetectedItem ) -- Returns a SetUnit if there are targets to be CASed...
|
||||||
if TargetSetUnit then
|
if TargetSetUnit then
|
||||||
Task = TASK_A2G_CAS:New( Mission, self.SetGroup, string.format( "CAS.%03d", DetectedItemID ), TargetSetUnit )
|
Task = TASK_A2G_CAS:New( Mission, self.SetGroup, string.format( "CAS.%03d", DetectedItemID ), TargetSetUnit )
|
||||||
|
Task:SetDetection( Detection, TaskIndex )
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Evaluate BAI
|
-- Evaluate BAI
|
||||||
@ -310,6 +362,7 @@ do -- TASK_A2G_DISPATCHER
|
|||||||
local TargetSetUnit = self:EvaluateBAI( DetectedItem, self.Mission:GetCommandCenter():GetPositionable():GetCoalition() ) -- Returns a SetUnit if there are targets to be BAIed...
|
local TargetSetUnit = self:EvaluateBAI( DetectedItem, self.Mission:GetCommandCenter():GetPositionable():GetCoalition() ) -- Returns a SetUnit if there are targets to be BAIed...
|
||||||
if TargetSetUnit then
|
if TargetSetUnit then
|
||||||
Task = TASK_A2G_BAI:New( Mission, self.SetGroup, string.format( "BAI.%03d", DetectedItemID ), TargetSetUnit )
|
Task = TASK_A2G_BAI:New( Mission, self.SetGroup, string.format( "BAI.%03d", DetectedItemID ), TargetSetUnit )
|
||||||
|
Task:SetDetection( Detection, TaskIndex )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -379,7 +379,7 @@ function CONTROLLABLE:SetTask( DCSTask, WaitTime )
|
|||||||
end
|
end
|
||||||
|
|
||||||
if not WaitTime or WaitTime == 0 then
|
if not WaitTime or WaitTime == 0 then
|
||||||
self:SetTask( DCSTask )
|
SetTask( DCSTask )
|
||||||
else
|
else
|
||||||
self.TaskScheduler:Schedule( self, SetTask, { DCSTask }, WaitTime )
|
self.TaskScheduler:Schedule( self, SetTask, { DCSTask }, WaitTime )
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user