Progress implementing teh SETTINGS class and coordinates per Controllable of the player

This commit is contained in:
FlightControl 2017-05-20 13:32:21 +02:00
parent 5fd4f96fc8
commit 96fdf72400
10 changed files with 119 additions and 87 deletions

View File

@ -154,19 +154,20 @@ do -- ACT_ROUTE
--- Get the routing text to be displayed. --- Get the routing text to be displayed.
-- The route mode determines the text displayed. -- The route mode determines the text displayed.
-- @param #ACT_ROUTE self -- @param #ACT_ROUTE self
-- @param Core.Point#COORDINATE FromCoordinate -- @param Wrapper.Controllable#CONTROLLABLE Controllable
-- @return #string -- @return #string
function ACT_ROUTE:GetRouteText( FromCoordinate ) function ACT_ROUTE:GetRouteText( Controllable )
local RouteText = "" local RouteText = ""
if self.Coordinate then if self.Coordinate then
RouteText = "Route to " .. self.Coordinate:ToString( FromCoordinate ) RouteText = "Route to " .. self.Coordinate:ToString( Controllable )
end end
if self.Zone then if self.Zone then
RouteText = "Route to " .. self.Zone:GetCoordinate():ToString( FromCoordinate ) local Coordinate = self.Zone:GetPointVec3( self.Altitude )
Coordinate:SetHeading( self.Heading )
RouteText = "Route to zone " .. Coordinate:ToString( Controllable )
end end
return RouteText return RouteText
@ -395,8 +396,12 @@ do -- ACT_ROUTE_ZONE
--- Set Zone --- Set Zone
-- @param #ACT_ROUTE_ZONE self -- @param #ACT_ROUTE_ZONE self
-- @param Core.Zone#ZONE_BASE Zone The Zone object where to route to. -- @param Core.Zone#ZONE_BASE Zone The Zone object where to route to.
function ACT_ROUTE_ZONE:SetZone( Zone ) -- @param #number Altitude
-- @param #number Heading
function ACT_ROUTE_ZONE:SetZone( Zone, Altitude, Heading ) -- R2.2 Added altitude and heading
self.Zone = Zone self.Zone = Zone
self.Altitude = Altitude
self.Heading = Heading
end end
--- Get Zone --- Get Zone
@ -429,9 +434,9 @@ do -- ACT_ROUTE_ZONE
-- @param #string From -- @param #string From
-- @param #string To -- @param #string To
function ACT_ROUTE_ZONE:onafterReport( ProcessUnit, From, Event, To ) function ACT_ROUTE_ZONE:onafterReport( ProcessUnit, From, Event, To )
self:E( { ProcessUnit = ProcessUnit } )
local TaskUnitCoordinate = ProcessUnit:GetCoordinate() local RouteText = self:GetRouteText( ProcessUnit )
local RouteText = self:GetRouteText( TaskUnitCoordinate )
self:Message( RouteText ) self:Message( RouteText )
end end

View File

