diff --git a/Moose Development/Moose/Actions/Act_Assign.lua b/Moose Development/Moose/Actions/Act_Assign.lua index 25a62656c..7d45ad21a 100644 --- a/Moose Development/Moose/Actions/Act_Assign.lua +++ b/Moose Development/Moose/Actions/Act_Assign.lua @@ -175,7 +175,7 @@ do -- ACT_ASSIGN_ACCEPT self:Message( "You are assigned to the task " .. self.Task:GetName() ) - self.Task:Assign( ProcessUnit, self.Task ) + self.Task:Assign( ProcessUnit, ProcessUnit:GetPlayerName() ) end end -- ACT_ASSIGN_ACCEPT diff --git a/Moose Development/Moose/Tasking/DetectionManager.lua b/Moose Development/Moose/Tasking/DetectionManager.lua index ddbaa4301..7601701a0 100644 --- a/Moose Development/Moose/Tasking/DetectionManager.lua +++ b/Moose Development/Moose/Tasking/DetectionManager.lua @@ -2,7 +2,7 @@ -- -- === -- --- 1) @{DetectionManager#DETECTION_MANAGER} class, extends @{Base#BASE} +-- 1) @{DetectionManager#DETECTION_MANAGER} class, extends @{Fsm#FSM} -- ==================================================================== -- The @{DetectionManager#DETECTION_MANAGER} class defines the core functions to report detected objects to groups. -- Reportings can be done in several manners, and it is up to the derived classes if DETECTION_MANAGER to model the reporting behaviour. @@ -48,7 +48,7 @@ do -- DETECTION MANAGER -- @type DETECTION_MANAGER -- @field Set#SET_GROUP SetGroup The groups to which the FAC will report to. -- @field Functional.Detection#DETECTION_BASE Detection The DETECTION_BASE object that is used to report the detected objects. - -- @extends Base#BASE + -- @extends Core.Fsm#FSM DETECTION_MANAGER = { ClassName = "DETECTION_MANAGER", SetGroup = nil, @@ -63,19 +63,37 @@ do -- DETECTION MANAGER function DETECTION_MANAGER:New( SetGroup, Detection ) -- Inherits from BASE - local self = BASE:Inherit( self, BASE:New() ) -- Functional.Detection#DETECTION_MANAGER + local self = BASE:Inherit( self, FSM:New() ) -- #DETECTION_MANAGER self.SetGroup = SetGroup self.Detection = Detection + self:SetStartState( "Stopped" ) + self:AddTransition( "Stopped", "Start", "Started" ) + self:AddTransition( "Started", "Stop", "Stopped" ) + self:AddTransition( "Started", "Report", "Started" ) + self:SetReportInterval( 30 ) self:SetReportDisplayTime( 25 ) - - Detection:__Start( 5 ) - + + Detection:__Start( 1 ) + return self end + function DETECTION_MANAGER:onafterStart( From, Event, To ) + self:Report() + end + + function DETECTION_MANAGER:onafterReport( From, Event, To ) + + self:E( "onafterReport" ) + + self:__Report( -self._ReportInterval ) + + self:ProcessDetected( self.Detection ) + end + --- Set the reporting time interval. -- @param #DETECTION_MANAGER self -- @param #number ReportInterval The interval in seconds when a report needs to be done. @@ -106,51 +124,14 @@ do -- DETECTION MANAGER return self._ReportDisplayTime end - - --- Reports the detected items to the @{Set#SET_GROUP}. -- @param #DETECTION_MANAGER self -- @param Functional.Detection#DETECTION_BASE Detection -- @return #DETECTION_MANAGER self - function DETECTION_MANAGER:ReportDetected( Detection ) - self:F2() + function DETECTION_MANAGER:ProcessDetected( Detection ) + self:E() end - - --- Schedule the FAC reporting. - -- @param #DETECTION_MANAGER self - -- @param #number DelayTime The delay in seconds to wait the reporting. - -- @param #number ReportInterval The repeat interval in seconds for the reporting to happen repeatedly. - -- @return #DETECTION_MANAGER self - function DETECTION_MANAGER:Schedule( DelayTime, ReportInterval ) - self:F2() - - self._ScheduleDelayTime = DelayTime - - self:SetReportInterval( ReportInterval ) - - self.FacScheduler = SCHEDULER:New(self, self._FacScheduler, { self, "DetectionManager" }, self._ScheduleDelayTime, self._ReportInterval ) - return self - end - - --- Report the detected @{Unit#UNIT}s detected within the @{Detection#DETECTION_BASE} object to the @{Set#SET_GROUP}s. - -- @param #DETECTION_MANAGER self - function DETECTION_MANAGER:_FacScheduler( SchedulerName ) - self:F2( { SchedulerName } ) - - return self:ProcessDetected( self.Detection ) - --- self.SetGroup:ForEachGroup( --- --- @param Wrapper.Group#GROUP Group --- function( Group ) --- if Group:IsAlive() then --- return self:ProcessDetected( self.Detection ) --- end --- end --- ) - --- return true - end end diff --git a/Moose Development/Moose/Tasking/Task.lua b/Moose Development/Moose/Tasking/Task.lua index 566b237c2..befa29682 100644 --- a/Moose Development/Moose/Tasking/Task.lua +++ b/Moose Development/Moose/Tasking/Task.lua @@ -981,11 +981,16 @@ end -- @param #string Event -- @param #string From -- @param #string To -function TASK:onenterAssigned( From, Event, To ) +function TASK:onenterAssigned( From, Event, To, PlayerUnit, PlayerName ) self:E("Task Assigned") self:MessageToGroups( "Task " .. self:GetName() .. " has been assigned to your group." ) + + if self.Dispatcher then + self.Dispatcher:Assign( self, PlayerUnit, PlayerName ) + end + self:GetMission():__Start( 1 ) end @@ -1097,6 +1102,18 @@ function TASK:onbeforeTimeOut( From, Event, To ) return false end +do -- Dispatcher + + --- Set dispatcher of a task + -- @param #TASK self + -- @param Tasking.DetectionManager#DETECTION_MANAGER Dispatcher + -- @return #TASK + function TASK:SetDispatcher( Dispatcher ) + self.Dispatcher = Dispatcher + end + +end + do -- Reporting --- Create a summary report of the Task. diff --git a/Moose Development/Moose/Tasking/Task_A2G.lua b/Moose Development/Moose/Tasking/Task_A2G.lua index 785f11e48..fde116f2c 100644 --- a/Moose Development/Moose/Tasking/Task_A2G.lua +++ b/Moose Development/Moose/Tasking/Task_A2G.lua @@ -1,4 +1,7 @@ ---- This module contains the TASK_A2G classes. +--- **Tasking** - The TASK_A2G models tasks for players in Air to Ground engagements. +-- +-- ![Banner Image](..\Presentations\TASK_A2G\Dia1.JPG) +-- -- -- # 1) @{Task_A2G#TASK_A2G} class, extends @{Task#TASK} -- @@ -12,10 +15,30 @@ -- * **Success**: The A2G task is successfully completed. -- * **Failed**: The A2G task has failed. This will happen if the player exists the task early, without communicating a possible cancellation to HQ. -- --- # 1) @{Task_A2G#TASK_SEAD} class, extends @{Task_A2G#TASK_A2G} +-- # 1.1) Set the scoring of achievements in an A2G attack. +-- +-- Scoring or penalties can be given in the following circumstances: +-- +-- * @{#TASK_A2G.SetScoreOnDestroy}(): Set a score when a target in scope of the A2G attack, has been destroyed. +-- * @{#TASK_A2G.SetScoreOnSuccess}(): Set a score when all the targets in scope of the A2G attack, have been destroyed. +-- * @{#TASK_A2G.SetPenaltyOnFailed}(): Set a penalty when the A2G attack has failed. +-- +-- # 2) @{Task_A2G#TASK_SEAD} class, extends @{Task_A2G#TASK_A2G} -- -- The @{#TASK_SEAD} class defines a SEAD task for a @{Set} of Target Units. -- +-- === +-- +-- # 3) @{Task_A2G#TASK_CAS} class, extends @{Task_A2G#TASK_A2G} +-- +-- The @{#TASK_CAS} class defines a CAS task for a @{Set} of Target Units. +-- +-- === +-- +-- # 4) @{Task_A2G#TASK_BAI} class, extends @{Task_A2G#TASK_A2G} +-- +-- The @{#TASK_BAI} class defines a BAI task for a @{Set} of Target Units. +-- -- ==== -- -- # **API CHANGE HISTORY** @@ -277,6 +300,52 @@ do -- TASK_A2G local ActRouteTarget = ProcessUnit:GetProcess( "Engaging", "RouteToTargetZone" ) -- Actions.Act_Route#ACT_ROUTE_ZONE return ActRouteTarget:GetZone() end + + --- Set a score when a target in scope of the A2G attack, has been destroyed . + -- @param #TASK_A2G self + -- @param #string Text The text to display to the player, when the target has been destroyed. + -- @param #number Score The score in points. + -- @param Wrapper.Unit#UNIT TaskUnit + -- @return #TASK_A2G + function TASK_A2G:SetScoreOnDestroy( Text, Score, TaskUnit ) + + local ProcessUnit = self:GetUnitProcess( TaskUnit ) + + ProcessUnit:AddScoreProcess( "Engaging", "Account", "Account", Text, Score ) + + return self + end + + --- Set a score when all the targets in scope of the A2G attack, have been destroyed. + -- @param #TASK_A2G self + -- @param #string Text The text to display to the player, when all targets hav been destroyed. + -- @param #number Score The score in points. + -- @param Wrapper.Unit#UNIT TaskUnit + -- @return #TASK_A2G + function TASK_A2G:SetScoreOnSuccess( Text, Score, TaskUnit ) + + local ProcessUnit = self:GetUnitProcess( TaskUnit ) + + ProcessUnit:AddScore( "Success", Text, Score ) + + return self + end + + --- Set a penalty when the A2G attack has failed. + -- @param #TASK_A2G self + -- @param #string Text The text to display to the player, when the A2G attack has failed. + -- @param #number Penalty The penalty in points. + -- @param Wrapper.Unit#UNIT TaskUnit + -- @return #TASK_A2G + function TASK_A2G:SetPenaltyOnFailed( Text, Penalty, TaskUnit ) + + local ProcessUnit = self:GetUnitProcess( TaskUnit ) + + ProcessUnit:AddScore( "Failed", Text, Penalty ) + + return self + end + end diff --git a/Moose Development/Moose/Tasking/Task_A2G_Dispatcher.lua b/Moose Development/Moose/Tasking/Task_A2G_Dispatcher.lua index 06c3a4234..e5186ebf1 100644 --- a/Moose Development/Moose/Tasking/Task_A2G_Dispatcher.lua +++ b/Moose Development/Moose/Tasking/Task_A2G_Dispatcher.lua @@ -72,7 +72,20 @@ do -- TASK_A2G_DISPATCHER self.Detection = Detection self.Mission = Mission - self:Schedule( 30 ) + self:AddTransition( "Started", "Assign", "Started" ) + + --- OnAfter Transition Handler for Event Assign. + -- @function [parent=#TASK_A2G_DISPATCHER] OnAfterAssign + -- @param #TASK_A2G_DISPATCHER self + -- @param #string From The From State string. + -- @param #string Event The Event string. + -- @param #string To The To State string. + -- @param Tasking.Task_A2G#TASK_A2G Task + -- @param Wrapper.Unit#UNIT TaskUnit + -- @param #string PlayerName + + self:__Start( 5 ) + return self end @@ -186,7 +199,7 @@ do -- TASK_A2G_DISPATCHER -- @param Functional.Detection#DETECTION_BASE Detection The detection created by the @{Detection#DETECTION_BASE} derived object. -- @return #boolean Return true if you want the task assigning to continue... false will cancel the loop. function TASK_A2G_DISPATCHER:ProcessDetected( Detection ) - self:F2() + self:E() local AreaMsg = {} local TaskMsg = {} @@ -217,6 +230,7 @@ do -- TASK_A2G_DISPATCHER if TargetSetUnit then local Task = TASK_SEAD:New( Mission, self.SetGroup, string.format( "SEAD.%03d", ItemID ), TargetSetUnit ) Task:SetTargetZone( DetectedZone ) + Task:SetDispatcher( self ) SEADTask = Mission:AddTask( Task ) end end @@ -232,6 +246,7 @@ do -- TASK_A2G_DISPATCHER if TargetSetUnit then local Task = TASK_CAS:New( Mission, self.SetGroup, string.format( "CAS.%03d", ItemID ), TargetSetUnit ) --Task:SetTargetZone( DetectedZone ) + Task:SetDispatcher( self ) CASTask = Mission:AddTask( Task ) end end @@ -247,6 +262,7 @@ do -- TASK_A2G_DISPATCHER if TargetSetUnit then local Task = TASK_BAI:New( Mission, self.SetGroup, string.format( "BAI.%03d", ItemID ), TargetSetUnit ) Task:SetTargetZone( DetectedZone ) + Task:SetDispatcher( self ) BAITask = Mission:AddTask( Task ) end end diff --git a/Moose Mission Setup/Moose Mission Update/l10n/DEFAULT/Moose.lua b/Moose Mission Setup/Moose Mission Update/l10n/DEFAULT/Moose.lua index e0e8f6129..09b01c6a7 100644 --- a/Moose Mission Setup/Moose Mission Update/l10n/DEFAULT/Moose.lua +++ b/Moose Mission Setup/Moose Mission Update/l10n/DEFAULT/Moose.lua @@ -1,5 +1,5 @@ env.info( '*** MOOSE STATIC INCLUDE START *** ' ) -env.info( 'Moose Generation Timestamp: 20170319_0550' ) +env.info( 'Moose Generation Timestamp: 20170319_0757' ) local base = _G Include = {} @@ -31134,7 +31134,7 @@ do -- ACT_ASSIGN_ACCEPT self:Message( "You are assigned to the task " .. self.Task:GetName() ) - self.Task:Assign( ProcessUnit, self.Task ) + self.Task:Assign( ProcessUnit, ProcessUnit:GetPlayerName() ) end end -- ACT_ASSIGN_ACCEPT @@ -34019,11 +34019,16 @@ end -- @param #string Event -- @param #string From -- @param #string To -function TASK:onenterAssigned( From, Event, To ) +function TASK:onenterAssigned( From, Event, To, PlayerUnit, PlayerName ) self:E("Task Assigned") self:MessageToGroups( "Task " .. self:GetName() .. " has been assigned to your group." ) + + if self.Dispatcher then + self.Dispatcher:Assign( self, PlayerUnit, PlayerName ) + end + self:GetMission():__Start( 1 ) end @@ -34135,6 +34140,18 @@ function TASK:onbeforeTimeOut( From, Event, To ) return false end +do -- Dispatcher + + --- Set dispatcher of a task + -- @param #TASK self + -- @param Tasking.DetectionManager#DETECTION_MANAGER Dispatcher + -- @return #TASK + function TASK:SetDispatcher( Dispatcher ) + self.Dispatcher = Dispatcher + end + +end + do -- Reporting --- Create a summary report of the Task. @@ -34193,7 +34210,7 @@ end -- Reporting -- -- === -- --- 1) @{DetectionManager#DETECTION_MANAGER} class, extends @{Base#BASE} +-- 1) @{DetectionManager#DETECTION_MANAGER} class, extends @{Fsm#FSM} -- ==================================================================== -- The @{DetectionManager#DETECTION_MANAGER} class defines the core functions to report detected objects to groups. -- Reportings can be done in several manners, and it is up to the derived classes if DETECTION_MANAGER to model the reporting behaviour. @@ -34239,7 +34256,7 @@ do -- DETECTION MANAGER -- @type DETECTION_MANAGER -- @field Set#SET_GROUP SetGroup The groups to which the FAC will report to. -- @field Functional.Detection#DETECTION_BASE Detection The DETECTION_BASE object that is used to report the detected objects. - -- @extends Base#BASE + -- @extends Core.Fsm#FSM DETECTION_MANAGER = { ClassName = "DETECTION_MANAGER", SetGroup = nil, @@ -34254,19 +34271,37 @@ do -- DETECTION MANAGER function DETECTION_MANAGER:New( SetGroup, Detection ) -- Inherits from BASE - local self = BASE:Inherit( self, BASE:New() ) -- Functional.Detection#DETECTION_MANAGER + local self = BASE:Inherit( self, FSM:New() ) -- #DETECTION_MANAGER self.SetGroup = SetGroup self.Detection = Detection + self:SetStartState( "Stopped" ) + self:AddTransition( "Stopped", "Start", "Started" ) + self:AddTransition( "Started", "Stop", "Stopped" ) + self:AddTransition( "Started", "Report", "Started" ) + self:SetReportInterval( 30 ) self:SetReportDisplayTime( 25 ) - - Detection:__Start( 5 ) - + + Detection:__Start( 1 ) + return self end + function DETECTION_MANAGER:onafterStart( From, Event, To ) + self:Report() + end + + function DETECTION_MANAGER:onafterReport( From, Event, To ) + + self:E( "onafterReport" ) + + self:__Report( -self._ReportInterval ) + + self:ProcessDetected( self.Detection ) + end + --- Set the reporting time interval. -- @param #DETECTION_MANAGER self -- @param #number ReportInterval The interval in seconds when a report needs to be done. @@ -34297,51 +34332,14 @@ do -- DETECTION MANAGER return self._ReportDisplayTime end - - --- Reports the detected items to the @{Set#SET_GROUP}. -- @param #DETECTION_MANAGER self -- @param Functional.Detection#DETECTION_BASE Detection -- @return #DETECTION_MANAGER self - function DETECTION_MANAGER:ReportDetected( Detection ) - self:F2() + function DETECTION_MANAGER:ProcessDetected( Detection ) + self:E() end - - --- Schedule the FAC reporting. - -- @param #DETECTION_MANAGER self - -- @param #number DelayTime The delay in seconds to wait the reporting. - -- @param #number ReportInterval The repeat interval in seconds for the reporting to happen repeatedly. - -- @return #DETECTION_MANAGER self - function DETECTION_MANAGER:Schedule( DelayTime, ReportInterval ) - self:F2() - - self._ScheduleDelayTime = DelayTime - - self:SetReportInterval( ReportInterval ) - - self.FacScheduler = SCHEDULER:New(self, self._FacScheduler, { self, "DetectionManager" }, self._ScheduleDelayTime, self._ReportInterval ) - return self - end - - --- Report the detected @{Unit#UNIT}s detected within the @{Detection#DETECTION_BASE} object to the @{Set#SET_GROUP}s. - -- @param #DETECTION_MANAGER self - function DETECTION_MANAGER:_FacScheduler( SchedulerName ) - self:F2( { SchedulerName } ) - - return self:ProcessDetected( self.Detection ) - --- self.SetGroup:ForEachGroup( --- --- @param Wrapper.Group#GROUP Group --- function( Group ) --- if Group:IsAlive() then --- return self:ProcessDetected( self.Detection ) --- end --- end --- ) - --- return true - end end @@ -34500,7 +34498,20 @@ do -- TASK_A2G_DISPATCHER self.Detection = Detection self.Mission = Mission - self:Schedule( 30 ) + self:AddTransition( "Started", "Assign", "Started" ) + + --- OnAfter Transition Handler for Event Assign. + -- @function [parent=#TASK_A2G_DISPATCHER] OnAfterAssign + -- @param #TASK_A2G_DISPATCHER self + -- @param #string From The From State string. + -- @param #string Event The Event string. + -- @param #string To The To State string. + -- @param Tasking.Task_A2G#TASK_A2G Task + -- @param Wrapper.Unit#UNIT TaskUnit + -- @param #string PlayerName + + self:__Start( 5 ) + return self end @@ -34614,7 +34625,7 @@ do -- TASK_A2G_DISPATCHER -- @param Functional.Detection#DETECTION_BASE Detection The detection created by the @{Detection#DETECTION_BASE} derived object. -- @return #boolean Return true if you want the task assigning to continue... false will cancel the loop. function TASK_A2G_DISPATCHER:ProcessDetected( Detection ) - self:F2() + self:E() local AreaMsg = {} local TaskMsg = {} @@ -34645,6 +34656,7 @@ do -- TASK_A2G_DISPATCHER if TargetSetUnit then local Task = TASK_SEAD:New( Mission, self.SetGroup, string.format( "SEAD.%03d", ItemID ), TargetSetUnit ) Task:SetTargetZone( DetectedZone ) + Task:SetDispatcher( self ) SEADTask = Mission:AddTask( Task ) end end @@ -34660,6 +34672,7 @@ do -- TASK_A2G_DISPATCHER if TargetSetUnit then local Task = TASK_CAS:New( Mission, self.SetGroup, string.format( "CAS.%03d", ItemID ), TargetSetUnit ) --Task:SetTargetZone( DetectedZone ) + Task:SetDispatcher( self ) CASTask = Mission:AddTask( Task ) end end @@ -34675,6 +34688,7 @@ do -- TASK_A2G_DISPATCHER if TargetSetUnit then local Task = TASK_BAI:New( Mission, self.SetGroup, string.format( "BAI.%03d", ItemID ), TargetSetUnit ) Task:SetTargetZone( DetectedZone ) + Task:SetDispatcher( self ) BAITask = Mission:AddTask( Task ) end end @@ -34711,7 +34725,10 @@ do -- TASK_A2G_DISPATCHER return true end -end--- This module contains the TASK_A2G classes. +end--- **Tasking** - The TASK_A2G models tasks for players in Air to Ground engagements. +-- +-- ![Banner Image](..\Presentations\TASK_A2G\Dia1.JPG) +-- -- -- # 1) @{Task_A2G#TASK_A2G} class, extends @{Task#TASK} -- @@ -34725,10 +34742,30 @@ end--- This module contains the TASK_A2G classes. -- * **Success**: The A2G task is successfully completed. -- * **Failed**: The A2G task has failed. This will happen if the player exists the task early, without communicating a possible cancellation to HQ. -- --- # 1) @{Task_A2G#TASK_SEAD} class, extends @{Task_A2G#TASK_A2G} +-- # 1.1) Set the scoring of achievements in an A2G attack. +-- +-- Scoring or penalties can be given in the following circumstances: +-- +-- * @{#TASK_A2G.SetScoreOnDestroy}(): Set a score when a target in scope of the A2G attack, has been destroyed. +-- * @{#TASK_A2G.SetScoreOnSuccess}(): Set a score when all the targets in scope of the A2G attack, have been destroyed. +-- * @{#TASK_A2G.SetPenaltyOnFailed}(): Set a penalty when the A2G attack has failed. +-- +-- # 2) @{Task_A2G#TASK_SEAD} class, extends @{Task_A2G#TASK_A2G} -- -- The @{#TASK_SEAD} class defines a SEAD task for a @{Set} of Target Units. -- +-- === +-- +-- # 3) @{Task_A2G#TASK_CAS} class, extends @{Task_A2G#TASK_A2G} +-- +-- The @{#TASK_CAS} class defines a CAS task for a @{Set} of Target Units. +-- +-- === +-- +-- # 4) @{Task_A2G#TASK_BAI} class, extends @{Task_A2G#TASK_A2G} +-- +-- The @{#TASK_BAI} class defines a BAI task for a @{Set} of Target Units. +-- -- ==== -- -- # **API CHANGE HISTORY** @@ -34990,6 +35027,52 @@ do -- TASK_A2G local ActRouteTarget = ProcessUnit:GetProcess( "Engaging", "RouteToTargetZone" ) -- Actions.Act_Route#ACT_ROUTE_ZONE return ActRouteTarget:GetZone() end + + --- Set a score when a target in scope of the A2G attack, has been destroyed . + -- @param #TASK_A2G self + -- @param #string Text The text to display to the player, when the target has been destroyed. + -- @param #number Score The score in points. + -- @param Wrapper.Unit#UNIT TaskUnit + -- @return #TASK_A2G + function TASK_A2G:SetScoreOnDestroy( Text, Score, TaskUnit ) + + local ProcessUnit = self:GetUnitProcess( TaskUnit ) + + ProcessUnit:AddScoreProcess( "Engaging", "Account", "Account", Text, Score ) + + return self + end + + --- Set a score when all the targets in scope of the A2G attack, have been destroyed. + -- @param #TASK_A2G self + -- @param #string Text The text to display to the player, when all targets hav been destroyed. + -- @param #number Score The score in points. + -- @param Wrapper.Unit#UNIT TaskUnit + -- @return #TASK_A2G + function TASK_A2G:SetScoreOnSuccess( Text, Score, TaskUnit ) + + local ProcessUnit = self:GetUnitProcess( TaskUnit ) + + ProcessUnit:AddScore( "Success", Text, Score ) + + return self + end + + --- Set a penalty when the A2G attack has failed. + -- @param #TASK_A2G self + -- @param #string Text The text to display to the player, when the A2G attack has failed. + -- @param #number Penalty The penalty in points. + -- @param Wrapper.Unit#UNIT TaskUnit + -- @return #TASK_A2G + function TASK_A2G:SetPenaltyOnFailed( Text, Penalty, TaskUnit ) + + local ProcessUnit = self:GetUnitProcess( TaskUnit ) + + ProcessUnit:AddScore( "Failed", Text, Penalty ) + + return self + end + end diff --git a/Moose Mission Setup/Moose.lua b/Moose Mission Setup/Moose.lua index e0e8f6129..09b01c6a7 100644 --- a/Moose Mission Setup/Moose.lua +++ b/Moose Mission Setup/Moose.lua @@ -1,5 +1,5 @@ env.info( '*** MOOSE STATIC INCLUDE START *** ' ) -env.info( 'Moose Generation Timestamp: 20170319_0550' ) +env.info( 'Moose Generation Timestamp: 20170319_0757' ) local base = _G Include = {} @@ -31134,7 +31134,7 @@ do -- ACT_ASSIGN_ACCEPT self:Message( "You are assigned to the task " .. self.Task:GetName() ) - self.Task:Assign( ProcessUnit, self.Task ) + self.Task:Assign( ProcessUnit, ProcessUnit:GetPlayerName() ) end end -- ACT_ASSIGN_ACCEPT @@ -34019,11 +34019,16 @@ end -- @param #string Event -- @param #string From -- @param #string To -function TASK:onenterAssigned( From, Event, To ) +function TASK:onenterAssigned( From, Event, To, PlayerUnit, PlayerName ) self:E("Task Assigned") self:MessageToGroups( "Task " .. self:GetName() .. " has been assigned to your group." ) + + if self.Dispatcher then + self.Dispatcher:Assign( self, PlayerUnit, PlayerName ) + end + self:GetMission():__Start( 1 ) end @@ -34135,6 +34140,18 @@ function TASK:onbeforeTimeOut( From, Event, To ) return false end +do -- Dispatcher + + --- Set dispatcher of a task + -- @param #TASK self + -- @param Tasking.DetectionManager#DETECTION_MANAGER Dispatcher + -- @return #TASK + function TASK:SetDispatcher( Dispatcher ) + self.Dispatcher = Dispatcher + end + +end + do -- Reporting --- Create a summary report of the Task. @@ -34193,7 +34210,7 @@ end -- Reporting -- -- === -- --- 1) @{DetectionManager#DETECTION_MANAGER} class, extends @{Base#BASE} +-- 1) @{DetectionManager#DETECTION_MANAGER} class, extends @{Fsm#FSM} -- ==================================================================== -- The @{DetectionManager#DETECTION_MANAGER} class defines the core functions to report detected objects to groups. -- Reportings can be done in several manners, and it is up to the derived classes if DETECTION_MANAGER to model the reporting behaviour. @@ -34239,7 +34256,7 @@ do -- DETECTION MANAGER -- @type DETECTION_MANAGER -- @field Set#SET_GROUP SetGroup The groups to which the FAC will report to. -- @field Functional.Detection#DETECTION_BASE Detection The DETECTION_BASE object that is used to report the detected objects. - -- @extends Base#BASE + -- @extends Core.Fsm#FSM DETECTION_MANAGER = { ClassName = "DETECTION_MANAGER", SetGroup = nil, @@ -34254,19 +34271,37 @@ do -- DETECTION MANAGER function DETECTION_MANAGER:New( SetGroup, Detection ) -- Inherits from BASE - local self = BASE:Inherit( self, BASE:New() ) -- Functional.Detection#DETECTION_MANAGER + local self = BASE:Inherit( self, FSM:New() ) -- #DETECTION_MANAGER self.SetGroup = SetGroup self.Detection = Detection + self:SetStartState( "Stopped" ) + self:AddTransition( "Stopped", "Start", "Started" ) + self:AddTransition( "Started", "Stop", "Stopped" ) + self:AddTransition( "Started", "Report", "Started" ) + self:SetReportInterval( 30 ) self:SetReportDisplayTime( 25 ) - - Detection:__Start( 5 ) - + + Detection:__Start( 1 ) + return self end + function DETECTION_MANAGER:onafterStart( From, Event, To ) + self:Report() + end + + function DETECTION_MANAGER:onafterReport( From, Event, To ) + + self:E( "onafterReport" ) + + self:__Report( -self._ReportInterval ) + + self:ProcessDetected( self.Detection ) + end + --- Set the reporting time interval. -- @param #DETECTION_MANAGER self -- @param #number ReportInterval The interval in seconds when a report needs to be done. @@ -34297,51 +34332,14 @@ do -- DETECTION MANAGER return self._ReportDisplayTime end - - --- Reports the detected items to the @{Set#SET_GROUP}. -- @param #DETECTION_MANAGER self -- @param Functional.Detection#DETECTION_BASE Detection -- @return #DETECTION_MANAGER self - function DETECTION_MANAGER:ReportDetected( Detection ) - self:F2() + function DETECTION_MANAGER:ProcessDetected( Detection ) + self:E() end - - --- Schedule the FAC reporting. - -- @param #DETECTION_MANAGER self - -- @param #number DelayTime The delay in seconds to wait the reporting. - -- @param #number ReportInterval The repeat interval in seconds for the reporting to happen repeatedly. - -- @return #DETECTION_MANAGER self - function DETECTION_MANAGER:Schedule( DelayTime, ReportInterval ) - self:F2() - - self._ScheduleDelayTime = DelayTime - - self:SetReportInterval( ReportInterval ) - - self.FacScheduler = SCHEDULER:New(self, self._FacScheduler, { self, "DetectionManager" }, self._ScheduleDelayTime, self._ReportInterval ) - return self - end - - --- Report the detected @{Unit#UNIT}s detected within the @{Detection#DETECTION_BASE} object to the @{Set#SET_GROUP}s. - -- @param #DETECTION_MANAGER self - function DETECTION_MANAGER:_FacScheduler( SchedulerName ) - self:F2( { SchedulerName } ) - - return self:ProcessDetected( self.Detection ) - --- self.SetGroup:ForEachGroup( --- --- @param Wrapper.Group#GROUP Group --- function( Group ) --- if Group:IsAlive() then --- return self:ProcessDetected( self.Detection ) --- end --- end --- ) - --- return true - end end @@ -34500,7 +34498,20 @@ do -- TASK_A2G_DISPATCHER self.Detection = Detection self.Mission = Mission - self:Schedule( 30 ) + self:AddTransition( "Started", "Assign", "Started" ) + + --- OnAfter Transition Handler for Event Assign. + -- @function [parent=#TASK_A2G_DISPATCHER] OnAfterAssign + -- @param #TASK_A2G_DISPATCHER self + -- @param #string From The From State string. + -- @param #string Event The Event string. + -- @param #string To The To State string. + -- @param Tasking.Task_A2G#TASK_A2G Task + -- @param Wrapper.Unit#UNIT TaskUnit + -- @param #string PlayerName + + self:__Start( 5 ) + return self end @@ -34614,7 +34625,7 @@ do -- TASK_A2G_DISPATCHER -- @param Functional.Detection#DETECTION_BASE Detection The detection created by the @{Detection#DETECTION_BASE} derived object. -- @return #boolean Return true if you want the task assigning to continue... false will cancel the loop. function TASK_A2G_DISPATCHER:ProcessDetected( Detection ) - self:F2() + self:E() local AreaMsg = {} local TaskMsg = {} @@ -34645,6 +34656,7 @@ do -- TASK_A2G_DISPATCHER if TargetSetUnit then local Task = TASK_SEAD:New( Mission, self.SetGroup, string.format( "SEAD.%03d", ItemID ), TargetSetUnit ) Task:SetTargetZone( DetectedZone ) + Task:SetDispatcher( self ) SEADTask = Mission:AddTask( Task ) end end @@ -34660,6 +34672,7 @@ do -- TASK_A2G_DISPATCHER if TargetSetUnit then local Task = TASK_CAS:New( Mission, self.SetGroup, string.format( "CAS.%03d", ItemID ), TargetSetUnit ) --Task:SetTargetZone( DetectedZone ) + Task:SetDispatcher( self ) CASTask = Mission:AddTask( Task ) end end @@ -34675,6 +34688,7 @@ do -- TASK_A2G_DISPATCHER if TargetSetUnit then local Task = TASK_BAI:New( Mission, self.SetGroup, string.format( "BAI.%03d", ItemID ), TargetSetUnit ) Task:SetTargetZone( DetectedZone ) + Task:SetDispatcher( self ) BAITask = Mission:AddTask( Task ) end end @@ -34711,7 +34725,10 @@ do -- TASK_A2G_DISPATCHER return true end -end--- This module contains the TASK_A2G classes. +end--- **Tasking** - The TASK_A2G models tasks for players in Air to Ground engagements. +-- +-- ![Banner Image](..\Presentations\TASK_A2G\Dia1.JPG) +-- -- -- # 1) @{Task_A2G#TASK_A2G} class, extends @{Task#TASK} -- @@ -34725,10 +34742,30 @@ end--- This module contains the TASK_A2G classes. -- * **Success**: The A2G task is successfully completed. -- * **Failed**: The A2G task has failed. This will happen if the player exists the task early, without communicating a possible cancellation to HQ. -- --- # 1) @{Task_A2G#TASK_SEAD} class, extends @{Task_A2G#TASK_A2G} +-- # 1.1) Set the scoring of achievements in an A2G attack. +-- +-- Scoring or penalties can be given in the following circumstances: +-- +-- * @{#TASK_A2G.SetScoreOnDestroy}(): Set a score when a target in scope of the A2G attack, has been destroyed. +-- * @{#TASK_A2G.SetScoreOnSuccess}(): Set a score when all the targets in scope of the A2G attack, have been destroyed. +-- * @{#TASK_A2G.SetPenaltyOnFailed}(): Set a penalty when the A2G attack has failed. +-- +-- # 2) @{Task_A2G#TASK_SEAD} class, extends @{Task_A2G#TASK_A2G} -- -- The @{#TASK_SEAD} class defines a SEAD task for a @{Set} of Target Units. -- +-- === +-- +-- # 3) @{Task_A2G#TASK_CAS} class, extends @{Task_A2G#TASK_A2G} +-- +-- The @{#TASK_CAS} class defines a CAS task for a @{Set} of Target Units. +-- +-- === +-- +-- # 4) @{Task_A2G#TASK_BAI} class, extends @{Task_A2G#TASK_A2G} +-- +-- The @{#TASK_BAI} class defines a BAI task for a @{Set} of Target Units. +-- -- ==== -- -- # **API CHANGE HISTORY** @@ -34990,6 +35027,52 @@ do -- TASK_A2G local ActRouteTarget = ProcessUnit:GetProcess( "Engaging", "RouteToTargetZone" ) -- Actions.Act_Route#ACT_ROUTE_ZONE return ActRouteTarget:GetZone() end + + --- Set a score when a target in scope of the A2G attack, has been destroyed . + -- @param #TASK_A2G self + -- @param #string Text The text to display to the player, when the target has been destroyed. + -- @param #number Score The score in points. + -- @param Wrapper.Unit#UNIT TaskUnit + -- @return #TASK_A2G + function TASK_A2G:SetScoreOnDestroy( Text, Score, TaskUnit ) + + local ProcessUnit = self:GetUnitProcess( TaskUnit ) + + ProcessUnit:AddScoreProcess( "Engaging", "Account", "Account", Text, Score ) + + return self + end + + --- Set a score when all the targets in scope of the A2G attack, have been destroyed. + -- @param #TASK_A2G self + -- @param #string Text The text to display to the player, when all targets hav been destroyed. + -- @param #number Score The score in points. + -- @param Wrapper.Unit#UNIT TaskUnit + -- @return #TASK_A2G + function TASK_A2G:SetScoreOnSuccess( Text, Score, TaskUnit ) + + local ProcessUnit = self:GetUnitProcess( TaskUnit ) + + ProcessUnit:AddScore( "Success", Text, Score ) + + return self + end + + --- Set a penalty when the A2G attack has failed. + -- @param #TASK_A2G self + -- @param #string Text The text to display to the player, when the A2G attack has failed. + -- @param #number Penalty The penalty in points. + -- @param Wrapper.Unit#UNIT TaskUnit + -- @return #TASK_A2G + function TASK_A2G:SetPenaltyOnFailed( Text, Penalty, TaskUnit ) + + local ProcessUnit = self:GetUnitProcess( TaskUnit ) + + ProcessUnit:AddScore( "Failed", Text, Penalty ) + + return self + end + end diff --git a/Moose Presentations/TASK.pptx b/Moose Presentations/TASK.pptx new file mode 100644 index 000000000..70da479bc Binary files /dev/null and b/Moose Presentations/TASK.pptx differ diff --git a/Moose Presentations/TASK_A2G.pptx b/Moose Presentations/TASK_A2G.pptx new file mode 100644 index 000000000..9254132a1 Binary files /dev/null and b/Moose Presentations/TASK_A2G.pptx differ diff --git a/Moose Test Missions/TAD - Task Dispatching/TAD-200 - A2G Task Dispatching with SCORING/TAD-200 - A2G Task Dispatching with SCORING.lua b/Moose Test Missions/TAD - Task Dispatching/TAD-200 - A2G Task Dispatching with SCORING/TAD-200 - A2G Task Dispatching with SCORING.lua new file mode 100644 index 000000000..4df46302e --- /dev/null +++ b/Moose Test Missions/TAD - Task Dispatching/TAD-200 - A2G Task Dispatching with SCORING/TAD-200 - A2G Task Dispatching with SCORING.lua @@ -0,0 +1,64 @@ +--- +-- Name: TAD-200 - A2G Task Dispatching with SCORING +-- Author: FlightControl +-- Date Created: 19 Mar 2017 +-- +-- # Situation: +-- +-- This mission demonstrates the scoring of dynamic task dispatching for Air to Ground operations. +-- +-- # Test cases: +-- +-- 1. Observe the FAC(A)'s detecting targets and grouping them. +-- 2. Check that the HQ provides menus to engage on a task set by the FACs. +-- 3. Engage on a task and destroy a target. Check if scoring is given for that target. +-- 4. Engage all targets in the task, and check if mission success is achieved and that a scoring is given. +-- 5. Restart the mission, and crash into the ground, check if you can get penalties. +-- +local HQ = GROUP:FindByName( "HQ", "Bravo HQ" ) + +local CommandCenter = COMMANDCENTER:New( HQ, "Lima" ) + +local Scoring = SCORING:New( "Detect Demo" ) + +local Mission = MISSION + :New( CommandCenter, "Overlord", "High", "Attack Detect Mission Briefing", coalition.side.RED ) + :AddScoring( Scoring ) + +local FACSet = SET_GROUP:New():FilterPrefixes( "FAC" ):FilterCoalitions("red"):FilterStart() + +local FACAreas = DETECTION_UNITS:New( FACSet ) + + +local AttackGroups = SET_GROUP:New():FilterCoalitions( "red" ):FilterPrefixes( "Attack" ):FilterStart() + +TaskDispatcher = TASK_A2G_DISPATCHER:New( Mission, AttackGroups, FACAreas ) + +--- @param #TaskDispatcher self +-- @param From +-- @param Event +-- @param To +-- @param Tasking.Task_A2G#TASK_A2G Task +-- @param Wrapper.Unit#UNIT TaskUnit +-- @param #string PlayerName +function TaskDispatcher:OnAfterAssign( From, Event, To, Task, TaskUnit, PlayerName ) + Task:SetScoreOnDestroy( "Player " .. PlayerName .. " destroyed a target", 20, TaskUnit ) + Task:SetScoreOnSuccess( "The task has been successfully completed!", 200, TaskUnit ) + Task:SetPenaltyOnFailed( "The task has failed completion!", -100, TaskUnit ) +end + +-- Now this is REALLY neat. I set the goal of the mission to be the destruction of Target #004. +-- This is just an example, but many more examples can follow... + +-- Every time a Task becomes Successful, it will trigger the Complete event in the Mission. +-- The mission designer NEED TO OVERRIDE the OnBeforeComplete to prevent the mission from getting into completion +-- too early! + +function Mission:OnBeforeComplete( From, Event, To ) + local Group004 = GROUP:FindByName( "Target #004" ) + if Group004:IsAlive() == false then + Mission:GetCommandCenter():MessageToCoalition( "Mission Complete!" ) + return true + end + return false +end \ No newline at end of file diff --git a/Moose Test Missions/TAD - Task Dispatching/TAD-200 - A2G Task Dispatching with SCORING/TAD-200 - A2G Task Dispatching with SCORING.miz b/Moose Test Missions/TAD - Task Dispatching/TAD-200 - A2G Task Dispatching with SCORING/TAD-200 - A2G Task Dispatching with SCORING.miz new file mode 100644 index 000000000..75669c27e Binary files /dev/null and b/Moose Test Missions/TAD - Task Dispatching/TAD-200 - A2G Task Dispatching with SCORING/TAD-200 - A2G Task Dispatching with SCORING.miz differ diff --git a/docs/Documentation/AI_Patrol.html b/docs/Documentation/AI_Patrol.html index 5703ae81f..2235f2a59 100644 --- a/docs/Documentation/AI_Patrol.html +++ b/docs/Documentation/AI_Patrol.html @@ -920,9 +920,6 @@ Use the method AIPATROLZONE.M - -

This table contains the targets detected during patrol.

-
diff --git a/docs/Documentation/Detection.html b/docs/Documentation/Detection.html index 63e791daa..f00ac4e81 100644 --- a/docs/Documentation/Detection.html +++ b/docs/Documentation/Detection.html @@ -2243,7 +2243,7 @@ self

- #number + DETECTION_BASE.DetectionInterval diff --git a/docs/Documentation/Point.html b/docs/Documentation/Point.html index 63ef7724d..d62614444 100644 --- a/docs/Documentation/Point.html +++ b/docs/Documentation/Point.html @@ -1346,6 +1346,7 @@ The new calculated POINT_VEC2.

+ POINT_VEC2.z diff --git a/docs/Documentation/Spawn.html b/docs/Documentation/Spawn.html index b9f9cb7db..7814eda9f 100644 --- a/docs/Documentation/Spawn.html +++ b/docs/Documentation/Spawn.html @@ -1870,9 +1870,6 @@ The group that was spawned. You can use this group for further actions.

- -

Don't repeat the group from Take-Off till Landing and back Take-Off by ReSpawning.

-
@@ -2326,9 +2323,6 @@ when nothing was spawned.

- -

Overwrite unit names by default with group name.

-
@@ -2343,9 +2337,6 @@ when nothing was spawned.

- -

By default, no InitLimit

-
@@ -2381,7 +2372,7 @@ when nothing was spawned.

- #number + SPAWN.SpawnMaxGroups @@ -2398,7 +2389,7 @@ when nothing was spawned.

- #number + SPAWN.SpawnMaxUnitsAlive @@ -2716,7 +2707,7 @@ Spawn_BE_KA50 = SPAWN:New( 'BE KA-50@RAMP-Ground Defense' ):Schedule( 600, 0.5 )
- #boolean + SPAWN.SpawnUnControlled @@ -2740,7 +2731,7 @@ Spawn_BE_KA50 = SPAWN:New( 'BE KA-50@RAMP-Ground Defense' ):Schedule( 600, 0.5 ) -

Flag that indicates if all the Groups of the SpawnGroup need to be visible when Spawned.

+

When the first Spawn executes, all the Groups need to be made visible before start.

diff --git a/docs/Documentation/Task_A2G.html b/docs/Documentation/Task_A2G.html index 8b3b168d3..ae2b00495 100644 --- a/docs/Documentation/Task_A2G.html +++ b/docs/Documentation/Task_A2G.html @@ -72,10 +72,13 @@

Module Task_A2G

-

This module contains the TASK_A2G classes.

+

Tasking - The TASK_A2G models tasks for players in Air to Ground engagements.

+

Banner Image

+ +

1) TaskA2G#TASKA2G class, extends Task#TASK

