diff --git a/Moose Development/Moose/Actions/Act_Route.lua b/Moose Development/Moose/Actions/Act_Route.lua index a336dffea..56d0a849c 100644 --- a/Moose Development/Moose/Actions/Act_Route.lua +++ b/Moose Development/Moose/Actions/Act_Route.lua @@ -157,17 +157,49 @@ do -- ACT_ROUTE -- @param Wrapper.Controllable#CONTROLLABLE Controllable -- @return #string function ACT_ROUTE:GetRouteText( Controllable ) - + + self:E() + local RouteText = "" + local Coordinate = nil -- Core.Point#COORDINATE + if self.Coordinate then - RouteText = self.Coordinate:ToString( Controllable ) + Coordinate = self.Coordinate end if self.Zone then - local Coordinate = self.Zone:GetPointVec3( self.Altitude ) + Coordinate = self.Zone:GetPointVec3( self.Altitude ) Coordinate:SetHeading( self.Heading ) - RouteText = Coordinate:ToString( Controllable ) + end + + + local CC = self:GetTask():GetMission():GetCommandCenter() + if CC then + if CC:IsModeWWII() then + -- Find closest reference point to the target. + local ShortestDistance = 0 + local ShortestReferencePoint = nil + local ShortestReferenceName = "" + self:E( { CC.ReferencePoints } ) + for ZoneName, Zone in pairs( CC.ReferencePoints ) do + self:E( { ZoneName = ZoneName } ) + local Zone = Zone -- Core.Zone#ZONE + local ZoneCoord = Zone:GetCoordinate() + local ZoneDistance = ZoneCoord:Get2DDistance( self.Coordinate ) + self:E( { ShortestDistance, ShortestReferenceName } ) + if ShortestDistance == 0 or ZoneDistance < ShortestDistance then + ShortestDistance = ZoneDistance + ShortestReferencePoint = ZoneCoord + ShortestReferenceName = CC.ReferenceNames[ZoneName] + end + end + if ShortestReferencePoint then + RouteText = Coordinate:ToStringFromRP( ShortestReferencePoint, ShortestReferenceName, Controllable ) + end + else + RouteText = self.Coordinate:ToString( Controllable ) + end end return RouteText diff --git a/Moose Development/Moose/Core/Cargo.lua b/Moose Development/Moose/Core/Cargo.lua index 02f4c344b..5ecb9e6b3 100644 --- a/Moose Development/Moose/Core/Cargo.lua +++ b/Moose Development/Moose/Core/Cargo.lua @@ -13,9 +13,9 @@ -- -- # Demo Missions -- --- ### [CARGO Demo Missions source code]() +-- ### [CARGO Demo Missions source code](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master-release/CGO%20-%20Cargo) -- --- ### [CARGO Demo Missions, only for beta testers]() +-- ### [CARGO Demo Missions, only for beta testers](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/CGO%20-%20Cargo) -- -- ### [ALL Demo Missions pack of the last release](https://github.com/FlightControl-Master/MOOSE_MISSIONS/releases) -- @@ -23,7 +23,7 @@ -- -- # YouTube Channel -- --- ### [SPAWNSTATIC YouTube Channel]() +-- ### [CARGO YouTube Channel](https://www.youtube.com/watch?v=tM00lTlkpYs&list=PL7ZUrU4zZUl2zUTuKrLW5RsO9zLMqUtbf) -- -- ==== -- diff --git a/Moose Development/Moose/Core/Database.lua b/Moose Development/Moose/Core/Database.lua index fed13c2a4..0a40cfb62 100644 --- a/Moose Development/Moose/Core/Database.lua +++ b/Moose Development/Moose/Core/Database.lua @@ -64,6 +64,7 @@ DATABASE = { COUNTRY_NAME = {}, NavPoints = {}, PLAYERSETTINGS = {}, + ZONENAMES = {}, } local _DATABASECoalition = @@ -1024,6 +1025,11 @@ function DATABASE:_RegisterTemplates() end --if coa_name == 'red' or coa_name == 'blue' and type(coa_data) == 'table' then end --for coa_name, coa_data in pairs(mission.coalition) do + for ZoneID, ZoneData in pairs( env.mission.triggers.zones ) do + local ZoneName = ZoneData.name + self.ZONENAMES[ZoneName] = ZoneName + end + return self end diff --git a/Moose Development/Moose/Core/Point.lua b/Moose Development/Moose/Core/Point.lua index 35cd570c9..7b299aba1 100644 --- a/Moose Development/Moose/Core/Point.lua +++ b/Moose Development/Moose/Core/Point.lua @@ -62,6 +62,7 @@ do -- COORDINATE --- @type COORDINATE -- @extends Core.Base#BASE + --- # COORDINATE class, extends @{Base#BASE} -- -- COORDINATE defines a 3D point in the simulator and with its methods, you can use or manipulate the point in 3D space. @@ -182,7 +183,7 @@ do -- COORDINATE -- @param #COORDINATE self -- @param Dcs.DCSTypes#Vec2 Vec2 The Vec2 point. -- @param Dcs.DCSTypes#Distance LandHeightAdd (optional) The default height if required to be evaluated will be the land height of the x, y coordinate. You can specify an extra height to be added to the land height. - -- @return Core.Point#COORDINATE + -- @return #COORDINATE function COORDINATE:NewFromVec2( Vec2, LandHeightAdd ) local LandHeight = land.getHeight( Vec2 ) @@ -204,9 +205,8 @@ do -- COORDINATE -- @return Core.Point#COORDINATE function COORDINATE:NewFromVec3( Vec3 ) - local self = self:New( Vec3.x, Vec3.y, Vec3.z ) + local self = self:New( Vec3.x, Vec3.y, Vec3.z ) -- #COORDINATE - --local self = BASE:Inherit( self, POINT_VEC3:NewFromVec3( Vec3 ) ) -- Core.Point#COORDINATE self:F2( self ) return self @@ -773,6 +773,37 @@ do -- COORDINATE return "MGRS, " .. UTILS.tostringMGRS( MGRS, MGRS_Accuracy ) end + --- Provides a coordinate string of the point, based on a coordinate format system: + -- * Uses default settings in COORDINATE. + -- * Can be overridden if for a GROUP containing x clients, a menu was selected to override the default. + -- @param #COORDINATE self + -- @param Wrapper.Controllable#CONTROLLABLE Controllable + -- @param Core.Settings#SETTINGS Settings + -- @return #string The coordinate Text in the configured coordinate system. + function COORDINATE:ToStringFromRP( ReferenceCoord, ReferenceName, Controllable, Settings ) -- R2.2 + + self:E( { ReferenceCoord = ReferenceCoord, ReferenceName = ReferenceName } ) + + local Settings = Settings or ( Controllable and _DATABASE:GetPlayerSettings( Controllable:GetPlayerName() ) ) or _SETTINGS + + local IsAir = Controllable and Controllable:IsAirPlane() or false + + if IsAir then + local DirectionVec3 = ReferenceCoord:GetDirectionVec3( self ) + local AngleRadians = self:GetAngleRadians( DirectionVec3 ) + local Distance = self:Get2DDistance( ReferenceCoord ) + return "Targets are the last seen " .. self:GetBRText( AngleRadians, Distance, Settings ) .. " from " .. ReferenceName + else + local DirectionVec3 = ReferenceCoord:GetDirectionVec3( self ) + local AngleRadians = self:GetAngleRadians( DirectionVec3 ) + local Distance = self:Get2DDistance( ReferenceCoord ) + return "Target are located " .. self:GetBRText( AngleRadians, Distance, Settings ) .. " from " .. ReferenceName + end + + return nil + + end + --- Provides a coordinate string of the point, based on a coordinate format system: -- * Uses default settings in COORDINATE. -- * Can be overridden if for a GROUP containing x clients, a menu was selected to override the default. @@ -1107,7 +1138,7 @@ do -- POINT_VEC2 LandHeightAdd = LandHeightAdd or 0 LandHeight = LandHeight + LandHeightAdd - local self = BASE:Inherit( self, COORDINATE:NewFromVec2( Vec2, LandHeightAdd ) ) -- Core.Point#POINT_VEC2 + local self = BASE:Inherit( self, COORDINATE:NewFromVec2( Vec2, LandHeightAdd ) ) -- #POINT_VEC2 self:F2( self ) return self @@ -1119,9 +1150,7 @@ do -- POINT_VEC2 -- @return Core.Point#POINT_VEC2 self function POINT_VEC2:NewFromVec3( Vec3 ) - local self = BASE:Inherit( self, BASE:New() ) - - local self = BASE:Inherit( self, COORDINATE:New( Vec3.x, Vec3.y, Vec3.z ) ) -- Core.Point#POINT_VEC2 + local self = BASE:Inherit( self, COORDINATE:NewFromVec3( Vec3 ) ) -- #POINT_VEC2 self:F2( self ) return self diff --git a/Moose Development/Moose/Core/Zone.lua b/Moose Development/Moose/Core/Zone.lua index 7544c43bc..8ae7aa3ff 100644 --- a/Moose Development/Moose/Core/Zone.lua +++ b/Moose Development/Moose/Core/Zone.lua @@ -225,7 +225,6 @@ end --- Returns a @{Point#COORDINATE} of the zone. -- @param #ZONE_BASE self --- @param Dcs.DCSTypes#Distance Height The height to add to the land height where the center of the zone is located. -- @return Core.Point#COORDINATE The Coordinate of the zone. function ZONE_BASE:GetCoordinate() self:F2( self.ZoneName ) diff --git a/Moose Development/Moose/Functional/Detection.lua b/Moose Development/Moose/Functional/Detection.lua index 8ece18ed5..856e40851 100644 --- a/Moose Development/Moose/Functional/Detection.lua +++ b/Moose Development/Moose/Functional/Detection.lua @@ -519,9 +519,11 @@ do -- DETECTION_BASE self.DetectionRun = 0 self:UnIdentifyAllDetectedObjects() -- Resets the DetectedObjectsIdentified table + local DetectionTimeStamp = timer.getTime() + for DetectionGroupID, DetectionGroupData in pairs( self.DetectionSetGroup:GetSet() ) do --self:E( { DetectionGroupData } ) - self:__DetectionGroup( DetectDelay, DetectionGroupData ) -- Process each detection asynchronously. + self:__DetectionGroup( DetectDelay, DetectionGroupData, DetectionTimeStamp ) -- Process each detection asynchronously. self.DetectionCount = self.DetectionCount + 1 DetectDelay = DetectDelay + 0.1 end @@ -532,7 +534,7 @@ do -- DETECTION_BASE -- @param #string Event The Event string. -- @param #string To The To State string. -- @param Wrapper.Group#GROUP DetectionGroup The Group detecting. - function DETECTION_BASE:onafterDetectionGroup( From, Event, To, DetectionGroup ) + function DETECTION_BASE:onafterDetectionGroup( From, Event, To, DetectionGroup, DetectionTimeStamp ) self:E( { From, Event, To } ) self.DetectionRun = self.DetectionRun + 1 @@ -557,7 +559,7 @@ do -- DETECTION_BASE self.DetectDLINK ) - self:T( DetectedTargets ) + self:F( DetectedTargets ) for DetectionObjectID, Detection in pairs( DetectedTargets ) do local DetectedObject = Detection.object -- Dcs.DCSWrapper.Object#Object @@ -592,7 +594,7 @@ do -- DETECTION_BASE local DetectedUnitCategory = DetectedObject:getDesc().category - self:T2( { "Detected Target:", DetectionGroupName, DetectedObjectName, Distance, DetectedUnitCategory } ) + self:F( { "Detected Target:", DetectionGroupName, DetectedObjectName, Distance, DetectedUnitCategory } ) -- Calculate Acceptance @@ -676,6 +678,7 @@ do -- DETECTION_BASE self.DetectedObjects[DetectedObjectName] = self.DetectedObjects[DetectedObjectName] or {} self.DetectedObjects[DetectedObjectName].Name = DetectedObjectName + self.DetectedObjects[DetectedObjectName].IsDetected = TargetIsDetected self.DetectedObjects[DetectedObjectName].IsVisible = TargetIsVisible self.DetectedObjects[DetectedObjectName].LastTime = TargetLastTime self.DetectedObjects[DetectedObjectName].LastPos = TargetLastPos @@ -683,6 +686,7 @@ do -- DETECTION_BASE self.DetectedObjects[DetectedObjectName].KnowType = TargetKnowType self.DetectedObjects[DetectedObjectName].KnowDistance = Detection.distance -- TargetKnowDistance self.DetectedObjects[DetectedObjectName].Distance = Distance + self.DetectedObjects[DetectedObjectName].DetectionTimeStamp = DetectionTimeStamp local DetectedUnit = UNIT:FindByName( DetectedObjectName ) @@ -706,9 +710,23 @@ do -- DETECTION_BASE if self.DetectionCount > 0 and self.DetectionRun == self.DetectionCount then self:T( "--> Create Detection Sets" ) + + -- First check if all DetectedObjects were detected. + -- This is important. When there are DetectedObjects in the list, but were not detected, + -- And these remain undetected for more than 60 seconds, then these DetectedObjects will be flagged as not Detected. + -- IsDetected = false! + -- This is used in A2A_TASK_DISPATCHER to initiate fighter sweeping! The TASK_A2A_INTERCEPT tasks will be replaced with TASK_A2A_SWEEP tasks. + for DetectedObjectName, DetectedObject in pairs( self.DetectedObjects ) do + if self.DetectedObjects[DetectedObjectName].IsDetected == true and self.DetectedObjects[DetectedObjectName].DetectionTimeStamp + 60 <= DetectionTimeStamp then + self.DetectedObjects[DetectedObjectName].IsDetected = false + end + end self:CreateDetectionItems() -- Polymorphic call to Create/Update the DetectionItems list for the DETECTION_ class grouping method. - self:CleanDetectionItems() -- Any DetectionItem that has a Set with zero elements in it, must be removed from the DetectionItems list. + for DetectedItemID, DetectedItem in pairs( self.DetectedItems ) do + self:UpdateDetectedItemDetection( DetectedItem ) + self:CleanDetectionItem( DetectedItem, DetectedItemID ) -- Any DetectionItem that has a Set with zero elements in it, must be removed from the DetectionItems list. + end self:__Detect( self.DetectionInterval ) end @@ -720,23 +738,19 @@ do -- DETECTION_BASE do -- DetectionItems Creation - --- Make a DetectionSet table. This function will be overridden in the derived clsses. + -- Clean the DetectedItem table. -- @param #DETECTION_BASE self -- @return #DETECTION_BASE - function DETECTION_BASE:CleanDetectionItems() --R2.1 Clean the DetectionItems list + function DETECTION_BASE:CleanDetectionItem( DetectedItem, DetectedItemID ) self:F2() -- We clean all DetectedItems. -- if there are any remaining DetectedItems with no Set Objects then the Item in the DetectedItems must be deleted. - for DetectedItemID, DetectedItemData in pairs( self.DetectedItems ) do - - local DetectedItem = DetectedItemData -- #DETECTION_BASE.DetectedItem - local DetectedSet = DetectedItem.Set - - if DetectedSet:Count() == 0 then - self:RemoveDetectedItem(DetectedItemID) - end + local DetectedSet = DetectedItem.Set + + if DetectedSet:Count() == 0 then + self:RemoveDetectedItem( DetectedItemID ) end return self @@ -1160,7 +1174,7 @@ do -- DETECTION_BASE --- @param Wrapper.Unit#UNIT PlayerUnit function( PlayerUnitName ) local PlayerUnit = UNIT:FindByName( PlayerUnitName ) - if PlayerUnit:IsInZone(DetectionZone) then + if PlayerUnit and PlayerUnit:IsInZone(DetectionZone) then DetectedItem.FriendliesNearBy = DetectedItem.FriendliesNearBy or {} local PlayerUnitName = PlayerUnit:GetName() DetectedItem.PlayersNearBy = DetectedItem.PlayersNearBy or {} @@ -1368,6 +1382,37 @@ do -- DETECTION_BASE return nil end + --- Set IsDetected flag for all DetectedItems. + -- @param #DETECTION_BASE self + -- @return #DETECTION_BASE.DetectedItem DetectedItem + -- @return #boolean true if at least one UNIT is detected from the DetectedSet, false if no UNIT was detected from the DetectedSet. + function DETECTION_BASE:UpdateDetectedItemDetection( DetectedItem ) + + local IsDetected = false + + for UnitName, UnitData in pairs( DetectedItem.Set:GetSet() ) do + local DetectedObject = self.DetectedObjects[UnitName] + if DetectedObject.IsDetected then + IsDetected = true + break + end + end + + self:F( { IsDetected = DetectedItem.IsDetected } ) + + DetectedItem.IsDetected = IsDetected + + return IsDetected + end + + --- Checks if there is at least one UNIT detected in the Set of the the DetectedItem. + -- @param #DETECTION_BASE self + -- @return #boolean true if at least one UNIT is detected from the DetectedSet, false if no UNIT was detected from the DetectedSet. + function DETECTION_BASE:IsDetectedItemDetected( DetectedItem ) + + return DetectedItem.IsDetected + end + do -- Coordinates --- Get the COORDINATE of a detection item using a given numeric index. @@ -2195,7 +2240,7 @@ do -- DETECTION_AREAS DetectedItem.NearestFAC = NearestFAC end - + --- Returns the A2G threat level of the units in the DetectedItem -- @param #DETECTION_AREAS self -- @param #DETECTION_BASE.DetectedItem DetectedItem @@ -2325,6 +2370,7 @@ do -- DETECTION_AREAS for DetectedItemID, DetectedItemData in pairs( self.DetectedItems ) do local DetectedItem = DetectedItemData -- #DETECTION_BASE.DetectedItem + if DetectedItem then self:T( { "Detected Item ID:", DetectedItemID } ) @@ -2489,7 +2535,7 @@ do -- DETECTION_AREAS self:ReportFriendliesNearBy( { DetectedItem = DetectedItem, ReportSetGroup = self.DetectionSetGroup } ) -- Fill the Friendlies table self:CalculateThreatLevelA2G( DetectedItem ) -- Calculate A2G threat level self:NearestFAC( DetectedItem ) - + if DETECTION_AREAS._SmokeDetectedUnits or self._SmokeDetectedUnits then DetectedZone.ZoneUNIT:SmokeRed() end diff --git a/Moose Development/Moose/Functional/Spawn.lua b/Moose Development/Moose/Functional/Spawn.lua index 6e9386a7d..862cc6f07 100644 --- a/Moose Development/Moose/Functional/Spawn.lua +++ b/Moose Development/Moose/Functional/Spawn.lua @@ -855,7 +855,10 @@ function SPAWN:SpawnWithIndex( SpawnIndex ) -- If there is a SpawnFunction hook defined, call it. if self.SpawnFunctionHook then - self.SpawnFunctionHook( self.SpawnGroups[self.SpawnIndex].Group, unpack( self.SpawnFunctionArguments ) ) + -- delay calling this for .1 seconds so that it hopefully comes after the BIRTH event of the group. + self.SpawnHookScheduler = SCHEDULER:New() + self.SpawnHookScheduler:Schedule( nil, self.SpawnFunctionHook, { self.SpawnGroups[self.SpawnIndex].Group, unpack( self.SpawnFunctionArguments)}, 0.1 ) + -- self.SpawnFunctionHook( self.SpawnGroups[self.SpawnIndex].Group, unpack( self.SpawnFunctionArguments ) ) end -- TODO: Need to fix this by putting an "R" in the name of the group when the group repeats. --if self.Repeat then diff --git a/Moose Development/Moose/Tasking/CommandCenter.lua b/Moose Development/Moose/Tasking/CommandCenter.lua index fcedca865..30a4fe883 100644 --- a/Moose Development/Moose/Tasking/CommandCenter.lua +++ b/Moose Development/Moose/Tasking/CommandCenter.lua @@ -91,6 +91,9 @@ COMMANDCENTER = { CommandCenterCoalition = nil, CommandCenterPositionable = nil, Name = "", + ReferencePoints = {}, + ReferenceNames = {}, + CommunicationMode = "80", } --- The constructor takes an IDENTIFIABLE as the HQ command center. -- @param #COMMANDCENTER self @@ -253,6 +256,46 @@ function COMMANDCENTER:RemoveMission( Mission ) return Mission end +--- Set reference points known by the command center to guide airborne units during WWII. +-- These reference points are zones, with a special name. +-- @param #COMMANDCENTER self +-- @param #string ReferenceZonePrefix Reference points. +-- @return #COMMANDCENTER +function COMMANDCENTER:SetReferenceZones( ReferenceZonePrefix ) + local MatchPattern = "(.*)#(.*)" + self:F( { MatchPattern = MatchPattern } ) + for ReferenceZoneName in pairs( _DATABASE.ZONENAMES ) do + local ZoneName, ReferenceName = string.match( ReferenceZoneName, MatchPattern ) + self:F( { ZoneName = ZoneName, ReferenceName = ReferenceName } ) + if ZoneName and ReferenceName and ZoneName == ReferenceZonePrefix then + self.ReferencePoints[ReferenceZoneName] = ZONE:New( ReferenceZoneName ) + self.ReferenceNames[ReferenceZoneName] = ReferenceName + end + end + return self +end + +--- Set the commandcenter operations in WWII mode +-- This will disable LL, MGRS, BRA, BULLS from the settings. +-- It will also disable the settings at the settings menu for these. +-- And, it will use any ReferenceZones set as reference points for communication. +-- @param #COMMANDCENTER self +-- @return #COMMANDCENTER +function COMMANDCENTER:SetModeWWII() + self.CommunicationMode = "WWII" +end + + +--- Returns if the commandcenter operations is in WWII mode +-- @param #COMMANDCENTER self +-- @return #boolean true if in WWII mode. +function COMMANDCENTER:IsModeWWII() + return self.CommunicationMode == "WWII" +end + + + + --- Sets the menu structure of the Missions governed by the HQ command center. -- @param #COMMANDCENTER self function COMMANDCENTER:SetMenu() diff --git a/Moose Development/Moose/Tasking/Task_A2A.lua b/Moose Development/Moose/Tasking/Task_A2A.lua index 2590a06f9..2bd6cfc80 100644 --- a/Moose Development/Moose/Tasking/Task_A2A.lua +++ b/Moose Development/Moose/Tasking/Task_A2A.lua @@ -384,6 +384,53 @@ do -- TASK_A2A_INTERCEPT end +do -- TASK_A2A_SWEEP + + --- The TASK_A2A_SWEEP class + -- @type TASK_A2A_SWEEP + -- @field Set#SET_UNIT TargetSetUnit + -- @extends Tasking.Task#TASK + TASK_A2A_SWEEP = { + ClassName = "TASK_A2A_SWEEP", + } + + + + --- Instantiates a new TASK_A2A_SWEEP. + -- @param #TASK_A2A_SWEEP self + -- @param Tasking.Mission#MISSION Mission + -- @param Core.Set#SET_GROUP SetGroup The set of groups for which the Task can be assigned. + -- @param #string TaskName The name of the Task. + -- @param Core.Set#SET_UNIT TargetSetUnit + -- @param #string TaskBriefing The briefing of the task. + -- @return #TASK_A2A_SWEEP self + function TASK_A2A_SWEEP:New( Mission, SetGroup, TaskName, TargetSetUnit, TaskBriefing ) + local self = BASE:Inherit( self, TASK_A2A:New( Mission, SetGroup, TaskName, TargetSetUnit, "INTERCEPT", TaskBriefing ) ) -- #TASK_A2A_SWEEP + self:F() + + Mission:AddTask( self ) + + --TODO: Add BR, Altitude, type of planes... + + self:SetBriefing( + TaskBriefing or + "Perform a fighter sweep. Incoming intruders were detected and could be hiding at the location.\n" + ) + + local TargetCoordinate = TargetSetUnit:GetFirst():GetCoordinate() + self:SetInfo( "Coordinates", TargetCoordinate ) + + self:SetInfo( "Assumed Threat", "[" .. string.rep( "■", TargetSetUnit:CalculateThreatLevelA2G() ) .. "]" ) + local DetectedItemsCount = TargetSetUnit:Count() + local DetectedItemsTypes = TargetSetUnit:GetTypeNames() + self:SetInfo( "Lost Targets", string.format( "%d of %s", DetectedItemsCount, DetectedItemsTypes ) ) + + return self + end + +end + + do -- TASK_A2A_ENGAGE --- The TASK_A2A_ENGAGE class diff --git a/Moose Development/Moose/Tasking/Task_A2A_Dispatcher.lua b/Moose Development/Moose/Tasking/Task_A2A_Dispatcher.lua index ca0f56050..0a7d58a08 100644 --- a/Moose Development/Moose/Tasking/Task_A2A_Dispatcher.lua +++ b/Moose Development/Moose/Tasking/Task_A2A_Dispatcher.lua @@ -1,35 +1,6 @@ --- **Tasking** - The TASK_A2A_DISPATCHER creates and manages player TASK_A2A tasks based on detected targets. -- -- === --- --- # 1) @{#TASK_A2A_DISPATCHER} class, extends @{#DETECTION_MANAGER} --- --- The @{#TASK_A2A_DISPATCHER} class implements the dynamic dispatching of tasks upon groups of detected units determined a @{Set} of EWR installation groups. --- The EWR will detect units, will group them, and will dispatch @{Task}s to groups. Depending on the type of target detected, different tasks will be dispatched. --- Find a summary below describing for which situation a task type is created: --- --- * **INTERCEPT Task**: Is created when the target is known, is detected and within a danger zone, and there is no friendly airborne in range. --- * **SWEEP Task**: Is created when the target is unknown, was detected and the last position is only known, and within a danger zone, and there is no friendly airborne in range. --- * **ENGAGE Task**: Is created when the target is known, is detected and within a danger zone, and there is a friendly airborne in range, that will receive this task. --- --- Other task types will follow... --- --- 3.1) TASK_A2A_DISPATCHER constructor: --- -------------------------------------- --- The @{#TASK_A2A_DISPATCHER.New}() method creates a new TASK_A2A_DISPATCHER instance. --- --- === --- --- # **API CHANGE HISTORY** --- --- The underlying change log documents the API changes. Please read this carefully. The following notation is used: --- --- * **Added** parts are expressed in bold type face. --- * _Removed_ parts are expressed in italic type face. --- --- Hereby the change log: --- --- === -- -- # **AUTHORS and CONTRIBUTIONS** -- @@ -45,15 +16,31 @@ do -- TASK_A2A_DISPATCHER --- TASK_A2A_DISPATCHER class. -- @type TASK_A2A_DISPATCHER - -- @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. The Detection object will only function in RADAR mode!!! - -- @field Tasking.Mission#MISSION Mission -- @extends Tasking.DetectionManager#DETECTION_MANAGER + + --- # TASK_A2A_DISPATCHER class, extends @{Tasking#DETECTION_MANAGER} + -- + -- The @{#TASK_A2A_DISPATCHER} class implements the dynamic dispatching of tasks upon groups of detected units determined a @{Set} of EWR installation groups. + -- The EWR will detect units, will group them, and will dispatch @{Task}s to groups. Depending on the type of target detected, different tasks will be dispatched. + -- Find a summary below describing for which situation a task type is created: + -- + -- * **INTERCEPT Task**: Is created when the target is known, is detected and within a danger zone, and there is no friendly airborne in range. + -- * **SWEEP Task**: Is created when the target is unknown, was detected and the last position is only known, and within a danger zone, and there is no friendly airborne in range. + -- * **ENGAGE Task**: Is created when the target is known, is detected and within a danger zone, and there is a friendly airborne in range, that will receive this task. + -- + -- Other task types will follow... + -- + -- # TASK_A2A_DISPATCHER constructor: + -- -------------------------------------- + -- The @{#TASK_A2A_DISPATCHER.New}() method creates a new TASK_A2A_DISPATCHER instance. + -- + -- @field #TASK_A2A_DISPATCHER TASK_A2A_DISPATCHER = { ClassName = "TASK_A2A_DISPATCHER", Mission = nil, Detection = nil, Tasks = {}, + SweepZones = {}, } @@ -71,6 +58,8 @@ do -- TASK_A2A_DISPATCHER self.Detection = Detection self.Mission = Mission + + -- TODO: Check detection through radar. self.Detection:FilterCategories( Unit.Category.AIRPLANE, Unit.Category.HELICOPTER ) --self.Detection:InitDetectRadar( true ) self.Detection:SetDetectionInterval( 30 ) @@ -104,10 +93,11 @@ do -- TASK_A2A_DISPATCHER local DetectedSet = DetectedItem.Set local DetectedZone = DetectedItem.Zone + -- Check if there is at least one UNIT in the DetectedSet is visible. + + if DetectedItem.IsDetected == true then - if true then - - -- Here we're doing something advanced... We're copying the DetectedSet, but making a new Set only with SEADable Radar units in it. + -- Here we're doing something advanced... We're copying the DetectedSet. local TargetSetUnit = SET_UNIT:New() TargetSetUnit:SetDatabase( DetectedSet ) TargetSetUnit:FilterOnce() -- Filter but don't do any events!!! Elements are added manually upon each detection. @@ -117,6 +107,33 @@ do -- TASK_A2A_DISPATCHER return nil end + + + --- Creates an SWEEP task when there are targets for it. + -- @param #TASK_A2A_DISPATCHER self + -- @param Functional.Detection#DETECTION_BASE.DetectedItem DetectedItem + -- @return Set#SET_UNIT TargetSetUnit: The target set of units. + -- @return #nil If there are no targets to be set. + function TASK_A2A_DISPATCHER:EvaluateSWEEP( DetectedItem ) + self:F( { DetectedItem.ItemID } ) + + local DetectedSet = DetectedItem.Set + local DetectedZone = DetectedItem.Zone + + + if DetectedItem.IsDetected == false then + + -- Here we're doing something advanced... We're copying the DetectedSet. + local TargetSetUnit = SET_UNIT:New() + TargetSetUnit:SetDatabase( DetectedSet ) + TargetSetUnit:FilterOnce() -- Filter but don't do any events!!! Elements are added manually upon each detection. + + return TargetSetUnit + end + + return nil + end + --- Creates an ENGAGE task when there are human friendlies airborne near the targets. -- @param #TASK_A2A_DISPATCHER self @@ -131,10 +148,11 @@ do -- TASK_A2A_DISPATCHER local PlayersCount, PlayersReport = self:GetPlayerFriendliesNearBy( DetectedItem ) + + -- Only allow ENGAGE when there are Players near the zone, and when the Area has detected items since the last run in a 60 seconds time zone. + if PlayersCount > 0 and DetectedItem.IsDetected == true then - if PlayersCount > 0 then - - -- Here we're doing something advanced... We're copying the DetectedSet, but making a new Set only with SEADable Radar units in it. + -- Here we're doing something advanced... We're copying the DetectedSet. local TargetSetUnit = SET_UNIT:New() TargetSetUnit:SetDatabase( DetectedSet ) TargetSetUnit:FilterOnce() -- Filter but don't do any events!!! Elements are added manually upon each detection. @@ -180,6 +198,15 @@ do -- TASK_A2A_DISPATCHER if IsPlayers == true then Remove = true end + if DetectedItem.IsDetected == false then + Remove = true + end + end + + if TaskType == "SWEEP" then + if DetectedItem.IsDetected == true then + Remove = true + end end local DetectedSet = DetectedItem.Set -- Core.Set#SET_UNIT @@ -350,6 +377,11 @@ do -- TASK_A2A_DISPATCHER local TargetSetUnit = self:EvaluateINTERCEPT( DetectedItem ) -- Returns a SetUnit if there are targets to be INTERCEPTed... if TargetSetUnit then Task = TASK_A2A_INTERCEPT:New( Mission, self.SetGroup, string.format( "INTERCEPT.%03d", DetectedID ), TargetSetUnit ) + else + local TargetSetUnit = self:EvaluateSWEEP( DetectedItem ) -- Returns a SetUnit + if TargetSetUnit then + Task = TASK_A2A_SWEEP:New( Mission, self.SetGroup, string.format( "SWEEP.%03d", DetectedID ), TargetSetUnit ) + end end end diff --git a/Moose Development/Moose/Wrapper/Controllable.lua b/Moose Development/Moose/Wrapper/Controllable.lua index a1e05db0d..d56bb6dad 100644 --- a/Moose Development/Moose/Wrapper/Controllable.lua +++ b/Moose Development/Moose/Wrapper/Controllable.lua @@ -61,6 +61,7 @@ -- * @{#CONTROLLABLE.EnRouteTaskAWACS}: (AIR) Aircraft will act as an AWACS for friendly units (will provide them with information about contacts). No parameters. -- * @{#CONTROLLABLE.EnRouteTaskEngageControllable}: (AIR) Engaging a controllable. The task does not assign the target controllable to the unit/controllable to attack now; it just allows the unit/controllable to engage the target controllable as well as other assigned targets. -- * @{#CONTROLLABLE.EnRouteTaskEngageTargets}: (AIR) Engaging targets of defined types. +-- * @{#CONTROLLABLE.EnRouteTaskEngageTargetsInZone}: (AIR) Engaging a targets of defined types at circle-shaped zone. -- * @{#CONTROLLABLE.EnRouteTaskEWR}: (AIR) Attack the Unit. -- * @{#CONTROLLABLE.EnRouteTaskFAC}: (AIR + GROUND) The task makes the controllable/unit a FAC and lets the FAC to choose a targets (enemy ground controllable) around as well as other assigned targets. -- * @{#CONTROLLABLE.EnRouteTaskFAC_EngageControllable}: (AIR + GROUND) The task makes the controllable/unit a FAC and lets the FAC to choose the target (enemy ground controllable) as well as other assigned targets. @@ -1088,7 +1089,7 @@ end -- @param Dcs.DCSTypes#AttributeNameArray TargetTypes Array of target categories allowed to engage. -- @param #number Priority All en-route tasks have the priority parameter. This is a number (less value - higher priority) that determines actions related to what task will be performed first. -- @return Dcs.DCSTasking.Task#Task The DCS task structure. -function CONTROLLABLE:EnRouteTaskEngageTargets( Vec2, Radius, TargetTypes, Priority ) +function CONTROLLABLE:EnRouteTaskEngageTargetsInZone( Vec2, Radius, TargetTypes, Priority ) self:F2( { self.ControllableName, Vec2, Radius, TargetTypes, Priority } ) -- EngageTargetsInZone = { diff --git a/Utils/Slate Documentation Generator/bin/TreeHierarchy.csv b/Utils/Slate Documentation Generator/bin/TreeHierarchy.csv index c5a17961d..2f09984f2 100644 --- a/Utils/Slate Documentation Generator/bin/TreeHierarchy.csv +++ b/Utils/Slate Documentation Generator/bin/TreeHierarchy.csv @@ -8,21 +8,21 @@ @K=function, @M=Task_A2G, @N=onafterEngage, @P=Fsm, @F=../../../MOOSE/Moose Development/Moose\Tasking\Task_A2G.lua, @C=6215, @K=function, @M=Task_A2G, @N=onafterRouteToTarget, @P=Fsm, @F=../../../MOOSE/Moose Development/Moose\Tasking\Task_A2G.lua, @C=6537, @K=function, @M=Task_A2G, @N=onafterRouteToTargets, @P=Fsm, @F=../../../MOOSE/Moose Development/Moose\Tasking\Task_A2G.lua, @C=7416, -@K=function, @M=Task_Cargo, @N=onafterSelectAction, @P=Fsm, @F=../../../MOOSE/Moose Development/Moose\Tasking\Task_CARGO.lua, @C=10673, -@K=function, @M=Task_Cargo, @N=OnLeaveWaitingForCommand, @P=Fsm, @F=../../../MOOSE/Moose Development/Moose\Tasking\Task_CARGO.lua, @C=13702, -@K=function, @M=Task_Cargo, @N=onafterRouteToPickup, @P=Fsm, @F=../../../MOOSE/Moose Development/Moose\Tasking\Task_CARGO.lua, @C=14474, -@K=function, @M=Task_Cargo, @N=onafterArriveAtPickup, @P=Fsm, @F=../../../MOOSE/Moose Development/Moose\Tasking\Task_CARGO.lua, @C=15093, -@K=function, @M=Task_Cargo, @N=onafterCancelRouteToPickup, @P=Fsm, @F=../../../MOOSE/Moose Development/Moose\Tasking\Task_CARGO.lua, @C=15634, -@K=function, @M=Task_Cargo, @N=onafterRouteToDeploy, @P=Fsm, @F=../../../MOOSE/Moose Development/Moose\Tasking\Task_CARGO.lua, @C=15971, -@K=function, @M=Task_Cargo, @N=onafterArriveAtDeploy, @P=Fsm, @F=../../../MOOSE/Moose Development/Moose\Tasking\Task_CARGO.lua, @C=16418, -@K=function, @M=Task_Cargo, @N=onafterCancelRouteToDeploy, @P=Fsm, @F=../../../MOOSE/Moose Development/Moose\Tasking\Task_CARGO.lua, @C=16846, -@K=function, @M=Task_Cargo, @N=onafterLanded, @P=Fsm, @F=../../../MOOSE/Moose Development/Moose\Tasking\Task_CARGO.lua, @C=18133, -@K=function, @M=Task_Cargo, @N=onafterPrepareBoarding, @P=Fsm, @F=../../../MOOSE/Moose Development/Moose\Tasking\Task_CARGO.lua, @C=18899, -@K=function, @M=Task_Cargo, @N=onafterBoard, @P=Fsm, @F=../../../MOOSE/Moose Development/Moose\Tasking\Task_CARGO.lua, @C=19359, -@K=function, @M=Task_Cargo, @N=onafterBoarded, @P=Fsm, @F=../../../MOOSE/Moose Development/Moose\Tasking\Task_CARGO.lua, @C=20300, -@K=function, @M=Task_Cargo, @N=onafterPrepareUnBoarding, @P=Fsm, @F=../../../MOOSE/Moose Development/Moose\Tasking\Task_CARGO.lua, @C=20983, -@K=function, @M=Task_Cargo, @N=onafterUnBoard, @P=Fsm, @F=../../../MOOSE/Moose Development/Moose\Tasking\Task_CARGO.lua, @C=21943, -@K=function, @M=Task_Cargo, @N=onafterUnBoarded, @P=Fsm, @F=../../../MOOSE/Moose Development/Moose\Tasking\Task_CARGO.lua, @C=22962, +@K=function, @M=Task_Cargo, @N=onafterSelectAction, @P=Fsm, @F=../../../MOOSE/Moose Development/Moose\Tasking\Task_CARGO.lua, @C=10711, +@K=function, @M=Task_Cargo, @N=OnLeaveWaitingForCommand, @P=Fsm, @F=../../../MOOSE/Moose Development/Moose\Tasking\Task_CARGO.lua, @C=13740, +@K=function, @M=Task_Cargo, @N=onafterRouteToPickup, @P=Fsm, @F=../../../MOOSE/Moose Development/Moose\Tasking\Task_CARGO.lua, @C=14601, +@K=function, @M=Task_Cargo, @N=onafterArriveAtPickup, @P=Fsm, @F=../../../MOOSE/Moose Development/Moose\Tasking\Task_CARGO.lua, @C=15222, +@K=function, @M=Task_Cargo, @N=onafterCancelRouteToPickup, @P=Fsm, @F=../../../MOOSE/Moose Development/Moose\Tasking\Task_CARGO.lua, @C=15751, +@K=function, @M=Task_Cargo, @N=onafterRouteToDeploy, @P=Fsm, @F=../../../MOOSE/Moose Development/Moose\Tasking\Task_CARGO.lua, @C=16088, +@K=function, @M=Task_Cargo, @N=onafterArriveAtDeploy, @P=Fsm, @F=../../../MOOSE/Moose Development/Moose\Tasking\Task_CARGO.lua, @C=16535, +@K=function, @M=Task_Cargo, @N=onafterCancelRouteToDeploy, @P=Fsm, @F=../../../MOOSE/Moose Development/Moose\Tasking\Task_CARGO.lua, @C=16963, +@K=function, @M=Task_Cargo, @N=onafterLanded, @P=Fsm, @F=../../../MOOSE/Moose Development/Moose\Tasking\Task_CARGO.lua, @C=18250, +@K=function, @M=Task_Cargo, @N=onafterPrepareBoarding, @P=Fsm, @F=../../../MOOSE/Moose Development/Moose\Tasking\Task_CARGO.lua, @C=19016, +@K=function, @M=Task_Cargo, @N=onafterBoard, @P=Fsm, @F=../../../MOOSE/Moose Development/Moose\Tasking\Task_CARGO.lua, @C=19476, +@K=function, @M=Task_Cargo, @N=onafterBoarded, @P=Fsm, @F=../../../MOOSE/Moose Development/Moose\Tasking\Task_CARGO.lua, @C=20417, +@K=function, @M=Task_Cargo, @N=onafterPrepareUnBoarding, @P=Fsm, @F=../../../MOOSE/Moose Development/Moose\Tasking\Task_CARGO.lua, @C=21100, +@K=function, @M=Task_Cargo, @N=onafterUnBoard, @P=Fsm, @F=../../../MOOSE/Moose Development/Moose\Tasking\Task_CARGO.lua, @C=22060, +@K=function, @M=Task_Cargo, @N=onafterUnBoarded, @P=Fsm, @F=../../../MOOSE/Moose Development/Moose\Tasking\Task_CARGO.lua, @C=23079, @K=function, @M=Designate, @N=OnBeforeLaseOn, @P=DESIGNATE , @F=../../../MOOSE/Moose Development/Moose\Functional\Designate.lua, @C=12218, @K=function, @M=Designate, @N=OnAfterLaseOn, @P=DESIGNATE , @F=../../../MOOSE/Moose Development/Moose\Functional\Designate.lua, @C=12466, @K=function, @M=Designate, @N=LaseOn, @P=DESIGNATE , @F=../../../MOOSE/Moose Development/Moose\Functional\Designate.lua, @C=12687, diff --git a/docs/Documentation/Cargo.html b/docs/Documentation/Cargo.html index 875f99a43..243a8f68c 100644 --- a/docs/Documentation/Cargo.html +++ b/docs/Documentation/Cargo.html @@ -119,9 +119,9 @@
Returns the current minimum height of the group.
+Gets the player name of the group.
Gets the player name of the group.
+ +#string: +The player name of the group.
+ +MissionGoals Trigger for MISSION
OnAfter Transition Handler for Event Fail.
+MissionGoals Handler OnAfter for MISSION
OnBefore Transition Handler for Event Fail.
+MissionGoals Handler OnBefore for MISSION
Asynchronous Event Trigger for Event Fail.
+MissionGoals Asynchronous Trigger for MISSION
MissionGoals Trigger for MISSION
+MissionGoals Handler OnAfter for MISSION
+ +#string From :
#string Event :
#string To :
#boolean: Return false to cancel Transition.
+ +MissionGoals Handler OnBefore for MISSION
+ +#string From :
#string Event :
#string To :
#boolean:
+ +MissionGoals Asynchronous Trigger for MISSION
+ +#number Delay :
Returns if a Coordinate has Line of Sight (LOS) with the ToCoordinate.
-Is the mode to A2A
-Is the mode to A2G
-Set the mode to A2A
-Set the mode to A2G
#boolean: true If the ToCoordinate has LOS with the Coordinate, otherwise false.
- - -Is the mode to A2A
- -#boolean:
- - -Is the mode to A2G
- -#boolean:
- - -Set the mode to A2A
- -Set the mode to A2G
- -(default true)
(default true)
By default, no InitLimit
+Set a score when all the targets in scope of the A2G attack, have been destroyed.
+@return SmokeColor
+ Color :
+Might be SMOKECOLOR.Blue, SMOKECOLOR.Red SMOKECOLOR.Orange, SMOKECOLOR.White or SMOKECOLOR.Green
self :
SmokeColor :