First prototype of task dispatching with menu

This commit is contained in:
FlightControl 2016-07-08 16:16:48 +02:00
parent 6ba6390b5d
commit 0c13744309
16 changed files with 51775 additions and 162 deletions

View File

@ -214,6 +214,14 @@ function DETECTION_BASE:GetDetectedSet( Index )
return nil
end
--- Get the detected @{Zone}s.
-- @param #DETECTION_BASE self
-- @return #DETECTION_BASE.DetectedZones DetectedZones
function DETECTION_BASE:GetDetectedZones()
local DetectionZones = self.DetectedZones
return DetectionZones
end
--- Make a DetectionSet table. This function will be overridden in the derived clsses.
-- @param #DETECTION_BASE self

View File

@ -4,7 +4,7 @@
--
-- 1) @{Fac#DETECTION_MANAGER} class, extends @{Base#BASE}
-- ==============================================
-- The @{Fac#DETECTION_MANAGER} class defines the core functions to report detected objects to clients.
-- The @{Fac#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.
--
-- 1.1) DETECTION_MANAGER constructor:
@ -44,26 +44,26 @@
--- DETECTION_MANAGER class.
-- @type DETECTION_MANAGER
-- @field Set#SET_CLIENT ClientSet The clients to which the FAC will report to.
-- @field Set#SET_GROUP SetGroup The groups to which the FAC will report to.
-- @field Detection#DETECTION_BASE Detection The DETECTION_BASE object that is used to report the detected objects.
-- @extends Base#BASE
DETECTION_MANAGER = {
ClassName = "DETECTION_MANAGER",
ClientSet = nil,
SetGroup = nil,
Detection = nil,
}
--- FAC constructor.
-- @param #DETECTION_MANAGER self
-- @param Set#SET_CLIENT ClientSet
-- @param Set#SET_GROUP SetGroup
-- @param Detection#DETECTION_BASE Detection
-- @return #DETECTION_MANAGER self
function DETECTION_MANAGER:New( ClientSet, Detection )
function DETECTION_MANAGER:New( SetGroup, Detection )
-- Inherits from BASE
local self = BASE:Inherit( self, BASE:New() ) -- Fac#DETECTION_MANAGER
local self = BASE:Inherit( self, BASE:New() ) -- Detection#DETECTION_MANAGER
self.ClientSet = ClientSet
self.SetGroup = SetGroup
self.Detection = Detection
self:SetReportInterval( 60 )
@ -102,7 +102,7 @@ function DETECTION_MANAGER:GetReportDisplayTime()
return self._ReportDisplayTime
end
--- Reports the detected items to the @{Set#SET_CLIENT}.
--- Reports the detected items to the @{Set#SET_GROUP}.
-- @param #DETECTION_MANAGER self
-- @param Set#SET_BASE DetectedSets The detected Sets created by the @{Detection#DETECTION_BASE} object.
-- @return #DETECTION_MANAGER self
@ -129,17 +129,18 @@ function DETECTION_MANAGER:Schedule( DelayTime, ReportInterval )
return self
end
--- Report the detected @{Unit#UNIT}s detected within the @{DetectION#DETECTION_BASE} object to the @{Set#SET_CLIENT}s.
--- 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 } )
self.ClientSet:ForEachClient(
--- @param Client#CLIENT Client
function( Client )
if Client:IsAlive() then
self.SetGroup:ForEachGroup(
--- @param Group#GROUP Group
function( Group )
if Group:IsAlive() then
local DetectedSets = self.Detection:GetDetectedSets()
return self:ProcessDetected( Client, DetectedSets )
local DetectedZones =self.Detection:GetDetectedZones()
return self:ProcessDetected( Group, DetectedSets, DetectedZones )
end
end
)
@ -151,7 +152,7 @@ end
--- FAC_REPORTING class.
-- @type FAC_REPORTING
-- @field Set#SET_CLIENT ClientSet The clients to which the FAC will report to.
-- @field Set#SET_GROUP SetGroup The groups to which the FAC will report to.
-- @field Detection#DETECTION_BASE Detection The DETECTION_BASE object that is used to report the detected objects.
-- @extends #DETECTION_MANAGER
FAC_REPORTING = {
@ -161,27 +162,28 @@ FAC_REPORTING = {
--- FAC_REPORTING constructor.
-- @param #FAC_REPORTING self
-- @param Set#SET_CLIENT ClientSet
-- @param Set#SET_GROUP SetGroup
-- @param Detection#DETECTION_BASE Detection
-- @return #FAC_REPORTING self
function FAC_REPORTING:New( ClientSet, Detection )
function FAC_REPORTING:New( SetGroup, Detection )
-- Inherits from DETECTION_MANAGER
local self = BASE:Inherit( self, DETECTION_MANAGER:New( ClientSet, Detection ) ) -- #FAC_REPORTING
local self = BASE:Inherit( self, DETECTION_MANAGER:New( SetGroup, Detection ) ) -- #FAC_REPORTING
self:Schedule( 5, 60 )
return self
end
--- Reports the detected items to the @{Set#SET_CLIENT}.
--- Reports the detected items to the @{Set#SET_GROUP}.
-- @param #FAC_REPORTING self
-- @param Client#CLIENT Client The @{Client} object to where the report needs to go.
-- @param Group#GROUP Group The @{Group} object to where the report needs to go.
-- @param Set#SET_BASE DetectedSets The detected Sets created by the @{Detection#DETECTION_BASE} object.
-- @return #boolean Return true if you want the reporting to continue... false will cancel the reporting loop.
function FAC_REPORTING:ProcessDetected( Client, DetectedSets )
self:F2( Client )
function FAC_REPORTING:ProcessDetected( Group, DetectedSets, DetectedZones )
self:F2( Group )
self:E( Group )
local DetectedMsg = {}
for DetectedUnitSetID, DetectedUnitSet in pairs( DetectedSets ) do
local UnitSet = DetectedUnitSet -- Set#SET_UNIT
@ -202,8 +204,8 @@ function FAC_REPORTING:ProcessDetected( Client, DetectedSets )
local MessageText = table.concat( MT, ", " )
DetectedMsg[#DetectedMsg+1] = " - Group #" .. DetectedUnitSetID .. ": " .. MessageText
end
local FACGroup = self.Detection:GetFACGroup()
FACGroup:MessageToClient( "Reporting detected target groups:\n" .. table.concat( DetectedMsg, "\n" ), self:GetReportDisplayTime(), Client )
local FACGroup = self.Detection:GetDetectionGroups()
FACGroup:MessageToGroup( "Reporting detected target groups:\n" .. table.concat( DetectedMsg, "\n" ), self:GetReportDisplayTime(), Group )
return true
end
@ -213,80 +215,83 @@ end
--- TASK_DISPATCHER class.
-- @type TASK_DISPATCHER
-- @field Set#SET_CLIENT ClientSet The clients to which the FAC will report to.
-- @field Set#SET_GROUP SetGroup The groups to which the FAC will report to.
-- @field Detection#DETECTION_BASE Detection The DETECTION_BASE object that is used to report the detected objects.
-- @field Mission#MISSION Mission
-- @field Group#GROUP CommandCenter
-- @extends #DETECTION_MANAGER
TASK_DISPATCHER = {
ClassName = "TASK_DISPATCHER",
Mission = nil,
CommandCenter = nil,
Detection = nil,
}
--- TASK_DISPATCHER constructor.
-- @param #TASK_DISPATCHER self
-- @param Set#SET_CLIENT ClientSet
-- @param Set#SET_GROUP SetGroup
-- @param Detection#DETECTION_BASE Detection
-- @return #TASK_DISPATCHER self
function TASK_DISPATCHER:New( ClientSet, Detection, TaskType, Priority )
function TASK_DISPATCHER:New( Mission, CommandCenter, SetGroup, Detection )
-- Inherits from DETECTION_MANAGER
local self = BASE:Inherit( self, DETECTION_MANAGER:New( ClientSet, Detection ) ) -- #TASK_DISPATCHER
local self = BASE:Inherit( self, DETECTION_MANAGER:New( SetGroup, Detection ) ) -- #TASK_DISPATCHER
self:Schedule( 5, 60 )
self.Detection = Detection
self.CommandCenter = CommandCenter
self.Mission = Mission
self:Schedule( 30 )
return self
end
--- Assigns tasks in relation to the detected items to the @{Set#SET_CLIENT}.
-- @param #FAC_REPORTING self
-- @param Client#CLIENT Client The @{Client} object to where the report needs to go.
-- @param Set#SET_BASE DetectedSets The detected Sets created by the @{Detection#DETECTION_BASE} object.
-- @param Mission#MISSIONSCHEDULER MissionScheduler
-- @param #string TaskID The task to be executed.
--- Assigns tasks in relation to the detected items to the @{Set#SET_GROUP}.
-- @param #TASK_DISPATCHER self
-- @param Group#GROUP Group The @{Group} object to where the report needs to go.
-- @param #table DetectedSets The detected Sets created by the @{Detection#DETECTION_BASE} object.
-- @param #table DetectedZones The detected Zones cretaed by the @{Detection#DETECTION_BASE} object.
-- @return #boolean Return true if you want the task assigning to continue... false will cancel the loop.
function TASK_DISPATCHER:ProcessDetected( Client, DetectedSets, MissionScheduler, Targets )
self:F2( Client )
function TASK_DISPATCHER:ProcessDetected( TaskGroup, DetectedSets, DetectedZones )
self:F2( TaskGroup )
local DetectedMsg = {}
local FACGroup = self.Detection:GetFACGroup()
local FACGroup = self.Detection:GetDetectionGroups()
local FACGroupName = FACGroup:GetName()
for DetectedUnitSetID, DetectedUnitSet in pairs( DetectedSets ) do
self:E( TaskGroup )
--- First we need to the detected targets.
for DetectedID, DetectedUnitSet in pairs( DetectedSets ) do
local UnitSet = DetectedUnitSet -- Set#SET_UNIT
local MT = {} -- Message Text
local UnitTypes = {}
if not MissionScheduler.FindMission( FACGroupName ) then
local Mission = MISSION:New()
MissionScheduler.AddMission(Mission)
end
for DetectedUnitID, DetectedUnitData in pairs( UnitSet:GetSet() ) do
local DetectedUnit = DetectedUnitData -- Unit#UNIT
local UnitType = DetectedUnit:GetTypeName()
self:E( DetectedUnit )
local DetectedUnitName = DetectedUnit:GetName()
local UnitType = DetectedUnit:GetTypeName()
if Task:GetTarget( DetectedUnitName ) then
if not UnitTypes[UnitType] then
UnitTypes[UnitType] = 1
else
UnitTypes[UnitType] = UnitTypes[UnitType] + 1
end
Task:AddTarget( DetectedUnit )
-- Determine if the set has radar targets. If it does, construct a SEAD task.
local RadarCount = UnitSet:HasRadar( Unit.RadarType.AS )
if RadarCount > 0 then
local DetectedZone = DetectedZones[DetectedID]
local Task = TASK_SEAD:New( self.Mission, UnitSet, DetectedZone, UnitSet )
self.Mission:AddTask( Task )
MT[#MT+1] = "SEAD task added."
end
end
for UnitTypeID, UnitType in pairs( UnitTypes ) do
MT[#MT+1] = Task:GetCommand() .. " " .. UnitType .. " of " .. UnitTypeID
end
local MessageText = table.concat( MT, ", " )
DetectedMsg[#DetectedMsg+1] = " - Group #" .. DetectedUnitSetID .. ": " .. MessageText
DetectedMsg[#DetectedMsg+1] = " - Group #" .. DetectedID .. ": " .. MessageText
end
Task:Assign( Client )
local FACGroup = self.Detection:GetFACGroup()
FACGroup:MessageToClient( "Reporting detected target groups:\n" .. table.concat( DetectedMsg, "\n" ), self:GetReportDisplayTime(), Client )
self.CommandCenter:MessageToGroup( "Reporting tasks for target groups:\n" .. table.concat( DetectedMsg, "\n" ), self:GetReportDisplayTime(), TaskGroup )
self.Mission:FillMissionMenu( TaskGroup )
return true
end

View File

@ -949,6 +949,23 @@ function GROUP:MessageToClient( Message, Duration, Client )
return nil
end
--- Send a message to a @{Group}.
-- The message will appear in the message area. The message will begin with the callsign of the group and the type of the first unit sending the message.
-- @param #GROUP self
-- @param #string Message The message text
-- @param DCSTypes#Duration Duration The duration of the message.
-- @param Group#GROUP MessageGroup The GROUP object receiving the message.
function GROUP:MessageToGroup( Message, Duration, MsgGroup )
self:F2( { Message, Duration } )
local DCSGroup = self:GetDCSObject()
if DCSGroup then
self:GetMessage( Message, Duration ):ToGroup( MsgGroup )
end
return nil
end
--- Send a message to the players in the @{Group}.
-- The message will appear in the message area. The message will begin with the callsign of the group and the type of the first unit sending the message.
-- @param #GROUP self

View File

@ -13,7 +13,10 @@ MISSION = {
Name = "",
MissionStatus = "PENDING",
_Clients = {},
_Tasks = {},
Tasks = {},
TaskMenus = {},
TaskCategoryMenus = {},
TaskTypeMenus = {},
_ActiveTasks = {},
GoalFunction = nil,
MissionReportTrigger = 0,
@ -44,27 +47,17 @@ end
-- @param #string MissionName is the name of the mission. This name will be used to reference the status of each mission by the players.
-- @param #string MissionPriority is a string indicating the "priority" of the Mission. f.e. "Primary", "Secondary" or "First", "Second". It is free format and up to the Mission designer to choose. There are no rules behind this field.
-- @param #string MissionBriefing is a string indicating the mission briefing to be shown when a player joins a @{CLIENT}.
-- @param DCSCoalitionObject#coalition DCSCoalition is a string indicating the coalition or party to which this mission belongs to. It is free format and can be chosen freely by the mission designer. Note that this field is not to be confused with the coalition concept of the ME. Examples of a Mission Coalition could be "NATO", "CCCP", "Intruders", "Terrorists"...
-- @param DCSCoalitionObject#coalition MissionCoalition is a string indicating the coalition or party to which this mission belongs to. It is free format and can be chosen freely by the mission designer. Note that this field is not to be confused with the coalition concept of the ME. Examples of a Mission Coalition could be "NATO", "CCCP", "Intruders", "Terrorists"...
-- @return #MISSION self
-- @usage
-- -- Declare a few missions.
-- local Mission = MISSIONSCHEDULER.AddMission( 'Russia Transport Troops SA-6', 'Operational', 'Transport troops from the control center to one of the SA-6 SAM sites to activate their operation.', 'Russia' )
-- local Mission = MISSIONSCHEDULER.AddMission( 'Patriots', 'Primary', 'Our intelligence reports that 3 Patriot SAM defense batteries are located near Ruisi, Kvarhiti and Gori.', 'Russia' )
-- local Mission = MISSIONSCHEDULER.AddMission( 'Package Delivery', 'Operational', 'In order to be in full control of the situation, we need you to deliver a very important package at a secret location. Fly undetected through the NATO defenses and deliver the secret package. The secret agent is located at waypoint 4.', 'Russia' )
-- local Mission = MISSIONSCHEDULER.AddMission( 'Rescue General', 'Tactical', 'Our intelligence has received a remote signal behind Gori. We believe it is a very important Russian General that was captured by Georgia. Go out there and rescue him! Ensure you stay out of the battle zone, keep south. Waypoint 4 is the location of our Russian General.', 'Russia' )
-- local Mission = MISSIONSCHEDULER.AddMission( 'NATO Transport Troops', 'Operational', 'Transport 3 groups of air defense engineers from our barracks "Gold" and "Titan" to each patriot battery control center to activate our air defenses.', 'NATO' )
-- local Mission = MISSIONSCHEDULER.AddMission( 'SA-6 SAMs', 'Primary', 'Our intelligence reports that 3 SA-6 SAM defense batteries are located near Didmukha, Khetagurov and Berula. Eliminate the Russian SAMs.', 'NATO' )
-- local Mission = MISSIONSCHEDULER.AddMission( 'NATO Sling Load', 'Operational', 'Fly to the cargo pickup zone at Dzegvi or Kaspi, and sling the cargo to Soganlug airbase.', 'NATO' )
-- local Mission = MISSIONSCHEDULER.AddMission( 'Rescue secret agent', 'Tactical', 'In order to be in full control of the situation, we need you to rescue a secret agent from the woods behind enemy lines. Avoid the Russian defenses and rescue the agent. Keep south until Khasuri, and keep your eyes open for any SAM presence. The agent is located at waypoint 4 on your kneeboard.', 'NATO' )
function MISSION:New( MissionName, MissionPriority, MissionBriefing, DCSCoalition )
function MISSION:New( MissionName, MissionPriority, MissionBriefing, MissionCoalition )
self = MISSION:Meta()
self:T( { MissionName, MissionPriority, MissionBriefing, DCSCoalition } )
self:T( { MissionName, MissionPriority, MissionBriefing, MissionCoalition } )
self.Name = MissionName
self.MissionPriority = MissionPriority
self.MissionBriefing = MissionBriefing
self.DCSCoalition = DCSCoalition
self.MissionCoalition = MissionCoalition
self:SetMissionMenu()
@ -97,7 +90,7 @@ end
-- @param #MISSION self
-- @return #MISSION self
function MISSION:SetMissionMenu()
self.MissionMenu = MENU_COALITION:New( self.DCSCoalition, self.Name )
self.MissionMenu = MENU_COALITION:New( self.MissionCoalition, self.Name )
end
--- Gets the mission menu for the coalition.
@ -116,6 +109,83 @@ function MISSION:ClearMissionMenu()
self.MissionMenu = nil
end
--- Fill mission menu for the Group.
-- @param #MISSION self
-- @return #MISSION self
function MISSION:FillMissionMenu( TaskGroup )
local MissionMenu = self:GetMissionMenu()
local TaskMenus = self.TaskMenus
local TaskCategoryMenus = self.TaskCategoryMenus
local TaskTypeMenus = self.TaskTypeMenus
for TaskIndex, TaskTable in pairs( self.Tasks ) do
for _, Task in pairs( TaskTable ) do
Task = Task -- Task#TASK_BASE
local TaskType = Task:GetType()
local TaskName = Task:GetName()
local TaskID = Task:GetID()
local TaskCategory = Task:GetCategory()
local TaskMenuID = TaskCategory .. "." ..TaskType .. "." .. TaskName .. "." .. TaskID
if not TaskMenus[TaskMenuID] then
TaskMenus[TaskMenuID] = {}
if not TaskCategoryMenus[TaskCategory] then
TaskCategoryMenus[TaskCategory] = MENU_COALITION:New( self.MissionCoalition, TaskCategory, MissionMenu )
end
TaskMenus[TaskMenuID].MenuCategory = TaskCategoryMenus[TaskCategory]
if not TaskTypeMenus[TaskType] then
TaskTypeMenus[TaskType] = MENU_COALITION:New( self.MissionCoalition, TaskType, TaskMenus[TaskMenuID].MenuCategory )
end
TaskMenus[TaskMenuID].MenuType = TaskTypeMenus[TaskType]
TaskMenus[TaskMenuID].Menu = MENU_GROUP_COMMAND:New( TaskGroup, TaskName .. "." .. TaskID, TaskMenus[TaskMenuID].MenuType, self.AssignTaskToGroup, { self = self, Task = Task, TaskGroup = TaskGroup } )
end
end
end
end
function MISSION.AssignTaskToGroup( MenuParam )
local self = MenuParam.self
local Task = MenuParam.Task -- Task#TASK_BASE
local TaskGroup = MenuParam.TaskGroup
Task:AssignToGroup( TaskGroup )
end
--- Register a @{Task} to be completed within the @{Mission}.
-- Note that there can be multiple @{Task}s registered to be completed.
-- Each Task can be set a certain Goals. The Mission will not be completed until all Goals are reached.
-- @param #MISSION self
-- @param Task#TASK_BASE Task is the @{Task} object.
-- @return Task#TASK_BASE The task added.
function MISSION:AddTask( Task )
self:F()
local TaskCategory = Task:GetCategory()
local TaskType = Task:GetType()
local TaskName = Task:GetName()
local TaskIndex = TaskCategory .. "." ..TaskType .. "." .. TaskName
self.Tasks[TaskIndex] = self.Tasks[TaskIndex] or {}
local TaskID = #self.Tasks[TaskIndex] + 1
self.Tasks[TaskIndex][TaskID] = Task
Task:SetID( TaskID )
return Task
end
--- old stuff
--- Returns if a Mission has completed.
-- @return bool
function MISSION:IsCompleted()
@ -304,41 +374,6 @@ function MISSION:FindClient( ClientName )
end
--- Register a @{TASK} to be completed within the @{MISSION}. Note that there can be multiple @{TASK}s registered to be completed. Each TASK can be set a certain Goal. The MISSION will not be completed until all Goals are reached.
-- @param TASK Task is the @{TASK} object. The object must have been instantiated with @{TASK:New} or any of its inherited @{TASK}s.
-- @param number TaskNumber is the sequence number of the TASK within the MISSION. This number does have to be chronological.
-- @return TASK
-- @usage
-- -- Define a few tasks for the Mission.
-- PickupZones = { "NATO Gold Pickup Zone", "NATO Titan Pickup Zone" }
-- PickupSignalUnits = { "NATO Gold Coordination Center", "NATO Titan Coordination Center" }
--
-- -- Assign the Pickup Task
-- local PickupTask = PICKUPTASK:New( PickupZones, CARGO_TYPE.ENGINEERS, CLIENT.ONBOARDSIDE.LEFT )
-- PickupTask:AddSmokeBlue( PickupSignalUnits )
-- PickupTask:SetGoalTotal( 3 )
-- Mission:AddTask( PickupTask, 1 )
--
-- -- Assign the Deploy Task
-- local PatriotActivationZones = { "US Patriot Battery 1 Activation", "US Patriot Battery 2 Activation", "US Patriot Battery 3 Activation" }
-- local PatriotActivationZonesSmokeUnits = { "US SAM Patriot - Battery 1 Control", "US SAM Patriot - Battery 2 Control", "US SAM Patriot - Battery 3 Control" }
-- local DeployTask = DEPLOYTASK:New( PatriotActivationZones, CARGO_TYPE.ENGINEERS )
-- --DeployTask:SetCargoTargetZoneName( 'US Troops Attack ' .. math.random(2) )
-- DeployTask:AddSmokeBlue( PatriotActivationZonesSmokeUnits )
-- DeployTask:SetGoalTotal( 3 )
-- DeployTask:SetGoalTotal( 3, "Patriots activated" )
-- Mission:AddTask( DeployTask, 2 )
function MISSION:AddTask( Task, TaskNumber )
self:F()
self._Tasks[TaskNumber] = Task
self._Tasks[TaskNumber]:EnableEvents()
self._Tasks[TaskNumber].ID = TaskNumber
return Task
end
--- Get the TASK idenified by the TaskNumber from the Mission. This function is useful in GoalFunctions.
-- @param number TaskNumber is the number of the @{TASK} within the @{MISSION}.
-- @return TASK

View File

@ -296,7 +296,7 @@ function SET_BASE:Add( ObjectName, Object )
self.List.Count = self.List.Count + 1
self.Set[ObjectName] = t
self.Set[ObjectName] = t._
end
@ -514,7 +514,7 @@ function SET_BASE:ForEach( IteratorFunction, arg, Set, Function, FunctionArgumen
local function CoRoutine()
local Count = 0
for ObjectID, ObjectData in pairs( Set ) do
local Object = ObjectData._
local Object = ObjectData
self:T3( Object )
if Function then
if Function( unpack( FunctionArguments ), Object ) == true then
@ -1284,6 +1284,32 @@ function SET_UNIT:ForEachUnitNotInZone( ZoneObject, IteratorFunction, ... )
return self
end
--- Returns if the @{Set} has targets having a radar (of a given type).
-- @param #SET_UNIT self
-- @param DCSUnit#Unit.RadarType RadarType
-- @return #number The amount of radars in the Set with the given type
function SET_UNIT:HasRadar( RadarType )
self:F2( RadarType )
local RadarCount = 0
for UnitID, UnitData in pairs( self:GetSet()) do
local UnitSensorTest = UnitData -- Unit#UNIT
local HasSensors
if RadarType then
HasSensors = UnitSensorTest:HasSensors( Unit.SensorType.RADAR, RadarType )
else
HasSensors = UnitSensorTest:HasSensors( Unit.SensorType.RADAR )
end
self:E(HasSensors)
if HasSensors then
RadarCount = RadarCount + 1
end
end
return RadarCount
end
----- Iterate the SET_UNIT and call an interator function for each **alive** player, providing the Unit of the player and optional parameters.

View File

@ -14,10 +14,11 @@ TASK_BASE = {
Scores = {},
}
--- Instantiates a new TASK_BASE. Should never be used. Interface Class.
-- @param #TASK_BASE self
-- @return #TASK_BASE self
function TASK_BASE:New( Mission, TaskName )
function TASK_BASE:New( Mission, TaskName, TaskType, TaskCategory )
local self = BASE:Inherit( self, BASE:New() )
self:F()
@ -25,6 +26,9 @@ function TASK_BASE:New( Mission, TaskName )
self.Fsm = {}
self.Mission = Mission
self.TaskName = TaskName
self.TaskType = TaskType
self.TaskCategory = TaskCategory
self.TaskID = 0
self.TaskBriefing = "You are assigned to the task: " .. self.TaskName .. "."
return self
@ -177,28 +181,69 @@ function TASK_BASE:_EventUnAssignUnit( Event )
return nil
end
--- Gets the scoring of the task
--- Gets the Scoring of the task
-- @param #TASK_BASE self
-- @return Scoring#SCORING Scoring
function TASK_BASE:GetScoring()
return self.Mission:GetScoring()
end
--- Sets the name of the task
--- Sets the Name of the Task
-- @param #TASK_BASE self
-- @param #string TaskName
-- @return Scoring#SCORING Scoring
function TASK_BASE:SetName( TaskName )
self.TaskName = TaskName
end
--- Gets the name of the task
--- Gets the Name of the Task
-- @param #TASK_BASE self
-- @return Scoring#SCORING Scoring
-- @return #string The Task Name
function TASK_BASE:GetName()
return self.TaskName
end
--- Sets the Type of the Task
-- @param #TASK_BASE self
-- @param #string TaskType
function TASK_BASE:SetType( TaskType )
self.TaskType = TaskType
end
--- Gets the Type of the Task
-- @param #TASK_BASE self
-- @return #string TaskType
function TASK_BASE:GetType()
return self.TaskType
end
--- Sets the Category of the Task
-- @param #TASK_BASE self
-- @param #string TaskCategory
function TASK_BASE:SetCategory( TaskCategory )
self.TaskCategory = TaskCategory
end
--- Gets the Category of the Task
-- @param #TASK_BASE self
-- @return #string TaskCategory
function TASK_BASE:GetCategory()
return self.TaskCategory
end
--- Sets the ID of the Task
-- @param #TASK_BASE self
-- @param #string TaskID
function TASK_BASE:SetID( TaskID )
self.TaskID = TaskID
end
--- Gets the ID of the Task
-- @param #TASK_BASE self
-- @return #string TaskID
function TASK_BASE:GetID()
return self.TaskID
end
--- Sets a @{Task} to status **Success**.
-- @param #TASK_BASE self

View File

@ -14,7 +14,7 @@ TASK_SEAD = {
-- @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" ) )
local self = BASE:Inherit( self, TASK_BASE:New( Mission, "SEAD Attack", "SEAD", "A2G" ) )
self:F()
self.TargetSetUnit = TargetSetUnit

View File

@ -109,6 +109,14 @@ UNIT = {
-- @field Orange
-- @field Blue
--- Unit.SensorType
-- @type Unit.SensorType
-- @field OPTIC
-- @field RADAR
-- @field IRST
-- @field RWR
-- Registration.
--- Create a new UNIT from DCSUnit.
@ -334,6 +342,23 @@ end
-- Need to add here a function per sensortype
-- unit:hasSensors(Unit.SensorType.RADAR, Unit.RadarType.AS)
--- Returns if the unit has sensors of a certain type.
-- @param Unit#UNIT self
-- @return #boolean returns true if the unit has specified types of sensors. This function is more preferable than Unit.getSensors() if you don't want to get information about all the unit's sensors, and just want to check if the unit has specified types of sensors.
-- @return #nil The DCS Unit is not existing or alive.
function UNIT:HasSensors( ... )
self:F2( arg )
local DCSUnit = self:GetDCSObject()
if DCSUnit then
local HasSensors = DCSUnit:hasSensors( unpack( arg ) )
return HasSensors
end
return nil
end
--- Returns two values:
--
-- * First value indicates if at least one of the unit's radar(s) is on.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -85,10 +85,12 @@ COPY /b Moose.lua + %1\AirbasePolice.lua Moose.lua
COPY /b Moose.lua + %1\Detection.lua Moose.lua
COPY /b Moose.lua + %1\FAC.lua Moose.lua
COPY /b Moose.lua + %1\StateMachine.lua Moose.lua
COPY /b Moose.lua + %1\Task2.lua Moose.lua
COPY /b Moose.lua + %1\TaskMenu.lua Moose.lua
COPY /b Moose.lua + %1\TaskRoute.lua Moose.lua
COPY /b Moose.lua + %1\TaskSead.lua Moose.lua
COPY /b Moose.lua + %1\Process.lua Moose.lua
COPY /b Moose.lua + %1\Process_Assign.lua Moose.lua
COPY /b Moose.lua + %1\Process_Route.lua Moose.lua
COPY /b Moose.lua + %1\Process_SEAD.lua Moose.lua
COPY /b Moose.lua + %1\Task.lua Moose.lua
COPY /b Moose.lua + %1\Task_SEAD.lua Moose.lua
COPY /b Moose.lua + "Moose Create Static\Moose_Trace_Off.lua" Moose.lua

View File

@ -1,13 +1,11 @@
local FACGroup = GROUP:FindByName( "FAC Group" )
local FACGroup = GROUP:FindByName( "FAC" )
local FACDetection = DETECTION_UNITGROUPS:New( FACGroup, 1000, 250 )
local SeadClientSet = SET_CLIENT:New():FilterCoalitions( "blue" ):FilterStart()
local SEAD_Attack = SET_GROUP:New():FilterCoalitions( "red" ):FilterPrefixes( "SEAD Attack" ):FilterStart()
local DestroyClientSet = SET_CLIENT:New():FilterCoalitions( "blue" ):FilterStart()
local Mission = MISSION:New( "SEAD Mission", "High", "SEAD Mission Briefing", coalition.side.RED )
local CommandCenter = GROUP:FindByName( "HQ" )
local Targets_SEAD_Set = SET_UNIT:New():FilterCoalitions( "red" ):FilterPrefixes( "RU Patriot" ):FilterStart()
local Targets_SEAD = TARGETS:New( "SEAD", Targets_SEAD_Set )
local TaskAssign = TASK_DISPATCHER:New( CommmandCenter, SeadClientSet, FACDetection, Targets_SEAD )
local TaskAssign = TASK_DISPATCHER:New( Mission, CommandCenter, SEAD_Attack, FACDetection )