The #TASK_A2G class defines Air To Ground tasks for a Set of Target Units, @@ -90,12 +93,34 @@ The TASK_A2G is implemented using a Stat

  • Failed: The A2G task has failed. This will happen if the player exists the task early, without communicating a possible cancellation to HQ.
  • -

    1) TaskA2G#TASKSEAD class, extends TaskA2G#TASKA2G

    +

    1.1) Set the scoring of achievements in an A2G attack.

    + +

    Scoring or penalties can be given in the following circumstances:

    + + + +

    2) TaskA2G#TASKSEAD class, extends TaskA2G#TASKA2G

    The #TASK_SEAD class defines a SEAD task for a Set of Target Units.


    +

    3) TaskA2G#TASKCAS class, extends TaskA2G#TASKA2G

    + +

    The #TASK_CAS class defines a CAS task for a Set of Target Units.

    + +
    + +

    4) TaskA2G#TASKBAI class, extends TaskA2G#TASKA2G

    + +

    The #TASK_BAI class defines a BAI task for a Set of Target Units.

    + +
    +

    API CHANGE HISTORY

    The underlying change log documents the API changes. Please read this carefully. The following notation is used:

    @@ -195,6 +220,12 @@ The TASK_A2G is implemented using a Stat TASK_A2G:New(Mission, SetGroup, TaskName, UnitSetTargets, TargetDistance, TargetZone, TargetSetUnit, TaskType)

    Instantiates a new TASK_A2G.

    + + + + TASK_A2G:SetPenaltyOnFailed(Text, Penalty, TaskUnit) + +

    Set a penalty when the A2G attack has failed.

    @@ -207,6 +238,18 @@ The TASK_A2G is implemented using a Stat TASK_A2G:SetRendezVousZone(RendezVousZone, TaskUnit) + + + + TASK_A2G:SetScoreOnDestroy(Text, Score, TaskUnit) + +

    Set a score when a target in scope of the A2G attack, has been destroyed .

    + + + + TASK_A2G:SetScoreOnSuccess(Text, Score, TaskUnit) + +

    Set a score when all the targets in scope of the A2G attack, have been destroyed.

    @@ -566,6 +609,44 @@ If the TargetZone parameter is specified, the player will be routed to the cente

    #TASK_A2G: self

    + +
    +
    +
    + + +TASK_A2G:SetPenaltyOnFailed(Text, Penalty, TaskUnit) + +
    +
    + +

    Set a penalty when the A2G attack has failed.

    + +

    Parameters

    +
      +
    • + +

      #string Text : +The text to display to the player, when the A2G attack has failed.

      + +
    • +
    • + +

      #number Penalty : +The penalty in points.

      + +
    • +
    • + +

      Wrapper.Unit#UNIT TaskUnit :

      + +
    • +
    +

    Return value

    + +

    #TASK_A2G:

    + +
    @@ -631,6 +712,82 @@ The Zone object where the RendezVous is located on the map.

    + +TASK_A2G:SetScoreOnDestroy(Text, Score, TaskUnit) + +
    +
    + +

    Set a score when a target in scope of the A2G attack, has been destroyed .

    + +

    Parameters

    +
      +
    • + +

      #string Text : +The text to display to the player, when the target has been destroyed.

      + +
    • +
    • + +

      #number Score : +The score in points.

      + +
    • +
    • + +

      Wrapper.Unit#UNIT TaskUnit :

      + +
    • +
    +

    Return value

    + +

    #TASK_A2G:

    + + +
    +
    +
    +
    + + +TASK_A2G:SetScoreOnSuccess(Text, Score, TaskUnit) + +
    +
    + +

    Set a score when all the targets in scope of the A2G attack, have been destroyed.

    + +

    Parameters

    +
      +
    • + +

      #string Text : +The text to display to the player, when all targets hav been destroyed.

      + +
    • +
    • + +

      #number Score : +The score in points.

      + +
    • +
    • + +

      Wrapper.Unit#UNIT TaskUnit :

      + +
    • +
    +

    Return value

    + +

    #TASK_A2G:

    + + +
    +
    +
    +
    + TASK_A2G:SetTargetPointVec2(TargetPointVec2, TaskUnit) diff --git a/docs/Documentation/index.html b/docs/Documentation/index.html index 2bda7fee8..e511745e6 100644 --- a/docs/Documentation/index.html +++ b/docs/Documentation/index.html @@ -402,7 +402,7 @@ and creates a CSV file logging the scoring events and results for use at team or Task_A2G -

    This module contains the TASK_A2G classes.

    +

    Tasking - The TASK_A2G models tasks for players in Air to Ground engagements.

    diff --git a/docs/Presentations/TASK_A2G/Dia1.JPG b/docs/Presentations/TASK_A2G/Dia1.JPG new file mode 100644 index 000000000..08c642ea5 Binary files /dev/null and b/docs/Presentations/TASK_A2G/Dia1.JPG differ