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:
parent
ce19e3bc03
commit
86b283c7f0
@ -268,7 +268,7 @@ end
|
||||
function TASK_DISPATCHER:EvaluateTaskSEAD( Mission, DetectedArea )
|
||||
self:F( { Mission, DetectedArea.AreaID } )
|
||||
|
||||
MT = {}
|
||||
local MT = {}
|
||||
|
||||
local DetectedSet = DetectedArea.Set
|
||||
local DetectedZone = DetectedArea.Zone
|
||||
@ -280,14 +280,15 @@ function TASK_DISPATCHER:EvaluateTaskSEAD( Mission, DetectedArea )
|
||||
if RadarCount > 0 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.
|
||||
local TargetSetUnit = SET_UNIT:New()
|
||||
TargetSetUnit:CopyFilter( DetectedSet )
|
||||
local TargetSetUnit = SET_UNIT:New():SetDatabase( DetectedSet )
|
||||
TargetSetUnit:FilterHasRadar( Unit.RadarType.AS )
|
||||
self:E( TargetSetUnit.Filter )
|
||||
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 )
|
||||
MT[#MT+1] = "SEAD"
|
||||
DetectedArea.Tasks.SEADTask = Task
|
||||
end
|
||||
else
|
||||
@ -296,10 +297,10 @@ function TASK_DISPATCHER:EvaluateTaskSEAD( Mission, DetectedArea )
|
||||
end
|
||||
end
|
||||
|
||||
if MT ~= {} then
|
||||
if #MT > 0 then
|
||||
return table.concat( MT, "," )
|
||||
else
|
||||
return ""
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
@ -311,7 +312,7 @@ end
|
||||
function TASK_DISPATCHER:EvaluateTaskCAS( Mission, DetectedArea )
|
||||
self:F2( { Mission, DetectedArea.AreaID } )
|
||||
|
||||
MT = {}
|
||||
local MT = {}
|
||||
|
||||
local DetectedSet = DetectedArea.Set
|
||||
local DetectedZone = DetectedArea.Zone
|
||||
@ -321,9 +322,10 @@ function TASK_DISPATCHER:EvaluateTaskCAS( Mission, DetectedArea )
|
||||
DetectedArea.Tasks = DetectedArea.Tasks or {}
|
||||
if GroundUnitCount > 0 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 )
|
||||
MT[#MT+1] = "CAS"
|
||||
DetectedArea.Tasks.CASTask = Task
|
||||
end
|
||||
else
|
||||
@ -332,17 +334,17 @@ function TASK_DISPATCHER:EvaluateTaskCAS( Mission, DetectedArea )
|
||||
end
|
||||
end
|
||||
|
||||
if MT ~= {} then
|
||||
if #MT > 0 then
|
||||
return table.concat( MT, "," )
|
||||
else
|
||||
return ""
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
--- 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.
|
||||
-- @return #DETECTION_MANAGER self
|
||||
-- @return #string The text
|
||||
function TASK_DISPATCHER:GetDetectedItemsText( DetectedSet )
|
||||
self:F2()
|
||||
|
||||
@ -384,28 +386,33 @@ function TASK_DISPATCHER:ProcessDetected( TaskGroup, Detection )
|
||||
|
||||
self:E( TaskGroup )
|
||||
|
||||
|
||||
--- First we need to the detected targets.
|
||||
for DetectedAreaID, DetectedAreaData in ipairs( Detection:GetDetectedAreas() ) do
|
||||
|
||||
local MT = {} -- Message Text
|
||||
|
||||
local DetectedArea = DetectedAreaData -- Detection#DETECTION_UNITGROUPS.DetectedArea
|
||||
local TargetSetUnit = DetectedArea.Set
|
||||
local MT = {} -- Message Text
|
||||
local UnitTypes = {}
|
||||
self:E( "Targets in DetectedArea " .. DetectedArea.AreaID .. ":" .. TargetSetUnit:Count() )
|
||||
TargetSetUnit:Flush()
|
||||
local TargetZone = DetectedArea.Zone -- Zone#ZONE_BASE
|
||||
Detection:FlareDetectedZones()
|
||||
Detection:FlareDetectedUnits()
|
||||
|
||||
for DetectedUnitID, DetectedUnitData in pairs( TargetSetUnit:GetSet() ) do
|
||||
|
||||
local TargetUnit = DetectedUnitData -- Unit#UNIT
|
||||
self:E( TargetUnit )
|
||||
local TargetUnitName = TargetUnit:GetName()
|
||||
local TargetUnitType = TargetUnit:GetTypeName()
|
||||
|
||||
MT[#MT+1] = self:EvaluateTaskSEAD( self.Mission, DetectedArea )
|
||||
MT[#MT+1] = self:EvaluateTaskCAS( self.Mission, DetectedArea )
|
||||
-- Evaluate SEAD Task
|
||||
local SEADText = self:EvaluateTaskSEAD( self.Mission, DetectedArea )
|
||||
if SEADText then
|
||||
MT[#MT+1] = SEADText
|
||||
end
|
||||
|
||||
-- Evaluate CAS task
|
||||
local CASText = self:EvaluateTaskCAS( self.Mission, DetectedArea )
|
||||
if CASText then
|
||||
MT[#MT+1] = CASText
|
||||
end
|
||||
|
||||
DetectedMsg[#DetectedMsg+1] = " - Group #" .. DetectedAreaID .. ": " .. self:GetDetectedItemsText( TargetSetUnit ) .. ". " .. table.concat( MT, "," ) .. " tasks addded."
|
||||
DetectedMsg[#DetectedMsg+1] = "- Group #" .. DetectedAreaID .. ":" .. table.concat( MT, "," )
|
||||
end
|
||||
|
||||
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 )
|
||||
|
||||
MESSAGE:New( "TargetCount = " .. self.TargetSetUnit:Count(), 15 ):ToAll()
|
||||
self.TargetSetUnit:Flush()
|
||||
if self.TargetSetUnit:Count() > 0 then
|
||||
self:NextEvent( Fsm.MoreTargets )
|
||||
else
|
||||
|
||||
@ -351,12 +351,16 @@ end
|
||||
|
||||
--- 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 OtherSet
|
||||
-- @param #SET_BASE BaseSet
|
||||
-- @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
|
||||
|
||||
-- Now base the new Set on the BaseSet
|
||||
self.Database = BaseSet:GetSet()
|
||||
return self
|
||||
end
|
||||
|
||||
@ -630,7 +634,7 @@ function SET_BASE:Flush()
|
||||
for ObjectName, Object in pairs( self.Set ) do
|
||||
ObjectNames = ObjectNames .. ObjectName .. ", "
|
||||
end
|
||||
self:T( { "Objects in Set:", ObjectNames } )
|
||||
self:E( { "Objects in Set:", ObjectNames } )
|
||||
|
||||
return ObjectNames
|
||||
end
|
||||
@ -1455,7 +1459,9 @@ function SET_UNIT:IsIncludeObject( MUnit )
|
||||
for RadarTypeID, RadarType in pairs( self.Filter.RadarTypes ) do
|
||||
self:E( { "Radar:", RadarType } )
|
||||
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
|
||||
end
|
||||
end
|
||||
|
||||
@ -158,6 +158,7 @@ function TASK_BASE:_EventAssignUnit( Event )
|
||||
local TaskPlayerName = TaskUnit:GetPlayerName()
|
||||
if TaskPlayerName ~= nil then
|
||||
if not self:HasStateMachine( TaskUnit ) then
|
||||
self.TaskUnit = TaskUnit
|
||||
self:AssignToUnit( TaskUnit )
|
||||
end
|
||||
end
|
||||
@ -332,6 +333,22 @@ function TASK_BASE:SetBriefing( TaskBriefing )
|
||||
return self
|
||||
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
|
||||
-- @param #TASK_BASE self
|
||||
-- @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()
|
||||
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
|
||||
|
||||
|
||||
|
||||
@ -13,8 +13,8 @@ TASK_CAS = {
|
||||
-- @param Set#SET_UNIT UnitSetTargets
|
||||
-- @param Zone#ZONE_BASE TargetZone
|
||||
-- @return #TASK_CAS self
|
||||
function TASK_CAS:New( Mission, TargetSetUnit, TargetZone )
|
||||
local self = BASE:Inherit( self, TASK_BASE:New( Mission, "CAS Attack", "CAS", "A2G" ) )
|
||||
function TASK_CAS:New( Mission, MenuText, TargetSetUnit, TargetZone )
|
||||
local self = BASE:Inherit( self, TASK_BASE:New( Mission, MenuText, "CAS", "A2G" ) )
|
||||
self:F()
|
||||
|
||||
self.TargetSetUnit = TargetSetUnit
|
||||
|
||||
@ -13,8 +13,8 @@ TASK_SEAD = {
|
||||
-- @param Set#SET_UNIT UnitSetTargets
|
||||
-- @param Zone#ZONE_BASE TargetZone
|
||||
-- @return #TASK_SEAD self
|
||||
function TASK_SEAD:New( Mission, TargetSetUnit, TargetZone )
|
||||
local self = BASE:Inherit( self, TASK_BASE:New( Mission, "SEAD Attack", "SEAD", "A2G" ) )
|
||||
function TASK_SEAD:New( Mission, MenuText, TargetSetUnit, TargetZone )
|
||||
local self = BASE:Inherit( self, TASK_BASE:New( Mission, MenuText, "SEAD", "A2G" ) )
|
||||
self:F()
|
||||
|
||||
self.TargetSetUnit = TargetSetUnit
|
||||
@ -36,7 +36,7 @@ end
|
||||
-- @return #TASK_SEAD self
|
||||
function TASK_SEAD:AssignToUnit( TaskUnit )
|
||||
self:F( TaskUnit:GetName() )
|
||||
|
||||
|
||||
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 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 )
|
||||
ProcessSEAD:AddScore( "Destroy", "destroyed a radar", 25 )
|
||||
ProcessSEAD:AddScore( "Failed", "failed to destroy a radar", -100 )
|
||||
self:AddScore( "Success", "Destroyed all target radars", 250 )
|
||||
|
||||
Process:Next()
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
env.info( '*** MOOSE DYNAMIC INCLUDE START *** ' )
|
||||
env.info( 'Moose Generation Timestamp: 20160710_0833' )
|
||||
env.info( 'Moose Generation Timestamp: 20160713_0623' )
|
||||
|
||||
local base = _G
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
env.info( '*** MOOSE DYNAMIC INCLUDE START *** ' )
|
||||
env.info( 'Moose Generation Timestamp: 20160710_0833' )
|
||||
env.info( 'Moose Generation Timestamp: 20160713_0623' )
|
||||
|
||||
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.
Loading…
x
Reference in New Issue
Block a user