mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
SEAD working correctly + readjust test missions not to loose anything.
This commit is contained in:
@@ -268,7 +268,7 @@ end
|
|||||||
function TASK_DISPATCHER:EvaluateTaskSEAD( Mission, DetectedArea )
|
function TASK_DISPATCHER:EvaluateTaskSEAD( Mission, DetectedArea )
|
||||||
self:F( { Mission, DetectedArea.AreaID } )
|
self:F( { Mission, DetectedArea.AreaID } )
|
||||||
|
|
||||||
MT = {}
|
local MT = {}
|
||||||
|
|
||||||
local DetectedSet = DetectedArea.Set
|
local DetectedSet = DetectedArea.Set
|
||||||
local DetectedZone = DetectedArea.Zone
|
local DetectedZone = DetectedArea.Zone
|
||||||
@@ -280,14 +280,15 @@ function TASK_DISPATCHER:EvaluateTaskSEAD( Mission, DetectedArea )
|
|||||||
if RadarCount > 0 then
|
if RadarCount > 0 then
|
||||||
if not DetectedArea.Tasks.SEADTask then
|
if not DetectedArea.Tasks.SEADTask then
|
||||||
-- Here we're doing something advanced... We're copying the DetectedSet, but making a new Set only with Radar units in it.
|
-- Here we're doing something advanced... We're copying the DetectedSet, but making a new Set only with Radar units in it.
|
||||||
local TargetSetUnit = SET_UNIT:New()
|
local TargetSetUnit = SET_UNIT:New():SetDatabase( DetectedSet )
|
||||||
TargetSetUnit:CopyFilter( DetectedSet )
|
|
||||||
TargetSetUnit:FilterHasRadar( Unit.RadarType.AS )
|
TargetSetUnit:FilterHasRadar( Unit.RadarType.AS )
|
||||||
self:E( TargetSetUnit.Filter )
|
self:E( TargetSetUnit.Filter )
|
||||||
TargetSetUnit:FilterStart()
|
TargetSetUnit:FilterStart()
|
||||||
local Task = TASK_SEAD:New( Mission, TargetSetUnit, DetectedZone )
|
|
||||||
|
local MenuText = "SEAD " .. self:GetDetectedItemsText( TargetSetUnit )
|
||||||
|
MT[#MT+1] = " - " .. MenuText
|
||||||
|
local Task = TASK_SEAD:New( Mission, MenuText, TargetSetUnit, DetectedZone )
|
||||||
self.Mission:AddTask( Task )
|
self.Mission:AddTask( Task )
|
||||||
MT[#MT+1] = "SEAD"
|
|
||||||
DetectedArea.Tasks.SEADTask = Task
|
DetectedArea.Tasks.SEADTask = Task
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@@ -296,10 +297,10 @@ function TASK_DISPATCHER:EvaluateTaskSEAD( Mission, DetectedArea )
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if MT ~= {} then
|
if #MT > 0 then
|
||||||
return table.concat( MT, "," )
|
return table.concat( MT, "," )
|
||||||
else
|
else
|
||||||
return ""
|
return nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -311,7 +312,7 @@ end
|
|||||||
function TASK_DISPATCHER:EvaluateTaskCAS( Mission, DetectedArea )
|
function TASK_DISPATCHER:EvaluateTaskCAS( Mission, DetectedArea )
|
||||||
self:F2( { Mission, DetectedArea.AreaID } )
|
self:F2( { Mission, DetectedArea.AreaID } )
|
||||||
|
|
||||||
MT = {}
|
local MT = {}
|
||||||
|
|
||||||
local DetectedSet = DetectedArea.Set
|
local DetectedSet = DetectedArea.Set
|
||||||
local DetectedZone = DetectedArea.Zone
|
local DetectedZone = DetectedArea.Zone
|
||||||
@@ -321,9 +322,10 @@ function TASK_DISPATCHER:EvaluateTaskCAS( Mission, DetectedArea )
|
|||||||
DetectedArea.Tasks = DetectedArea.Tasks or {}
|
DetectedArea.Tasks = DetectedArea.Tasks or {}
|
||||||
if GroundUnitCount > 0 then
|
if GroundUnitCount > 0 then
|
||||||
if not DetectedArea.Tasks.CASTask then
|
if not DetectedArea.Tasks.CASTask then
|
||||||
local Task = TASK_CAS:New( Mission, DetectedSet , DetectedZone )
|
local MenuText = "CAS " .. self:GetDetectedItemsText( DetectedSet )
|
||||||
|
MT[#MT+1] = " -" .. MenuText
|
||||||
|
local Task = TASK_CAS:New( Mission, MenuText, DetectedSet , DetectedZone )
|
||||||
self.Mission:AddTask( Task )
|
self.Mission:AddTask( Task )
|
||||||
MT[#MT+1] = "CAS"
|
|
||||||
DetectedArea.Tasks.CASTask = Task
|
DetectedArea.Tasks.CASTask = Task
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@@ -332,17 +334,17 @@ function TASK_DISPATCHER:EvaluateTaskCAS( Mission, DetectedArea )
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if MT ~= {} then
|
if #MT > 0 then
|
||||||
return table.concat( MT, "," )
|
return table.concat( MT, "," )
|
||||||
else
|
else
|
||||||
return ""
|
return nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Creates a string of the detected items in a @{Detection}.
|
--- Creates a string of the detected items in a @{Detection}.
|
||||||
-- @param #DETECTION_MANAGER self
|
-- @param #TASK_DISPATCHER self
|
||||||
-- @param Set#SET_UNIT DetectedSet The detected Set created by the @{Detection#DETECTION_BASE} object.
|
-- @param Set#SET_UNIT DetectedSet The detected Set created by the @{Detection#DETECTION_BASE} object.
|
||||||
-- @return #DETECTION_MANAGER self
|
-- @return #string The text
|
||||||
function TASK_DISPATCHER:GetDetectedItemsText( DetectedSet )
|
function TASK_DISPATCHER:GetDetectedItemsText( DetectedSet )
|
||||||
self:F2()
|
self:F2()
|
||||||
|
|
||||||
@@ -384,28 +386,33 @@ function TASK_DISPATCHER:ProcessDetected( TaskGroup, Detection )
|
|||||||
|
|
||||||
self:E( TaskGroup )
|
self:E( TaskGroup )
|
||||||
|
|
||||||
|
|
||||||
--- First we need to the detected targets.
|
--- First we need to the detected targets.
|
||||||
for DetectedAreaID, DetectedAreaData in ipairs( Detection:GetDetectedAreas() ) do
|
for DetectedAreaID, DetectedAreaData in ipairs( Detection:GetDetectedAreas() ) do
|
||||||
|
|
||||||
|
local MT = {} -- Message Text
|
||||||
|
|
||||||
local DetectedArea = DetectedAreaData -- Detection#DETECTION_UNITGROUPS.DetectedArea
|
local DetectedArea = DetectedAreaData -- Detection#DETECTION_UNITGROUPS.DetectedArea
|
||||||
local TargetSetUnit = DetectedArea.Set
|
local TargetSetUnit = DetectedArea.Set
|
||||||
local MT = {} -- Message Text
|
self:E( "Targets in DetectedArea " .. DetectedArea.AreaID .. ":" .. TargetSetUnit:Count() )
|
||||||
local UnitTypes = {}
|
TargetSetUnit:Flush()
|
||||||
local TargetZone = DetectedArea.Zone -- Zone#ZONE_BASE
|
local TargetZone = DetectedArea.Zone -- Zone#ZONE_BASE
|
||||||
Detection:FlareDetectedZones()
|
Detection:FlareDetectedZones()
|
||||||
Detection:FlareDetectedUnits()
|
Detection:FlareDetectedUnits()
|
||||||
|
|
||||||
for DetectedUnitID, DetectedUnitData in pairs( TargetSetUnit:GetSet() ) do
|
-- Evaluate SEAD Task
|
||||||
|
local SEADText = self:EvaluateTaskSEAD( self.Mission, DetectedArea )
|
||||||
local TargetUnit = DetectedUnitData -- Unit#UNIT
|
if SEADText then
|
||||||
self:E( TargetUnit )
|
MT[#MT+1] = SEADText
|
||||||
local TargetUnitName = TargetUnit:GetName()
|
end
|
||||||
local TargetUnitType = TargetUnit:GetTypeName()
|
|
||||||
|
-- Evaluate CAS task
|
||||||
MT[#MT+1] = self:EvaluateTaskSEAD( self.Mission, DetectedArea )
|
local CASText = self:EvaluateTaskCAS( self.Mission, DetectedArea )
|
||||||
MT[#MT+1] = self:EvaluateTaskCAS( self.Mission, DetectedArea )
|
if CASText then
|
||||||
|
MT[#MT+1] = CASText
|
||||||
end
|
end
|
||||||
|
|
||||||
DetectedMsg[#DetectedMsg+1] = " - Group #" .. DetectedAreaID .. ": " .. self:GetDetectedItemsText( TargetSetUnit ) .. ". " .. table.concat( MT, "," ) .. " tasks addded."
|
DetectedMsg[#DetectedMsg+1] = "- Group #" .. DetectedAreaID .. ":" .. table.concat( MT, "," )
|
||||||
end
|
end
|
||||||
|
|
||||||
self.CommandCenter:MessageToGroup( "Reporting tasks for target groups:\n" .. table.concat( DetectedMsg, "\n" ), self:GetReportDisplayTime(), TaskGroup )
|
self.CommandCenter:MessageToGroup( "Reporting tasks for target groups:\n" .. table.concat( DetectedMsg, "\n" ), self:GetReportDisplayTime(), TaskGroup )
|
||||||
|
|||||||
@@ -1,17 +0,0 @@
|
|||||||
--- @module Task2Workflow
|
|
||||||
|
|
||||||
--- The TASK2_WORKFLOW class
|
|
||||||
-- @type TASK2_WORKFLOW
|
|
||||||
-- @extends Base#BASE
|
|
||||||
TASK2_WORKFLOW = {
|
|
||||||
ClassName = "TASK2_WORKFLOW",
|
|
||||||
}
|
|
||||||
|
|
||||||
function TASK2_WORKFLOW:New( Client, Task )
|
|
||||||
|
|
||||||
-- Inherits from BASE
|
|
||||||
local self = BASE:Inherit( self, BASE:New() )
|
|
||||||
|
|
||||||
Task:Assign( Client )
|
|
||||||
|
|
||||||
end
|
|
||||||
@@ -76,6 +76,7 @@ end
|
|||||||
function PROCESS_SEAD:OnHitTarget( Fsm, Event, From, To, Event )
|
function PROCESS_SEAD:OnHitTarget( Fsm, Event, From, To, Event )
|
||||||
|
|
||||||
MESSAGE:New( "TargetCount = " .. self.TargetSetUnit:Count(), 15 ):ToAll()
|
MESSAGE:New( "TargetCount = " .. self.TargetSetUnit:Count(), 15 ):ToAll()
|
||||||
|
self.TargetSetUnit:Flush()
|
||||||
if self.TargetSetUnit:Count() > 0 then
|
if self.TargetSetUnit:Count() > 0 then
|
||||||
self:NextEvent( Fsm.MoreTargets )
|
self:NextEvent( Fsm.MoreTargets )
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -351,12 +351,16 @@ end
|
|||||||
|
|
||||||
--- Copies the Filter criteria from a given Set (for rebuilding a new Set based on an existing Set).
|
--- Copies the Filter criteria from a given Set (for rebuilding a new Set based on an existing Set).
|
||||||
-- @param #SET_BASE self
|
-- @param #SET_BASE self
|
||||||
-- @param #SET_BASE OtherSet
|
-- @param #SET_BASE BaseSet
|
||||||
-- @return #SET_BASE
|
-- @return #SET_BASE
|
||||||
function SET_BASE:CopyFilter( OtherSet )
|
function SET_BASE:SetDatabase( BaseSet )
|
||||||
|
|
||||||
local OtherFilter = routines.utils.deepCopy( OtherSet.Filter )
|
-- Copy the filter criteria of the BaseSet
|
||||||
|
local OtherFilter = routines.utils.deepCopy( BaseSet.Filter )
|
||||||
self.Filter = OtherFilter
|
self.Filter = OtherFilter
|
||||||
|
|
||||||
|
-- Now base the new Set on the BaseSet
|
||||||
|
self.Database = BaseSet:GetSet()
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -630,7 +634,7 @@ function SET_BASE:Flush()
|
|||||||
for ObjectName, Object in pairs( self.Set ) do
|
for ObjectName, Object in pairs( self.Set ) do
|
||||||
ObjectNames = ObjectNames .. ObjectName .. ", "
|
ObjectNames = ObjectNames .. ObjectName .. ", "
|
||||||
end
|
end
|
||||||
self:T( { "Objects in Set:", ObjectNames } )
|
self:E( { "Objects in Set:", ObjectNames } )
|
||||||
|
|
||||||
return ObjectNames
|
return ObjectNames
|
||||||
end
|
end
|
||||||
@@ -1455,7 +1459,9 @@ function SET_UNIT:IsIncludeObject( MUnit )
|
|||||||
for RadarTypeID, RadarType in pairs( self.Filter.RadarTypes ) do
|
for RadarTypeID, RadarType in pairs( self.Filter.RadarTypes ) do
|
||||||
self:E( { "Radar:", RadarType } )
|
self:E( { "Radar:", RadarType } )
|
||||||
if MUnit:HasSensors( Unit.SensorType.RADAR, RadarType ) == true then
|
if MUnit:HasSensors( Unit.SensorType.RADAR, RadarType ) == true then
|
||||||
self:E( "RADAR Found" )
|
if MUnit:GetRadar() == true then -- This call is necessary to evaluate the SEAD capability.
|
||||||
|
self:E( "RADAR Found" )
|
||||||
|
end
|
||||||
MUnitRadar = true
|
MUnitRadar = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -158,6 +158,7 @@ function TASK_BASE:_EventAssignUnit( Event )
|
|||||||
local TaskPlayerName = TaskUnit:GetPlayerName()
|
local TaskPlayerName = TaskUnit:GetPlayerName()
|
||||||
if TaskPlayerName ~= nil then
|
if TaskPlayerName ~= nil then
|
||||||
if not self:HasStateMachine( TaskUnit ) then
|
if not self:HasStateMachine( TaskUnit ) then
|
||||||
|
self.TaskUnit = TaskUnit
|
||||||
self:AssignToUnit( TaskUnit )
|
self:AssignToUnit( TaskUnit )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -332,6 +333,22 @@ function TASK_BASE:SetBriefing( TaskBriefing )
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Adds a score for the TASK to be achieved.
|
||||||
|
-- @param #TASK_BASE self
|
||||||
|
-- @param #string TaskStatus is the status of the TASK when the score needs to be given.
|
||||||
|
-- @param #string ScoreText is a text describing the score that is given according the status.
|
||||||
|
-- @param #number Score is a number providing the score of the status.
|
||||||
|
-- @return #TASK_BASE self
|
||||||
|
function TASK_BASE:AddScore( TaskStatus, ScoreText, Score )
|
||||||
|
self:F2( { TaskStatus, ScoreText, Score } )
|
||||||
|
|
||||||
|
self.Scores[TaskStatus] = self.Scores[TaskStatus] or {}
|
||||||
|
self.Scores[TaskStatus].ScoreText = ScoreText
|
||||||
|
self.Scores[TaskStatus].Score = Score
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
--- StateMachine callback function for a TASK
|
--- StateMachine callback function for a TASK
|
||||||
-- @param #TASK_BASE self
|
-- @param #TASK_BASE self
|
||||||
-- @param StateMachine#STATEMACHINE_TASK Fsm
|
-- @param StateMachine#STATEMACHINE_TASK Fsm
|
||||||
@@ -344,6 +361,13 @@ function TASK_BASE:OnStateChange( Fsm, Event, From, To )
|
|||||||
MESSAGE:New( "Task " .. self.TaskName .. " : " .. Event .. " changed to state " .. To, 15 ):ToAll()
|
MESSAGE:New( "Task " .. self.TaskName .. " : " .. Event .. " changed to state " .. To, 15 ):ToAll()
|
||||||
self:SetState( self, "State", To )
|
self:SetState( self, "State", To )
|
||||||
|
|
||||||
|
if self.Scores[To] then
|
||||||
|
local Scoring = self:GetScoring()
|
||||||
|
if Scoring then
|
||||||
|
Scoring:_AddMissionTaskScore( self.Mission, self.TaskUnit, self.Scores[To].ScoreText, self.Scores[To].Score )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -13,8 +13,8 @@ TASK_CAS = {
|
|||||||
-- @param Set#SET_UNIT UnitSetTargets
|
-- @param Set#SET_UNIT UnitSetTargets
|
||||||
-- @param Zone#ZONE_BASE TargetZone
|
-- @param Zone#ZONE_BASE TargetZone
|
||||||
-- @return #TASK_CAS self
|
-- @return #TASK_CAS self
|
||||||
function TASK_CAS:New( Mission, TargetSetUnit, TargetZone )
|
function TASK_CAS:New( Mission, MenuText, TargetSetUnit, TargetZone )
|
||||||
local self = BASE:Inherit( self, TASK_BASE:New( Mission, "CAS Attack", "CAS", "A2G" ) )
|
local self = BASE:Inherit( self, TASK_BASE:New( Mission, MenuText, "CAS", "A2G" ) )
|
||||||
self:F()
|
self:F()
|
||||||
|
|
||||||
self.TargetSetUnit = TargetSetUnit
|
self.TargetSetUnit = TargetSetUnit
|
||||||
|
|||||||
@@ -13,8 +13,8 @@ TASK_SEAD = {
|
|||||||
-- @param Set#SET_UNIT UnitSetTargets
|
-- @param Set#SET_UNIT UnitSetTargets
|
||||||
-- @param Zone#ZONE_BASE TargetZone
|
-- @param Zone#ZONE_BASE TargetZone
|
||||||
-- @return #TASK_SEAD self
|
-- @return #TASK_SEAD self
|
||||||
function TASK_SEAD:New( Mission, TargetSetUnit, TargetZone )
|
function TASK_SEAD:New( Mission, MenuText, TargetSetUnit, TargetZone )
|
||||||
local self = BASE:Inherit( self, TASK_BASE:New( Mission, "SEAD Attack", "SEAD", "A2G" ) )
|
local self = BASE:Inherit( self, TASK_BASE:New( Mission, MenuText, "SEAD", "A2G" ) )
|
||||||
self:F()
|
self:F()
|
||||||
|
|
||||||
self.TargetSetUnit = TargetSetUnit
|
self.TargetSetUnit = TargetSetUnit
|
||||||
@@ -36,7 +36,7 @@ end
|
|||||||
-- @return #TASK_SEAD self
|
-- @return #TASK_SEAD self
|
||||||
function TASK_SEAD:AssignToUnit( TaskUnit )
|
function TASK_SEAD:AssignToUnit( TaskUnit )
|
||||||
self:F( TaskUnit:GetName() )
|
self:F( TaskUnit:GetName() )
|
||||||
|
|
||||||
local ProcessAssign = self:AddProcess( TaskUnit, PROCESS_ASSIGN:New( self, TaskUnit, self.TaskBriefing ) )
|
local ProcessAssign = self:AddProcess( TaskUnit, PROCESS_ASSIGN:New( self, TaskUnit, self.TaskBriefing ) )
|
||||||
local ProcessRoute = self:AddProcess( TaskUnit, PROCESS_ROUTE:New( self, TaskUnit, self.TargetZone ) )
|
local ProcessRoute = self:AddProcess( TaskUnit, PROCESS_ROUTE:New( self, TaskUnit, self.TargetZone ) )
|
||||||
local ProcessSEAD = self:AddProcess( TaskUnit, PROCESS_SEAD:New( self, TaskUnit, self.TargetSetUnit ) )
|
local ProcessSEAD = self:AddProcess( TaskUnit, PROCESS_SEAD:New( self, TaskUnit, self.TargetSetUnit ) )
|
||||||
@@ -65,6 +65,7 @@ function TASK_SEAD:AssignToUnit( TaskUnit )
|
|||||||
ProcessRoute:AddScore( "Failed", "failed to destroy a radar", -100 )
|
ProcessRoute:AddScore( "Failed", "failed to destroy a radar", -100 )
|
||||||
ProcessSEAD:AddScore( "Destroy", "destroyed a radar", 25 )
|
ProcessSEAD:AddScore( "Destroy", "destroyed a radar", 25 )
|
||||||
ProcessSEAD:AddScore( "Failed", "failed to destroy a radar", -100 )
|
ProcessSEAD:AddScore( "Failed", "failed to destroy a radar", -100 )
|
||||||
|
self:AddScore( "Success", "Destroyed all target radars", 250 )
|
||||||
|
|
||||||
Process:Next()
|
Process:Next()
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
env.info( '*** MOOSE DYNAMIC INCLUDE START *** ' )
|
env.info( '*** MOOSE DYNAMIC INCLUDE START *** ' )
|
||||||
env.info( 'Moose Generation Timestamp: 20160710_0833' )
|
env.info( 'Moose Generation Timestamp: 20160713_0623' )
|
||||||
|
|
||||||
local base = _G
|
local base = _G
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
env.info( '*** MOOSE DYNAMIC INCLUDE START *** ' )
|
env.info( '*** MOOSE DYNAMIC INCLUDE START *** ' )
|
||||||
env.info( 'Moose Generation Timestamp: 20160710_0833' )
|
env.info( 'Moose Generation Timestamp: 20160713_0623' )
|
||||||
|
|
||||||
local base = _G
|
local base = _G
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user