mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2026-08-25 21:36:25 +00:00
Fixes
* Added a maximum markings per designated target group. So not all FACs are occupied. * Optimized the designation report. Move the horizontal line. * Ensured in DESIGNATE that when targets are ordered to be smoke or designated, that this also will happen. Was issue with the scheduler, which got garbage collected before actually being executed, resulting in an obsolete schedule. * Fixed the tasking, coordinates are now updated when enquiring a task report.
This commit is contained in:
@@ -210,7 +210,8 @@ SCHEDULER = {
|
|||||||
-- @return #SCHEDULER self.
|
-- @return #SCHEDULER self.
|
||||||
-- @return #number The ScheduleID of the planned schedule.
|
-- @return #number The ScheduleID of the planned schedule.
|
||||||
function SCHEDULER:New( SchedulerObject, SchedulerFunction, SchedulerArguments, Start, Repeat, RandomizeFactor, Stop )
|
function SCHEDULER:New( SchedulerObject, SchedulerFunction, SchedulerArguments, Start, Repeat, RandomizeFactor, Stop )
|
||||||
local self = BASE:Inherit( self, BASE:New() )
|
|
||||||
|
local self = BASE:Inherit( self, BASE:New() ) -- #SCHEDULER
|
||||||
self:F2( { Start, Repeat, RandomizeFactor, Stop } )
|
self:F2( { Start, Repeat, RandomizeFactor, Stop } )
|
||||||
|
|
||||||
local ScheduleID = nil
|
local ScheduleID = nil
|
||||||
|
|||||||
@@ -390,6 +390,7 @@ do -- DESIGNATE
|
|||||||
self:SetThreatLevelPrioritization( false ) -- self.ThreatLevelPrioritization, default is threat level priorization off
|
self:SetThreatLevelPrioritization( false ) -- self.ThreatLevelPrioritization, default is threat level priorization off
|
||||||
self:SetMaximumDesignations( 5 ) -- Sets the maximum designations. The default is 5 designations.
|
self:SetMaximumDesignations( 5 ) -- Sets the maximum designations. The default is 5 designations.
|
||||||
self:SetMaximumDistanceDesignations( 12000 ) -- Sets the maximum distance on which designations can be accepted. The default is 8000 meters.
|
self:SetMaximumDistanceDesignations( 12000 ) -- Sets the maximum distance on which designations can be accepted. The default is 8000 meters.
|
||||||
|
self:SetMaximumMarkings( 2 ) -- Per target group, a maximum of 2 markings will be made by default.
|
||||||
|
|
||||||
self.LaserCodesUsed = {}
|
self.LaserCodesUsed = {}
|
||||||
|
|
||||||
@@ -397,6 +398,8 @@ do -- DESIGNATE
|
|||||||
|
|
||||||
self:__Detect( -15 )
|
self:__Detect( -15 )
|
||||||
|
|
||||||
|
self.MarkScheduler = SCHEDULER:New( self )
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -460,6 +463,16 @@ do -- DESIGNATE
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Set the maximum amount of markings FACs will do, per designated target group.
|
||||||
|
-- @param #DESIGNATE self
|
||||||
|
-- @param #number MaximumMarkings Maximum markings FACs will do, per designated target group.
|
||||||
|
-- @return #DESIGNATE
|
||||||
|
function DESIGNATE:SetMaximumMarkings( MaximumMarkings )
|
||||||
|
self.MaximumMarkings = MaximumMarkings
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Set an array of possible laser codes.
|
--- Set an array of possible laser codes.
|
||||||
-- Each new lase will select a code from this table.
|
-- Each new lase will select a code from this table.
|
||||||
-- @param #DESIGNATE self
|
-- @param #DESIGNATE self
|
||||||
@@ -693,8 +706,8 @@ do -- DESIGNATE
|
|||||||
local DetectedItem = DetectedItems[DesignateIndex]
|
local DetectedItem = DetectedItems[DesignateIndex]
|
||||||
if DetectedItem then
|
if DetectedItem then
|
||||||
local Report = self.Detection:DetectedItemReportSummary( DesignateIndex, AttackGroup ):Text( ", " )
|
local Report = self.Detection:DetectedItemReportSummary( DesignateIndex, AttackGroup ):Text( ", " )
|
||||||
DetectedReport:Add( " - " .. Report )
|
|
||||||
DetectedReport:Add( string.rep( "-", 140 ) )
|
DetectedReport:Add( string.rep( "-", 140 ) )
|
||||||
|
DetectedReport:Add( " - " .. Report )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -910,6 +923,8 @@ do -- DESIGNATE
|
|||||||
|
|
||||||
local TargetSetUnit = self.Detection:GetDetectedSet( Index )
|
local TargetSetUnit = self.Detection:GetDetectedSet( Index )
|
||||||
|
|
||||||
|
local MarkedCount = 0
|
||||||
|
|
||||||
TargetSetUnit:Flush()
|
TargetSetUnit:Flush()
|
||||||
|
|
||||||
--self:F( { Recces = self.Recces } )
|
--self:F( { Recces = self.Recces } )
|
||||||
@@ -927,30 +942,47 @@ do -- DESIGNATE
|
|||||||
TargetSetUnit:ForEachUnitPerThreatLevel( 10, 0,
|
TargetSetUnit:ForEachUnitPerThreatLevel( 10, 0,
|
||||||
--- @param Wrapper.Unit#UNIT SmokeUnit
|
--- @param Wrapper.Unit#UNIT SmokeUnit
|
||||||
function( TargetUnit )
|
function( TargetUnit )
|
||||||
|
|
||||||
self:F( { TargetUnit = TargetUnit:GetName() } )
|
self:F( { TargetUnit = TargetUnit:GetName() } )
|
||||||
|
|
||||||
|
if MarkedCount < self.MaximumMarkings then
|
||||||
|
|
||||||
if TargetUnit:IsAlive() then
|
if TargetUnit:IsAlive() then
|
||||||
|
|
||||||
local Recce = self.Recces[TargetUnit]
|
local Recce = self.Recces[TargetUnit]
|
||||||
|
|
||||||
if not Recce then
|
if not Recce then
|
||||||
|
|
||||||
|
self:E( "Lasing..." )
|
||||||
self.RecceSet:Flush()
|
self.RecceSet:Flush()
|
||||||
|
|
||||||
for RecceGroupID, RecceGroup in pairs( self.RecceSet:GetSet() ) do
|
for RecceGroupID, RecceGroup in pairs( self.RecceSet:GetSet() ) do
|
||||||
for UnitID, UnitData in pairs( RecceGroup:GetUnits() or {} ) do
|
for UnitID, UnitData in pairs( RecceGroup:GetUnits() or {} ) do
|
||||||
|
|
||||||
local RecceUnit = UnitData -- Wrapper.Unit#UNIT
|
local RecceUnit = UnitData -- Wrapper.Unit#UNIT
|
||||||
local RecceUnitDesc = RecceUnit:GetDesc()
|
local RecceUnitDesc = RecceUnit:GetDesc()
|
||||||
--self:F( { RecceUnit = RecceUnit:GetName(), RecceDescription = RecceUnitDesc } )
|
--self:F( { RecceUnit = RecceUnit:GetName(), RecceDescription = RecceUnitDesc } )
|
||||||
|
|
||||||
if RecceUnit:IsLasing() == false then
|
if RecceUnit:IsLasing() == false then
|
||||||
--self:F( { IsDetected = RecceUnit:IsDetected( TargetUnit ), IsLOS = RecceUnit:IsLOS( TargetUnit ) } )
|
--self:F( { IsDetected = RecceUnit:IsDetected( TargetUnit ), IsLOS = RecceUnit:IsLOS( TargetUnit ) } )
|
||||||
|
|
||||||
if RecceUnit:IsDetected( TargetUnit ) and RecceUnit:IsLOS( TargetUnit ) then
|
if RecceUnit:IsDetected( TargetUnit ) and RecceUnit:IsLOS( TargetUnit ) then
|
||||||
|
|
||||||
local LaserCodeIndex = math.random( 1, #self.LaserCodes )
|
local LaserCodeIndex = math.random( 1, #self.LaserCodes )
|
||||||
local LaserCode = self.LaserCodes[LaserCodeIndex]
|
local LaserCode = self.LaserCodes[LaserCodeIndex]
|
||||||
--self:F( { LaserCode = LaserCode, LaserCodeUsed = self.LaserCodesUsed[LaserCode] } )
|
--self:F( { LaserCode = LaserCode, LaserCodeUsed = self.LaserCodesUsed[LaserCode] } )
|
||||||
|
|
||||||
if not self.LaserCodesUsed[LaserCode] then
|
if not self.LaserCodesUsed[LaserCode] then
|
||||||
|
|
||||||
self.LaserCodesUsed[LaserCode] = LaserCodeIndex
|
self.LaserCodesUsed[LaserCode] = LaserCodeIndex
|
||||||
local Spot = RecceUnit:LaseUnit( TargetUnit, LaserCode, Duration )
|
local Spot = RecceUnit:LaseUnit( TargetUnit, LaserCode, Duration )
|
||||||
local AttackSet = self.AttackSet
|
local AttackSet = self.AttackSet
|
||||||
|
|
||||||
function Spot:OnAfterDestroyed( From, Event, To )
|
function Spot:OnAfterDestroyed( From, Event, To )
|
||||||
self:E( "Destroyed Message" )
|
self:E( "Destroyed Message" )
|
||||||
self.Recce:MessageToSetGroup( "Target " .. TargetUnit:GetTypeName() .. " destroyed. " .. TargetSetUnit:Count() .. " targets left.", 5, AttackSet )
|
self.Recce:MessageToSetGroup( "Target " .. TargetUnit:GetTypeName() .. " destroyed. " .. TargetSetUnit:Count() .. " targets left.", 5, AttackSet )
|
||||||
end
|
end
|
||||||
|
|
||||||
self.Recces[TargetUnit] = RecceUnit
|
self.Recces[TargetUnit] = RecceUnit
|
||||||
RecceUnit:MessageToSetGroup( "Marking " .. TargetUnit:GetTypeName() .. " with laser " .. RecceUnit:GetSpot().LaserCode .. " for " .. Duration .. "s.", 5, self.AttackSet )
|
RecceUnit:MessageToSetGroup( "Marking " .. TargetUnit:GetTypeName() .. " with laser " .. RecceUnit:GetSpot().LaserCode .. " for " .. Duration .. "s.", 5, self.AttackSet )
|
||||||
-- OK. We have assigned for the Recce a TargetUnit. We can exit the function.
|
-- OK. We have assigned for the Recce a TargetUnit. We can exit the function.
|
||||||
@@ -961,21 +993,28 @@ do -- DESIGNATE
|
|||||||
end
|
end
|
||||||
else
|
else
|
||||||
-- The Recce is lasing, but the Target is not detected or within LOS. So stop lasing and send a report.
|
-- The Recce is lasing, but the Target is not detected or within LOS. So stop lasing and send a report.
|
||||||
|
|
||||||
if not RecceUnit:IsDetected( TargetUnit ) or not RecceUnit:IsLOS( TargetUnit ) then
|
if not RecceUnit:IsDetected( TargetUnit ) or not RecceUnit:IsLOS( TargetUnit ) then
|
||||||
|
|
||||||
local Recce = self.Recces[TargetUnit] -- Wrapper.Unit#UNIT
|
local Recce = self.Recces[TargetUnit] -- Wrapper.Unit#UNIT
|
||||||
|
|
||||||
if Recce then
|
if Recce then
|
||||||
Recce:LaseOff()
|
Recce:LaseOff()
|
||||||
Recce:MessageToSetGroup( "Target " .. TargetUnit:GetTypeName() "out of LOS. Cancelling lase!", 5, self.AttackSet )
|
Recce:MessageToSetGroup( "Target " .. TargetUnit:GetTypeName() "out of LOS. Cancelling lase!", 5, self.AttackSet )
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
MarkedCount = MarkedCount + 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
MarkedCount = MarkedCount + 1
|
||||||
Recce:MessageToSetGroup( "Marking " .. TargetUnit:GetTypeName() .. " with laser " .. Recce.LaserCode .. ".", 5, self.AttackSet )
|
Recce:MessageToSetGroup( "Marking " .. TargetUnit:GetTypeName() .. " with laser " .. Recce.LaserCode .. ".", 5, self.AttackSet )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
)
|
)
|
||||||
|
|
||||||
self:__Lasing( 30, Index, Duration )
|
self:__Lasing( 30, Index, Duration )
|
||||||
@@ -1021,19 +1060,29 @@ do -- DESIGNATE
|
|||||||
local TargetSetUnit = self.Detection:GetDetectedSet( Index )
|
local TargetSetUnit = self.Detection:GetDetectedSet( Index )
|
||||||
local TargetSetUnitCount = TargetSetUnit:Count()
|
local TargetSetUnitCount = TargetSetUnit:Count()
|
||||||
|
|
||||||
TargetSetUnit:ForEachUnit(
|
local MarkedCount = 0
|
||||||
|
|
||||||
|
TargetSetUnit:ForEachUnitPerThreatLevel( 10, 0,
|
||||||
--- @param Wrapper.Unit#UNIT SmokeUnit
|
--- @param Wrapper.Unit#UNIT SmokeUnit
|
||||||
function( SmokeUnit )
|
function( SmokeUnit )
|
||||||
self:E("In procedure")
|
|
||||||
if math.random( 1, TargetSetUnitCount ) == math.random( 1, TargetSetUnitCount ) then
|
if MarkedCount < self.MaximumMarkings then
|
||||||
|
|
||||||
|
MarkedCount = MarkedCount + 1
|
||||||
|
|
||||||
|
self:E( "Smoking ..." )
|
||||||
|
|
||||||
local RecceGroup = self.RecceSet:FindNearestGroupFromPointVec2(SmokeUnit:GetPointVec2())
|
local RecceGroup = self.RecceSet:FindNearestGroupFromPointVec2(SmokeUnit:GetPointVec2())
|
||||||
local RecceUnit = RecceGroup:GetUnit( 1 )
|
local RecceUnit = RecceGroup:GetUnit( 1 )
|
||||||
|
|
||||||
if RecceUnit then
|
if RecceUnit then
|
||||||
|
|
||||||
RecceUnit:MessageToSetGroup( "Smoking " .. SmokeUnit:GetTypeName() .. ".", 5, self.AttackSet )
|
RecceUnit:MessageToSetGroup( "Smoking " .. SmokeUnit:GetTypeName() .. ".", 5, self.AttackSet )
|
||||||
SCHEDULER:New( nil,
|
|
||||||
|
self.MarkScheduler:Schedule( self,
|
||||||
function()
|
function()
|
||||||
if SmokeUnit:IsAlive() then
|
if SmokeUnit:IsAlive() then
|
||||||
SmokeUnit:Smoke( Color, 50 )
|
SmokeUnit:Smoke( Color, 50, 2 )
|
||||||
end
|
end
|
||||||
self:Done( Index )
|
self:Done( Index )
|
||||||
end, {}, math.random( 5, 20 )
|
end, {}, math.random( 5, 20 )
|
||||||
@@ -1059,7 +1108,7 @@ do -- DESIGNATE
|
|||||||
local RecceUnit = RecceGroup:GetUnit( 1 )
|
local RecceUnit = RecceGroup:GetUnit( 1 )
|
||||||
if RecceUnit then
|
if RecceUnit then
|
||||||
RecceUnit:MessageToSetGroup( "Illuminating " .. TargetUnit:GetTypeName() .. ".", 5, self.AttackSet )
|
RecceUnit:MessageToSetGroup( "Illuminating " .. TargetUnit:GetTypeName() .. ".", 5, self.AttackSet )
|
||||||
SCHEDULER:New( self,
|
self.MarkScheduler:Schedule( self,
|
||||||
function()
|
function()
|
||||||
if TargetUnit:IsAlive() then
|
if TargetUnit:IsAlive() then
|
||||||
TargetUnit:GetPointVec3():AddY(300):IlluminationBomb()
|
TargetUnit:GetPointVec3():AddY(300):IlluminationBomb()
|
||||||
|
|||||||
@@ -1382,6 +1382,7 @@ end
|
|||||||
-- @return #string
|
-- @return #string
|
||||||
function TASK:ReportOverview( ReportGroup ) --R2.1 fixed report. Now nicely formatted and contains the info required.
|
function TASK:ReportOverview( ReportGroup ) --R2.1 fixed report. Now nicely formatted and contains the info required.
|
||||||
|
|
||||||
|
self:UpdateTaskInfo()
|
||||||
|
|
||||||
-- List the name of the Task.
|
-- List the name of the Task.
|
||||||
local TaskName = self:GetName()
|
local TaskName = self:GetName()
|
||||||
@@ -1479,6 +1480,8 @@ end
|
|||||||
-- @return #string
|
-- @return #string
|
||||||
function TASK:ReportDetails( ReportGroup )
|
function TASK:ReportDetails( ReportGroup )
|
||||||
|
|
||||||
|
self:UpdateTaskInfo()
|
||||||
|
|
||||||
local Report = REPORT:New():SetIndent( 3 )
|
local Report = REPORT:New():SetIndent( 3 )
|
||||||
|
|
||||||
-- List the name of the Task.
|
-- List the name of the Task.
|
||||||
|
|||||||
@@ -765,11 +765,18 @@ end
|
|||||||
|
|
||||||
--- Smoke the POSITIONABLE.
|
--- Smoke the POSITIONABLE.
|
||||||
-- @param #POSITIONABLE self
|
-- @param #POSITIONABLE self
|
||||||
function POSITIONABLE:Smoke( SmokeColor, Range )
|
-- @param Utilities.Utils#SMOKECOLOR SmokeColor The color to smoke to positionable.
|
||||||
|
-- @param #number Range The range in meters to randomize the smoking around the positionable.
|
||||||
|
-- @param #number AddHeight The height in meters to add to the altitude of the positionable.
|
||||||
|
function POSITIONABLE:Smoke( SmokeColor, Range, AddHeight )
|
||||||
self:F2()
|
self:F2()
|
||||||
if Range then
|
if Range then
|
||||||
trigger.action.smoke( self:GetRandomVec3( Range ), SmokeColor )
|
local Vec3 = self:GetRandomVec3( Range )
|
||||||
|
Vec3.y = Vec3.y + AddHeight or 0
|
||||||
|
trigger.action.smoke( Vec3, SmokeColor )
|
||||||
else
|
else
|
||||||
|
local Vec3 = self:GetVec3()
|
||||||
|
Vec3.y = Vec3.y + AddHeight or 0
|
||||||
trigger.action.smoke( self:GetVec3(), SmokeColor )
|
trigger.action.smoke( self:GetVec3(), SmokeColor )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user