@ -241,6 +241,7 @@ POINT_VEC3 = {
-- @extends Core.Point#COORDINATE -- @extends Core.Point#COORDINATE
--- # POINT_VEC2 class, extends @{Point#COORDINATE} --- # POINT_VEC2 class, extends @{Point#COORDINATE}
-- --
-- The @{Point#POINT_VEC2} class defines a 2D point in the simulator. The height coordinate (if needed) will be the land height + an optional added height specified. -- The @{Point#POINT_VEC2} class defines a 2D point in the simulator. The height coordinate (if needed) will be the land height + an optional added height specified.
@ -272,8 +273,6 @@ POINT_VEC2 = {
} }
do -- COORDINATE do -- COORDINATE
--- COORDINATE constructor. --- COORDINATE constructor.
@ -449,6 +448,8 @@ do -- COORDINATE
else else
return ' at ' .. UTILS.Round( UTILS.MetersToFeet( self.y ), -3 ) return ' at ' .. UTILS.Round( UTILS.MetersToFeet( self.y ), -3 )
end end
else
return ""
end end
end end
@ -720,7 +721,8 @@ do -- COORDINATE
local AngleRadians = self:GetAngleRadians( DirectionVec3 ) local AngleRadians = self:GetAngleRadians( DirectionVec3 )
local Distance = FromCoordinate:Get2DDistance( self ) local Distance = FromCoordinate:Get2DDistance( self )
local Altitude = self:GetAltitudeText() local Altitude = self:GetAltitudeText()
return "BRAA: " .. self:GetBRText( AngleRadians, Distance, Settings ) local AspectText = self:ToStringAspect( FromCoordinate )
return "BRAA: " .. self:GetBRText( AngleRadians, Distance, Settings ) .. ( AspectText and ", " .. AspectText or "" )
end end
--- Return a BULLS string from a COORDINATE to the BULLS of the coalition. --- Return a BULLS string from a COORDINATE to the BULLS of the coalition.
@ -791,24 +793,26 @@ do -- COORDINATE
-- * Uses default settings in COORDINATE. -- * Uses default settings in COORDINATE.
-- * Can be overridden if for a GROUP containing x clients, a menu was selected to override the default. -- * Can be overridden if for a GROUP containing x clients, a menu was selected to override the default.
-- @param #COORDINATE self -- @param #COORDINATE self
-- @param #COORDINATE FromCoordinate -- @param Wrapper.Controllable#CONTROLLABLE Controllable
-- @param Core.Settings#SETTINGS Settings -- @param Core.Settings#SETTINGS Settings
-- @return #string The coordinate Text in the configured coordinate system. -- @return #string The coordinate Text in the configured coordinate system.
function COORDINATE:ToString( FromCoordinate, Settings ) -- R2.2 function COORDINATE:ToString( Controllable, Settings ) -- R2.2
local Settings = Settings or _SETTINGS local Settings = Settings or _SETTINGS
if self:IsModeA2A() then local IsAir = Controllable and Controllable:IsAir() or false
if IsAir then
local Coordinate = Controllable:GetCoordinate()
Coordinate:SetModeA2A()
if Settings:IsA2A_BRA() then if Settings:IsA2A_BRA() then
return self:ToStringBRAA( FromCoordinate, Settings ) return self:ToStringBRAA( Coordinate, Settings )
end end
if Settings:IsA2A_BULLS() then if Settings:IsA2A_BULLS() then
return self:ToStringBULLS( FromCoordinate, Settings ) return self:ToStringBULLS( Coordinate, Settings )
end end
end else
if self:IsModeA2G() then
if Settings:IsA2G_LL() then if Settings:IsA2G_LL() then
return self:ToStringLL( Settings ) return self:ToStringLL( Settings )
end end

View File

@ -251,7 +251,7 @@ function ZONE_BASE:GetVec3( Height )
local Vec2 = self:GetVec2() local Vec2 = self:GetVec2()
local Vec3 = { x = Vec2.x, y = land.getHeight( self:GetVec2() ) + Height, z = Vec2.y } local Vec3 = { x = Vec2.x, y = Height and Height or land.getHeight( self:GetVec2() ), z = Vec2.y }
self:T2( { Vec3 } ) self:T2( { Vec3 } )

View File

@ -538,7 +538,7 @@ do -- DESIGNATE
for Index, DetectedItemData in pairs( DetectedItems ) do for Index, DetectedItemData in pairs( DetectedItems ) do
local Report = self.Detection:DetectedItemReportSummary( Index ) local Report = self.Detection:DetectedItemReportSummary( Index, AttackGroup )
DetectedReport:Add(" - " .. Report) DetectedReport:Add(" - " .. Report)
end end
@ -639,7 +639,7 @@ do -- DESIGNATE
for Index, DetectedItemData in pairs( DetectedItems ) do for Index, DetectedItemData in pairs( DetectedItems ) do
local Report = self.Detection:DetectedItemMenu( Index ) local Report = self.Detection:DetectedItemMenu( Index, AttackGroup )
if not self.Designating[Index] then if not self.Designating[Index] then
local DetectedMenu = MENU_GROUP:New( AttackGroup, Report, DesignateMenu ) local DetectedMenu = MENU_GROUP:New( AttackGroup, Report, DesignateMenu )

View File

@ -1359,7 +1359,7 @@ do -- DETECTION_BASE
-- @param #DETECTION_BASE self -- @param #DETECTION_BASE self
-- @param Index -- @param Index
-- @return #string -- @return #string
function DETECTION_BASE:DetectedItemMenu( Index ) function DETECTION_BASE:DetectedItemMenu( Index, AttackGroup )
self:F( Index ) self:F( Index )
return nil return nil
end end
@ -1369,7 +1369,7 @@ do -- DETECTION_BASE
-- @param #DETECTION_BASE self -- @param #DETECTION_BASE self
-- @param Index -- @param Index
-- @return #string -- @return #string
function DETECTION_BASE:DetectedItemReportSummary( Index ) function DETECTION_BASE:DetectedItemReportSummary( Index, AttackGroup )
self:F( Index ) self:F( Index )
return nil return nil
end end
@ -1377,7 +1377,7 @@ do -- DETECTION_BASE
--- Report detailed of a detectedion result. --- Report detailed of a detectedion result.
-- @param #DETECTION_BASE self -- @param #DETECTION_BASE self
-- @return #string -- @return #string
function DETECTION_BASE:DetectedReportDetailed() function DETECTION_BASE:DetectedReportDetailed( AttackGroup )
self:F() self:F()
return nil return nil
end end
@ -1574,7 +1574,7 @@ do -- DETECTION_UNITS
-- @param #DETECTION_UNITS self -- @param #DETECTION_UNITS self
-- @param Index -- @param Index
-- @return #string -- @return #string
function DETECTION_UNITS:DetectedItemMenu( Index ) function DETECTION_UNITS:DetectedItemMenu( Index, AttackGroup )
self:F( Index ) self:F( Index )
local DetectedItem = self:GetDetectedItem( Index ) local DetectedItem = self:GetDetectedItem( Index )
@ -1593,7 +1593,7 @@ do -- DETECTION_UNITS
self:T(DetectedItemUnit) self:T(DetectedItemUnit)
local DetectedItemCoordinate = DetectedItemUnit:GetCoordinate() local DetectedItemCoordinate = DetectedItemUnit:GetCoordinate()
local DetectedItemCoordText = DetectedItemCoordinate:ToString() local DetectedItemCoordText = DetectedItemCoordinate:ToString( AttackGroup )
ReportSummary = string.format( ReportSummary = string.format(
"%s - %s", "%s - %s",
@ -1612,7 +1612,7 @@ do -- DETECTION_UNITS
-- @param #DETECTION_UNITS self -- @param #DETECTION_UNITS self
-- @param Index -- @param Index
-- @return #string -- @return #string
function DETECTION_UNITS:DetectedItemReportSummary( Index ) function DETECTION_UNITS:DetectedItemReportSummary( Index, AttackGroup )
self:F( { Index, self.DetectedItems } ) self:F( { Index, self.DetectedItems } )
local DetectedItem = self:GetDetectedItem( Index ) local DetectedItem = self:GetDetectedItem( Index )
@ -1654,7 +1654,7 @@ do -- DETECTION_UNITS
end end
local DetectedItemCoordinate = DetectedItemUnit:GetCoordinate() local DetectedItemCoordinate = DetectedItemUnit:GetCoordinate()
local DetectedItemCoordText = DetectedItemCoordinate:ToString() local DetectedItemCoordText = DetectedItemCoordinate:ToString( AttackGroup )
local ThreatLevelA2G = DetectedItemUnit:GetThreatLevel( DetectedItem ) local ThreatLevelA2G = DetectedItemUnit:GetThreatLevel( DetectedItem )
@ -1679,13 +1679,13 @@ do -- DETECTION_UNITS
--- Report detailed of a detection result. --- Report detailed of a detection result.
-- @param #DETECTION_UNITS self -- @param #DETECTION_UNITS self
-- @return #string -- @return #string
function DETECTION_UNITS:DetectedReportDetailed() function DETECTION_UNITS:DetectedReportDetailed( AttackGroup )
self:F() self:F()
local Report = REPORT:New( "Detected units:" ) local Report = REPORT:New( "Detected units:" )
for DetectedItemID, DetectedItem in pairs( self.DetectedItems ) do for DetectedItemID, DetectedItem in pairs( self.DetectedItems ) do
local DetectedItem = DetectedItem -- #DETECTION_BASE.DetectedItem local DetectedItem = DetectedItem -- #DETECTION_BASE.DetectedItem
local ReportSummary = self:DetectedItemReportSummary( DetectedItemID ) local ReportSummary = self:DetectedItemReportSummary( DetectedItemID, AttackGroup )
Report:Add( ReportSummary ) Report:Add( ReportSummary )
end end
@ -1844,7 +1844,7 @@ do -- DETECTION_TYPES
-- @param #DETECTION_TYPES self -- @param #DETECTION_TYPES self
-- @param Index -- @param Index
-- @return #string -- @return #string
function DETECTION_TYPES:DetectedItemMenu( DetectedTypeName ) function DETECTION_TYPES:DetectedItemMenu( DetectedTypeName, AttackGroup )
self:F( DetectedTypeName ) self:F( DetectedTypeName )
local DetectedItem = self:GetDetectedItem( DetectedTypeName ) local DetectedItem = self:GetDetectedItem( DetectedTypeName )
@ -1857,7 +1857,7 @@ do -- DETECTION_TYPES
local DetectedItemUnit = DetectedSet:GetFirst() local DetectedItemUnit = DetectedSet:GetFirst()
local DetectedItemCoordinate = DetectedItemUnit:GetCoordinate() local DetectedItemCoordinate = DetectedItemUnit:GetCoordinate()
local DetectedItemCoordText = DetectedItemCoordinate:ToString() local DetectedItemCoordText = DetectedItemCoordinate:ToString( AttackGroup )
self:E( { DetectedItemID, self:E( { DetectedItemID,
DetectedItemCoordText } ) DetectedItemCoordText } )
@ -1877,7 +1877,7 @@ do -- DETECTION_TYPES
-- @param #DETECTION_TYPES self -- @param #DETECTION_TYPES self
-- @param Index -- @param Index
-- @return #string -- @return #string
function DETECTION_TYPES:DetectedItemReportSummary( DetectedTypeName ) function DETECTION_TYPES:DetectedItemReportSummary( DetectedTypeName, AttackGroup )
self:F( DetectedTypeName ) self:F( DetectedTypeName )
local DetectedItem = self:GetDetectedItem( DetectedTypeName ) local DetectedItem = self:GetDetectedItem( DetectedTypeName )
@ -1894,7 +1894,7 @@ do -- DETECTION_TYPES
local DetectedItemUnit = DetectedSet:GetFirst() local DetectedItemUnit = DetectedSet:GetFirst()
local DetectedItemCoordinate = DetectedItemUnit:GetCoordinate() local DetectedItemCoordinate = DetectedItemUnit:GetCoordinate()
local DetectedItemCoordText = DetectedItemCoordinate:ToString() local DetectedItemCoordText = DetectedItemCoordinate:ToString( AttackGroup )
local ReportSummary = string.format( local ReportSummary = string.format(
"%s - %s - Threat:[%s](%2d) - %2d of %s", "%s - %s - Threat:[%s](%2d) - %2d of %s",
@ -1914,13 +1914,13 @@ do -- DETECTION_TYPES
--- Report detailed of a detection result. --- Report detailed of a detection result.
-- @param #DETECTION_TYPES self -- @param #DETECTION_TYPES self
-- @return #string -- @return #string
function DETECTION_TYPES:DetectedReportDetailed() function DETECTION_TYPES:DetectedReportDetailed( AttackGroup )
self:F() self:F()
local Report = REPORT:New( "Detected types:" ) local Report = REPORT:New( "Detected types:" )
for DetectedItemTypeName, DetectedItem in pairs( self.DetectedItems ) do for DetectedItemTypeName, DetectedItem in pairs( self.DetectedItems ) do
local DetectedItem = DetectedItem -- #DETECTION_BASE.DetectedItem local DetectedItem = DetectedItem -- #DETECTION_BASE.DetectedItem
local ReportSummary = self:DetectedItemReportSummary( DetectedItemTypeName ) local ReportSummary = self:DetectedItemReportSummary( DetectedItemTypeName, AttackGroup )
Report:Add( ReportSummary ) Report:Add( ReportSummary )
end end
@ -2001,7 +2001,7 @@ do -- DETECTION_AREAS
-- @param #DETECTION_AREAS self -- @param #DETECTION_AREAS self
-- @param Index -- @param Index
-- @return #string -- @return #string
function DETECTION_AREAS:DetectedItemMenu( Index ) function DETECTION_AREAS:DetectedItemMenu( Index, AttackGroup )
self:F( Index ) self:F( Index )
local DetectedItem = self:GetDetectedItem( Index ) local DetectedItem = self:GetDetectedItem( Index )
@ -2013,7 +2013,7 @@ do -- DETECTION_AREAS
local DetectedZone = self:GetDetectedItemZone( Index ) local DetectedZone = self:GetDetectedItemZone( Index )
local DetectedItemCoordinate = DetectedZone:GetCoordinate() local DetectedItemCoordinate = DetectedZone:GetCoordinate()
local DetectedItemCoordText = DetectedItemCoordinate:ToString() local DetectedItemCoordText = DetectedItemCoordinate:ToString( AttackGroup )
local ReportSummary = string.format( local ReportSummary = string.format(
"%s - %s", "%s - %s",
@ -2031,7 +2031,7 @@ do -- DETECTION_AREAS
-- @param #DETECTION_AREAS self -- @param #DETECTION_AREAS self
-- @param Index -- @param Index
-- @return #string -- @return #string
function DETECTION_AREAS:DetectedItemReportSummary( Index ) function DETECTION_AREAS:DetectedItemReportSummary( Index, AttackGroup )
self:F( Index ) self:F( Index )
local DetectedItem = self:GetDetectedItem( Index ) local DetectedItem = self:GetDetectedItem( Index )
@ -2043,7 +2043,7 @@ do -- DETECTION_AREAS
local DetectedZone = self:GetDetectedItemZone( Index ) local DetectedZone = self:GetDetectedItemZone( Index )
local DetectedItemCoordinate = DetectedZone:GetCoordinate() local DetectedItemCoordinate = DetectedZone:GetCoordinate()
local DetectedItemCoordText = DetectedItemCoordinate:ToString() local DetectedItemCoordText = DetectedItemCoordinate:ToString( AttackGroup )
local ThreatLevelA2G = self:GetTreatLevelA2G( DetectedItem ) local ThreatLevelA2G = self:GetTreatLevelA2G( DetectedItem )
local DetectedItemsCount = DetectedSet:Count() local DetectedItemsCount = DetectedSet:Count()
@ -2068,13 +2068,13 @@ do -- DETECTION_AREAS
--- Report detailed of a detection result. --- Report detailed of a detection result.
-- @param #DETECTION_AREAS self -- @param #DETECTION_AREAS self
-- @return #string -- @return #string
function DETECTION_AREAS:DetectedReportDetailed() --R2.1 Fixed missing report function DETECTION_AREAS:DetectedReportDetailed( AttackGroup) --R2.1 Fixed missing report
self:F() self:F()
local Report = REPORT:New( "Detected areas:" ) local Report = REPORT:New( "Detected areas:" )
for DetectedItemIndex, DetectedItem in pairs( self.DetectedItems ) do for DetectedItemIndex, DetectedItem in pairs( self.DetectedItems ) do
local DetectedItem = DetectedItem -- #DETECTION_BASE.DetectedItem local DetectedItem = DetectedItem -- #DETECTION_BASE.DetectedItem
local ReportSummary = self:DetectedItemReportSummary( DetectedItemIndex ) local ReportSummary = self:DetectedItemReportSummary( DetectedItemIndex, AttackGroup )
Report:Add( ReportSummary ) Report:Add( ReportSummary )
end end

View File

@ -1164,7 +1164,7 @@ function ESCORT:_ReportTargetsScheduler()
self:E( { DetectedItemID, DetectedItem } ) self:E( { DetectedItemID, DetectedItem } )
-- Remove the sub menus of the Attack menu of the Escort for the EscortGroup. -- Remove the sub menus of the Attack menu of the Escort for the EscortGroup.
local DetectedItemReportSummary = self.Detection:DetectedItemReportSummary( DetectedItemID ) local DetectedItemReportSummary = self.Detection:DetectedItemReportSummary( DetectedItemID, EscortGroupData )
if ClientEscortGroupName == EscortGroupName then if ClientEscortGroupName == EscortGroupName then

View File

@ -243,6 +243,8 @@ do -- TASK_A2A
-- @param Wrapper.Unit#UNIT TaskUnit -- @param Wrapper.Unit#UNIT TaskUnit
function TASK_A2A:SetTargetCoordinate( TargetCoordinate, TaskUnit ) function TASK_A2A:SetTargetCoordinate( TargetCoordinate, TaskUnit )
TargetCoordinate:SetModeA2A()
local ProcessUnit = self:GetUnitProcess( TaskUnit ) local ProcessUnit = self:GetUnitProcess( TaskUnit )
local ActRouteTarget = ProcessUnit:GetProcess( "Engaging", "RouteToTargetPoint" ) -- Actions.Act_Route#ACT_ROUTE_POINT local ActRouteTarget = ProcessUnit:GetProcess( "Engaging", "RouteToTargetPoint" ) -- Actions.Act_Route#ACT_ROUTE_POINT
@ -265,12 +267,12 @@ do -- TASK_A2A
--- @param #TASK_A2A self --- @param #TASK_A2A self
-- @param Core.Zone#ZONE_BASE TargetZone The Zone object where the Target is located on the map. -- @param Core.Zone#ZONE_BASE TargetZone The Zone object where the Target is located on the map.
-- @param Wrapper.Unit#UNIT TaskUnit -- @param Wrapper.Unit#UNIT TaskUnit
function TASK_A2A:SetTargetZone( TargetZone, TaskUnit ) function TASK_A2A:SetTargetZone( TargetZone, Altitude, Heading, TaskUnit )
local ProcessUnit = self:GetUnitProcess( TaskUnit ) local ProcessUnit = self:GetUnitProcess( TaskUnit )
local ActRouteTarget = ProcessUnit:GetProcess( "Engaging", "RouteToTargetZone" ) -- Actions.Act_Route#ACT_ROUTE_ZONE local ActRouteTarget = ProcessUnit:GetProcess( "Engaging", "RouteToTargetZone" ) -- Actions.Act_Route#ACT_ROUTE_ZONE
ActRouteTarget:SetZone( TargetZone ) ActRouteTarget:SetZone( TargetZone, Altitude, Heading )
end end
@ -363,17 +365,20 @@ do -- TASK_INTERCEPT
--TODO: Add BR, Altitude, type of planes... --TODO: Add BR, Altitude, type of planes...
local TargetCoord = TargetSetUnit:GetFirst():GetCoordinate()
local TargetPositionText = TargetCoord:ToString()
local TargetThreatLevel = TargetSetUnit:CalculateThreatLevelA2G()
self:SetBriefing( self:SetBriefing(
TaskBriefing or TaskBriefing or
"Intercept incoming intruders.\n" .. "Intercept incoming intruders.\n"
"Last Known Coordinates: " .. TargetPositionText .. "\n" ..
"Threat Level: [" .. string.rep( "", TargetThreatLevel ) .. "]"
) )
local TargetCoordinate = TargetSetUnit:GetFirst():GetCoordinate()
TargetCoordinate:SetModeA2A()
self:SetInfo( "Coordinates", TargetCoordinate )
self:SetInfo( "ThreatLevel", "[" .. string.rep( "", TargetSetUnit:CalculateThreatLevelA2G() ) .. "]" )
local DetectedItemsCount = TargetSetUnit:Count()
local DetectedItemsTypes = TargetSetUnit:GetTypeNames()
self:SetInfo( "Targets", string.format( "%d of %s", DetectedItemsCount, DetectedItemsTypes ) )
return self return self
end end

View File

@ -184,18 +184,8 @@ do -- TASK_A2A_DISPATCHER
if Task then if Task then
self.Tasks[DetectedID] = Task self.Tasks[DetectedID] = Task
Task:SetTargetZone( DetectedZone ) Task:SetTargetZone( DetectedZone, DetectedSet:GetFirst():GetAltitude(), DetectedSet:GetFirst():GetHeading() )
Task:SetDispatcher( self ) Task:SetDispatcher( self )
Task:SetInfo( "ThreatLevel", "[" .. string.rep( "", DetectedSet:CalculateThreatLevelA2G() ) .. "]" )
local DetectedItemsCount = DetectedSet:Count()
local DetectedItemsTypes = DetectedSet:GetTypeNames()
Task:SetInfo( "Targets", string.format( "%d of %s", DetectedItemsCount, DetectedItemsTypes ) )
local Coordinate = Detection:GetDetectedItemCoordinate( DetectedIndex )
Coordinate:SetModeA2A()
Task:SetInfo( "Coordinates", Coordinate )
Task:SetInfo( "Object", DetectedSet:GetFirst() )
Mission:AddTask( Task ) Mission:AddTask( Task )
else else
self:E("This should not happen") self:E("This should not happen")

View File

@ -375,17 +375,20 @@ do -- TASK_SEAD
Mission:AddTask( self ) Mission:AddTask( self )
local TargetCoord = TargetSetUnit:GetFirst():GetCoordinate()
local TargetPositionText = TargetCoord:ToString()
local TargetThreatLevel = TargetSetUnit:CalculateThreatLevelA2G()
self:SetBriefing( self:SetBriefing(
TaskBriefing or TaskBriefing or
"Execute a Suppression of Enemy Air Defenses.\n" .. "Execute a Suppression of Enemy Air Defenses.\n"
"Initial Coordinates: " .. TargetPositionText .. "\n" ..
"Threat Level: [" .. string.rep( "", TargetThreatLevel ) .. "]"
) )
local TargetCoordinate = TargetSetUnit:GetFirst():GetCoordinate()
TargetCoordinate:SetModeA2G()
self:SetInfo( "Coordinates", TargetCoordinate )
self:SetInfo( "ThreatLevel", "[" .. string.rep( "", TargetSetUnit:CalculateThreatLevelA2G() ) .. "]" )
local DetectedItemsCount = TargetSetUnit:Count()
local DetectedItemsTypes = TargetSetUnit:GetTypeNames()
self:SetInfo( "Targets", string.format( "%d of %s", DetectedItemsCount, DetectedItemsTypes ) )
return self return self
end end
@ -415,17 +418,20 @@ do -- TASK_BAI
Mission:AddTask( self ) Mission:AddTask( self )
local TargetCoord = TargetSetUnit:GetFirst():GetCoordinate()
local TargetPositionText = TargetCoord:ToString()
local TargetThreatLevel = TargetSetUnit:CalculateThreatLevelA2G()
self:SetBriefing( self:SetBriefing(
TaskBriefing or TaskBriefing or
"Execute a Battlefield Air Interdiction of a group of enemy targets.\n" .. "Execute a Battlefield Air Interdiction of a group of enemy targets.\n"
"Initial Coordinates: " .. TargetPositionText .. "\n" ..
"Threat Level: [" .. string.rep( "", TargetThreatLevel ) .. "]"
) )
local TargetCoordinate = TargetSetUnit:GetFirst():GetCoordinate()
TargetCoordinate:SetModeA2G()
self:SetInfo( "Coordinates", TargetCoordinate )
self:SetInfo( "ThreatLevel", "[" .. string.rep( "", TargetSetUnit:CalculateThreatLevelA2G() ) .. "]" )
local DetectedItemsCount = TargetSetUnit:Count()
local DetectedItemsTypes = TargetSetUnit:GetTypeNames()
self:SetInfo( "Targets", string.format( "%d of %s", DetectedItemsCount, DetectedItemsTypes ) )
return self return self
end end
@ -455,18 +461,21 @@ do -- TASK_CAS
Mission:AddTask( self ) Mission:AddTask( self )
local TargetCoord = TargetSetUnit:GetFirst():GetCoordinate()
local TargetPositionText = TargetCoord:ToString()
local TargetThreatLevel = TargetSetUnit:CalculateThreatLevelA2G()
self:SetBriefing( self:SetBriefing(
TaskBriefing or TaskBriefing or
"Execute a Close Air Support for a group of enemy targets.\n" .. "Execute a Close Air Support for a group of enemy targets.\n" ..
"Beware of friendlies at the vicinity!\n" .. "Beware of friendlies at the vicinity!\n"
"Initial Coordinates: " .. TargetPositionText .. "\n" ..
"Threat Level: [" .. string.rep( "", TargetThreatLevel ) .. "]"
) )
local TargetCoordinate = TargetSetUnit:GetFirst():GetCoordinate()
TargetCoordinate:SetModeA2G()
self:SetInfo( "Coordinates", TargetCoordinate )
self:SetInfo( "ThreatLevel", "[" .. string.rep( "", TargetSetUnit:CalculateThreatLevelA2G() ) .. "]" )
local DetectedItemsCount = TargetSetUnit:Count()
local DetectedItemsTypes = TargetSetUnit:GetTypeNames()
self:SetInfo( "Targets", string.format( "%d of %s", DetectedItemsCount, DetectedItemsTypes ) )
return self return self
end end

View File

@ -485,6 +485,25 @@ function GROUP:GetPointVec2()
return nil return nil
end end
--- Returns a COORDINATE object indicating the point of the first UNIT of the GROUP within the mission.
-- @param Wrapper.Group#GROUP self
-- @return Core.Point#COORDINATE The COORDINATE of the GROUP.
-- @return #nil The POSITIONABLE is not existing or alive.
function GROUP:GetCoordinate()
self:F2( self.PositionableName )
local FirstUnit = self:GetUnit(1)
if FirstUnit then
local FirstUnitCoordinate = FirstUnit:GetCoordinate()
self:T3(FirstUnitCoordinate)
return FirstUnitCoordinate
end
return nil
end
--- Returns a random @{DCSTypes#Vec3} vector (point in 3D of the UNIT within the mission) within a range around the first UNIT of the GROUP. --- Returns a random @{DCSTypes#Vec3} vector (point in 3D of the UNIT within the mission) within a range around the first UNIT of the GROUP.
-- @param #GROUP self -- @param #GROUP self
-- @param #number Radius -- @param #number Radius