From 00d1aec210225ec2b69e50792cb1cfe1aafe5e6d Mon Sep 17 00:00:00 2001 From: TommyC81 Date: Tue, 28 Dec 2021 14:01:05 +0400 Subject: [PATCH] General fixes (#1673) * General minor Code formatting and minor typo/document fixes. * Update Marker.lua Code formatting and minor typo/document fixes. Note specifically the correction of "self.tocoaliton" to "self.tocoalition". --- Moose Development/Moose/AI/AI_A2A_Cap.lua | 6 +- .../Moose/AI/AI_A2A_Dispatcher.lua | 698 ++++++-------- Moose Development/Moose/AI/AI_A2A_Gci.lua | 6 +- Moose Development/Moose/AI/AI_A2A_Patrol.lua | 12 +- .../Moose/AI/AI_A2G_Dispatcher.lua | 22 +- Moose Development/Moose/AI/AI_A2G_SEAD.lua | 4 +- Moose Development/Moose/AI/AI_Air.lua | 16 +- .../Moose/AI/AI_Air_Dispatcher.lua | 122 ++- Moose Development/Moose/AI/AI_Air_Engage.lua | 4 +- Moose Development/Moose/AI/AI_Air_Patrol.lua | 6 +- Moose Development/Moose/AI/AI_BAI.lua | 8 +- Moose Development/Moose/AI/AI_CAP.lua | 8 +- Moose Development/Moose/AI/AI_CAS.lua | 8 +- Moose Development/Moose/AI/AI_Patrol.lua | 28 +- Moose Development/Moose/Cargo/Cargo.lua | 4 +- Moose Development/Moose/Core/Database.lua | 7 +- Moose Development/Moose/Core/Event.lua | 9 +- Moose Development/Moose/Core/Fsm.lua | 24 +- Moose Development/Moose/Core/Menu.lua | 2 +- Moose Development/Moose/Core/Spawn.lua | 4 +- Moose Development/Moose/Core/Zone.lua | 492 +++++----- .../Moose/Functional/Artillery.lua | 2 +- Moose Development/Moose/Functional/RAT.lua | 6 +- .../Moose/Functional/Warehouse.lua | 12 +- .../Moose/Functional/ZoneCaptureCoalition.lua | 27 +- .../Moose/Functional/ZoneGoalCoalition.lua | 110 ++- Moose Development/Moose/Ops/Airboss.lua | 2 +- Moose Development/Moose/Tasking/Mission.lua | 2 +- Moose Development/Moose/Tasking/Task.lua | 2 +- Moose Development/Moose/Utilities/Utils.lua | 2 +- .../Moose/Wrapper/Controllable.lua | 881 ++++++++---------- .../Moose/Wrapper/Identifiable.lua | 2 +- Moose Development/Moose/Wrapper/Marker.lua | 353 ++++--- 33 files changed, 1329 insertions(+), 1562 deletions(-) diff --git a/Moose Development/Moose/AI/AI_A2A_Cap.lua b/Moose Development/Moose/AI/AI_A2A_Cap.lua index f86bed9c0..aa43344e6 100644 --- a/Moose Development/Moose/AI/AI_A2A_Cap.lua +++ b/Moose Development/Moose/AI/AI_A2A_Cap.lua @@ -40,8 +40,8 @@ -- -- ![Process](..\Presentations\AI_CAP\Dia10.JPG) -- --- Until a fuel or damage treshold has been reached by the AI, or when the AI is commanded to RTB. --- When the fuel treshold has been reached, the airplane will fly towards the nearest friendly airbase and will land. +-- Until a fuel or damage threshold has been reached by the AI, or when the AI is commanded to RTB. +-- When the fuel threshold has been reached, the airplane will fly towards the nearest friendly airbase and will land. -- -- ![Process](..\Presentations\AI_CAP\Dia13.JPG) -- @@ -71,7 +71,7 @@ -- * **@{AI.AI_Patrol#AI_PATROL_ZONE.Detected}**: The AI has detected new targets. -- * **@{#AI_A2A_CAP.Destroy}**: The AI has destroyed a bogey @{Wrapper.Unit}. -- * **@{#AI_A2A_CAP.Destroyed}**: The AI has destroyed all bogeys @{Wrapper.Unit}s assigned in the CAS task. --- * **Status** ( Group ): The AI is checking status (fuel and damage). When the tresholds have been reached, the AI will RTB. +-- * **Status** ( Group ): The AI is checking status (fuel and damage). When the thresholds have been reached, the AI will RTB. -- -- ## 3. Set the Range of Engagement -- diff --git a/Moose Development/Moose/AI/AI_A2A_Dispatcher.lua b/Moose Development/Moose/AI/AI_A2A_Dispatcher.lua index 941ac29e5..6c5ac333c 100644 --- a/Moose Development/Moose/AI/AI_A2A_Dispatcher.lua +++ b/Moose Development/Moose/AI/AI_A2A_Dispatcher.lua @@ -40,7 +40,7 @@ -- AI\_A2A\_DISPATCHER is the main A2A defense class that models the A2A defense system. -- AI\_A2A\_GCICAP derives or inherits from AI\_A2A\_DISPATCHER and is a more **noob** user friendly class, but is less flexible. -- --- Before you start using the AI\_A2A\_DISPATCHER or AI\_A2A\_GCICAP ask youself the following questions. +-- Before you start using the AI\_A2A\_DISPATCHER or AI\_A2A\_GCICAP ask yourself the following questions. -- -- ## 0. Do I need AI\_A2A\_DISPATCHER or do I need AI\_A2A\_GCICAP? -- @@ -82,7 +82,7 @@ -- -- A good functioning defense will have a "maximum range" evaluated to the enemy when CAP will be engaged or GCI will be spawned. -- --- ## 6. Which Airbases, Carrier Ships, Farps will take part in the defense system for the Coalition? +-- ## 6. Which Airbases, Carrier Ships, FARPs will take part in the defense system for the Coalition? -- -- Carefully plan which airbases will take part in the coalition. Color each airbase in the color of the coalition. -- @@ -91,7 +91,7 @@ -- The defense system works with Squadrons. Each Squadron must be given a unique name, that forms the **key** to the defense system. -- Several options and activities can be set per Squadron. -- --- ## 8. Where will the Squadrons be located? On Airbases? On Carrier Ships? On Farps? +-- ## 8. Where will the Squadrons be located? On Airbases? On Carrier Ships? On FARPs? -- -- Squadrons are placed as the "home base" on an airfield, carrier or farp. -- Carefully plan where each Squadron will be located as part of the defense system. @@ -149,7 +149,7 @@ -- * From a parking spot with running engines -- * From a parking spot with cold engines -- --- **The default takeoff method is staight in the air.** +-- **The default takeoff method is straight in the air.** -- -- ## 17. For each Squadron, which landing method will I use? -- @@ -185,8 +185,6 @@ -- @module AI.AI_A2A_Dispatcher -- @image AI_Air_To_Air_Dispatching.JPG - - do -- AI_A2A_DISPATCHER --- AI_A2A_DISPATCHER class. @@ -266,7 +264,7 @@ do -- AI_A2A_DISPATCHER -- **DetectionSetGroup** is then being configured to filter all active groups with a group name starting with **DF CCCP AWACS** or **DF CCCP EWR** to be included in the Set. -- **DetectionSetGroup** is then being ordered to start the dynamic filtering. Note that any destroy or new spawn of a group with the above names will be removed or added to the Set. -- - -- Then a new Detection object is created from the class DETECTION_AREAS. A grouping radius of 30000 is choosen, which is 30km. + -- Then a new Detection object is created from the class DETECTION_AREAS. A grouping radius of 30000 is chosen, which is 30km. -- The **Detection** object is then passed to the @{#AI_A2A_DISPATCHER.New}() method to indicate the EWR network configuration and setup the A2A defense detection mechanism. -- -- You could build a **mutual defense system** like this: @@ -474,7 +472,7 @@ do -- AI_A2A_DISPATCHER -- * @{#AI_A2A_DISPATCHER.SetSquadronLandingAtRunway}() will despawn the returning aircraft directly after landing at the runway. -- * @{#AI_A2A_DISPATCHER.SetSquadronLandingAtEngineShutdown}() will despawn the returning aircraft when the aircraft has returned to its parking spot and has turned off its engines. -- - -- You can use these methods to minimize the airbase coodination overhead and to increase the airbase efficiency. + -- You can use these methods to minimize the airbase coordination overhead and to increase the airbase efficiency. -- When there are lots of aircraft returning for landing, at the same airbase, the takeoff process will be halted, which can cause a complete failure of the -- A2A defense system, as no new CAP or GCI planes can takeoff. -- Note that the method @{#AI_A2A_DISPATCHER.SetSquadronLandingNearAirbase}() will only work for returning aircraft, not for damaged or out of fuel aircraft. @@ -502,7 +500,7 @@ do -- AI_A2A_DISPATCHER -- -- ![Banner Image](..\Presentations\AI_A2A_DISPATCHER\Dia12.JPG) -- - -- In the case of GCI, the @{#AI_A2A_DISPATCHER.SetSquadronGrouping}() method has additional behaviour. When there aren't enough CAP flights airborne, a GCI will be initiated for the remaining + -- In the case of GCI, the @{#AI_A2A_DISPATCHER.SetSquadronGrouping}() method has additional behavior. When there aren't enough CAP flights airborne, a GCI will be initiated for the remaining -- targets to be engaged. Depending on the grouping parameter, the spawned flights for GCI are grouped into this setting. -- For example with a group setting of 2, if 3 targets are detected and cannot be engaged by CAP or any airborne flight, -- a GCI needs to be started, the GCI flights will be grouped as follows: Group 1 of 2 flights and Group 2 of one flight! @@ -537,13 +535,13 @@ do -- AI_A2A_DISPATCHER -- -- The **overhead value is set for a Squadron**, and can be **dynamically adjusted** during mission execution, so to adjust the defense overhead when the tactical situation changes. -- - -- ## 6.5. Squadron fuel treshold. + -- ## 6.5. Squadron fuel threshold. -- - -- When an airplane gets **out of fuel** to a certain %-tage, which is by default **15% (0.15)**, there are two possible actions that can be taken: + -- When an airplane gets **out of fuel** to a certain %, which is by default **15% (0.15)**, there are two possible actions that can be taken: -- - The defender will go RTB, and will be replaced with a new defender if possible. -- - The defender will refuel at a tanker, if a tanker has been specified for the squadron. -- - -- Use the method @{#AI_A2A_DISPATCHER.SetSquadronFuelThreshold}() to set the **squadron fuel treshold** of spawned airplanes for all squadrons. + -- Use the method @{#AI_A2A_DISPATCHER.SetSquadronFuelThreshold}() to set the **squadron fuel threshold** of spawned airplanes for all squadrons. -- -- ## 7. Setup a squadron for CAP -- @@ -608,7 +606,7 @@ do -- AI_A2A_DISPATCHER -- * The minimum and maximum engage speed -- * The type of altitude measurement -- - -- These define how the squadron will perform the CAP while partrolling. Different terrain types requires different types of CAP. + -- These define how the squadron will perform the CAP while patrolling. Different terrain types requires different types of CAP. -- -- The @{#AI_A2A_DISPATCHER.SetSquadronCapInterval}() method specifies **how much** and **when** CAP flights will takeoff. -- @@ -676,7 +674,7 @@ do -- AI_A2A_DISPATCHER -- Essentially this controls how many flights of GCI aircraft can be active at any time. -- Note allowing large numbers of active GCI flights can adversely impact mission performance on low or medium specification hosts/servers. -- GCI needs to be setup at strategic airbases. Too far will mean that the aircraft need to fly a long way to reach the intruders, - -- too short will mean that the intruders may have alraedy passed the ideal interception point! + -- too short will mean that the intruders may have already passed the ideal interception point! -- -- For example, the following setup will create a GCI for squadron "Sochi": -- @@ -734,17 +732,17 @@ do -- AI_A2A_DISPATCHER -- -- Use the method @{#AI_A2A_DISPATCHER.SetDefaultGrouping}() to set the **default grouping** of spawned airplanes for all squadrons. -- - -- ## 10.5. Default RTB fuel treshold. + -- ## 10.5. Default RTB fuel threshold. -- - -- When an airplane gets **out of fuel** to a certain %-tage, which is **15% (0.15)**, it will go RTB, and will be replaced with a new airplane when applicable. + -- When an airplane gets **out of fuel** to a certain %, which is **15% (0.15)**, it will go RTB, and will be replaced with a new airplane when applicable. -- - -- Use the method @{#AI_A2A_DISPATCHER.SetDefaultFuelThreshold}() to set the **default fuel treshold** of spawned airplanes for all squadrons. + -- Use the method @{#AI_A2A_DISPATCHER.SetDefaultFuelThreshold}() to set the **default fuel threshold** of spawned airplanes for all squadrons. -- - -- ## 10.6. Default RTB damage treshold. + -- ## 10.6. Default RTB damage threshold. -- - -- When an airplane is **damaged** to a certain %-tage, which is **40% (0.40)**, it will go RTB, and will be replaced with a new airplane when applicable. + -- When an airplane is **damaged** to a certain %, which is **40% (0.40)**, it will go RTB, and will be replaced with a new airplane when applicable. -- - -- Use the method @{#AI_A2A_DISPATCHER.SetDefaultDamageThreshold}() to set the **default damage treshold** of spawned airplanes for all squadrons. + -- Use the method @{#AI_A2A_DISPATCHER.SetDefaultDamageThreshold}() to set the **default damage threshold** of spawned airplanes for all squadrons. -- -- ## 10.7. Default settings for CAP. -- @@ -773,7 +771,7 @@ do -- AI_A2A_DISPATCHER -- -- In the mission editor, setup a group with task Refuelling. A tanker unit of the correct coalition will be automatically selected. -- Then, use the method @{#AI_A2A_DISPATCHER.SetDefaultTanker}() to set the tanker for the dispatcher. - -- Use the method @{#AI_A2A_DISPATCHER.SetDefaultFuelThreshold}() to set the %-tage left in the defender airplane tanks when a refuel action is needed. + -- Use the method @{#AI_A2A_DISPATCHER.SetDefaultFuelThreshold}() to set the % left in the defender airplane tanks when a refuel action is needed. -- -- When the tanker specified is alive and in the air, the tanker will be used for refuelling. -- @@ -787,7 +785,7 @@ do -- AI_A2A_DISPATCHER -- A2ADispatcher:SetSquadronCapInterval("Sochi", 2, 30, 600, 1 ) -- A2ADispatcher:SetSquadronGci( "Sochi", 900, 1200 ) -- - -- -- Set the default tanker for refuelling to "Tanker", when the default fuel treshold has reached 90% fuel left. + -- -- Set the default tanker for refuelling to "Tanker", when the default fuel threshold has reached 90% fuel left. -- A2ADispatcher:SetDefaultFuelThreshold( 0.9 ) -- A2ADispatcher:SetDefaultTanker( "Tanker" ) -- @@ -852,7 +850,6 @@ do -- AI_A2A_DISPATCHER Detection = nil, } - --- Squadron data structure. -- @type AI_A2A_DISPATCHER.Squadron -- @field #string Name Name of the squadron. @@ -871,7 +868,7 @@ do -- AI_A2A_DISPATCHER -- @field #number FuelThreshold Fuel threshold [0,1] for RTB. -- @field #string TankerName Name of the refuelling tanker. -- @field #table Table of template group names of the squadron. - -- @field #table Spawn Table of spaws Core.Spawn#SPAWN. + -- @field #table Spawn Table of spawns Core.Spawn#SPAWN. -- @field #table TemplatePrefixes -- @field #boolean Racetrack If true, CAP flights will perform a racetrack pattern rather than randomly patrolling the zone. -- @field #number RacetrackLengthMin Min Length of race track in meters. Default 10,000 m. @@ -888,7 +885,7 @@ do -- AI_A2A_DISPATCHER --- @field #AI_A2A_DISPATCHER.Takeoff Takeoff AI_A2A_DISPATCHER.Takeoff = GROUP.Takeoff - --- Defnes Landing location. + --- Defines Landing type/location. -- @field Landing AI_A2A_DISPATCHER.Landing = { NearAirbase = 1, @@ -897,26 +894,26 @@ do -- AI_A2A_DISPATCHER } --- AI_A2A_DISPATCHER constructor. - -- This is defining the A2A DISPATCHER for one coaliton. + -- This is defining the A2A DISPATCHER for one coalition. -- The Dispatcher works with a @{Functional.Detection#DETECTION_BASE} object that is taking of the detection of targets using the EWR units. - -- The Detection object is polymorphic, depending on the type of detection object choosen, the detection will work differently. + -- The Detection object is polymorphic, depending on the type of detection object chosen, the detection will work differently. -- @param #AI_A2A_DISPATCHER self -- @param Functional.Detection#DETECTION_BASE Detection The DETECTION object that will detects targets using the the Early Warning Radar network. -- @return #AI_A2A_DISPATCHER self -- @usage -- - -- -- Setup the Detection, using DETECTION_AREAS. - -- -- First define the SET of GROUPs that are defining the EWR network. - -- -- Here with prefixes DF CCCP AWACS, DF CCCP EWR. - -- DetectionSetGroup = SET_GROUP:New() - -- DetectionSetGroup:FilterPrefixes( { "DF CCCP AWACS", "DF CCCP EWR" } ) - -- DetectionSetGroup:FilterStart() + -- -- Setup the Detection, using DETECTION_AREAS. + -- -- First define the SET of GROUPs that are defining the EWR network. + -- -- Here with prefixes DF CCCP AWACS, DF CCCP EWR. + -- DetectionSetGroup = SET_GROUP:New() + -- DetectionSetGroup:FilterPrefixes( { "DF CCCP AWACS", "DF CCCP EWR" } ) + -- DetectionSetGroup:FilterStart() -- - -- -- Define the DETECTION_AREAS, using the DetectionSetGroup, with a 30km grouping radius. - -- Detection = DETECTION_AREAS:New( DetectionSetGroup, 30000 ) + -- -- Define the DETECTION_AREAS, using the DetectionSetGroup, with a 30km grouping radius. + -- Detection = DETECTION_AREAS:New( DetectionSetGroup, 30000 ) -- - -- -- Now Setup the A2A dispatcher, and initialize it using the Detection object. - -- A2ADispatcher = AI_A2A_DISPATCHER:New( Detection ) -- + -- -- Now Setup the A2A dispatcher, and initialize it using the Detection object. + -- A2ADispatcher = AI_A2A_DISPATCHER:New( Detection ) -- function AI_A2A_DISPATCHER:New( Detection ) @@ -933,12 +930,12 @@ do -- AI_A2A_DISPATCHER -- TODO: Check detection through radar. self.Detection:FilterCategories( { Unit.Category.AIRPLANE, Unit.Category.HELICOPTER } ) - --self.Detection:InitDetectRadar( true ) + -- self.Detection:InitDetectRadar( true ) self.Detection:SetRefreshTimeInterval( 30 ) self:SetEngageRadius() self:SetGciRadius() - self:SetIntercept( 300 ) -- A default intercept delay time of 300 seconds. + self:SetIntercept( 300 ) -- A default intercept delay time of 300 seconds. self:SetDisengageRadius( 300000 ) -- The default Disengage Radius is 300 km. self:SetDefaultTakeoff( AI_A2A_DISPATCHER.Takeoff.Air ) @@ -951,7 +948,6 @@ do -- AI_A2A_DISPATCHER self:SetDefaultCapTimeInterval( 180, 600 ) -- Between 180 and 600 seconds. self:SetDefaultCapLimit( 1 ) -- Maximum one CAP per squadron. - self:AddTransition( "Started", "Assign", "Started" ) --- OnAfter Transition Handler for Event Assign. @@ -1059,17 +1055,14 @@ do -- AI_A2A_DISPATCHER -- @param Functional.Detection#DETECTION_BASE.DetectedItem AttackerDetection Detected item. -- @param #table Defenders Defenders table. - -- Subscribe to the CRASH event so that when planes are shot -- by a Unit from the dispatcher, they will be removed from the detection... -- This will avoid the detection to still "know" the shot unit until the next detection. -- Otherwise, a new intercept or engage may happen for an already shot plane! - self:HandleEvent( EVENTS.Crash, self.OnEventCrashOrDead ) self:HandleEvent( EVENTS.Dead, self.OnEventCrashOrDead ) - --self:HandleEvent( EVENTS.RemoveUnit, self.OnEventCrashOrDead ) - + -- self:HandleEvent( EVENTS.RemoveUnit, self.OnEventCrashOrDead ) self:HandleEvent( EVENTS.Land ) self:HandleEvent( EVENTS.EngineShutdown ) @@ -1086,7 +1079,6 @@ do -- AI_A2A_DISPATCHER return self end - --- On after "Start" event. -- @param #AI_A2A_DISPATCHER self function AI_A2A_DISPATCHER:onafterStart( From, Event, To ) @@ -1094,8 +1086,8 @@ do -- AI_A2A_DISPATCHER self:GetParent( self, AI_A2A_DISPATCHER ).onafterStart( self, From, Event, To ) -- Spawn the resources. - for SquadronName,_DefenderSquadron in pairs( self.DefenderSquadrons ) do - local DefenderSquadron=_DefenderSquadron --#AI_A2A_DISPATCHER.Squadron + for SquadronName, _DefenderSquadron in pairs( self.DefenderSquadrons ) do + local DefenderSquadron = _DefenderSquadron -- #AI_A2A_DISPATCHER.Squadron DefenderSquadron.Resources = {} if DefenderSquadron.ResourceCount then for Resource = 1, DefenderSquadron.ResourceCount do @@ -1105,7 +1097,6 @@ do -- AI_A2A_DISPATCHER end end - --- Park defender. -- @param #AI_A2A_DISPATCHER self -- @param #AI_A2A_DISPATCHER.Squadron DefenderSquadron The squadron. @@ -1113,7 +1104,7 @@ do -- AI_A2A_DISPATCHER local TemplateID = math.random( 1, #DefenderSquadron.Spawn ) - local Spawn = DefenderSquadron.Spawn[ TemplateID ] -- Core.Spawn#SPAWN + local Spawn = DefenderSquadron.Spawn[TemplateID] -- Core.Spawn#SPAWN Spawn:InitGrouping( 1 ) @@ -1121,11 +1112,11 @@ do -- AI_A2A_DISPATCHER if self:IsSquadronVisible( DefenderSquadron.Name ) then - local Grouping=DefenderSquadron.Grouping or self.DefenderDefault.Grouping + local Grouping = DefenderSquadron.Grouping or self.DefenderDefault.Grouping - Grouping=1 + Grouping = 1 - Spawn:InitGrouping(Grouping) + Spawn:InitGrouping( Grouping ) SpawnGroup = Spawn:SpawnAtAirbase( DefenderSquadron.Airbase, SPAWN.Takeoff.Cold ) @@ -1137,15 +1128,14 @@ do -- AI_A2A_DISPATCHER DefenderSquadron.Resources[TemplateID][GroupName] = {} DefenderSquadron.Resources[TemplateID][GroupName] = SpawnGroup - self.uncontrolled=self.uncontrolled or {} - self.uncontrolled[DefenderSquadron.Name]=self.uncontrolled[DefenderSquadron.Name] or {} + self.uncontrolled = self.uncontrolled or {} + self.uncontrolled[DefenderSquadron.Name] = self.uncontrolled[DefenderSquadron.Name] or {} - table.insert(self.uncontrolled[DefenderSquadron.Name], {group=SpawnGroup, name=GroupName, grouping=Grouping}) + table.insert( self.uncontrolled[DefenderSquadron.Name], { group = SpawnGroup, name = GroupName, grouping = Grouping } ) end end - --- Event base captured. -- @param #AI_A2A_DISPATCHER self -- @param Core.Event#EVENTDATA EventData @@ -1210,8 +1200,7 @@ do -- AI_A2A_DISPATCHER if Squadron then self:F( { SquadronName = Squadron.Name } ) local LandingMethod = self:GetSquadronLanding( Squadron.Name ) - if LandingMethod == AI_A2A_DISPATCHER.Landing.AtEngineShutdown and - not DefenderUnit:InAir() then + if LandingMethod == AI_A2A_DISPATCHER.Landing.AtEngineShutdown and not DefenderUnit:InAir() then local DefenderSize = Defender:GetSize() if DefenderSize == 1 then self:RemoveDefenderFromSquadron( Squadron, Defender ) @@ -1266,7 +1255,7 @@ do -- AI_A2A_DISPATCHER -- A2ADispatcher:SetDisengageRadius( 50000 ) -- -- -- Set 100km as the Disengage Radius. - -- A2ADispatcher:SetDisngageRadius() -- 300000 is the default value. + -- A2ADispatcher:SetDisengageRadius() -- 300000 is the default value. -- function AI_A2A_DISPATCHER:SetDisengageRadius( DisengageRadius ) @@ -1275,7 +1264,6 @@ do -- AI_A2A_DISPATCHER return self end - --- Define the radius to check if a target can be engaged by an ground controlled intercept. -- When targets are detected that are still really far off, you don't want the AI_A2A_DISPATCHER to launch intercepts just yet. -- You want it to wait until a certain Gci range is reached, which is the **distance of the closest airbase to target** @@ -1310,8 +1298,6 @@ do -- AI_A2A_DISPATCHER return self end - - --- Define a border area to simulate a **cold war** scenario. -- A **cold war** is one where CAP aircraft patrol their territory but will not attack enemy aircraft or launch GCI aircraft unless enemy aircraft enter their territory. In other words the EWR may detect an enemy aircraft but will only send aircraft to attack it if it crosses the border. -- A **hot war** is one where CAP aircraft will intercept any detected enemy aircraft and GCI aircraft will launch against detected enemy aircraft without regard for territory. In other words if the ground radar can detect the enemy aircraft then it will send CAP and GCI aircraft to attack it. @@ -1369,18 +1355,17 @@ do -- AI_A2A_DISPATCHER return self end - - --- Set the default damage treshold when defenders will RTB. - -- The default damage treshold is by default set to 40%, which means that when the airplane is 40% damaged, it will go RTB. + --- Set the default damage threshold when defenders will RTB. + -- The default damage threshold is by default set to 40%, which means that when the airplane is 40% damaged, it will go RTB. -- @param #AI_A2A_DISPATCHER self - -- @param #number DamageThreshold A decimal number between 0 and 1, that expresses the %-tage of the damage treshold before going RTB. + -- @param #number DamageThreshold A decimal number between 0 and 1, that expresses the % of the damage threshold before going RTB. -- @return #AI_A2A_DISPATCHER self -- @usage -- -- -- Now Setup the A2A dispatcher, and initialize it using the Detection object. -- A2ADispatcher = AI_A2A_DISPATCHER:New( Detection ) -- - -- -- Now Setup the default damage treshold. + -- -- Now Setup the default damage threshold. -- A2ADispatcher:SetDefaultDamageThreshold( 0.90 ) -- Go RTB when the airplane 90% damaged. -- function AI_A2A_DISPATCHER:SetDefaultDamageThreshold( DamageThreshold ) @@ -1390,7 +1375,6 @@ do -- AI_A2A_DISPATCHER return self end - --- Set the default CAP time interval for squadrons, which will be used to determine a random CAP timing. -- The default CAP time interval is between 180 and 600 seconds. -- @param #AI_A2A_DISPATCHER self @@ -1413,7 +1397,6 @@ do -- AI_A2A_DISPATCHER return self end - --- Set the default CAP limit for squadrons, which will be used to determine how many CAP can be airborne at the same time for the squadron. -- The default CAP limit is 1 CAP, which means one CAP group being spawned. -- @param #AI_A2A_DISPATCHER self @@ -1448,7 +1431,6 @@ do -- AI_A2A_DISPATCHER return self end - --- Calculates which AI friendlies are nearby the area -- @param #AI_A2A_DISPATCHER self -- @param Functional.Detection#DETECTION_BASE.DetectedItem DetectedItem @@ -1508,7 +1490,7 @@ do -- AI_A2A_DISPATCHER local Message = "Clearing (" .. self.DefenderTasks[Defender].Type .. ") " Message = Message .. Defender:GetName() if Target then - Message = Message .. ( Target and ( " from " .. Target.Index .. " [" .. Target.Set:Count() .. "]" ) ) or "" + Message = Message .. (Target and (" from " .. Target.Index .. " [" .. Target.Set:Count() .. "]")) or "" end self:F( { Target = Message } ) end @@ -1535,17 +1517,16 @@ do -- AI_A2A_DISPATCHER if Defender and DefenderTask and DefenderTask.Target then DefenderTask.Target = nil end --- if Defender and DefenderTask then --- if DefenderTask.Fsm:Is( "Fuel" ) --- or DefenderTask.Fsm:Is( "LostControl") --- or DefenderTask.Fsm:Is( "Damaged" ) then --- self:ClearDefenderTask( Defender ) --- end --- end + -- if Defender and DefenderTask then + -- if DefenderTask.Fsm:Is( "Fuel" ) + -- or DefenderTask.Fsm:Is( "LostControl") + -- or DefenderTask.Fsm:Is( "Damaged" ) then + -- self:ClearDefenderTask( Defender ) + -- end + -- end return self end - --- Set defender task. -- @param #AI_A2A_DISPATCHER self -- @param #string SquadronName Name of the squadron. @@ -1556,7 +1537,7 @@ do -- AI_A2A_DISPATCHER -- @return #AI_A2A_DISPATCHER self function AI_A2A_DISPATCHER:SetDefenderTask( SquadronName, Defender, Type, Fsm, Target ) - self:F( { SquadronName = SquadronName, Defender = Defender:GetName(), Type=Type, Target=Target } ) + self:F( { SquadronName = SquadronName, Defender = Defender:GetName(), Type = Type, Target = Target } ) self.DefenderTasks[Defender] = self.DefenderTasks[Defender] or {} self.DefenderTasks[Defender].Type = Type @@ -1569,7 +1550,6 @@ do -- AI_A2A_DISPATCHER return self end - --- Set defender task target. -- @param #AI_A2A_DISPATCHER self -- @param Wrapper.Group#GROUP Defender The defender group. @@ -1587,7 +1567,6 @@ do -- AI_A2A_DISPATCHER return self end - --- This is the main method to define Squadrons programmatically. -- Squadrons: -- @@ -1630,6 +1609,7 @@ do -- AI_A2A_DISPATCHER -- If you have only one prefix name for a squadron, you don't need to use the `{ }`, otherwise you need to use the brackets. -- -- @param #number ResourceCount (optional) A number that specifies how many resources are in stock of the squadron. If not specified, the squadron will have infinite resources available. + -- @return #AI_A2A_DISPATCHER self -- -- @usage -- -- Now Setup the A2A dispatcher, and initialize it using the Detection object. @@ -1656,14 +1636,11 @@ do -- AI_A2A_DISPATCHER -- A2ADispatcher:SetSquadron( "104th", "Batumi", "Mig-29" ) -- A2ADispatcher:SetSquadron( "23th", "Batumi", "Su-27" ) -- - -- - -- @return #AI_A2A_DISPATCHER self function AI_A2A_DISPATCHER:SetSquadron( SquadronName, AirbaseName, TemplatePrefixes, ResourceCount ) - self.DefenderSquadrons[SquadronName] = self.DefenderSquadrons[SquadronName] or {} - local DefenderSquadron = self.DefenderSquadrons[SquadronName] --#AI_A2A_DISPATCHER.Squadron + local DefenderSquadron = self.DefenderSquadrons[SquadronName] -- #AI_A2A_DISPATCHER.Squadron DefenderSquadron.Name = SquadronName DefenderSquadron.Airbase = AIRBASE:FindByName( AirbaseName ) @@ -1680,7 +1657,7 @@ do -- AI_A2A_DISPATCHER else for TemplateID, SpawnTemplate in pairs( TemplatePrefixes ) do self.DefenderSpawns[SpawnTemplate] = self.DefenderSpawns[SpawnTemplate] or SPAWN:New( SpawnTemplate ) -- :InitCleanUp( 180 ) - DefenderSquadron.Spawn[#DefenderSquadron.Spawn+1] = self.DefenderSpawns[SpawnTemplate] + DefenderSquadron.Spawn[#DefenderSquadron.Spawn + 1] = self.DefenderSpawns[SpawnTemplate] end end DefenderSquadron.ResourceCount = ResourceCount @@ -1689,7 +1666,7 @@ do -- AI_A2A_DISPATCHER self:SetSquadronLanguage( SquadronName, "EN" ) -- Squadrons speak English by default. - self:F( { Squadron = {SquadronName, AirbaseName, TemplatePrefixes, ResourceCount } } ) + self:F( { Squadron = { SquadronName, AirbaseName, TemplatePrefixes, ResourceCount } } ) return self end @@ -1708,7 +1685,6 @@ do -- AI_A2A_DISPATCHER return DefenderSquadron end - --- Set the Squadron visible before startup of the dispatcher. -- All planes will be spawned as uncontrolled on the parking spot. -- They will lock the parking spot. @@ -1717,33 +1693,33 @@ do -- AI_A2A_DISPATCHER -- @return #AI_A2A_DISPATCHER self -- @usage -- - -- -- Set the Squadron visible before startup of dispatcher. - -- A2ADispatcher:SetSquadronVisible( "Mineralnye" ) + -- -- Set the Squadron visible before startup of dispatcher. + -- A2ADispatcher:SetSquadronVisible( "Mineralnye" ) -- function AI_A2A_DISPATCHER:SetSquadronVisible( SquadronName ) self.DefenderSquadrons[SquadronName] = self.DefenderSquadrons[SquadronName] or {} - local DefenderSquadron = self:GetSquadron( SquadronName ) --#AI_A2A_DISPATCHER.Squadron + local DefenderSquadron = self:GetSquadron( SquadronName ) -- #AI_A2A_DISPATCHER.Squadron DefenderSquadron.Uncontrolled = true -- For now, grouping is forced to 1 due to other parts of the class which would not work well with grouping>1. - DefenderSquadron.Grouping=1 + DefenderSquadron.Grouping = 1 -- Get free parking for fighter aircraft. - local nfreeparking=DefenderSquadron.Airbase:GetFreeParkingSpotsNumber(AIRBASE.TerminalType.FighterAircraft, true) + local nfreeparking = DefenderSquadron.Airbase:GetFreeParkingSpotsNumber( AIRBASE.TerminalType.FighterAircraft, true ) -- Take number of free parking spots if no resource count was specifed. - DefenderSquadron.ResourceCount=DefenderSquadron.ResourceCount or nfreeparking + DefenderSquadron.ResourceCount = DefenderSquadron.ResourceCount or nfreeparking -- Check that resource count is not larger than free parking spots. - DefenderSquadron.ResourceCount=math.min(DefenderSquadron.ResourceCount, nfreeparking) + DefenderSquadron.ResourceCount = math.min( DefenderSquadron.ResourceCount, nfreeparking ) -- Set uncontrolled spawning option. - for SpawnTemplate,_DefenderSpawn in pairs( self.DefenderSpawns ) do - local DefenderSpawn=_DefenderSpawn --Core.Spawn#SPAWN - DefenderSpawn:InitUnControlled(true) + for SpawnTemplate, _DefenderSpawn in pairs( self.DefenderSpawns ) do + local DefenderSpawn = _DefenderSpawn -- Core.Spawn#SPAWN + DefenderSpawn:InitUnControlled( true ) end end @@ -1754,14 +1730,14 @@ do -- AI_A2A_DISPATCHER -- @return #boolean true if visible. -- @usage -- - -- -- Set the Squadron visible before startup of dispatcher. - -- local IsVisible = A2ADispatcher:IsSquadronVisible( "Mineralnye" ) + -- -- Set the Squadron visible before startup of dispatcher. + -- local IsVisible = A2ADispatcher:IsSquadronVisible( "Mineralnye" ) -- function AI_A2A_DISPATCHER:IsSquadronVisible( SquadronName ) self.DefenderSquadrons[SquadronName] = self.DefenderSquadrons[SquadronName] or {} - local DefenderSquadron = self:GetSquadron( SquadronName ) --#AI_A2A_DISPATCHER.Squadron + local DefenderSquadron = self:GetSquadron( SquadronName ) -- #AI_A2A_DISPATCHER.Squadron if DefenderSquadron then return DefenderSquadron.Uncontrolled == true @@ -1788,24 +1764,24 @@ do -- AI_A2A_DISPATCHER -- @return #AI_A2A_DISPATCHER -- @usage -- - -- -- CAP Squadron execution. - -- CAPZoneEast = ZONE_POLYGON:New( "CAP Zone East", GROUP:FindByName( "CAP Zone East" ) ) - -- -- Setup a CAP, engaging between 800 and 900 km/h, altitude 30 (above the sea), radio altitude measurement, - -- -- patrolling speed between 500 and 600 km/h, altitude between 4000 and 10000 meters, barometric altitude measurement. - -- A2ADispatcher:SetSquadronCapV2( "Mineralnye", 800, 900, 30, 30, "RADIO", CAPZoneEast, 500, 600, 4000, 10000, "BARO" ) - -- A2ADispatcher:SetSquadronCapInterval( "Mineralnye", 2, 30, 60, 1 ) + -- -- CAP Squadron execution. + -- CAPZoneEast = ZONE_POLYGON:New( "CAP Zone East", GROUP:FindByName( "CAP Zone East" ) ) + -- -- Setup a CAP, engaging between 800 and 900 km/h, altitude 30 (above the sea), radio altitude measurement, + -- -- patrolling speed between 500 and 600 km/h, altitude between 4000 and 10000 meters, barometric altitude measurement. + -- A2ADispatcher:SetSquadronCapV2( "Mineralnye", 800, 900, 30, 30, "RADIO", CAPZoneEast, 500, 600, 4000, 10000, "BARO" ) + -- A2ADispatcher:SetSquadronCapInterval( "Mineralnye", 2, 30, 60, 1 ) -- - -- CAPZoneWest = ZONE_POLYGON:New( "CAP Zone West", GROUP:FindByName( "CAP Zone West" ) ) - -- -- Setup a CAP, engaging between 800 and 1200 km/h, altitude between 4000 and 10000 meters, radio altitude measurement, - -- -- patrolling speed between 600 and 800 km/h, altitude between 4000 and 8000, barometric altitude measurement. - -- A2ADispatcher:SetSquadronCapV2( "Sochi", 800, 1200, 2000, 3000, "RADIO", CAPZoneWest, 600, 800, 4000, 8000, "BARO" ) - -- A2ADispatcher:SetSquadronCapInterval( "Sochi", 2, 30, 120, 1 ) + -- CAPZoneWest = ZONE_POLYGON:New( "CAP Zone West", GROUP:FindByName( "CAP Zone West" ) ) + -- -- Setup a CAP, engaging between 800 and 1200 km/h, altitude between 4000 and 10000 meters, radio altitude measurement, + -- -- patrolling speed between 600 and 800 km/h, altitude between 4000 and 8000, barometric altitude measurement. + -- A2ADispatcher:SetSquadronCapV2( "Sochi", 800, 1200, 2000, 3000, "RADIO", CAPZoneWest, 600, 800, 4000, 8000, "BARO" ) + -- A2ADispatcher:SetSquadronCapInterval( "Sochi", 2, 30, 120, 1 ) -- - -- CAPZoneMiddle = ZONE:New( "CAP Zone Middle") - -- -- Setup a CAP, engaging between 800 and 1200 km/h, altitude between 5000 and 8000 meters, barometric altitude measurement, - -- -- patrolling speed between 600 and 800 km/h, altitude between 4000 and 8000, radio altitude. - -- A2ADispatcher:SetSquadronCapV2( "Maykop", 800, 1200, 5000, 8000, "BARO", CAPZoneMiddle, 600, 800, 4000, 8000, "RADIO" ) - -- A2ADispatcher:SetSquadronCapInterval( "Maykop", 2, 30, 120, 1 ) + -- CAPZoneMiddle = ZONE:New( "CAP Zone Middle") + -- -- Setup a CAP, engaging between 800 and 1200 km/h, altitude between 5000 and 8000 meters, barometric altitude measurement, + -- -- patrolling speed between 600 and 800 km/h, altitude between 4000 and 8000, radio altitude. + -- A2ADispatcher:SetSquadronCapV2( "Maykop", 800, 1200, 5000, 8000, "BARO", CAPZoneMiddle, 600, 800, 4000, 8000, "RADIO" ) + -- A2ADispatcher:SetSquadronCapInterval( "Maykop", 2, 30, 120, 1 ) -- function AI_A2A_DISPATCHER:SetSquadronCap2( SquadronName, EngageMinSpeed, EngageMaxSpeed, EngageFloorAltitude, EngageCeilingAltitude, EngageAltType, Zone, PatrolMinSpeed, PatrolMaxSpeed, PatrolFloorAltitude, PatrolCeilingAltitude, PatrolAltType ) @@ -1857,18 +1833,18 @@ do -- AI_A2A_DISPATCHER -- @return #AI_A2A_DISPATCHER -- @usage -- - -- -- CAP Squadron execution. - -- CAPZoneEast = ZONE_POLYGON:New( "CAP Zone East", GROUP:FindByName( "CAP Zone East" ) ) - -- A2ADispatcher:SetSquadronCap( "Mineralnye", CAPZoneEast, 4000, 10000, 500, 600, 800, 900 ) - -- A2ADispatcher:SetSquadronCapInterval( "Mineralnye", 2, 30, 60, 1 ) + -- -- CAP Squadron execution. + -- CAPZoneEast = ZONE_POLYGON:New( "CAP Zone East", GROUP:FindByName( "CAP Zone East" ) ) + -- A2ADispatcher:SetSquadronCap( "Mineralnye", CAPZoneEast, 4000, 10000, 500, 600, 800, 900 ) + -- A2ADispatcher:SetSquadronCapInterval( "Mineralnye", 2, 30, 60, 1 ) -- - -- CAPZoneWest = ZONE_POLYGON:New( "CAP Zone West", GROUP:FindByName( "CAP Zone West" ) ) - -- A2ADispatcher:SetSquadronCap( "Sochi", CAPZoneWest, 4000, 8000, 600, 800, 800, 1200, "BARO" ) - -- A2ADispatcher:SetSquadronCapInterval( "Sochi", 2, 30, 120, 1 ) + -- CAPZoneWest = ZONE_POLYGON:New( "CAP Zone West", GROUP:FindByName( "CAP Zone West" ) ) + -- A2ADispatcher:SetSquadronCap( "Sochi", CAPZoneWest, 4000, 8000, 600, 800, 800, 1200, "BARO" ) + -- A2ADispatcher:SetSquadronCapInterval( "Sochi", 2, 30, 120, 1 ) -- - -- CAPZoneMiddle = ZONE:New( "CAP Zone Middle") - -- A2ADispatcher:SetSquadronCap( "Maykop", CAPZoneMiddle, 4000, 8000, 600, 800, 800, 1200, "RADIO" ) - -- A2ADispatcher:SetSquadronCapInterval( "Sochi", 2, 30, 120, 1 ) + -- CAPZoneMiddle = ZONE:New( "CAP Zone Middle") + -- A2ADispatcher:SetSquadronCap( "Maykop", CAPZoneMiddle, 4000, 8000, 600, 800, 800, 1200, "RADIO" ) + -- A2ADispatcher:SetSquadronCapInterval( "Sochi", 2, 30, 120, 1 ) -- function AI_A2A_DISPATCHER:SetSquadronCap( SquadronName, Zone, PatrolFloorAltitude, PatrolCeilingAltitude, PatrolMinSpeed, PatrolMaxSpeed, EngageMinSpeed, EngageMaxSpeed, AltType ) @@ -1885,18 +1861,18 @@ do -- AI_A2A_DISPATCHER -- @return #AI_A2A_DISPATCHER -- @usage -- - -- -- CAP Squadron execution. - -- CAPZoneEast = ZONE_POLYGON:New( "CAP Zone East", GROUP:FindByName( "CAP Zone East" ) ) - -- A2ADispatcher:SetSquadronCap( "Mineralnye", CAPZoneEast, 4000, 10000, 500, 600, 800, 900 ) - -- A2ADispatcher:SetSquadronCapInterval( "Mineralnye", 2, 30, 60, 1 ) + -- -- CAP Squadron execution. + -- CAPZoneEast = ZONE_POLYGON:New( "CAP Zone East", GROUP:FindByName( "CAP Zone East" ) ) + -- A2ADispatcher:SetSquadronCap( "Mineralnye", CAPZoneEast, 4000, 10000, 500, 600, 800, 900 ) + -- A2ADispatcher:SetSquadronCapInterval( "Mineralnye", 2, 30, 60, 1 ) -- - -- CAPZoneWest = ZONE_POLYGON:New( "CAP Zone West", GROUP:FindByName( "CAP Zone West" ) ) - -- A2ADispatcher:SetSquadronCap( "Sochi", CAPZoneWest, 4000, 8000, 600, 800, 800, 1200, "BARO" ) - -- A2ADispatcher:SetSquadronCapInterval( "Sochi", 2, 30, 120, 1 ) + -- CAPZoneWest = ZONE_POLYGON:New( "CAP Zone West", GROUP:FindByName( "CAP Zone West" ) ) + -- A2ADispatcher:SetSquadronCap( "Sochi", CAPZoneWest, 4000, 8000, 600, 800, 800, 1200, "BARO" ) + -- A2ADispatcher:SetSquadronCapInterval( "Sochi", 2, 30, 120, 1 ) -- - -- CAPZoneMiddle = ZONE:New( "CAP Zone Middle") - -- A2ADispatcher:SetSquadronCap( "Maykop", CAPZoneMiddle, 4000, 8000, 600, 800, 800, 1200, "RADIO" ) - -- A2ADispatcher:SetSquadronCapInterval( "Sochi", 2, 30, 120, 1 ) + -- CAPZoneMiddle = ZONE:New( "CAP Zone Middle") + -- A2ADispatcher:SetSquadronCap( "Maykop", CAPZoneMiddle, 4000, 8000, 600, 800, 800, 1200, "RADIO" ) + -- A2ADispatcher:SetSquadronCapInterval( "Sochi", 2, 30, 120, 1 ) -- function AI_A2A_DISPATCHER:SetSquadronCapInterval( SquadronName, CapLimit, LowInterval, HighInterval, Probability ) @@ -1914,7 +1890,7 @@ do -- AI_A2A_DISPATCHER Cap.Scheduler = Cap.Scheduler or SCHEDULER:New( self ) local Scheduler = Cap.Scheduler -- Core.Scheduler#SCHEDULER local ScheduleID = Cap.ScheduleID - local Variance = ( Cap.HighInterval - Cap.LowInterval ) / 2 + local Variance = (Cap.HighInterval - Cap.LowInterval) / 2 local Repeat = Cap.LowInterval + Variance local Randomization = Variance / Repeat local Start = math.random( 1, Cap.HighInterval ) @@ -1954,7 +1930,7 @@ do -- AI_A2A_DISPATCHER -- @param #string SquadronName The squadron name. -- @return #AI_A2A_DISPATCHER.Squadron DefenderSquadron function AI_A2A_DISPATCHER:CanCAP( SquadronName ) - self:F({SquadronName = SquadronName}) + self:F( { SquadronName = SquadronName } ) self.DefenderSquadrons[SquadronName] = self.DefenderSquadrons[SquadronName] or {} self.DefenderSquadrons[SquadronName].Cap = self.DefenderSquadrons[SquadronName].Cap or {} @@ -1963,7 +1939,7 @@ do -- AI_A2A_DISPATCHER if DefenderSquadron.Captured == false then -- We can only spawn new CAP if the base has not been captured. - if ( not DefenderSquadron.ResourceCount ) or ( DefenderSquadron.ResourceCount and DefenderSquadron.ResourceCount > 0 ) then -- And, if there are sufficient resources. + if (not DefenderSquadron.ResourceCount) or (DefenderSquadron.ResourceCount and DefenderSquadron.ResourceCount > 0) then -- And, if there are sufficient resources. local Cap = DefenderSquadron.Cap if Cap then @@ -1981,7 +1957,6 @@ do -- AI_A2A_DISPATCHER return nil end - --- Set race track pattern as default when any squadron is performing CAP. -- @param #AI_A2A_DISPATCHER self -- @param #number LeglengthMin Min length of the race track leg in meters. Default 10,000 m. @@ -1992,16 +1967,16 @@ do -- AI_A2A_DISPATCHER -- @param #number DurationMax (Optional) Max duration in seconds before switching the orbit position. Default is keep same orbit until RTB or engage. -- @param #table CapCoordinates Table of coordinates of first race track point. Second point is determined by leg length and heading. -- @return #AI_A2A_DISPATCHER self - function AI_A2A_DISPATCHER:SetDefaultCapRacetrack(LeglengthMin, LeglengthMax, HeadingMin, HeadingMax, DurationMin, DurationMax, CapCoordinates) + function AI_A2A_DISPATCHER:SetDefaultCapRacetrack( LeglengthMin, LeglengthMax, HeadingMin, HeadingMax, DurationMin, DurationMax, CapCoordinates ) - self.DefenderDefault.Racetrack=true - self.DefenderDefault.RacetrackLengthMin=LeglengthMin - self.DefenderDefault.RacetrackLengthMax=LeglengthMax - self.DefenderDefault.RacetrackHeadingMin=HeadingMin - self.DefenderDefault.RacetrackHeadingMax=HeadingMax - self.DefenderDefault.RacetrackDurationMin=DurationMin - self.DefenderDefault.RacetrackDurationMax=DurationMax - self.DefenderDefault.RacetrackCoordinates=CapCoordinates + self.DefenderDefault.Racetrack = true + self.DefenderDefault.RacetrackLengthMin = LeglengthMin + self.DefenderDefault.RacetrackLengthMax = LeglengthMax + self.DefenderDefault.RacetrackHeadingMin = HeadingMin + self.DefenderDefault.RacetrackHeadingMax = HeadingMax + self.DefenderDefault.RacetrackDurationMin = DurationMin + self.DefenderDefault.RacetrackDurationMax = DurationMax + self.DefenderDefault.RacetrackCoordinates = CapCoordinates return self end @@ -2017,31 +1992,30 @@ do -- AI_A2A_DISPATCHER -- @param #number DurationMax (Optional) Max duration in seconds before switching the orbit position. Default is keep same orbit until RTB or engage. -- @param #table CapCoordinates Table of coordinates of first race track point. Second point is determined by leg length and heading. -- @return #AI_A2A_DISPATCHER self - function AI_A2A_DISPATCHER:SetSquadronCapRacetrack(SquadronName, LeglengthMin, LeglengthMax, HeadingMin, HeadingMax, DurationMin, DurationMax, CapCoordinates) + function AI_A2A_DISPATCHER:SetSquadronCapRacetrack( SquadronName, LeglengthMin, LeglengthMax, HeadingMin, HeadingMax, DurationMin, DurationMax, CapCoordinates ) local DefenderSquadron = self:GetSquadron( SquadronName ) if DefenderSquadron then - DefenderSquadron.Racetrack=true - DefenderSquadron.RacetrackLengthMin=LeglengthMin - DefenderSquadron.RacetrackLengthMax=LeglengthMax - DefenderSquadron.RacetrackHeadingMin=HeadingMin - DefenderSquadron.RacetrackHeadingMax=HeadingMax - DefenderSquadron.RacetrackDurationMin=DurationMin - DefenderSquadron.RacetrackDurationMax=DurationMax - DefenderSquadron.RacetrackCoordinates=CapCoordinates + DefenderSquadron.Racetrack = true + DefenderSquadron.RacetrackLengthMin = LeglengthMin + DefenderSquadron.RacetrackLengthMax = LeglengthMax + DefenderSquadron.RacetrackHeadingMin = HeadingMin + DefenderSquadron.RacetrackHeadingMax = HeadingMax + DefenderSquadron.RacetrackDurationMin = DurationMin + DefenderSquadron.RacetrackDurationMax = DurationMax + DefenderSquadron.RacetrackCoordinates = CapCoordinates end return self end - --- Check if squadron can do GCI. -- @param #AI_A2A_DISPATCHER self -- @param #string SquadronName The squadron name. -- @return #table DefenderSquadron function AI_A2A_DISPATCHER:CanGCI( SquadronName ) - self:F({SquadronName = SquadronName}) + self:F( { SquadronName = SquadronName } ) self.DefenderSquadrons[SquadronName] = self.DefenderSquadrons[SquadronName] or {} self.DefenderSquadrons[SquadronName].Gci = self.DefenderSquadrons[SquadronName].Gci or {} @@ -2050,7 +2024,7 @@ do -- AI_A2A_DISPATCHER if DefenderSquadron.Captured == false then -- We can only spawn new CAP if the base has not been captured. - if ( not DefenderSquadron.ResourceCount ) or ( DefenderSquadron.ResourceCount and DefenderSquadron.ResourceCount > 0 ) then -- And, if there are sufficient resources. + if (not DefenderSquadron.ResourceCount) or (DefenderSquadron.ResourceCount and DefenderSquadron.ResourceCount > 0) then -- And, if there are sufficient resources. local Gci = DefenderSquadron.Gci if Gci then return DefenderSquadron @@ -2068,14 +2042,14 @@ do -- AI_A2A_DISPATCHER -- @param DCS#Altitude EngageFloorAltitude The lowest altitude in meters where to execute the engagement. -- @param DCS#Altitude EngageCeilingAltitude The highest altitude in meters where to execute the engagement. -- @param DCS#AltitudeType EngageAltType The altitude type ("RADIO"=="AGL", "BARO"=="ASL"). Defaults to "RADIO". + -- @return #AI_A2A_DISPATCHER -- @usage -- - -- -- GCI Squadron execution. - -- A2ADispatcher:SetSquadronGci2( "Mozdok", 900, 1200, 5000, 5000, "BARO" ) - -- A2ADispatcher:SetSquadronGci2( "Novo", 900, 2100, 30, 30, "RADIO" ) - -- A2ADispatcher:SetSquadronGci2( "Maykop", 900, 1200, 100, 300, "RADIO" ) + -- -- GCI Squadron execution. + -- A2ADispatcher:SetSquadronGci2( "Mozdok", 900, 1200, 5000, 5000, "BARO" ) + -- A2ADispatcher:SetSquadronGci2( "Novo", 900, 2100, 30, 30, "RADIO" ) + -- A2ADispatcher:SetSquadronGci2( "Maykop", 900, 1200, 100, 300, "RADIO" ) -- - -- @return #AI_A2A_DISPATCHER function AI_A2A_DISPATCHER:SetSquadronGci2( SquadronName, EngageMinSpeed, EngageMaxSpeed, EngageFloorAltitude, EngageCeilingAltitude, EngageAltType ) self.DefenderSquadrons[SquadronName] = self.DefenderSquadrons[SquadronName] or {} @@ -2097,14 +2071,14 @@ do -- AI_A2A_DISPATCHER -- @param #string SquadronName The squadron name. -- @param #number EngageMinSpeed The minimum speed [km/h] at which the GCI can be executed. -- @param #number EngageMaxSpeed The maximum speed [km/h] at which the GCI can be executed. + -- @return #AI_A2A_DISPATCHER -- @usage -- - -- -- GCI Squadron execution. - -- A2ADispatcher:SetSquadronGci( "Mozdok", 900, 1200 ) - -- A2ADispatcher:SetSquadronGci( "Novo", 900, 2100 ) - -- A2ADispatcher:SetSquadronGci( "Maykop", 900, 1200 ) + -- -- GCI Squadron execution. + -- A2ADispatcher:SetSquadronGci( "Mozdok", 900, 1200 ) + -- A2ADispatcher:SetSquadronGci( "Novo", 900, 2100 ) + -- A2ADispatcher:SetSquadronGci( "Maykop", 900, 1200 ) -- - -- @return #AI_A2A_DISPATCHER function AI_A2A_DISPATCHER:SetSquadronGci( SquadronName, EngageMinSpeed, EngageMaxSpeed ) self.DefenderSquadrons[SquadronName] = self.DefenderSquadrons[SquadronName] or {} @@ -2120,7 +2094,8 @@ do -- AI_A2A_DISPATCHER --- Defines the default amount of extra planes that will take-off as part of the defense system. -- @param #AI_A2A_DISPATCHER self - -- @param #number Overhead The %-tage of Units that dispatching command will allocate to intercept in surplus of detected amount of units. + -- @param #number Overhead The % of Units that dispatching command will allocate to intercept in surplus of detected amount of units. + -- @return #AI_A2A_DISPATCHER -- The default overhead is 1, so equal balance. The @{#AI_A2A_DISPATCHER.SetOverhead}() method can be used to tweak the defense strength, -- taking into account the plane types of the squadron. For example, a MIG-31 with full long-distance A2A missiles payload, may still be less effective than a F-15C with short missiles... -- So in this case, one may want to use the Overhead method to allocate more defending planes as the amount of detected attacking planes. @@ -2147,7 +2122,6 @@ do -- AI_A2A_DISPATCHER -- -- A2ADispatcher:SetDefaultOverhead( 1.5 ) -- - -- @return #AI_A2A_DISPATCHER function AI_A2A_DISPATCHER:SetDefaultOverhead( Overhead ) self.DefenderDefault.Overhead = Overhead @@ -2155,11 +2129,11 @@ do -- AI_A2A_DISPATCHER return self end - --- Defines the amount of extra planes that will take-off as part of the defense system. -- @param #AI_A2A_DISPATCHER self -- @param #string SquadronName The name of the squadron. - -- @param #number Overhead The %-tage of Units that dispatching command will allocate to intercept in surplus of detected amount of units. + -- @param #number Overhead The % of Units that dispatching command will allocate to intercept in surplus of detected amount of units. + -- @return #AI_A2A_DISPATCHER self -- The default overhead is 1, so equal balance. The @{#AI_A2A_DISPATCHER.SetOverhead}() method can be used to tweak the defense strength, -- taking into account the plane types of the squadron. For example, a MIG-31 with full long-distance A2A missiles payload, may still be less effective than a F-15C with short missiles... -- So in this case, one may want to use the Overhead method to allocate more defending planes as the amount of detected attacking planes. @@ -2186,7 +2160,6 @@ do -- AI_A2A_DISPATCHER -- -- A2ADispatcher:SetSquadronOverhead( "SquadronName", 1.5 ) -- - -- @return #AI_A2A_DISPATCHER self function AI_A2A_DISPATCHER:SetSquadronOverhead( SquadronName, Overhead ) local DefenderSquadron = self:GetSquadron( SquadronName ) @@ -2195,11 +2168,11 @@ do -- AI_A2A_DISPATCHER return self end - --- Sets the default grouping of new airplanes spawned. -- Grouping will trigger how new airplanes will be grouped if more than one airplane is spawned for defense. -- @param #AI_A2A_DISPATCHER self -- @param #number Grouping The level of grouping that will be applied of the CAP or GCI defenders. + -- @return #AI_A2A_DISPATCHER self -- @usage: -- -- local A2ADispatcher = AI_A2A_DISPATCHER:New( ... ) @@ -2207,8 +2180,6 @@ do -- AI_A2A_DISPATCHER -- -- Set a grouping by default per 2 airplanes. -- A2ADispatcher:SetDefaultGrouping( 2 ) -- - -- - -- @return #AI_A2A_DISPATCHER self function AI_A2A_DISPATCHER:SetDefaultGrouping( Grouping ) self.DefenderDefault.Grouping = Grouping @@ -2216,12 +2187,12 @@ do -- AI_A2A_DISPATCHER return self end - --- Sets the grouping of new airplanes spawned. -- Grouping will trigger how new airplanes will be grouped if more than one airplane is spawned for defense. -- @param #AI_A2A_DISPATCHER self -- @param #string SquadronName The name of the squadron. -- @param #number Grouping The level of grouping that will be applied of the CAP or GCI defenders. + -- @return #AI_A2A_DISPATCHER self -- @usage: -- -- local A2ADispatcher = AI_A2A_DISPATCHER:New( ... ) @@ -2229,8 +2200,6 @@ do -- AI_A2A_DISPATCHER -- -- Set a grouping per 2 airplanes. -- A2ADispatcher:SetSquadronGrouping( "SquadronName", 2 ) -- - -- - -- @return #AI_A2A_DISPATCHER self function AI_A2A_DISPATCHER:SetSquadronGrouping( SquadronName, Grouping ) local DefenderSquadron = self:GetSquadron( SquadronName ) @@ -2239,10 +2208,10 @@ do -- AI_A2A_DISPATCHER return self end - --- Defines the default method at which new flights will spawn and take-off as part of the defense system. -- @param #AI_A2A_DISPATCHER self -- @param #number Takeoff From the airbase hot, from the airbase cold, in the air, from the runway. + -- @return #AI_A2A_DISPATCHER self -- @usage: -- -- local A2ADispatcher = AI_A2A_DISPATCHER:New( ... ) @@ -2259,9 +2228,6 @@ do -- AI_A2A_DISPATCHER -- -- Let new flights by default take-off from the airbase cold. -- A2ADispatcher:SetDefaultTakeoff( AI_A2A_Dispatcher.Takeoff.Cold ) -- - -- - -- @return #AI_A2A_DISPATCHER self - -- function AI_A2A_DISPATCHER:SetDefaultTakeoff( Takeoff ) self.DefenderDefault.Takeoff = Takeoff @@ -2273,6 +2239,7 @@ do -- AI_A2A_DISPATCHER -- @param #AI_A2A_DISPATCHER self -- @param #string SquadronName The name of the squadron. -- @param #number Takeoff From the airbase hot, from the airbase cold, in the air, from the runway. + -- @return #AI_A2A_DISPATCHER self -- @usage: -- -- local A2ADispatcher = AI_A2A_DISPATCHER:New( ... ) @@ -2289,9 +2256,6 @@ do -- AI_A2A_DISPATCHER -- -- Let new flights take-off from the airbase cold. -- A2ADispatcher:SetSquadronTakeoff( "SquadronName", AI_A2A_Dispatcher.Takeoff.Cold ) -- - -- - -- @return #AI_A2A_DISPATCHER self - -- function AI_A2A_DISPATCHER:SetSquadronTakeoff( SquadronName, Takeoff ) local DefenderSquadron = self:GetSquadron( SquadronName ) @@ -2300,7 +2264,6 @@ do -- AI_A2A_DISPATCHER return self end - --- Gets the default method at which new flights will spawn and take-off as part of the defense system. -- @param #AI_A2A_DISPATCHER self -- @return #number Takeoff From the airbase hot, from the airbase cold, in the air, from the runway. @@ -2314,7 +2277,7 @@ do -- AI_A2A_DISPATCHER -- ... -- end -- - function AI_A2A_DISPATCHER:GetDefaultTakeoff( ) + function AI_A2A_DISPATCHER:GetDefaultTakeoff() return self.DefenderDefault.Takeoff end @@ -2339,9 +2302,9 @@ do -- AI_A2A_DISPATCHER return DefenderSquadron.Takeoff or self.DefenderDefault.Takeoff end - --- Sets flights to default take-off in the air, as part of the defense system. -- @param #AI_A2A_DISPATCHER self + -- @return #AI_A2A_DISPATCHER self -- @usage: -- -- local A2ADispatcher = AI_A2A_DISPATCHER:New( ... ) @@ -2349,8 +2312,6 @@ do -- AI_A2A_DISPATCHER -- -- Let new flights by default take-off in the air. -- A2ADispatcher:SetDefaultTakeoffInAir() -- - -- @return #AI_A2A_DISPATCHER self - -- function AI_A2A_DISPATCHER:SetDefaultTakeoffInAir() self:SetDefaultTakeoff( AI_A2A_DISPATCHER.Takeoff.Air ) @@ -2358,11 +2319,11 @@ do -- AI_A2A_DISPATCHER return self end - --- Sets flights to take-off in the air, as part of the defense system. -- @param #AI_A2A_DISPATCHER self -- @param #string SquadronName The name of the squadron. -- @param #number TakeoffAltitude (optional) The altitude in meters above the ground. If not given, the default takeoff altitude will be used. + -- @return #AI_A2A_DISPATCHER self -- @usage: -- -- local A2ADispatcher = AI_A2A_DISPATCHER:New( ... ) @@ -2370,8 +2331,6 @@ do -- AI_A2A_DISPATCHER -- -- Let new flights take-off in the air. -- A2ADispatcher:SetSquadronTakeoffInAir( "SquadronName" ) -- - -- @return #AI_A2A_DISPATCHER self - -- function AI_A2A_DISPATCHER:SetSquadronTakeoffInAir( SquadronName, TakeoffAltitude ) self:SetSquadronTakeoff( SquadronName, AI_A2A_DISPATCHER.Takeoff.Air ) @@ -2383,9 +2342,9 @@ do -- AI_A2A_DISPATCHER return self end - --- Sets flights by default to take-off from the runway, as part of the defense system. -- @param #AI_A2A_DISPATCHER self + -- @return #AI_A2A_DISPATCHER self -- @usage: -- -- local A2ADispatcher = AI_A2A_DISPATCHER:New( ... ) @@ -2393,8 +2352,6 @@ do -- AI_A2A_DISPATCHER -- -- Let new flights by default take-off from the runway. -- A2ADispatcher:SetDefaultTakeoffFromRunway() -- - -- @return #AI_A2A_DISPATCHER self - -- function AI_A2A_DISPATCHER:SetDefaultTakeoffFromRunway() self:SetDefaultTakeoff( AI_A2A_DISPATCHER.Takeoff.Runway ) @@ -2402,10 +2359,10 @@ do -- AI_A2A_DISPATCHER return self end - --- Sets flights to take-off from the runway, as part of the defense system. -- @param #AI_A2A_DISPATCHER self -- @param #string SquadronName The name of the squadron. + -- @return #AI_A2A_DISPATCHER self -- @usage: -- -- local A2ADispatcher = AI_A2A_DISPATCHER:New( ... ) @@ -2413,8 +2370,6 @@ do -- AI_A2A_DISPATCHER -- -- Let new flights take-off from the runway. -- A2ADispatcher:SetSquadronTakeoffFromRunway( "SquadronName" ) -- - -- @return #AI_A2A_DISPATCHER self - -- function AI_A2A_DISPATCHER:SetSquadronTakeoffFromRunway( SquadronName ) self:SetSquadronTakeoff( SquadronName, AI_A2A_DISPATCHER.Takeoff.Runway ) @@ -2422,9 +2377,9 @@ do -- AI_A2A_DISPATCHER return self end - --- Sets flights by default to take-off from the airbase at a hot location, as part of the defense system. -- @param #AI_A2A_DISPATCHER self + -- @return #AI_A2A_DISPATCHER self -- @usage: -- -- local A2ADispatcher = AI_A2A_DISPATCHER:New( ... ) @@ -2432,8 +2387,6 @@ do -- AI_A2A_DISPATCHER -- -- Let new flights by default take-off at a hot parking spot. -- A2ADispatcher:SetDefaultTakeoffFromParkingHot() -- - -- @return #AI_A2A_DISPATCHER self - -- function AI_A2A_DISPATCHER:SetDefaultTakeoffFromParkingHot() self:SetDefaultTakeoff( AI_A2A_DISPATCHER.Takeoff.Hot ) @@ -2444,6 +2397,7 @@ do -- AI_A2A_DISPATCHER --- Sets flights to take-off from the airbase at a hot location, as part of the defense system. -- @param #AI_A2A_DISPATCHER self -- @param #string SquadronName The name of the squadron. + -- @return #AI_A2A_DISPATCHER self -- @usage: -- -- local A2ADispatcher = AI_A2A_DISPATCHER:New( ... ) @@ -2451,8 +2405,6 @@ do -- AI_A2A_DISPATCHER -- -- Let new flights take-off in the air. -- A2ADispatcher:SetSquadronTakeoffFromParkingHot( "SquadronName" ) -- - -- @return #AI_A2A_DISPATCHER self - -- function AI_A2A_DISPATCHER:SetSquadronTakeoffFromParkingHot( SquadronName ) self:SetSquadronTakeoff( SquadronName, AI_A2A_DISPATCHER.Takeoff.Hot ) @@ -2460,9 +2412,9 @@ do -- AI_A2A_DISPATCHER return self end - --- Sets flights to by default take-off from the airbase at a cold location, as part of the defense system. -- @param #AI_A2A_DISPATCHER self + -- @return #AI_A2A_DISPATCHER self -- @usage: -- -- local A2ADispatcher = AI_A2A_DISPATCHER:New( ... ) @@ -2470,8 +2422,6 @@ do -- AI_A2A_DISPATCHER -- -- Let new flights take-off from a cold parking spot. -- A2ADispatcher:SetDefaultTakeoffFromParkingCold() -- - -- @return #AI_A2A_DISPATCHER self - -- function AI_A2A_DISPATCHER:SetDefaultTakeoffFromParkingCold() self:SetDefaultTakeoff( AI_A2A_DISPATCHER.Takeoff.Cold ) @@ -2479,10 +2429,10 @@ do -- AI_A2A_DISPATCHER return self end - --- Sets flights to take-off from the airbase at a cold location, as part of the defense system. -- @param #AI_A2A_DISPATCHER self -- @param #string SquadronName The name of the squadron. + -- @return #AI_A2A_DISPATCHER self -- @usage: -- -- local A2ADispatcher = AI_A2A_DISPATCHER:New( ... ) @@ -2490,8 +2440,6 @@ do -- AI_A2A_DISPATCHER -- -- Let new flights take-off from a cold parking spot. -- A2ADispatcher:SetSquadronTakeoffFromParkingCold( "SquadronName" ) -- - -- @return #AI_A2A_DISPATCHER self - -- function AI_A2A_DISPATCHER:SetSquadronTakeoffFromParkingCold( SquadronName ) self:SetSquadronTakeoff( SquadronName, AI_A2A_DISPATCHER.Takeoff.Cold ) @@ -2499,10 +2447,10 @@ do -- AI_A2A_DISPATCHER return self end - --- Defines the default altitude where airplanes will spawn in the air and take-off as part of the defense system, when the take-off in the air method has been selected. -- @param #AI_A2A_DISPATCHER self -- @param #number TakeoffAltitude The altitude in meters above the ground. + -- @return #AI_A2A_DISPATCHER self -- @usage: -- -- local A2ADispatcher = AI_A2A_DISPATCHER:New( ... ) @@ -2510,8 +2458,6 @@ do -- AI_A2A_DISPATCHER -- -- Set the default takeoff altitude when taking off in the air. -- A2ADispatcher:SetDefaultTakeoffInAirAltitude( 2000 ) -- This makes planes start at 2000 meters above the ground. -- - -- @return #AI_A2A_DISPATCHER self - -- function AI_A2A_DISPATCHER:SetDefaultTakeoffInAirAltitude( TakeoffAltitude ) self.DefenderDefault.TakeoffAltitude = TakeoffAltitude @@ -2523,6 +2469,7 @@ do -- AI_A2A_DISPATCHER -- @param #AI_A2A_DISPATCHER self -- @param #string SquadronName The name of the squadron. -- @param #number TakeoffAltitude The altitude in meters above the ground. + -- @return #AI_A2A_DISPATCHER self -- @usage: -- -- local A2ADispatcher = AI_A2A_DISPATCHER:New( ... ) @@ -2530,8 +2477,6 @@ do -- AI_A2A_DISPATCHER -- -- Set the default takeoff altitude when taking off in the air. -- A2ADispatcher:SetSquadronTakeoffInAirAltitude( "SquadronName", 2000 ) -- This makes planes start at 2000 meters above the ground. -- - -- @return #AI_A2A_DISPATCHER self - -- function AI_A2A_DISPATCHER:SetSquadronTakeoffInAirAltitude( SquadronName, TakeoffAltitude ) local DefenderSquadron = self:GetSquadron( SquadronName ) @@ -2540,10 +2485,10 @@ do -- AI_A2A_DISPATCHER return self end - --- Defines the default method at which flights will land and despawn as part of the defense system. -- @param #AI_A2A_DISPATCHER self -- @param #number Landing The landing method which can be NearAirbase, AtRunway, AtEngineShutdown + -- @return #AI_A2A_DISPATCHER self -- @usage: -- -- local A2ADispatcher = AI_A2A_DISPATCHER:New( ... ) @@ -2557,7 +2502,6 @@ do -- AI_A2A_DISPATCHER -- -- Let new flights by default despawn after landing and parking, and after engine shutdown. -- A2ADispatcher:SetDefaultLanding( AI_A2A_Dispatcher.Landing.AtEngineShutdown ) -- - -- @return #AI_A2A_DISPATCHER self function AI_A2A_DISPATCHER:SetDefaultLanding( Landing ) self.DefenderDefault.Landing = Landing @@ -2565,11 +2509,11 @@ do -- AI_A2A_DISPATCHER return self end - --- Defines the method at which flights will land and despawn as part of the defense system. -- @param #AI_A2A_DISPATCHER self -- @param #string SquadronName The name of the squadron. -- @param #number Landing The landing method which can be NearAirbase, AtRunway, AtEngineShutdown + -- @return #AI_A2A_DISPATCHER self -- @usage: -- -- local A2ADispatcher = AI_A2A_DISPATCHER:New( ... ) @@ -2583,7 +2527,6 @@ do -- AI_A2A_DISPATCHER -- -- Let new flights despawn after landing and parking, and after engine shutdown. -- A2ADispatcher:SetSquadronLanding( "SquadronName", AI_A2A_Dispatcher.Landing.AtEngineShutdown ) -- - -- @return #AI_A2A_DISPATCHER self function AI_A2A_DISPATCHER:SetSquadronLanding( SquadronName, Landing ) local DefenderSquadron = self:GetSquadron( SquadronName ) @@ -2592,7 +2535,6 @@ do -- AI_A2A_DISPATCHER return self end - --- Gets the default method at which flights will land and despawn as part of the defense system. -- @param #AI_A2A_DISPATCHER self -- @return #number Landing The landing method which can be NearAirbase, AtRunway, AtEngineShutdown @@ -2611,7 +2553,6 @@ do -- AI_A2A_DISPATCHER return self.DefenderDefault.Landing end - --- Gets the method at which flights will land and despawn as part of the defense system. -- @param #AI_A2A_DISPATCHER self -- @param #string SquadronName The name of the squadron. @@ -2632,9 +2573,9 @@ do -- AI_A2A_DISPATCHER return DefenderSquadron.Landing or self.DefenderDefault.Landing end - --- Sets flights by default to land and despawn near the airbase in the air, as part of the defense system. -- @param #AI_A2A_DISPATCHER self + -- @return #AI_A2A_DISPATCHER self -- @usage: -- -- local A2ADispatcher = AI_A2A_DISPATCHER:New( ... ) @@ -2642,7 +2583,6 @@ do -- AI_A2A_DISPATCHER -- -- Let flights by default to land near the airbase and despawn. -- A2ADispatcher:SetDefaultLandingNearAirbase() -- - -- @return #AI_A2A_DISPATCHER self function AI_A2A_DISPATCHER:SetDefaultLandingNearAirbase() self:SetDefaultLanding( AI_A2A_DISPATCHER.Landing.NearAirbase ) @@ -2650,10 +2590,10 @@ do -- AI_A2A_DISPATCHER return self end - --- Sets flights to land and despawn near the airbase in the air, as part of the defense system. -- @param #AI_A2A_DISPATCHER self -- @param #string SquadronName The name of the squadron. + -- @return #AI_A2A_DISPATCHER self -- @usage: -- -- local A2ADispatcher = AI_A2A_DISPATCHER:New( ... ) @@ -2661,7 +2601,6 @@ do -- AI_A2A_DISPATCHER -- -- Let flights to land near the airbase and despawn. -- A2ADispatcher:SetSquadronLandingNearAirbase( "SquadronName" ) -- - -- @return #AI_A2A_DISPATCHER self function AI_A2A_DISPATCHER:SetSquadronLandingNearAirbase( SquadronName ) self:SetSquadronLanding( SquadronName, AI_A2A_DISPATCHER.Landing.NearAirbase ) @@ -2669,9 +2608,9 @@ do -- AI_A2A_DISPATCHER return self end - --- Sets flights by default to land and despawn at the runway, as part of the defense system. -- @param #AI_A2A_DISPATCHER self + -- @return #AI_A2A_DISPATCHER self -- @usage: -- -- local A2ADispatcher = AI_A2A_DISPATCHER:New( ... ) @@ -2679,7 +2618,6 @@ do -- AI_A2A_DISPATCHER -- -- Let flights by default land at the runway and despawn. -- A2ADispatcher:SetDefaultLandingAtRunway() -- - -- @return #AI_A2A_DISPATCHER self function AI_A2A_DISPATCHER:SetDefaultLandingAtRunway() self:SetDefaultLanding( AI_A2A_DISPATCHER.Landing.AtRunway ) @@ -2687,10 +2625,10 @@ do -- AI_A2A_DISPATCHER return self end - --- Sets flights to land and despawn at the runway, as part of the defense system. -- @param #AI_A2A_DISPATCHER self -- @param #string SquadronName The name of the squadron. + -- @return #AI_A2A_DISPATCHER self -- @usage: -- -- local A2ADispatcher = AI_A2A_DISPATCHER:New( ... ) @@ -2698,7 +2636,6 @@ do -- AI_A2A_DISPATCHER -- -- Let flights land at the runway and despawn. -- A2ADispatcher:SetSquadronLandingAtRunway( "SquadronName" ) -- - -- @return #AI_A2A_DISPATCHER self function AI_A2A_DISPATCHER:SetSquadronLandingAtRunway( SquadronName ) self:SetSquadronLanding( SquadronName, AI_A2A_DISPATCHER.Landing.AtRunway ) @@ -2706,9 +2643,9 @@ do -- AI_A2A_DISPATCHER return self end - --- Sets flights by default to land and despawn at engine shutdown, as part of the defense system. -- @param #AI_A2A_DISPATCHER self + -- @return #AI_A2A_DISPATCHER self -- @usage: -- -- local A2ADispatcher = AI_A2A_DISPATCHER:New( ... ) @@ -2716,18 +2653,17 @@ do -- AI_A2A_DISPATCHER -- -- Let flights by default land and despawn at engine shutdown. -- A2ADispatcher:SetDefaultLandingAtEngineShutdown() -- - -- @return #AI_A2A_DISPATCHER self - function AI_A2A_DISPATCHER:SetDefaultLandingAtEngineShutdown() + function AI_A2A_DISPATCHER:SetDefaultLandingAtEngineShutdown() self:SetDefaultLanding( AI_A2A_DISPATCHER.Landing.AtEngineShutdown ) return self end - --- Sets flights to land and despawn at engine shutdown, as part of the defense system. -- @param #AI_A2A_DISPATCHER self -- @param #string SquadronName The name of the squadron. + -- @return #AI_A2A_DISPATCHER self -- @usage: -- -- local A2ADispatcher = AI_A2A_DISPATCHER:New( ... ) @@ -2735,7 +2671,6 @@ do -- AI_A2A_DISPATCHER -- -- Let flights land and despawn at engine shutdown. -- A2ADispatcher:SetSquadronLandingAtEngineShutdown( "SquadronName" ) -- - -- @return #AI_A2A_DISPATCHER self function AI_A2A_DISPATCHER:SetSquadronLandingAtEngineShutdown( SquadronName ) self:SetSquadronLanding( SquadronName, AI_A2A_DISPATCHER.Landing.AtEngineShutdown ) @@ -2743,17 +2678,17 @@ do -- AI_A2A_DISPATCHER return self end - --- Set the default fuel treshold when defenders will RTB or Refuel in the air. - -- The fuel treshold is by default set to 15%, which means that an airplane will stay in the air until 15% of its fuel has been consumed. + --- Set the default fuel threshold when defenders will RTB or Refuel in the air. + -- The fuel threshold is by default set to 15%, which means that an airplane will stay in the air until 15% of its fuel has been consumed. -- @param #AI_A2A_DISPATCHER self - -- @param #number FuelThreshold A decimal number between 0 and 1, that expresses the %-tage of the treshold of fuel remaining in the tank when the plane will go RTB or Refuel. + -- @param #number FuelThreshold A decimal number between 0 and 1, that expresses the % of the threshold of fuel remaining in the tank when the plane will go RTB or Refuel. -- @return #AI_A2A_DISPATCHER self -- @usage -- -- -- Now Setup the A2A dispatcher, and initialize it using the Detection object. -- A2ADispatcher = AI_A2A_DISPATCHER:New( Detection ) -- - -- -- Now Setup the default fuel treshold. + -- -- Now Setup the default fuel threshold. -- A2ADispatcher:SetDefaultFuelThreshold( 0.30 ) -- Go RTB when only 30% of fuel remaining in the tank. -- function AI_A2A_DISPATCHER:SetDefaultFuelThreshold( FuelThreshold ) @@ -2763,19 +2698,18 @@ do -- AI_A2A_DISPATCHER return self end - - --- Set the fuel treshold for the squadron when defenders will RTB or Refuel in the air. - -- The fuel treshold is by default set to 15%, which means that an airplane will stay in the air until 15% of its fuel has been consumed. + --- Set the fuel threshold for the squadron when defenders will RTB or Refuel in the air. + -- The fuel threshold is by default set to 15%, which means that an airplane will stay in the air until 15% of its fuel has been consumed. -- @param #AI_A2A_DISPATCHER self -- @param #string SquadronName The name of the squadron. - -- @param #number FuelThreshold A decimal number between 0 and 1, that expresses the %-tage of the treshold of fuel remaining in the tank when the plane will go RTB or Refuel. + -- @param #number FuelThreshold A decimal number between 0 and 1, that expresses the % of the threshold of fuel remaining in the tank when the plane will go RTB or Refuel. -- @return #AI_A2A_DISPATCHER self -- @usage -- -- -- Now Setup the A2A dispatcher, and initialize it using the Detection object. -- A2ADispatcher = AI_A2A_DISPATCHER:New( Detection ) -- - -- -- Now Setup the default fuel treshold. + -- -- Now Setup the default fuel threshold. -- A2ADispatcher:SetSquadronFuelThreshold( "SquadronName", 0.30 ) -- Go RTB when only 30% of fuel remaining in the tank. -- function AI_A2A_DISPATCHER:SetSquadronFuelThreshold( SquadronName, FuelThreshold ) @@ -2795,11 +2729,12 @@ do -- AI_A2A_DISPATCHER -- -- Now Setup the A2A dispatcher, and initialize it using the Detection object. -- A2ADispatcher = AI_A2A_DISPATCHER:New( Detection ) -- - -- -- Now Setup the default fuel treshold. + -- -- Now Setup the default fuel threshold. -- A2ADispatcher:SetDefaultFuelThreshold( 0.30 ) -- Go RTB when only 30% of fuel remaining in the tank. -- -- -- Now Setup the default tanker. -- A2ADispatcher:SetDefaultTanker( "Tanker" ) -- The group name of the tanker is "Tanker" in the Mission Editor. + -- function AI_A2A_DISPATCHER:SetDefaultTanker( TankerName ) self.DefenderDefault.TankerName = TankerName @@ -2807,7 +2742,6 @@ do -- AI_A2A_DISPATCHER return self end - --- Set the squadron tanker where defenders will Refuel in the air. -- @param #AI_A2A_DISPATCHER self -- @param #string SquadronName The name of the squadron. @@ -2818,11 +2752,12 @@ do -- AI_A2A_DISPATCHER -- -- Now Setup the A2A dispatcher, and initialize it using the Detection object. -- A2ADispatcher = AI_A2A_DISPATCHER:New( Detection ) -- - -- -- Now Setup the squadron fuel treshold. + -- -- Now Setup the squadron fuel threshold. -- A2ADispatcher:SetSquadronFuelThreshold( "SquadronName", 0.30 ) -- Go RTB when only 30% of fuel remaining in the tank. -- -- -- Now Setup the squadron tanker. -- A2ADispatcher:SetSquadronTanker( "SquadronName", "Tanker" ) -- The group name of the tanker is "Tanker" in the Mission Editor. + -- function AI_A2A_DISPATCHER:SetSquadronTanker( SquadronName, TankerName ) local DefenderSquadron = self:GetSquadron( SquadronName ) @@ -2831,7 +2766,6 @@ do -- AI_A2A_DISPATCHER return self end - --- Set the squadron language. -- @param #AI_A2A_DISPATCHER self -- @param #string SquadronName The name of the squadron. @@ -2859,7 +2793,6 @@ do -- AI_A2A_DISPATCHER return self end - --- Set the frequency of communication and the mode of communication for voice overs. -- @param #AI_A2A_DISPATCHER self -- @param #string SquadronName The name of the squadron. @@ -2894,7 +2827,7 @@ do -- AI_A2A_DISPATCHER function AI_A2A_DISPATCHER:AddDefenderToSquadron( Squadron, Defender, Size ) self.Defenders = self.Defenders or {} local DefenderName = Defender:GetName() - self.Defenders[ DefenderName ] = Squadron + self.Defenders[DefenderName] = Squadron if Squadron.ResourceCount then Squadron.ResourceCount = Squadron.ResourceCount - Size end @@ -2911,7 +2844,7 @@ do -- AI_A2A_DISPATCHER if Squadron.ResourceCount then Squadron.ResourceCount = Squadron.ResourceCount + Defender:GetSize() end - self.Defenders[ DefenderName ] = nil + self.Defenders[DefenderName] = nil self:F( { DefenderName = DefenderName, SquadronResourceCount = Squadron.ResourceCount } ) end @@ -2924,13 +2857,12 @@ do -- AI_A2A_DISPATCHER if Defender ~= nil then local DefenderName = Defender:GetName() self:F( { DefenderName = DefenderName } ) - return self.Defenders[ DefenderName ] + return self.Defenders[DefenderName] else - return nil + return nil end end - --- Creates an SWEEP task when there are targets for it. -- @param #AI_A2A_DISPATCHER self -- @param Functional.Detection#DETECTION_BASE.DetectedItem DetectedItem @@ -2941,7 +2873,6 @@ do -- AI_A2A_DISPATCHER local DetectedSet = DetectedItem.Set local DetectedZone = DetectedItem.Zone - if DetectedItem.IsDetected == false then -- Here we're doing something advanced... We're copying the DetectedSet. @@ -2971,9 +2902,9 @@ do -- AI_A2A_DISPATCHER if AIGroup and AIGroup:IsAlive() then -- Check if the CAP is patrolling or engaging. If not, this is not a valid CAP, even if it is alive! -- The CAP could be damaged, lost control, or out of fuel! - --env.info("FF fsm state "..tostring(DefenderTask.Fsm:GetState())) + -- env.info("FF fsm state "..tostring(DefenderTask.Fsm:GetState())) if DefenderTask.Fsm:Is( "Patrolling" ) or DefenderTask.Fsm:Is( "Engaging" ) or DefenderTask.Fsm:Is( "Refuelling" ) or DefenderTask.Fsm:Is( "Started" ) then - --env.info("FF capcount "..CapCount) + -- env.info("FF capcount "..CapCount) CapCount = CapCount + 1 end end @@ -2985,24 +2916,23 @@ do -- AI_A2A_DISPATCHER return CapCount end - --- Count number of engaging defender groups. -- @param #AI_A2A_DISPATCHER self -- @param Functional.Detection#DETECTION_BASE.DetectedItem AttackerDetection Detection object. -- @return #number Number of defender groups engaging. function AI_A2A_DISPATCHER:CountDefendersEngaged( AttackerDetection ) - -- First, count the active AIGroups Units, targetting the DetectedSet + -- First, count the active AIGroups Units, targeting the DetectedSet local DefenderCount = 0 local DetectedSet = AttackerDetection.Set - --DetectedSet:Flush() + -- DetectedSet:Flush() local DefenderTasks = self:GetDefenderTasks() for DefenderGroup, DefenderTask in pairs( DefenderTasks ) do local Defender = DefenderGroup -- Wrapper.Group#GROUP - local DefenderTaskTarget = DefenderTask.Target --Functional.Detection#DETECTION_BASE.DetectedItem + local DefenderTaskTarget = DefenderTask.Target -- Functional.Detection#DETECTION_BASE.DetectedItem local DefenderSquadronName = DefenderTask.SquadronName if DefenderTaskTarget and DefenderTaskTarget.Index == AttackerDetection.Index then @@ -3069,7 +2999,6 @@ do -- AI_A2A_DISPATCHER return Friendlies end - --- Activate resource. -- @param #AI_A2A_DISPATCHER self -- @param #AI_A2A_DISPATCHER.Squadron DefenderSquadron The defender squadron. @@ -3084,36 +3013,36 @@ do -- AI_A2A_DISPATCHER local DefenderGrouping = DefenderSquadron.Grouping or self.DefenderDefault.Grouping - DefenderGrouping = ( DefenderGrouping < DefendersNeeded ) and DefenderGrouping or DefendersNeeded + DefenderGrouping = (DefenderGrouping < DefendersNeeded) and DefenderGrouping or DefendersNeeded - --env.info(string.format("FF resource activate: Squadron=%s grouping=%d needed=%d visible=%s", SquadronName, DefenderGrouping, DefendersNeeded, tostring(self:IsSquadronVisible( SquadronName )))) + -- env.info(string.format("FF resource activate: Squadron=%s grouping=%d needed=%d visible=%s", SquadronName, DefenderGrouping, DefendersNeeded, tostring(self:IsSquadronVisible( SquadronName )))) if self:IsSquadronVisible( SquadronName ) then - local n=#self.uncontrolled[SquadronName] + local n = #self.uncontrolled[SquadronName] - if n>0 then + if n > 0 then -- Random number 1,...n - local id=math.random(n) + local id = math.random( n ) -- Pick a random defender group. - local Defender=self.uncontrolled[SquadronName][id].group --Wrapper.Group#GROUP + local Defender = self.uncontrolled[SquadronName][id].group -- Wrapper.Group#GROUP -- Start uncontrolled group. Defender:StartUncontrolled() -- Get grouping. - DefenderGrouping=self.uncontrolled[SquadronName][id].grouping + DefenderGrouping = self.uncontrolled[SquadronName][id].grouping -- Add defender to squadron. self:AddDefenderToSquadron( DefenderSquadron, Defender, DefenderGrouping ) -- Remove defender from uncontrolled table. - table.remove(self.uncontrolled[SquadronName], id) + table.remove( self.uncontrolled[SquadronName], id ) return Defender, DefenderGrouping else - return nil,0 + return nil, 0 end -- Here we CAP the new planes. @@ -3171,7 +3100,7 @@ do -- AI_A2A_DISPATCHER --- Squadron not visible --- ---------------------------- - local Spawn = DefenderSquadron.Spawn[ math.random( 1, #DefenderSquadron.Spawn ) ] -- Core.Spawn#SPAWN + local Spawn = DefenderSquadron.Spawn[math.random( 1, #DefenderSquadron.Spawn )] -- Core.Spawn#SPAWN if DefenderGrouping then Spawn:InitGrouping( DefenderGrouping ) @@ -3199,7 +3128,7 @@ do -- AI_A2A_DISPATCHER -- @param #string SquadronName Name of the squadron. function AI_A2A_DISPATCHER:onafterCAP( From, Event, To, SquadronName ) - self:F({SquadronName = SquadronName}) + self:F( { SquadronName = SquadronName } ) self.DefenderSquadrons[SquadronName] = self.DefenderSquadrons[SquadronName] or {} self.DefenderSquadrons[SquadronName].Cap = self.DefenderSquadrons[SquadronName].Cap or {} @@ -3223,13 +3152,13 @@ do -- AI_A2A_DISPATCHER AI_A2A_Fsm:SetDisengageRadius( self.DisengageRadius ) AI_A2A_Fsm:SetTanker( DefenderSquadron.TankerName or self.DefenderDefault.TankerName ) if DefenderSquadron.Racetrack or self.DefenderDefault.Racetrack then - AI_A2A_Fsm:SetRaceTrackPattern(DefenderSquadron.RacetrackLengthMin or self.DefenderDefault.RacetrackLengthMin, - DefenderSquadron.RacetrackLengthMax or self.DefenderDefault.RacetrackLengthMax, - DefenderSquadron.RacetrackHeadingMin or self.DefenderDefault.RacetrackHeadingMin, - DefenderSquadron.RacetrackHeadingMax or self.DefenderDefault.RacetrackHeadingMax, - DefenderSquadron.RacetrackDurationMin or self.DefenderDefault.RacetrackDurationMin, - DefenderSquadron.RacetrackDurationMax or self.DefenderDefault.RacetrackDurationMax, - DefenderSquadron.RacetrackCoordinates or self.DefenderDefault.RacetrackCoordinates) + AI_A2A_Fsm:SetRaceTrackPattern( DefenderSquadron.RacetrackLengthMin or self.DefenderDefault.RacetrackLengthMin, + DefenderSquadron.RacetrackLengthMax or self.DefenderDefault.RacetrackLengthMax, + DefenderSquadron.RacetrackHeadingMin or self.DefenderDefault.RacetrackHeadingMin, + DefenderSquadron.RacetrackHeadingMax or self.DefenderDefault.RacetrackHeadingMax, + DefenderSquadron.RacetrackDurationMin or self.DefenderDefault.RacetrackDurationMin, + DefenderSquadron.RacetrackDurationMax or self.DefenderDefault.RacetrackDurationMax, + DefenderSquadron.RacetrackCoordinates or self.DefenderDefault.RacetrackCoordinates ) end AI_A2A_Fsm:Start() @@ -3238,15 +3167,15 @@ do -- AI_A2A_DISPATCHER function AI_A2A_Fsm:onafterTakeoff( DefenderGroup, From, Event, To ) -- Issue GetCallsign() returns nil, see https://github.com/FlightControl-Master/MOOSE/issues/1228 if DefenderGroup and DefenderGroup:IsAlive() then - self:F({"CAP Takeoff", DefenderGroup:GetName()}) - --self:GetParent(self).onafterBirth( self, Defender, From, Event, To ) + self:F( { "CAP Takeoff", DefenderGroup:GetName() } ) + -- self:GetParent(self).onafterBirth( self, Defender, From, Event, To ) local DefenderName = DefenderGroup:GetCallsign() local Dispatcher = AI_A2A_Fsm:GetDispatcher() -- #AI_A2A_DISPATCHER local Squadron = Dispatcher:GetSquadronFromDefender( DefenderGroup ) if Squadron then - Dispatcher:MessageToPlayers( Squadron, DefenderName .. " Wheels up.", DefenderGroup ) + Dispatcher:MessageToPlayers( Squadron, DefenderName .. " Wheels up.", DefenderGroup ) AI_A2A_Fsm:__Patrol( 2 ) -- Start Patrolling end end @@ -3254,14 +3183,14 @@ do -- AI_A2A_DISPATCHER function AI_A2A_Fsm:onafterPatrolRoute( DefenderGroup, From, Event, To ) if DefenderGroup and DefenderGroup:IsAlive() then - self:F({"CAP PatrolRoute", DefenderGroup:GetName()}) - self:GetParent(self).onafterPatrolRoute( self, DefenderGroup, From, Event, To ) + self:F( { "CAP PatrolRoute", DefenderGroup:GetName() } ) + self:GetParent( self ).onafterPatrolRoute( self, DefenderGroup, From, Event, To ) local DefenderName = DefenderGroup:GetCallsign() local Dispatcher = self:GetDispatcher() -- #AI_A2G_DISPATCHER local Squadron = Dispatcher:GetSquadronFromDefender( DefenderGroup ) if Squadron then - Dispatcher:MessageToPlayers( Squadron, DefenderName .. ", patrolling.", DefenderGroup ) + Dispatcher:MessageToPlayers( Squadron, DefenderName .. ", patrolling.", DefenderGroup ) end Dispatcher:ClearDefenderTaskTarget( DefenderGroup ) @@ -3270,15 +3199,15 @@ do -- AI_A2A_DISPATCHER function AI_A2A_Fsm:onafterRTB( DefenderGroup, From, Event, To ) if DefenderGroup and DefenderGroup:IsAlive() then - self:F({"CAP RTB", DefenderGroup:GetName()}) + self:F( { "CAP RTB", DefenderGroup:GetName() } ) - self:GetParent(self).onafterRTB( self, DefenderGroup, From, Event, To ) + self:GetParent( self ).onafterRTB( self, DefenderGroup, From, Event, To ) local DefenderName = DefenderGroup:GetCallsign() local Dispatcher = self:GetDispatcher() -- #AI_A2A_DISPATCHER local Squadron = Dispatcher:GetSquadronFromDefender( DefenderGroup ) if Squadron then - Dispatcher:MessageToPlayers( Squadron, DefenderName .. " returning to base.", DefenderGroup ) + Dispatcher:MessageToPlayers( Squadron, DefenderName .. " returning to base.", DefenderGroup ) end Dispatcher:ClearDefenderTaskTarget( DefenderGroup ) end @@ -3287,8 +3216,8 @@ do -- AI_A2A_DISPATCHER --- @param #AI_A2A_DISPATCHER self function AI_A2A_Fsm:onafterHome( Defender, From, Event, To, Action ) if Defender and Defender:IsAlive() then - self:F({"CAP Home", Defender:GetName()}) - self:GetParent(self).onafterHome( self, Defender, From, Event, To ) + self:F( { "CAP Home", Defender:GetName() } ) + self:GetParent( self ).onafterHome( self, Defender, From, Event, To ) local Dispatcher = self:GetDispatcher() -- #AI_A2A_DISPATCHER local Squadron = Dispatcher:GetSquadronFromDefender( Defender ) @@ -3311,7 +3240,6 @@ do -- AI_A2A_DISPATCHER end - --- On after "ENGAGE" event. -- @param #AI_A2A_DISPATCHER self -- @param #string From From state. @@ -3320,7 +3248,7 @@ do -- AI_A2A_DISPATCHER -- @param Functional.Detection#DETECTION_BASE.DetectedItem AttackerDetection Detected item. -- @param #table Defenders Defenders table. function AI_A2A_DISPATCHER:onafterENGAGE( From, Event, To, AttackerDetection, Defenders ) - self:F("ENGAGING Detection ID="..tostring(AttackerDetection.ID)) + self:F( "ENGAGING Detection ID=" .. tostring( AttackerDetection.ID ) ) if Defenders then @@ -3347,7 +3275,7 @@ do -- AI_A2A_DISPATCHER -- @param #table DefenderFriendlies Friendly defenders. function AI_A2A_DISPATCHER:onafterGCI( From, Event, To, AttackerDetection, DefendersMissing, DefenderFriendlies ) - self:F("GCI Detection ID="..tostring(AttackerDetection.ID)) + self:F( "GCI Detection ID=" .. tostring( AttackerDetection.ID ) ) self:F( { From, Event, To, AttackerDetection.Index, DefendersMissing, DefenderFriendlies } ) @@ -3376,7 +3304,7 @@ do -- AI_A2A_DISPATCHER local BreakLoop = false - while( DefenderCount > 0 and not BreakLoop ) do + while (DefenderCount > 0 and not BreakLoop) do self:F( { DefenderSquadrons = self.DefenderSquadrons } ) @@ -3422,7 +3350,7 @@ do -- AI_A2A_DISPATCHER local DefenderGrouping = DefenderSquadron.Grouping or self.DefenderDefault.Grouping local DefendersNeeded = math.ceil( DefenderCount * DefenderOverhead ) - self:F( { Overhead = DefenderOverhead, SquadronOverhead = DefenderSquadron.Overhead , DefaultOverhead = self.DefenderDefault.Overhead } ) + self:F( { Overhead = DefenderOverhead, SquadronOverhead = DefenderSquadron.Overhead, DefaultOverhead = self.DefenderDefault.Overhead } ) self:F( { Grouping = DefenderGrouping, SquadronGrouping = DefenderSquadron.Grouping, DefaultGrouping = self.DefenderDefault.Grouping } ) self:F( { DefendersCount = DefenderCount, DefendersNeeded = DefendersNeeded } ) @@ -3433,7 +3361,7 @@ do -- AI_A2A_DISPATCHER BreakLoop = true end - while ( DefendersNeeded > 0 ) do + while (DefendersNeeded > 0) do local DefenderGCI, DefenderGrouping = self:ResourceActivate( DefenderSquadron, DefendersNeeded ) @@ -3451,13 +3379,11 @@ do -- AI_A2A_DISPATCHER Fsm:SetDisengageRadius( self.DisengageRadius ) Fsm:Start() - self:SetDefenderTask( ClosestDefenderSquadronName, DefenderGCI, "GCI", Fsm, AttackerDetection ) - function Fsm:onafterTakeoff( DefenderGroup, From, Event, To ) - self:F({"GCI Birth", DefenderGroup:GetName()}) - --self:GetParent(self).onafterBirth( self, Defender, From, Event, To ) + self:F( { "GCI Birth", DefenderGroup:GetName() } ) + -- self:GetParent(self).onafterBirth( self, Defender, From, Event, To ) local DefenderName = DefenderGroup:GetCallsign() local Dispatcher = Fsm:GetDispatcher() -- #AI_A2A_DISPATCHER @@ -3466,17 +3392,17 @@ do -- AI_A2A_DISPATCHER if DefenderTarget then if Squadron.Language == "EN" then - Dispatcher:MessageToPlayers( Squadron, DefenderName .. " wheels up.", DefenderGroup ) + Dispatcher:MessageToPlayers( Squadron, DefenderName .. " wheels up.", DefenderGroup ) elseif Squadron.Language == "RU" then - Dispatcher:MessageToPlayers( Squadron, DefenderName .. " колеса вверх.", DefenderGroup ) + Dispatcher:MessageToPlayers( Squadron, DefenderName .. " колеса вверх.", DefenderGroup ) end - --Fsm:__Engage( 2, DefenderTarget.Set ) -- Engage on the TargetSetUnit + -- Fsm:__Engage( 2, DefenderTarget.Set ) -- Engage on the TargetSetUnit Fsm:EngageRoute( DefenderTarget.Set ) -- Engage on the TargetSetUnit end end function Fsm:onafterEngageRoute( DefenderGroup, From, Event, To, AttackSetUnit ) - self:F({"GCI Route", DefenderGroup:GetName()}) + self:F( { "GCI Route", DefenderGroup:GetName() } ) local DefenderName = DefenderGroup:GetCallsign() local Dispatcher = Fsm:GetDispatcher() -- #AI_A2A_DISPATCHER @@ -3487,18 +3413,18 @@ do -- AI_A2A_DISPATCHER local Coordinate = FirstUnit:GetCoordinate() -- Core.Point#COORDINATE if Squadron.Language == "EN" then - Dispatcher:MessageToPlayers( Squadron, DefenderName .. ", intercepting bogeys at " .. Coordinate:ToStringA2A( DefenderGroup, nil, Squadron.Language ), DefenderGroup ) + Dispatcher:MessageToPlayers( Squadron, DefenderName .. ", intercepting bogeys at " .. Coordinate:ToStringA2A( DefenderGroup, nil, Squadron.Language ), DefenderGroup ) elseif Squadron.Language == "RU" then - Dispatcher:MessageToPlayers( Squadron, DefenderName .. ", перехват самолетов в " .. Coordinate:ToStringA2A( DefenderGroup, nil, Squadron.Language ), DefenderGroup ) + Dispatcher:MessageToPlayers( Squadron, DefenderName .. ", перехват самолетов в " .. Coordinate:ToStringA2A( DefenderGroup, nil, Squadron.Language ), DefenderGroup ) elseif Squadron.Language == "DE" then - Dispatcher:MessageToPlayers( Squadron, DefenderName .. ", Eindringlinge abfangen bei" .. Coordinate:ToStringA2A( DefenderGroup, nil, Squadron.Language ), DefenderGroup ) + Dispatcher:MessageToPlayers( Squadron, DefenderName .. ", Eindringlinge abfangen bei" .. Coordinate:ToStringA2A( DefenderGroup, nil, Squadron.Language ), DefenderGroup ) end end self:GetParent( Fsm ).onafterEngageRoute( self, DefenderGroup, From, Event, To, AttackSetUnit ) end function Fsm:onafterEngage( DefenderGroup, From, Event, To, AttackSetUnit ) - self:F({"GCI Engage", DefenderGroup:GetName()}) + self:F( { "GCI Engage", DefenderGroup:GetName() } ) local DefenderName = DefenderGroup:GetCallsign() local Dispatcher = Fsm:GetDispatcher() -- #AI_A2A_DISPATCHER @@ -3509,17 +3435,17 @@ do -- AI_A2A_DISPATCHER local Coordinate = FirstUnit:GetCoordinate() -- Core.Point#COORDINATE if Squadron.Language == "EN" then - Dispatcher:MessageToPlayers( Squadron, DefenderName .. ", engaging bogeys at " .. Coordinate:ToStringA2A( DefenderGroup, nil, Squadron.Language ), DefenderGroup ) + Dispatcher:MessageToPlayers( Squadron, DefenderName .. ", engaging bogeys at " .. Coordinate:ToStringA2A( DefenderGroup, nil, Squadron.Language ), DefenderGroup ) elseif Squadron.Language == "RU" then - Dispatcher:MessageToPlayers( Squadron, DefenderName .. ", захватывающие самолеты в " .. Coordinate:ToStringA2A( DefenderGroup, nil, Squadron.Language ), DefenderGroup ) + Dispatcher:MessageToPlayers( Squadron, DefenderName .. ", захватывающие самолеты в " .. Coordinate:ToStringA2A( DefenderGroup, nil, Squadron.Language ), DefenderGroup ) end end self:GetParent( Fsm ).onafterEngage( self, DefenderGroup, From, Event, To, AttackSetUnit ) end function Fsm:onafterRTB( DefenderGroup, From, Event, To ) - self:F({"GCI RTB", DefenderGroup:GetName()}) - self:GetParent(self).onafterRTB( self, DefenderGroup, From, Event, To ) + self:F( { "GCI RTB", DefenderGroup:GetName() } ) + self:GetParent( self ).onafterRTB( self, DefenderGroup, From, Event, To ) local DefenderName = DefenderGroup:GetCallsign() local Dispatcher = self:GetDispatcher() -- #AI_A2A_DISPATCHER @@ -3527,9 +3453,9 @@ do -- AI_A2A_DISPATCHER if Squadron then if Squadron.Language == "EN" then - Dispatcher:MessageToPlayers( Squadron, DefenderName .. " returning to base.", DefenderGroup ) + Dispatcher:MessageToPlayers( Squadron, DefenderName .. " returning to base.", DefenderGroup ) elseif Squadron.Language == "RU" then - Dispatcher:MessageToPlayers( Squadron, DefenderName .. ", возвращаясь на базу.", DefenderGroup ) + Dispatcher:MessageToPlayers( Squadron, DefenderName .. ", возвращаясь на базу.", DefenderGroup ) end end Dispatcher:ClearDefenderTaskTarget( DefenderGroup ) @@ -3537,8 +3463,8 @@ do -- AI_A2A_DISPATCHER --- @param #AI_A2A_DISPATCHER self function Fsm:onafterLostControl( Defender, From, Event, To ) - self:F({"GCI LostControl", Defender:GetName()}) - self:GetParent(self).onafterHome( self, Defender, From, Event, To ) + self:F( { "GCI LostControl", Defender:GetName() } ) + self:GetParent( self ).onafterHome( self, Defender, From, Event, To ) local Dispatcher = Fsm:GetDispatcher() -- #AI_A2A_DISPATCHER local Squadron = Dispatcher:GetSquadronFromDefender( Defender ) @@ -3550,18 +3476,18 @@ do -- AI_A2A_DISPATCHER --- @param #AI_A2A_DISPATCHER self function Fsm:onafterHome( DefenderGroup, From, Event, To, Action ) - self:F({"GCI Home", DefenderGroup:GetName()}) - self:GetParent(self).onafterHome( self, DefenderGroup, From, Event, To ) + self:F( { "GCI Home", DefenderGroup:GetName() } ) + self:GetParent( self ).onafterHome( self, DefenderGroup, From, Event, To ) local DefenderName = DefenderGroup:GetCallsign() local Dispatcher = self:GetDispatcher() -- #AI_A2A_DISPATCHER local Squadron = Dispatcher:GetSquadronFromDefender( DefenderGroup ) - if Squadron.Language == "EN" then - Dispatcher:MessageToPlayers( Squadron, DefenderName .. " landing at base.", DefenderGroup ) - elseif Squadron.Language == "RU" then - Dispatcher:MessageToPlayers( Squadron, DefenderName .. ", захватывающие самолеты в посадка на базу.", DefenderGroup ) - end + if Squadron.Language == "EN" then + Dispatcher:MessageToPlayers( Squadron, DefenderName .. " landing at base.", DefenderGroup ) + elseif Squadron.Language == "RU" then + Dispatcher:MessageToPlayers( Squadron, DefenderName .. ", захватывающие самолеты в посадка на базу.", DefenderGroup ) + end if Action and Action == "Destroy" then Dispatcher:RemoveDefenderFromSquadron( Squadron, DefenderGroup ) @@ -3575,8 +3501,8 @@ do -- AI_A2A_DISPATCHER end end - end -- if DefenderGCI then - end -- while ( DefendersNeeded > 0 ) do + end -- if DefenderGCI then + end -- while ( DefendersNeeded > 0 ) do end else -- No more resources, try something else. @@ -3592,8 +3518,6 @@ do -- AI_A2A_DISPATCHER end -- if AttackerUnit end - - --- Creates an ENGAGE task when there are human friendlies airborne near the targets. -- @param #AI_A2A_DISPATCHER self -- @param Functional.Detection#DETECTION_BASE.DetectedItem DetectedItem The detected item. @@ -3601,7 +3525,7 @@ do -- AI_A2A_DISPATCHER function AI_A2A_DISPATCHER:EvaluateENGAGE( DetectedItem ) self:F( { DetectedItem.ItemID } ) - -- First, count the active AIGroups Units, targetting the DetectedSet + -- First, count the active AIGroups Units, targeting the DetectedSet local DefenderCount = self:CountDefendersEngaged( DetectedItem ) local DefenderGroups = self:CountDefendersToBeEngaged( DetectedItem, DefenderCount ) @@ -3630,7 +3554,7 @@ do -- AI_A2A_DISPATCHER local AttackerSet = DetectedItem.Set local AttackerCount = AttackerSet:Count() - -- First, count the active AIGroups Units, targetting the DetectedSet + -- First, count the active AIGroups Units, targeting the DetectedSet local DefenderCount = self:CountDefendersEngaged( DetectedItem ) local DefendersMissing = AttackerCount - DefenderCount self:F( { AttackerCount = AttackerCount, DefenderCount = DefenderCount, DefendersMissing = DefendersMissing } ) @@ -3645,12 +3569,11 @@ do -- AI_A2A_DISPATCHER return nil, nil end - --- Assigns A2G AI Tasks in relation to the detected items. -- @param #AI_A2G_DISPATCHER self function AI_A2A_DISPATCHER:Order( DetectedItem ) - local detection=self.Detection -- Functional.Detection#DETECTION_AREAS + local detection = self.Detection -- Functional.Detection#DETECTION_AREAS local ShortestDistance = 999999999 @@ -3679,7 +3602,6 @@ do -- AI_A2A_DISPATCHER return ShortestDistance end - --- Shows the tactical display. -- @param #AI_A2A_DISPATCHER self -- @param Functional.Detection#DETECTION_BASE Detection The detection created by the @{Functional.Detection#DETECTION_BASE} derived object. @@ -3696,8 +3618,10 @@ do -- AI_A2A_DISPATCHER local DefenderGroupCount = 0 -- Now that all obsolete tasks are removed, loop through the detected targets. - --for DetectedItemID, DetectedItem in pairs( Detection:GetDetectedItems() ) do - for DetectedItemID, DetectedItem in UTILS.spairs( Detection:GetDetectedItems(), function( t, a, b ) return self:Order(t[a]) < self:Order(t[b]) end ) do + -- for DetectedItemID, DetectedItem in pairs( Detection:GetDetectedItems() ) do + for DetectedItemID, DetectedItem in UTILS.spairs( Detection:GetDetectedItems(), function( t, a, b ) + return self:Order( t[a] ) < self:Order( t[b] ) + end ) do local DetectedItem = DetectedItem -- Functional.Detection#DETECTION_BASE.DetectedItem local DetectedSet = DetectedItem.Set -- Core.Set#SET_UNIT @@ -3712,30 +3636,30 @@ do -- AI_A2A_DISPATCHER local DetectedItemChanged = DetectedItem.Changed -- Show tactical situation - Report:Add( string.format( "\n- Target %s (%s): (#%d) %s" , DetectedItem.ItemID, DetectedItem.Index, DetectedItem.Set:Count(), DetectedItem.Set:GetObjectNames() ) ) + Report:Add( string.format( "\n- Target %s (%s): (#%d) %s", DetectedItem.ItemID, DetectedItem.Index, DetectedItem.Set:Count(), DetectedItem.Set:GetObjectNames() ) ) for Defender, DefenderTask in pairs( self:GetDefenderTasks() ) do local Defender = Defender -- Wrapper.Group#GROUP - if DefenderTask.Target and DefenderTask.Target.Index == DetectedItem.Index then - if Defender and Defender:IsAlive() then - DefenderGroupCount = DefenderGroupCount + 1 - local Fuel = Defender:GetFuelMin() * 100 - local Damage = Defender:GetLife() / Defender:GetLife0() * 100 - Report:Add( string.format( " - %s*%d/%d (%s - %s): (#%d) F: %3d, D:%3d - %s", - Defender:GetName(), - Defender:GetSize(), - Defender:GetInitialSize(), - DefenderTask.Type, - DefenderTask.Fsm:GetState(), - Defender:GetSize(), - Fuel, - Damage, - Defender:HasTask() == true and "Executing" or "Idle" ) ) - end - end + if DefenderTask.Target and DefenderTask.Target.Index == DetectedItem.Index then + if Defender and Defender:IsAlive() then + DefenderGroupCount = DefenderGroupCount + 1 + local Fuel = Defender:GetFuelMin() * 100 + local Damage = Defender:GetLife() / Defender:GetLife0() * 100 + Report:Add( string.format( " - %s*%d/%d (%s - %s): (#%d) F: %3d, D:%3d - %s", + Defender:GetName(), + Defender:GetSize(), + Defender:GetInitialSize(), + DefenderTask.Type, + DefenderTask.Fsm:GetState(), + Defender:GetSize(), + Fuel, + Damage, + Defender:HasTask() == true and "Executing" or "Idle" ) ) + end + end end end - Report:Add( "\n- No Targets:") + Report:Add( "\n- No Targets:" ) local TaskCount = 0 for Defender, DefenderTask in pairs( self:GetDefenderTasks() ) do TaskCount = TaskCount + 1 @@ -3780,7 +3704,6 @@ do -- AI_A2A_DISPATCHER local TaskReport = REPORT:New() - for AIGroup, DefenderTask in pairs( self:GetDefenderTasks() ) do local AIGroup = AIGroup -- Wrapper.Group#GROUP if not AIGroup:IsAlive() then @@ -3814,8 +3737,10 @@ do -- AI_A2A_DISPATCHER -- Now that all obsolete tasks are removed, loop through the detected targets. -- Closest detected targets to be considered first! - --for DetectedItemID, DetectedItem in pairs( Detection:GetDetectedItems() ) do - for DetectedItemID, DetectedItem in UTILS.spairs( Detection:GetDetectedItems(), function( t, a, b ) return self:Order(t[a]) < self:Order(t[b]) end ) do + -- for DetectedItemID, DetectedItem in pairs( Detection:GetDetectedItems() ) do + for DetectedItemID, DetectedItem in UTILS.spairs( Detection:GetDetectedItems(), function( t, a, b ) + return self:Order( t[a] ) < self:Order( t[b] ) + end ) do local DetectedItem = DetectedItem -- Functional.Detection#DETECTION_BASE.DetectedItem local DetectedSet = DetectedItem.Set -- Core.Set#SET_UNIT @@ -3874,7 +3799,7 @@ do for PlayerUnitName, PlayerUnitData in pairs( PlayersNearBy ) do local PlayerUnit = PlayerUnitData -- Wrapper.Unit#UNIT local PlayerName = PlayerUnit:GetPlayerName() - --self:F( { PlayerName = PlayerName, PlayerUnit = PlayerUnit } ) + -- self:F( { PlayerName = PlayerName, PlayerUnit = PlayerUnit } ) if PlayerUnit:IsAirPlane() and PlayerName ~= nil then local FriendlyUnitThreatLevel = PlayerUnit:GetThreatLevel() PlayersCount = PlayersCount + 1 @@ -3887,19 +3812,18 @@ do end - --self:F( { PlayersCount = PlayersCount } ) + -- self:F( { PlayersCount = PlayersCount } ) local PlayerTypesReport = REPORT:New() if PlayersCount > 0 then for PlayerName, PlayerType in pairs( PlayerTypes ) do - PlayerTypesReport:Add( string.format('"%s" in %s', PlayerName, PlayerType ) ) + PlayerTypesReport:Add( string.format( '"%s" in %s', PlayerName, PlayerType ) ) end else PlayerTypesReport:Add( "-" ) end - return PlayersCount, PlayerTypesReport end @@ -3923,7 +3847,7 @@ do local FriendlyUnitThreatLevel = FriendlyUnit:GetThreatLevel() FriendliesCount = FriendliesCount + 1 local FriendlyType = FriendlyUnit:GetTypeName() - FriendlyTypes[FriendlyType] = FriendlyTypes[FriendlyType] and ( FriendlyTypes[FriendlyType] + 1 ) or 1 + FriendlyTypes[FriendlyType] = FriendlyTypes[FriendlyType] and (FriendlyTypes[FriendlyType] + 1) or 1 if DetectedTreatLevel < FriendlyUnitThreatLevel + 2 then end end @@ -3931,19 +3855,18 @@ do end - --self:F( { FriendliesCount = FriendliesCount } ) + -- self:F( { FriendliesCount = FriendliesCount } ) local FriendlyTypesReport = REPORT:New() if FriendliesCount > 0 then for FriendlyType, FriendlyTypeCount in pairs( FriendlyTypes ) do - FriendlyTypesReport:Add( string.format("%d of %s", FriendlyTypeCount, FriendlyType ) ) + FriendlyTypesReport:Add( string.format( "%d of %s", FriendlyTypeCount, FriendlyType ) ) end else FriendlyTypesReport:Add( "-" ) end - return FriendliesCount, FriendlyTypesReport end @@ -4050,13 +3973,13 @@ do -- -- ![Mission Editor Action](..\Presentations\AI_A2A_DISPATCHER\AI_A2A_GCICAP-ME_4.JPG) -- - -- **All airplane or helicopter groups that are starting with any of the choosen Template Prefixes will result in a squadron created at the airbase.** + -- **All airplane or helicopter groups that are starting with any of the chosen Template Prefixes will result in a squadron created at the airbase.** -- -- ### 1.4) Place floating helicopters to create the CAP zones defined by its route points. -- -- ![Mission Editor Action](..\Presentations\AI_A2A_DISPATCHER\AI_A2A_GCICAP-ME_5.JPG) -- - -- **All airplane or helicopter groups that are starting with any of the choosen Template Prefixes will result in a squadron created at the airbase.** + -- **All airplane or helicopter groups that are starting with any of the chosen Template Prefixes will result in a squadron created at the airbase.** -- -- The helicopter indicates the start of the CAP zone. -- The route points define the form of the CAP zone polygon. @@ -4069,7 +3992,7 @@ do -- -- ### 2.1) Planes are taking off in the air from the airbases. -- - -- This prevents airbases to get cluttered with airplanes taking off, it also reduces the risk of human players colliding with taxiiing airplanes, + -- This prevents airbases to get cluttered with airplanes taking off, it also reduces the risk of human players colliding with taxiing airplanes, -- resulting in the airbase to halt operations. -- -- You can change the way how planes take off by using the inherited methods from AI\_A2A\_DISPATCHER: @@ -4093,7 +4016,7 @@ do -- -- ### 2.2) Planes return near the airbase or will land if damaged. -- - -- When damaged airplanes return to the airbase, they will be routed and will dissapear in the air when they are near the airbase. + -- When damaged airplanes return to the airbase, they will be routed and will disappear in the air when they are near the airbase. -- There are exceptions to this rule, airplanes that aren't "listening" anymore due to damage or out of fuel, will return to the airbase and land. -- -- You can change the way how planes land by using the inherited methods from AI\_A2A\_DISPATCHER: @@ -4103,7 +4026,7 @@ do -- * @{#AI_A2A_DISPATCHER.SetSquadronLandingAtRunway}() will despawn the returning aircraft directly after landing at the runway. -- * @{#AI_A2A_DISPATCHER.SetSquadronLandingAtEngineShutdown}() will despawn the returning aircraft when the aircraft has returned to its parking spot and has turned off its engines. -- - -- You can use these methods to minimize the airbase coodination overhead and to increase the airbase efficiency. + -- You can use these methods to minimize the airbase coordination overhead and to increase the airbase efficiency. -- When there are lots of aircraft returning for landing, at the same airbase, the takeoff process will be halted, which can cause a complete failure of the -- A2A defense system, as no new CAP or GCI planes can takeoff. -- Note that the method @{#AI_A2A_DISPATCHER.SetSquadronLandingNearAirbase}() will only work for returning aircraft, not for damaged or out of fuel aircraft. @@ -4126,7 +4049,7 @@ do -- * The minimum and maximum engage speed -- * The type of altitude measurement -- - -- These define how the squadron will perform the CAP while partrolling. Different terrain types requires different types of CAP. + -- These define how the squadron will perform the CAP while patrolling. Different terrain types requires different types of CAP. -- -- The @{#AI_A2A_DISPATCHER.SetSquadronCapInterval}() method specifies **how much** and **when** CAP flights will takeoff. -- @@ -4152,7 +4075,7 @@ do -- Essentially this controls how many flights of GCI aircraft can be active at any time. -- Note allowing large numbers of active GCI flights can adversely impact mission performance on low or medium specification hosts/servers. -- GCI needs to be setup at strategic airbases. Too far will mean that the aircraft need to fly a long way to reach the intruders, - -- too short will mean that the intruders may have alraedy passed the ideal interception point! + -- too short will mean that the intruders may have already passed the ideal interception point! -- -- For example, the following setup will create a GCI for squadron "Sochi": -- @@ -4191,8 +4114,7 @@ do -- These late activated Groups start with the name `SQUADRON CCCP`. Each Group object contains only one Unit, and defines the weapon payload, skin and skill level. -- * `"CAP CCCP"`: CAP Zones are defined using floating, late activated Helicopter Group objects, where the route points define the route of the polygon of the CAP Zone. -- These Helicopter Group objects start with the name `CAP CCCP`, and will be the locations wherein CAP will be performed. - -- * `2` Defines how many CAP airplanes are patrolling in each CAP zone defined simulateneously. - -- + -- * `2` Defines how many CAP airplanes are patrolling in each CAP zone defined simultaneously. -- -- ### 4.2) A more advanced setup: -- @@ -4209,7 +4131,7 @@ do -- * `{ "104th CAP" }`: An array of the names of the CAP zones are defined using floating, late activated helicopter group objects, -- where the route points define the route of the polygon of the CAP Zone. -- These Helicopter Group objects start with the name `104th CAP`, and will be the locations wherein CAP will be performed. - -- * `4` Defines how many CAP airplanes are patrolling in each CAP zone defined simulateneously. + -- * `4` Defines how many CAP airplanes are patrolling in each CAP zone defined simultaneously. -- -- @field #AI_A2A_GCICAP AI_A2A_GCICAP = { @@ -4217,7 +4139,6 @@ do Detection = nil, } - --- AI_A2A_GCICAP constructor. -- @param #AI_A2A_GCICAP self -- @param #string EWRPrefixes A list of prefixes that of groups that setup the Early Warning Radar network. @@ -4297,7 +4218,7 @@ do -- -- The CAP Zone prefix is nil. No CAP is created. -- -- The CAP Limit is nil. -- -- The Grouping Radius is nil. The default range of 6km radius will be grouped as a group of targets. - -- -- The Engage Radius is set nil. The default Engage Radius will be used to consider a defenser being assigned to a task. + -- -- The Engage Radius is set nil. The default Engage Radius will be used to consider a defender being assigned to a task. -- -- The GCI Radius is nil. Any target detected within the default GCI Radius will be considered for GCI engagement. -- -- The amount of resources for each squadron is set to 30. Thus about 30 resources are allocated to each squadron created. -- @@ -4309,7 +4230,7 @@ do EWRSetGroup:FilterPrefixes( EWRPrefixes ) EWRSetGroup:FilterStart() - local Detection = DETECTION_AREAS:New( EWRSetGroup, GroupingRadius or 30000 ) + local Detection = DETECTION_AREAS:New( EWRSetGroup, GroupingRadius or 30000 ) local self = BASE:Inherit( self, AI_A2A_DISPATCHER:New( Detection ) ) -- #AI_A2A_GCICAP @@ -4330,14 +4251,11 @@ do end end - self.Templates = SET_GROUP - :New() - :FilterPrefixes( TemplatePrefixes ) - :FilterOnce() + self.Templates = SET_GROUP:New():FilterPrefixes( TemplatePrefixes ):FilterOnce() -- Setup squadrons - self:I( { Airbases = AirbaseNames } ) + self:I( { Airbases = AirbaseNames } ) self:I( "Defining Templates for Airbases ..." ) for AirbaseID, AirbaseName in pairs( AirbaseNames ) do @@ -4415,7 +4333,7 @@ do self:HandleEvent( EVENTS.Crash, self.OnEventCrashOrDead ) self:HandleEvent( EVENTS.Dead, self.OnEventCrashOrDead ) - --self:HandleEvent( EVENTS.RemoveUnit, self.OnEventCrashOrDead ) + -- self:HandleEvent( EVENTS.RemoveUnit, self.OnEventCrashOrDead ) self:HandleEvent( EVENTS.Land ) self:HandleEvent( EVENTS.EngineShutdown ) @@ -4512,7 +4430,7 @@ do -- -- The CAP Zone prefix is nil. No CAP is created. -- -- The CAP Limit is nil. -- -- The Grouping Radius is nil. The default range of 6km radius will be grouped as a group of targets. - -- -- The Engage Radius is set nil. The default Engage Radius will be used to consider a defenser being assigned to a task. + -- -- The Engage Radius is set nil. The default Engage Radius will be used to consider a defender being assigned to a task. -- -- The GCI Radius is nil. Any target detected within the default GCI Radius will be considered for GCI engagement. -- -- The amount of resources for each squadron is set to 30. Thus about 30 resources are allocated to each squadron created. -- diff --git a/Moose Development/Moose/AI/AI_A2A_Gci.lua b/Moose Development/Moose/AI/AI_A2A_Gci.lua index 4a3f4570b..15653d1e0 100644 --- a/Moose Development/Moose/AI/AI_A2A_Gci.lua +++ b/Moose Development/Moose/AI/AI_A2A_Gci.lua @@ -42,8 +42,8 @@ -- -- ![Process](..\Presentations\AI_GCI\Dia10.JPG) -- --- Until a fuel or damage treshold has been reached by the AI, or when the AI is commanded to RTB. --- When the fuel treshold has been reached, the airplane will fly towards the nearest friendly airbase and will land. +-- Until a fuel or damage threshold has been reached by the AI, or when the AI is commanded to RTB. +-- When the fuel threshold has been reached, the airplane will fly towards the nearest friendly airbase and will land. -- -- ![Process](..\Presentations\AI_GCI\Dia13.JPG) -- @@ -73,7 +73,7 @@ -- * **@{AI.AI_Patrol#AI_PATROL_ZONE.Detected}**: The AI has detected new targets. -- * **@{#AI_A2A_GCI.Destroy}**: The AI has destroyed a bogey @{Wrapper.Unit}. -- * **@{#AI_A2A_GCI.Destroyed}**: The AI has destroyed all bogeys @{Wrapper.Unit}s assigned in the CAS task. --- * **Status** ( Group ): The AI is checking status (fuel and damage). When the tresholds have been reached, the AI will RTB. +-- * **Status** ( Group ): The AI is checking status (fuel and damage). When the thresholds have been reached, the AI will RTB. -- -- ## 3. Set the Range of Engagement -- diff --git a/Moose Development/Moose/AI/AI_A2A_Patrol.lua b/Moose Development/Moose/AI/AI_A2A_Patrol.lua index d0a01bdd6..f4252fac1 100644 --- a/Moose Development/Moose/AI/AI_A2A_Patrol.lua +++ b/Moose Development/Moose/AI/AI_A2A_Patrol.lua @@ -39,8 +39,8 @@ -- -- ![Process](..\Presentations\AI_PATROL\Dia10.JPG) -- --- Until a fuel or damage treshold has been reached by the AI, or when the AI is commanded to RTB. --- When the fuel treshold has been reached, the airplane will fly towards the nearest friendly airbase and will land. +-- Until a fuel or damage threshold has been reached by the AI, or when the AI is commanded to RTB. +-- When the fuel threshold has been reached, the airplane will fly towards the nearest friendly airbase and will land. -- -- ![Process](..\Presentations\AI_PATROL\Dia11.JPG) -- @@ -68,7 +68,7 @@ -- * **RTB** ( Group ): Route the AI to the home base. -- * **Detect** ( Group ): The AI is detecting targets. -- * **Detected** ( Group ): The AI has detected new targets. --- * **Status** ( Group ): The AI is checking status (fuel and damage). When the tresholds have been reached, the AI will RTB. +-- * **Status** ( Group ): The AI is checking status (fuel and damage). When the thresholds have been reached, the AI will RTB. -- -- ## 3. Set or Get the AI controllable -- @@ -100,8 +100,8 @@ -- ## 6. Manage the "out of fuel" in the AI_A2A_PATROL -- -- When the AI is out of fuel, it is required that a new AI is started, before the old AI can return to the home base. --- Therefore, with a parameter and a calculation of the distance to the home base, the fuel treshold is calculated. --- When the fuel treshold is reached, the AI will continue for a given time its patrol task in orbit, +-- Therefore, with a parameter and a calculation of the distance to the home base, the fuel threshold is calculated. +-- When the fuel threshold is reached, the AI will continue for a given time its patrol task in orbit, -- while a new AI is targetted to the AI_A2A_PATROL. -- Once the time is finished, the old AI will return to the base. -- Use the method @{#AI_A2A_PATROL.ManageFuel}() to have this proces in place. @@ -109,7 +109,7 @@ -- ## 7. Manage "damage" behaviour of the AI in the AI_A2A_PATROL -- -- When the AI is damaged, it is required that a new Patrol is started. However, damage cannon be foreseen early on. --- Therefore, when the damage treshold is reached, the AI will return immediately to the home base (RTB). +-- Therefore, when the damage threshold is reached, the AI will return immediately to the home base (RTB). -- Use the method @{#AI_A2A_PATROL.ManageDamage}() to have this proces in place. -- -- === diff --git a/Moose Development/Moose/AI/AI_A2G_Dispatcher.lua b/Moose Development/Moose/AI/AI_A2G_Dispatcher.lua index 597f60ac7..9d6fd1573 100644 --- a/Moose Development/Moose/AI/AI_A2G_Dispatcher.lua +++ b/Moose Development/Moose/AI/AI_A2G_Dispatcher.lua @@ -3243,17 +3243,17 @@ do -- AI_A2G_DISPATCHER return self end - --- Set the default fuel treshold when defenders will RTB or Refuel in the air. - -- The fuel treshold is by default set to 15%, which means that an aircraft will stay in the air until 15% of its fuel is remaining. + --- Set the default fuel threshold when defenders will RTB or Refuel in the air. + -- The fuel threshold is by default set to 15%, which means that an aircraft will stay in the air until 15% of its fuel is remaining. -- @param #AI_A2G_DISPATCHER self - -- @param #number FuelThreshold A decimal number between 0 and 1, that expresses the % of the treshold of fuel remaining in the tank when the plane will go RTB or Refuel. + -- @param #number FuelThreshold A decimal number between 0 and 1, that expresses the % of the threshold of fuel remaining in the tank when the plane will go RTB or Refuel. -- @return #AI_A2G_DISPATCHER -- @usage -- -- -- Now Setup the A2G dispatcher, and initialize it using the Detection object. -- A2GDispatcher = AI_A2G_DISPATCHER:New( Detection ) -- - -- -- Now Setup the default fuel treshold. + -- -- Now Setup the default fuel threshold. -- A2GDispatcher:SetDefaultFuelThreshold( 0.30 ) -- Go RTB when only 30% of fuel remaining in the tank. -- function AI_A2G_DISPATCHER:SetDefaultFuelThreshold( FuelThreshold ) @@ -3264,18 +3264,18 @@ do -- AI_A2G_DISPATCHER end - --- Set the fuel treshold for the squadron when defenders will RTB or Refuel in the air. - -- The fuel treshold is by default set to 15%, which means that an aircraft will stay in the air until 15% of its fuel is remaining. + --- Set the fuel threshold for the squadron when defenders will RTB or Refuel in the air. + -- The fuel threshold is by default set to 15%, which means that an aircraft will stay in the air until 15% of its fuel is remaining. -- @param #AI_A2G_DISPATCHER self -- @param #string SquadronName The name of the squadron. - -- @param #number FuelThreshold A decimal number between 0 and 1, that expresses the % of the treshold of fuel remaining in the tank when the plane will go RTB or Refuel. + -- @param #number FuelThreshold A decimal number between 0 and 1, that expresses the % of the threshold of fuel remaining in the tank when the plane will go RTB or Refuel. -- @return #AI_A2G_DISPATCHER -- @usage -- -- -- Now Setup the A2G dispatcher, and initialize it using the Detection object. -- A2GDispatcher = AI_A2G_DISPATCHER:New( Detection ) -- - -- -- Now Setup the default fuel treshold. + -- -- Now Setup the default fuel threshold. -- A2GDispatcher:SetSquadronRefuelThreshold( "SquadronName", 0.30 ) -- Go RTB when only 30% of fuel remaining in the tank. -- function AI_A2G_DISPATCHER:SetSquadronFuelThreshold( SquadronName, FuelThreshold ) @@ -3295,7 +3295,7 @@ do -- AI_A2G_DISPATCHER -- -- Now Setup the A2G dispatcher, and initialize it using the Detection object. -- A2GDispatcher = AI_A2G_DISPATCHER:New( Detection ) -- - -- -- Now Setup the default fuel treshold. + -- -- Now Setup the default fuel threshold. -- A2GDispatcher:SetDefaultFuelThreshold( 0.30 ) -- Go RTB when only 30% of fuel remaining in the tank. -- -- -- Now Setup the default tanker. @@ -3318,7 +3318,7 @@ do -- AI_A2G_DISPATCHER -- -- Now Setup the A2G dispatcher, and initialize it using the Detection object. -- A2GDispatcher = AI_A2G_DISPATCHER:New( Detection ) -- - -- -- Now Setup the squadron fuel treshold. + -- -- Now Setup the squadron fuel threshold. -- A2GDispatcher:SetSquadronRefuelThreshold( "SquadronName", 0.30 ) -- Go RTB when only 30% of fuel remaining in the tank. -- -- -- Now Setup the squadron tanker. @@ -3421,7 +3421,7 @@ do -- AI_A2G_DISPATCHER -- @param #AI_A2G_DISPATCHER self function AI_A2G_DISPATCHER:CountDefendersEngaged( AttackerDetection, AttackerCount ) - -- First, count the active AIGroups Units, targetting the DetectedSet + -- First, count the active AIGroups Units, targeting the DetectedSet local DefendersEngaged = 0 local DefendersTotal = 0 diff --git a/Moose Development/Moose/AI/AI_A2G_SEAD.lua b/Moose Development/Moose/AI/AI_A2G_SEAD.lua index 6a0a32e3c..49d7ac16c 100644 --- a/Moose Development/Moose/AI/AI_A2G_SEAD.lua +++ b/Moose Development/Moose/AI/AI_A2G_SEAD.lua @@ -42,8 +42,8 @@ -- -- ![Process](..\Presentations\AI_GCI\Dia10.JPG) -- --- Until a fuel or damage treshold has been reached by the AI, or when the AI is commanded to RTB. --- When the fuel treshold has been reached, the airplane will fly towards the nearest friendly airbase and will land. +-- Until a fuel or damage threshold has been reached by the AI, or when the AI is commanded to RTB. +-- When the fuel threshold has been reached, the airplane will fly towards the nearest friendly airbase and will land. -- -- ![Process](..\Presentations\AI_GCI\Dia13.JPG) -- diff --git a/Moose Development/Moose/AI/AI_Air.lua b/Moose Development/Moose/AI/AI_Air.lua index 3c0724585..9d5397073 100644 --- a/Moose Development/Moose/AI/AI_Air.lua +++ b/Moose Development/Moose/AI/AI_Air.lua @@ -370,11 +370,11 @@ end --- When the AI is out of fuel, it is required that a new AI is started, before the old AI can return to the home base. --- Therefore, with a parameter and a calculation of the distance to the home base, the fuel treshold is calculated. --- When the fuel treshold is reached, the AI will continue for a given time its patrol task in orbit, while a new AIControllable is targetted to the AI_AIR. +-- Therefore, with a parameter and a calculation of the distance to the home base, the fuel threshold is calculated. +-- When the fuel threshold is reached, the AI will continue for a given time its patrol task in orbit, while a new AIControllable is targetted to the AI_AIR. -- Once the time is finished, the old AI will return to the base. -- @param #AI_AIR self --- @param #number FuelThresholdPercentage The treshold in percentage (between 0 and 1) when the AIControllable is considered to get out of fuel. +-- @param #number FuelThresholdPercentage The threshold in percentage (between 0 and 1) when the AIControllable is considered to get out of fuel. -- @param #number OutOfFuelOrbitTime The amount of seconds the out of fuel AIControllable will orbit before returning to the base. -- @return #AI_AIR self function AI_AIR:SetFuelThreshold( FuelThresholdPercentage, OutOfFuelOrbitTime ) @@ -387,14 +387,14 @@ function AI_AIR:SetFuelThreshold( FuelThresholdPercentage, OutOfFuelOrbitTime ) return self end ---- When the AI is damaged beyond a certain treshold, it is required that the AI returns to the home base. +--- When the AI is damaged beyond a certain threshold, it is required that the AI returns to the home base. -- However, damage cannot be foreseen early on. --- Therefore, when the damage treshold is reached, +-- Therefore, when the damage threshold is reached, -- the AI will return immediately to the home base (RTB). -- Note that for groups, the average damage of the complete group will be calculated. --- So, in a group of 4 airplanes, 2 lost and 2 with damage 0.2, the damage treshold will be 0.25. +-- So, in a group of 4 airplanes, 2 lost and 2 with damage 0.2, the damage threshold will be 0.25. -- @param #AI_AIR self --- @param #number PatrolDamageThreshold The treshold in percentage (between 0 and 1) when the AI is considered to be damaged. +-- @param #number PatrolDamageThreshold The threshold in percentage (between 0 and 1) when the AI is considered to be damaged. -- @return #AI_AIR self function AI_AIR:SetDamageThreshold( PatrolDamageThreshold ) @@ -476,7 +476,7 @@ function AI_AIR:onafterStatus() local Fuel = self.Controllable:GetFuelMin() - -- If the fuel in the controllable is below the treshold percentage, + -- If the fuel in the controllable is below the threshold percentage, -- then send for refuel in case of a tanker, otherwise RTB. if Fuel < self.FuelThresholdPercentage then diff --git a/Moose Development/Moose/AI/AI_Air_Dispatcher.lua b/Moose Development/Moose/AI/AI_Air_Dispatcher.lua index 7565f7a64..58e4308e4 100644 --- a/Moose Development/Moose/AI/AI_Air_Dispatcher.lua +++ b/Moose Development/Moose/AI/AI_Air_Dispatcher.lua @@ -10,11 +10,11 @@ -- * Setup (CAS) Controlled Air Support squadrons, to attack closeby enemy ground units near friendly installations. -- * Setup (BAI) Battleground Air Interdiction squadrons to attack remote enemy ground units and targets. -- * Define and use a detection network controlled by recce. --- * Define AIR defense squadrons at airbases, farps and carriers. +-- * Define AIR defense squadrons at airbases, FARPs and carriers. -- * Enable airbases for AIR defenses. -- * Add different planes and helicopter templates to squadrons. -- * Assign squadrons to execute a specific engagement type depending on threat level of the detected ground enemy unit composition. --- * Add multiple squadrons to different airbases, farps or carriers. +-- * Add multiple squadrons to different airbases, FARPs or carriers. -- * Define different ranges to engage upon. -- * Establish an automatic in air refuel process for planes using refuel tankers. -- * Setup default settings for all squadrons and AIR defenses. @@ -40,7 +40,7 @@ -- -- AI_AIR_DISPATCHER is the main AIR defense class that models the AIR defense system. -- --- Before you start using the AI_AIR_DISPATCHER, ask youself the following questions. +-- Before you start using the AI_AIR_DISPATCHER, ask yourself the following questions. -- -- -- ## 1. Which coalition am I modeling an AIR defense system for? blue or red? @@ -128,7 +128,7 @@ -- Depending on the defense type, different payloads will be needed. See further points on squadron definition. -- -- --- ## 7. Where will the Squadrons be located? On Airbases? On Carrier Ships? On Farps? +-- ## 7. Where will the Squadrons be located? On Airbases? On Carrier Ships? On FARPs? -- -- Squadrons are placed at the **home base** on an **airfield**, **carrier** or **farp**. -- Carefully plan where each Squadron will be located as part of the defense system required for mission effective defenses. @@ -354,7 +354,7 @@ do -- AI_AIR_DISPATCHER -- **DetectionSetGroup** is then calling `FilterStart()`, which is starting the dynamic filtering or inclusion of these groups. -- Note that any destroy or new spawn of a group having a name, starting with the above prefix, will be removed or added to the set. -- - -- Then a new detection object is created from the class `DETECTION_AREAS`. A grouping radius of 1000 meters (1km) is choosen. + -- Then a new detection object is created from the class `DETECTION_AREAS`. A grouping radius of 1000 meters (1km) is chosen. -- -- The `Detection` object is then passed to the @{#AI_AIR_DISPATCHER.New}() method to indicate the reconnaissance network -- configuration and setup the AIR defense detection mechanism. @@ -647,7 +647,7 @@ do -- AI_AIR_DISPATCHER -- * @{#AI_AIR_DISPATCHER.SetSquadronLandingAtRunway}() will despawn the returning aircraft directly after landing at the runway. -- * @{#AI_AIR_DISPATCHER.SetSquadronLandingAtEngineShutdown}() will despawn the returning aircraft when the aircraft has returned to its parking spot and has turned off its engines. -- - -- You can use these methods to minimize the airbase coodination overhead and to increase the airbase efficiency. + -- You can use these methods to minimize the airbase coordination overhead and to increase the airbase efficiency. -- When there are lots of aircraft returning for landing, at the same airbase, the takeoff process will be halted, which can cause a complete failure of the -- A2A defense system, as no new CAP or GCI planes can takeoff. -- Note that the method @{#AI_AIR_DISPATCHER.SetSquadronLandingNearAirbase}() will only work for returning aircraft, not for damaged or out of fuel aircraft. @@ -724,13 +724,13 @@ do -- AI_AIR_DISPATCHER -- -- Use the method @{#AI_AIR_DISPATCHER.SetSquadronEngageLimit}() to limit the amount of aircraft that will engage with the enemy, per squadron. -- - -- ## 4. Set the **fuel treshold**. + -- ## 4. Set the **fuel threshold**. -- - -- When aircraft get **out of fuel** to a certain %-tage, which is by default **15% (0.15)**, there are two possible actions that can be taken: + -- When aircraft get **out of fuel** to a certain %, which is by default **15% (0.15)**, there are two possible actions that can be taken: -- - The aircraft will go RTB, and will be replaced with a new aircraft if possible. -- - The aircraft will refuel at a tanker, if a tanker has been specified for the squadron. -- - -- Use the method @{#AI_AIR_DISPATCHER.SetSquadronFuelThreshold}() to set the **squadron fuel treshold** of the aircraft for all squadrons. + -- Use the method @{#AI_AIR_DISPATCHER.SetSquadronFuelThreshold}() to set the **squadron fuel threshold** of the aircraft for all squadrons. -- -- ## 6. Other configuration options -- @@ -786,17 +786,17 @@ do -- AI_AIR_DISPATCHER -- -- Use the method @{#AI_AIR_DISPATCHER.SetDefaultGrouping}() to set the **default grouping** of spawned airplanes for all squadrons. -- - -- ## 10.5. Default RTB fuel treshold. + -- ## 10.5. Default RTB fuel threshold. -- - -- When an airplane gets **out of fuel** to a certain %-tage, which is **15% (0.15)**, it will go RTB, and will be replaced with a new airplane when applicable. + -- When an airplane gets **out of fuel** to a certain %, which is **15% (0.15)**, it will go RTB, and will be replaced with a new airplane when applicable. -- - -- Use the method @{#AI_AIR_DISPATCHER.SetDefaultFuelThreshold}() to set the **default fuel treshold** of spawned airplanes for all squadrons. + -- Use the method @{#AI_AIR_DISPATCHER.SetDefaultFuelThreshold}() to set the **default fuel threshold** of spawned airplanes for all squadrons. -- - -- ## 10.6. Default RTB damage treshold. + -- ## 10.6. Default RTB damage threshold. -- - -- When an airplane is **damaged** to a certain %-tage, which is **40% (0.40)**, it will go RTB, and will be replaced with a new airplane when applicable. + -- When an airplane is **damaged** to a certain %, which is **40% (0.40)**, it will go RTB, and will be replaced with a new airplane when applicable. -- - -- Use the method @{#AI_AIR_DISPATCHER.SetDefaultDamageThreshold}() to set the **default damage treshold** of spawned airplanes for all squadrons. + -- Use the method @{#AI_AIR_DISPATCHER.SetDefaultDamageThreshold}() to set the **default damage threshold** of spawned airplanes for all squadrons. -- -- ## 10.7. Default settings for **patrol**. -- @@ -829,7 +829,7 @@ do -- AI_AIR_DISPATCHER -- -- In the mission editor, setup a group with task Refuelling. A tanker unit of the correct coalition will be automatically selected. -- Then, use the method @{#AI_AIR_DISPATCHER.SetDefaultTanker}() to set the tanker for the dispatcher. - -- Use the method @{#AI_AIR_DISPATCHER.SetDefaultFuelThreshold}() to set the %-tage left in the defender airplane tanks when a refuel action is needed. + -- Use the method @{#AI_AIR_DISPATCHER.SetDefaultFuelThreshold}() to set the % left in the defender airplane tanks when a refuel action is needed. -- -- When the tanker specified is alive and in the air, the tanker will be used for refuelling. -- @@ -843,7 +843,7 @@ do -- AI_AIR_DISPATCHER -- A2ADispatcher:SetSquadronCapInterval("Sochi", 2, 30, 600, 1 ) -- A2ADispatcher:SetSquadronGci( "Sochi", 900, 1200 ) -- - -- -- Set the default tanker for refuelling to "Tanker", when the default fuel treshold has reached 90% fuel left. + -- -- Set the default tanker for refuelling to "Tanker", when the default fuel threshold has reached 90% fuel left. -- A2ADispatcher:SetDefaultFuelThreshold( 0.9 ) -- A2ADispatcher:SetDefaultTanker( "Tanker" ) -- @@ -882,10 +882,7 @@ do -- AI_AIR_DISPATCHER -- As a result, the GCI and CAP will stop! -- However, the squadron will still stay alive. Any airplane that is airborne will continue its operations until all airborne airplanes -- of the squadron will be destroyed. This to keep consistency of air operations not to confuse the players. - -- - -- - -- - -- + -- -- @field #AI_AIR_DISPATCHER AI_AIR_DISPATCHER = { ClassName = "AI_AIR_DISPATCHER", @@ -914,10 +911,10 @@ do -- AI_AIR_DISPATCHER --- Enumerator for spawns at airbases -- @type AI_AIR_DISPATCHER.Takeoff -- @extends Wrapper.Group#GROUP.Takeoff - + --- @field #AI_AIR_DISPATCHER.Takeoff Takeoff AI_AIR_DISPATCHER.Takeoff = GROUP.Takeoff - + --- Defnes Landing location. -- @field #AI_AIR_DISPATCHER.Landing AI_AIR_DISPATCHER.Landing = { @@ -925,7 +922,7 @@ do -- AI_AIR_DISPATCHER AtRunway = 2, AtEngineShutdown = 3, } - + --- A defense queue item description -- @type AI_AIR_DISPATCHER.DefenseQueueItem -- @field Squadron @@ -936,7 +933,7 @@ do -- AI_AIR_DISPATCHER -- @field Functional.Detection#DETECTION_BASE AttackerDetection -- @field DefenderGrouping -- @field #string SquadronName The name of the squadron. - + --- Queue of planned defenses to be launched. -- This queue exists because defenses must be launched on FARPS, or in the air, or on an airbase, or on carriers. -- And some of these platforms have very limited amount of "launching" platforms. @@ -945,40 +942,39 @@ do -- AI_AIR_DISPATCHER -- This guarantees that launched defenders are also directly existing ... -- @type AI_AIR_DISPATCHER.DefenseQueue -- @list<#AI_AIR_DISPATCHER.DefenseQueueItem> DefenseQueueItem A list of all defenses being queued ... - + --- @field #AI_AIR_DISPATCHER.DefenseQueue DefenseQueue AI_AIR_DISPATCHER.DefenseQueue = {} - - + --- Defense approach types -- @type #AI_AIR_DISPATCHER.DefenseApproach AI_AIR_DISPATCHER.DefenseApproach = { Random = 1, Distance = 2, } - + --- AI_AIR_DISPATCHER constructor. - -- This is defining the AIR DISPATCHER for one coaliton. + -- This is defining the AIR DISPATCHER for one coalition. -- The Dispatcher works with a @{Functional.Detection#DETECTION_BASE} object that is taking of the detection of targets using the EWR units. - -- The Detection object is polymorphic, depending on the type of detection object choosen, the detection will work differently. + -- The Detection object is polymorphic, depending on the type of detection object chosen, the detection will work differently. -- @param #AI_AIR_DISPATCHER self -- @param Functional.Detection#DETECTION_BASE Detection The DETECTION object that will detects targets using the the Early Warning Radar network. -- @return #AI_AIR_DISPATCHER self -- @usage - -- - -- -- Setup the Detection, using DETECTION_AREAS. - -- -- First define the SET of GROUPs that are defining the EWR network. - -- -- Here with prefixes DF CCCP AWACS, DF CCCP EWR. - -- DetectionSetGroup = SET_GROUP:New() - -- DetectionSetGroup:FilterPrefixes( { "DF CCCP AWACS", "DF CCCP EWR" } ) - -- DetectionSetGroup:FilterStart() - -- - -- -- Define the DETECTION_AREAS, using the DetectionSetGroup, with a 30km grouping radius. - -- Detection = DETECTION_AREAS:New( DetectionSetGroup, 30000 ) - -- - -- -- Now Setup the AIR dispatcher, and initialize it using the Detection object. - -- AIRDispatcher = AI_AIR_DISPATCHER:New( Detection ) -- - -- + -- + -- -- Setup the Detection, using DETECTION_AREAS. + -- -- First define the SET of GROUPs that are defining the EWR network. + -- -- Here with prefixes DF CCCP AWACS, DF CCCP EWR. + -- DetectionSetGroup = SET_GROUP:New() + -- DetectionSetGroup:FilterPrefixes( { "DF CCCP AWACS", "DF CCCP EWR" } ) + -- DetectionSetGroup:FilterStart() + -- + -- -- Define the DETECTION_AREAS, using the DetectionSetGroup, with a 30km grouping radius. + -- Detection = DETECTION_AREAS:New( DetectionSetGroup, 30000 ) + -- + -- -- Now Setup the AIR dispatcher, and initialize it using the Detection object. + -- AIRDispatcher = AI_AIR_DISPATCHER:New( Detection ) + -- function AI_AIR_DISPATCHER:New( Detection ) -- Inherits from DETECTION_MANAGER @@ -1435,17 +1431,17 @@ do -- AI_AIR_DISPATCHER end - --- Set the default damage treshold when defenders will RTB. - -- The default damage treshold is by default set to 40%, which means that when the airplane is 40% damaged, it will go RTB. + --- Set the default damage threshold when defenders will RTB. + -- The default damage threshold is by default set to 40%, which means that when the airplane is 40% damaged, it will go RTB. -- @param #AI_AIR_DISPATCHER self - -- @param #number DamageThreshold A decimal number between 0 and 1, that expresses the %-tage of the damage treshold before going RTB. + -- @param #number DamageThreshold A decimal number between 0 and 1, that expresses the % of the damage threshold before going RTB. -- @return #AI_AIR_DISPATCHER -- @usage -- -- -- Now Setup the AIR dispatcher, and initialize it using the Detection object. -- AIRDispatcher = AI_AIR_DISPATCHER:New( Detection ) -- - -- -- Now Setup the default damage treshold. + -- -- Now Setup the default damage threshold. -- AIRDispatcher:SetDefaultDamageThreshold( 0.90 ) -- Go RTB when the airplane 90% damaged. -- function AI_AIR_DISPATCHER:SetDefaultDamageThreshold( DamageThreshold ) @@ -1989,7 +1985,7 @@ do -- AI_AIR_DISPATCHER --- Defines the default amount of extra planes that will take-off as part of the defense system. -- @param #AI_AIR_DISPATCHER self - -- @param #number Overhead The %-tage of Units that dispatching command will allocate to intercept in surplus of detected amount of units. + -- @param #number Overhead The % of Units that dispatching command will allocate to intercept in surplus of detected amount of units. -- The default overhead is 1, so equal balance. The @{#AI_AIR_DISPATCHER.SetOverhead}() method can be used to tweak the defense strength, -- taking into account the plane types of the squadron. For example, a MIG-31 with full long-distance AIR missiles payload, may still be less effective than a F-15C with short missiles... -- So in this case, one may want to use the Overhead method to allocate more defending planes as the amount of detected attacking planes. @@ -2028,7 +2024,7 @@ do -- AI_AIR_DISPATCHER --- Defines the amount of extra planes that will take-off as part of the defense system. -- @param #AI_AIR_DISPATCHER self -- @param #string SquadronName The name of the squadron. - -- @param #number Overhead The %-tage of Units that dispatching command will allocate to intercept in surplus of detected amount of units. + -- @param #number Overhead The % of Units that dispatching command will allocate to intercept in surplus of detected amount of units. -- The default overhead is 1, so equal balance. The @{#AI_AIR_DISPATCHER.SetOverhead}() method can be used to tweak the defense strength, -- taking into account the plane types of the squadron. For example, a MIG-31 with full long-distance AIR missiles payload, may still be less effective than a F-15C with short missiles... -- So in this case, one may want to use the Overhead method to allocate more defending planes as the amount of detected attacking planes. @@ -2068,7 +2064,7 @@ do -- AI_AIR_DISPATCHER --- Gets the overhead of planes as part of the defense system, in comparison with the attackers. -- @param #AI_AIR_DISPATCHER self -- @param #string SquadronName The name of the squadron. - -- @return #number The %-tage of Units that dispatching command will allocate to intercept in surplus of detected amount of units. + -- @return #number The % of Units that dispatching command will allocate to intercept in surplus of detected amount of units. -- The default overhead is 1, so equal balance. The @{#AI_AIR_DISPATCHER.SetOverhead}() method can be used to tweak the defense strength, -- taking into account the plane types of the squadron. For example, a MIG-31 with full long-distance AIR missiles payload, may still be less effective than a F-15C with short missiles... -- So in this case, one may want to use the Overhead method to allocate more defending planes as the amount of detected attacking planes. @@ -2674,17 +2670,17 @@ do -- AI_AIR_DISPATCHER return self end - --- Set the default fuel treshold when defenders will RTB or Refuel in the air. - -- The fuel treshold is by default set to 15%, which means that an airplane will stay in the air until 15% of its fuel has been consumed. + --- Set the default fuel threshold when defenders will RTB or Refuel in the air. + -- The fuel threshold is by default set to 15%, which means that an airplane will stay in the air until 15% of its fuel has been consumed. -- @param #AI_AIR_DISPATCHER self - -- @param #number FuelThreshold A decimal number between 0 and 1, that expresses the %-tage of the treshold of fuel remaining in the tank when the plane will go RTB or Refuel. + -- @param #number FuelThreshold A decimal number between 0 and 1, that expresses the % of the threshold of fuel remaining in the tank when the plane will go RTB or Refuel. -- @return #AI_AIR_DISPATCHER -- @usage -- -- -- Now Setup the AIR dispatcher, and initialize it using the Detection object. -- AIRDispatcher = AI_AIR_DISPATCHER:New( Detection ) -- - -- -- Now Setup the default fuel treshold. + -- -- Now Setup the default fuel threshold. -- AIRDispatcher:SetDefaultFuelThreshold( 0.30 ) -- Go RTB when only 30% of fuel remaining in the tank. -- function AI_AIR_DISPATCHER:SetDefaultFuelThreshold( FuelThreshold ) @@ -2695,18 +2691,18 @@ do -- AI_AIR_DISPATCHER end - --- Set the fuel treshold for the squadron when defenders will RTB or Refuel in the air. - -- The fuel treshold is by default set to 15%, which means that an airplane will stay in the air until 15% of its fuel has been consumed. + --- Set the fuel threshold for the squadron when defenders will RTB or Refuel in the air. + -- The fuel threshold is by default set to 15%, which means that an airplane will stay in the air until 15% of its fuel has been consumed. -- @param #AI_AIR_DISPATCHER self -- @param #string SquadronName The name of the squadron. - -- @param #number FuelThreshold A decimal number between 0 and 1, that expresses the %-tage of the treshold of fuel remaining in the tank when the plane will go RTB or Refuel. + -- @param #number FuelThreshold A decimal number between 0 and 1, that expresses the % of the threshold of fuel remaining in the tank when the plane will go RTB or Refuel. -- @return #AI_AIR_DISPATCHER -- @usage -- -- -- Now Setup the AIR dispatcher, and initialize it using the Detection object. -- AIRDispatcher = AI_AIR_DISPATCHER:New( Detection ) -- - -- -- Now Setup the default fuel treshold. + -- -- Now Setup the default fuel threshold. -- AIRDispatcher:SetSquadronRefuelThreshold( "SquadronName", 0.30 ) -- Go RTB when only 30% of fuel remaining in the tank. -- function AI_AIR_DISPATCHER:SetSquadronFuelThreshold( SquadronName, FuelThreshold ) @@ -2726,7 +2722,7 @@ do -- AI_AIR_DISPATCHER -- -- Now Setup the AIR dispatcher, and initialize it using the Detection object. -- AIRDispatcher = AI_AIR_DISPATCHER:New( Detection ) -- - -- -- Now Setup the default fuel treshold. + -- -- Now Setup the default fuel threshold. -- AIRDispatcher:SetDefaultFuelThreshold( 0.30 ) -- Go RTB when only 30% of fuel remaining in the tank. -- -- -- Now Setup the default tanker. @@ -2749,7 +2745,7 @@ do -- AI_AIR_DISPATCHER -- -- Now Setup the AIR dispatcher, and initialize it using the Detection object. -- AIRDispatcher = AI_AIR_DISPATCHER:New( Detection ) -- - -- -- Now Setup the squadron fuel treshold. + -- -- Now Setup the squadron fuel threshold. -- AIRDispatcher:SetSquadronRefuelThreshold( "SquadronName", 0.30 ) -- Go RTB when only 30% of fuel remaining in the tank. -- -- -- Now Setup the squadron tanker. @@ -2847,7 +2843,7 @@ do -- AI_AIR_DISPATCHER -- @param #AI_AIR_DISPATCHER self function AI_AIR_DISPATCHER:CountDefendersEngaged( AttackerDetection, AttackerCount ) - -- First, count the active AIGroups Units, targetting the DetectedSet + -- First, count the active AIGroups Units, targeting the DetectedSet local DefendersEngaged = 0 local DefendersTotal = 0 diff --git a/Moose Development/Moose/AI/AI_Air_Engage.lua b/Moose Development/Moose/AI/AI_Air_Engage.lua index c9f6bc562..a80402a2f 100644 --- a/Moose Development/Moose/AI/AI_Air_Engage.lua +++ b/Moose Development/Moose/AI/AI_Air_Engage.lua @@ -42,8 +42,8 @@ -- -- ![Process](..\Presentations\AI_GCI\Dia10.JPG) -- --- Until a fuel or damage treshold has been reached by the AI, or when the AI is commanded to RTB. --- When the fuel treshold has been reached, the airplane will fly towards the nearest friendly airbase and will land. +-- Until a fuel or damage threshold has been reached by the AI, or when the AI is commanded to RTB. +-- When the fuel threshold has been reached, the airplane will fly towards the nearest friendly airbase and will land. -- -- ![Process](..\Presentations\AI_GCI\Dia13.JPG) -- diff --git a/Moose Development/Moose/AI/AI_Air_Patrol.lua b/Moose Development/Moose/AI/AI_Air_Patrol.lua index 32bd99cea..185e64572 100644 --- a/Moose Development/Moose/AI/AI_Air_Patrol.lua +++ b/Moose Development/Moose/AI/AI_Air_Patrol.lua @@ -39,8 +39,8 @@ -- -- ![Process](..\Presentations\AI_CAP\Dia10.JPG) -- --- Until a fuel or damage treshold has been reached by the AI, or when the AI is commanded to RTB. --- When the fuel treshold has been reached, the airplane will fly towards the nearest friendly airbase and will land. +-- Until a fuel or damage threshold has been reached by the AI, or when the AI is commanded to RTB. +-- When the fuel threshold has been reached, the airplane will fly towards the nearest friendly airbase and will land. -- -- ![Process](..\Presentations\AI_CAP\Dia13.JPG) -- @@ -70,7 +70,7 @@ -- * **@{AI.AI_Patrol#AI_PATROL_ZONE.Detected}**: The AI has detected new targets. -- * **@{#AI_AIR_PATROL.Destroy}**: The AI has destroyed a bogey @{Wrapper.Unit}. -- * **@{#AI_AIR_PATROL.Destroyed}**: The AI has destroyed all bogeys @{Wrapper.Unit}s assigned in the CAS task. --- * **Status** ( Group ): The AI is checking status (fuel and damage). When the tresholds have been reached, the AI will RTB. +-- * **Status** ( Group ): The AI is checking status (fuel and damage). When the thresholds have been reached, the AI will RTB. -- -- ## 3. Set the Range of Engagement -- diff --git a/Moose Development/Moose/AI/AI_BAI.lua b/Moose Development/Moose/AI/AI_BAI.lua index 42bccbf06..b71afd048 100644 --- a/Moose Development/Moose/AI/AI_BAI.lua +++ b/Moose Development/Moose/AI/AI_BAI.lua @@ -49,7 +49,7 @@ -- Upon started, The AI will **Route** itself towards the random 3D point within a patrol zone, -- using a random speed within the given altitude and speed limits. -- Upon arrival at the 3D point, a new random 3D point will be selected within the patrol zone using the given limits. --- This cycle will continue until a fuel or damage treshold has been reached by the AI, or when the AI is commanded to RTB. +-- This cycle will continue until a fuel or damage threshold has been reached by the AI, or when the AI is commanded to RTB. -- -- ![Route Event](..\Presentations\AI_BAI\Dia5.JPG) -- @@ -87,7 +87,7 @@ -- It will keep patrolling there, until it is notified to RTB or move to another BOMB Zone. -- It can be notified to go RTB through the **RTB** event. -- --- When the fuel treshold has been reached, the airplane will fly towards the nearest friendly airbase and will land. +-- When the fuel threshold has been reached, the airplane will fly towards the nearest friendly airbase and will land. -- -- ![Engage Event](..\Presentations\AI_BAI\Dia12.JPG) -- @@ -117,7 +117,7 @@ -- * **@{AI.AI_Patrol#AI_PATROL_ZONE.Detected}**: The AI has detected new targets. -- * **@{#AI_BAI_ZONE.Destroy}**: The AI has destroyed a target @{Wrapper.Unit}. -- * **@{#AI_BAI_ZONE.Destroyed}**: The AI has destroyed all target @{Wrapper.Unit}s assigned in the BOMB task. --- * **Status**: The AI is checking status (fuel and damage). When the tresholds have been reached, the AI will RTB. +-- * **Status**: The AI is checking status (fuel and damage). When the thresholds have been reached, the AI will RTB. -- -- ## 3. Modify the Engage Zone behaviour to pinpoint a **map object** or **scenery object** -- @@ -602,7 +602,7 @@ function AI_BAI_ZONE:onafterEngage( Controllable, From, Event, To, self:SetRefreshTimeInterval( 2 ) self:SetDetectionActivated() - self:__Target( -2 ) -- Start Targetting + self:__Target( -2 ) -- Start targeting end end diff --git a/Moose Development/Moose/AI/AI_CAP.lua b/Moose Development/Moose/AI/AI_CAP.lua index 5366db4b4..611a27b54 100644 --- a/Moose Development/Moose/AI/AI_CAP.lua +++ b/Moose Development/Moose/AI/AI_CAP.lua @@ -4,7 +4,7 @@ -- -- * Patrol AI airplanes within a given zone. -- * Trigger detected events when enemy airplanes are detected. --- * Manage a fuel treshold to RTB on time. +-- * Manage a fuel threshold to RTB on time. -- * Engage the enemy when detected. -- -- @@ -65,8 +65,8 @@ -- -- ![Process](..\Presentations\AI_CAP\Dia10.JPG) -- --- Until a fuel or damage treshold has been reached by the AI, or when the AI is commanded to RTB. --- When the fuel treshold has been reached, the airplane will fly towards the nearest friendly airbase and will land. +-- Until a fuel or damage threshold has been reached by the AI, or when the AI is commanded to RTB. +-- When the fuel threshold has been reached, the airplane will fly towards the nearest friendly airbase and will land. -- -- ![Process](..\Presentations\AI_CAP\Dia13.JPG) -- @@ -96,7 +96,7 @@ -- * **@{AI.AI_Patrol#AI_PATROL_ZONE.Detected}**: The AI has detected new targets. -- * **@{#AI_CAP_ZONE.Destroy}**: The AI has destroyed a bogey @{Wrapper.Unit}. -- * **@{#AI_CAP_ZONE.Destroyed}**: The AI has destroyed all bogeys @{Wrapper.Unit}s assigned in the CAS task. --- * **Status** ( Group ): The AI is checking status (fuel and damage). When the tresholds have been reached, the AI will RTB. +-- * **Status** ( Group ): The AI is checking status (fuel and damage). When the thresholds have been reached, the AI will RTB. -- -- ## 3. Set the Range of Engagement -- diff --git a/Moose Development/Moose/AI/AI_CAS.lua b/Moose Development/Moose/AI/AI_CAS.lua index 33e07849d..d8879f409 100644 --- a/Moose Development/Moose/AI/AI_CAS.lua +++ b/Moose Development/Moose/AI/AI_CAS.lua @@ -49,7 +49,7 @@ -- Upon started, The AI will **Route** itself towards the random 3D point within a patrol zone, -- using a random speed within the given altitude and speed limits. -- Upon arrival at the 3D point, a new random 3D point will be selected within the patrol zone using the given limits. --- This cycle will continue until a fuel or damage treshold has been reached by the AI, or when the AI is commanded to RTB. +-- This cycle will continue until a fuel or damage threshold has been reached by the AI, or when the AI is commanded to RTB. -- -- ![Route Event](..\Presentations\AI_CAS\Dia5.JPG) -- @@ -87,7 +87,7 @@ -- It will keep patrolling there, until it is notified to RTB or move to another CAS Zone. -- It can be notified to go RTB through the **RTB** event. -- --- When the fuel treshold has been reached, the airplane will fly towards the nearest friendly airbase and will land. +-- When the fuel threshold has been reached, the airplane will fly towards the nearest friendly airbase and will land. -- -- ![Engage Event](..\Presentations\AI_CAS\Dia12.JPG) -- @@ -117,7 +117,7 @@ -- * **@{AI.AI_Patrol#AI_PATROL_ZONE.Detected}**: The AI has detected new targets. -- * **@{#AI_CAS_ZONE.Destroy}**: The AI has destroyed a target @{Wrapper.Unit}. -- * **@{#AI_CAS_ZONE.Destroyed}**: The AI has destroyed all target @{Wrapper.Unit}s assigned in the CAS task. --- * **Status**: The AI is checking status (fuel and damage). When the tresholds have been reached, the AI will RTB. +-- * **Status**: The AI is checking status (fuel and damage). When the thresholds have been reached, the AI will RTB. -- -- === -- @@ -520,7 +520,7 @@ function AI_CAS_ZONE:onafterEngage( Controllable, From, Event, To, self:SetRefreshTimeInterval( 2 ) self:SetDetectionActivated() - self:__Target( -2 ) -- Start Targetting + self:__Target( -2 ) -- Start targeting end end diff --git a/Moose Development/Moose/AI/AI_Patrol.lua b/Moose Development/Moose/AI/AI_Patrol.lua index 767dc4400..a20f02ee4 100644 --- a/Moose Development/Moose/AI/AI_Patrol.lua +++ b/Moose Development/Moose/AI/AI_Patrol.lua @@ -4,7 +4,7 @@ -- -- * Patrol AI airplanes within a given zone. -- * Trigger detected events when enemy airplanes are detected. --- * Manage a fuel treshold to RTB on time. +-- * Manage a fuel threshold to RTB on time. -- -- === -- @@ -72,8 +72,8 @@ -- -- ![Process](..\Presentations\AI_PATROL\Dia10.JPG) -- --- Until a fuel or damage treshold has been reached by the AI, or when the AI is commanded to RTB. --- When the fuel treshold has been reached, the airplane will fly towards the nearest friendly airbase and will land. +-- Until a fuel or damage threshold has been reached by the AI, or when the AI is commanded to RTB. +-- When the fuel threshold has been reached, the airplane will fly towards the nearest friendly airbase and will land. -- -- ![Process](..\Presentations\AI_PATROL\Dia11.JPG) -- @@ -101,7 +101,7 @@ -- * **RTB** ( Group ): Route the AI to the home base. -- * **Detect** ( Group ): The AI is detecting targets. -- * **Detected** ( Group ): The AI has detected new targets. --- * **Status** ( Group ): The AI is checking status (fuel and damage). When the tresholds have been reached, the AI will RTB. +-- * **Status** ( Group ): The AI is checking status (fuel and damage). When the thresholds have been reached, the AI will RTB. -- -- ## 3. Set or Get the AI controllable -- @@ -133,8 +133,8 @@ -- ## 6. Manage the "out of fuel" in the AI_PATROL_ZONE -- -- When the AI is out of fuel, it is required that a new AI is started, before the old AI can return to the home base. --- Therefore, with a parameter and a calculation of the distance to the home base, the fuel treshold is calculated. --- When the fuel treshold is reached, the AI will continue for a given time its patrol task in orbit, +-- Therefore, with a parameter and a calculation of the distance to the home base, the fuel threshold is calculated. +-- When the fuel threshold is reached, the AI will continue for a given time its patrol task in orbit, -- while a new AI is targetted to the AI_PATROL_ZONE. -- Once the time is finished, the old AI will return to the base. -- Use the method @{#AI_PATROL_ZONE.ManageFuel}() to have this proces in place. @@ -142,7 +142,7 @@ -- ## 7. Manage "damage" behaviour of the AI in the AI_PATROL_ZONE -- -- When the AI is damaged, it is required that a new AIControllable is started. However, damage cannon be foreseen early on. --- Therefore, when the damage treshold is reached, the AI will return immediately to the home base (RTB). +-- Therefore, when the damage threshold is reached, the AI will return immediately to the home base (RTB). -- Use the method @{#AI_PATROL_ZONE.ManageDamage}() to have this proces in place. -- -- === @@ -581,11 +581,11 @@ function AI_PATROL_ZONE:ClearDetectedUnits() end --- When the AI is out of fuel, it is required that a new AI is started, before the old AI can return to the home base. --- Therefore, with a parameter and a calculation of the distance to the home base, the fuel treshold is calculated. --- When the fuel treshold is reached, the AI will continue for a given time its patrol task in orbit, while a new AIControllable is targetted to the AI_PATROL_ZONE. +-- Therefore, with a parameter and a calculation of the distance to the home base, the fuel threshold is calculated. +-- When the fuel threshold is reached, the AI will continue for a given time its patrol task in orbit, while a new AIControllable is targetted to the AI_PATROL_ZONE. -- Once the time is finished, the old AI will return to the base. -- @param #AI_PATROL_ZONE self --- @param #number PatrolFuelThresholdPercentage The treshold in percentage (between 0 and 1) when the AIControllable is considered to get out of fuel. +-- @param #number PatrolFuelThresholdPercentage The threshold in percentage (between 0 and 1) when the AIControllable is considered to get out of fuel. -- @param #number PatrolOutOfFuelOrbitTime The amount of seconds the out of fuel AIControllable will orbit before returning to the base. -- @return #AI_PATROL_ZONE self function AI_PATROL_ZONE:ManageFuel( PatrolFuelThresholdPercentage, PatrolOutOfFuelOrbitTime ) @@ -596,14 +596,14 @@ function AI_PATROL_ZONE:ManageFuel( PatrolFuelThresholdPercentage, PatrolOutOfFu return self end ---- When the AI is damaged beyond a certain treshold, it is required that the AI returns to the home base. +--- When the AI is damaged beyond a certain threshold, it is required that the AI returns to the home base. -- However, damage cannot be foreseen early on. --- Therefore, when the damage treshold is reached, +-- Therefore, when the damage threshold is reached, -- the AI will return immediately to the home base (RTB). -- Note that for groups, the average damage of the complete group will be calculated. --- So, in a group of 4 airplanes, 2 lost and 2 with damage 0.2, the damage treshold will be 0.25. +-- So, in a group of 4 airplanes, 2 lost and 2 with damage 0.2, the damage threshold will be 0.25. -- @param #AI_PATROL_ZONE self --- @param #number PatrolDamageThreshold The treshold in percentage (between 0 and 1) when the AI is considered to be damaged. +-- @param #number PatrolDamageThreshold The threshold in percentage (between 0 and 1) when the AI is considered to be damaged. -- @return #AI_PATROL_ZONE self function AI_PATROL_ZONE:ManageDamage( PatrolDamageThreshold ) diff --git a/Moose Development/Moose/Cargo/Cargo.lua b/Moose Development/Moose/Cargo/Cargo.lua index df796aed1..c17c4affb 100644 --- a/Moose Development/Moose/Cargo/Cargo.lua +++ b/Moose Development/Moose/Cargo/Cargo.lua @@ -194,7 +194,7 @@ -- * is of type `Workmaterials` -- * will report when a carrier is within 500 meters -- * will board to carriers when the carrier is within 500 meters from the cargo object --- * will dissapear when the cargo is within 25 meters from the carrier during boarding +-- * will disappear when the cargo is within 25 meters from the carrier during boarding -- -- So the overall syntax of the #CARGO naming tag and arguments are: -- @@ -220,7 +220,7 @@ -- * is of type `Workmaterials` -- * will report when a carrier is within 500 meters -- * will board to carriers when the carrier is within 500 meters from the cargo object --- * will dissapear when the cargo is within 25 meters from the carrier during boarding +-- * will disappear when the cargo is within 25 meters from the carrier during boarding -- -- So the overall syntax of the #CARGO naming tag and arguments are: -- diff --git a/Moose Development/Moose/Core/Database.lua b/Moose Development/Moose/Core/Database.lua index 02a2d8b57..c5f19f1ef 100644 --- a/Moose Development/Moose/Core/Database.lua +++ b/Moose Development/Moose/Core/Database.lua @@ -903,7 +903,7 @@ function DATABASE:_RegisterPlayers() return self end ---- Private method that registers all Groups and Units within in the mission. +--- Private method that registers all Groups and Units within the mission. -- @param #DATABASE self -- @return #DATABASE self function DATABASE:_RegisterGroupsAndUnits() @@ -944,7 +944,7 @@ function DATABASE:_RegisterGroupsAndUnits() return self end ---- Private method that registers all Units of skill Client or Player within in the mission. +--- Private method that registers all Units of skill Client or Player within the mission. -- @param #DATABASE self -- @return #DATABASE self function DATABASE:_RegisterClients() @@ -957,7 +957,8 @@ function DATABASE:_RegisterClients() return self end ---- @param #DATABASE self +--- Private method that registers all Statics within the mission. +-- @param #DATABASE self function DATABASE:_RegisterStatics() local CoalitionsData = { GroupsRed = coalition.getStaticObjects( coalition.side.RED ), GroupsBlue = coalition.getStaticObjects( coalition.side.BLUE ), GroupsNeutral = coalition.getStaticObjects( coalition.side.NEUTRAL ) } diff --git a/Moose Development/Moose/Core/Event.lua b/Moose Development/Moose/Core/Event.lua index ea8b7575a..500e1871a 100644 --- a/Moose Development/Moose/Core/Event.lua +++ b/Moose Development/Moose/Core/Event.lua @@ -32,11 +32,11 @@ -- -- ![Objects](..\Presentations\EVENT\Dia5.JPG) -- --- There are 5 levels of kind of objects that the _EVENTDISPATCHER services: +-- There are 5 types/levels of objects that the _EVENTDISPATCHER services: -- -- * _DATABASE object: The core of the MOOSE objects. Any object that is created, deleted or updated, is done in this database. --- * SET_ derived classes: Subsets of the _DATABASE object. These subsets are updated by the _EVENTDISPATCHER as the second priority. --- * UNIT objects: UNIT objects can subscribe to DCS events. Each DCS event will be directly published to teh subscribed UNIT object. +-- * SET_ derived classes: These are subsets of the _DATABASE object. These subsets are updated by the _EVENTDISPATCHER as the second priority. +-- * UNIT objects: UNIT objects can subscribe to DCS events. Each DCS event will be directly published to the subscribed UNIT object. -- * GROUP objects: GROUP objects can subscribe to DCS events. Each DCS event will be directly published to the subscribed GROUP object. -- * Any other object: Various other objects can subscribe to DCS events. Each DCS event triggered will be published to each subscribed object. -- @@ -131,6 +131,8 @@ -- * Weapon data: Certain events populate weapon information. -- * Place data: Certain events populate place information. -- +-- Example code snippet: +-- -- --- This function is an Event Handling function that will be called when Tank1 is Dead. -- -- EventData is an EVENTDATA structure. -- -- We use the EventData.IniUnit to smoke the tank Green. @@ -150,6 +152,7 @@ -- In case a STATIC object is involved, the documentation indicates which fields will and won't not be populated. -- The fields **IniObjectCategory** and **TgtObjectCategory** contain the indicator which **kind of object is involved** in the event. -- You can use the enumerator **Object.Category.UNIT** and **Object.Category.STATIC** to check on IniObjectCategory and TgtObjectCategory. +-- -- Example code snippet: -- -- if Event.IniObjectCategory == Object.Category.UNIT then diff --git a/Moose Development/Moose/Core/Fsm.lua b/Moose Development/Moose/Core/Fsm.lua index e34e39eac..cca8c509b 100644 --- a/Moose Development/Moose/Core/Fsm.lua +++ b/Moose Development/Moose/Core/Fsm.lua @@ -18,11 +18,11 @@ -- -- A Finite State Machine (FSM) models a process flow that transitions between various **States** through triggered **Events**. -- --- A FSM can only be in one of a finite number of states. +-- A FSM can only be in one of a finite number of states. -- The machine is in only one state at a time; the state it is in at any given time is called the **current state**. -- It can change from one state to another when initiated by an **__internal__ or __external__ triggering event**, which is called a **transition**. --- An **FSM implementation** is defined by **a list of its states**, **its initial state**, and **the triggering events** for **each possible transition**. --- An FSM implementation is composed out of **two parts**, a set of **state transition rules**, and an implementation set of **state transition handlers**, implementing those transitions. +-- A **FSM implementation** is defined by **a list of its states**, **its initial state**, and **the triggering events** for **each possible transition**. +-- A FSM implementation is composed out of **two parts**, a set of **state transition rules**, and an implementation set of **state transition handlers**, implementing those transitions. -- -- The FSM class supports a **hierarchical implementation of a Finite State Machine**, -- that is, it allows to **embed existing FSM implementations in a master FSM**. @@ -34,21 +34,21 @@ -- orders him to destroy x targets and account the results. -- Other examples of ready made FSM could be: -- --- * route a plane to a zone flown by a human --- * detect targets by an AI and report to humans --- * account for destroyed targets by human players --- * handle AI infantry to deploy from or embark to a helicopter or airplane or vehicle --- * let an AI patrol a zone +-- * Route a plane to a zone flown by a human. +-- * Detect targets by an AI and report to humans. +-- * Account for destroyed targets by human players. +-- * Handle AI infantry to deploy from or embark to a helicopter or airplane or vehicle. +-- * Let an AI patrol a zone. -- --- The **MOOSE framework** uses extensively the FSM class and derived FSM\_ classes, +-- The **MOOSE framework** extensively uses the FSM class and derived FSM\_ classes, -- because **the goal of MOOSE is to simplify mission design complexity for mission building**. -- By efficiently utilizing the FSM class and derived classes, MOOSE allows mission designers to quickly build processes. -- **Ready made FSM-based implementations classes** exist within the MOOSE framework that **can easily be re-used, -- and tailored** by mission designers through **the implementation of Transition Handlers**. -- Each of these FSM implementation classes start either with: -- --- * an acronym **AI\_**, which indicates an FSM implementation directing **AI controlled** @{GROUP} and/or @{UNIT}. These AI\_ classes derive the @{#FSM_CONTROLLABLE} class. --- * an acronym **TASK\_**, which indicates an FSM implementation executing a @{TASK} executed by Groups of players. These TASK\_ classes derive the @{#FSM_TASK} class. +-- * an acronym **AI\_**, which indicates a FSM implementation directing **AI controlled** @{GROUP} and/or @{UNIT}. These AI\_ classes derive the @{#FSM_CONTROLLABLE} class. +-- * an acronym **TASK\_**, which indicates a FSM implementation executing a @{TASK} executed by Groups of players. These TASK\_ classes derive the @{#FSM_TASK} class. -- * an acronym **ACT\_**, which indicates an Sub-FSM implementation, directing **Humans actions** that need to be done in a @{TASK}, seated in a @{CLIENT} (slot) or a @{UNIT} (CA join). These ACT\_ classes derive the @{#FSM_PROCESS} class. -- -- Detailed explanations and API specifics are further below clarified and FSM derived class specifics are described in those class documentation sections. @@ -59,7 +59,7 @@ -- I've reworked this development (taken the concept), and created a **hierarchical state machine** out of it, embedded within the DCS simulator. -- Additionally, I've added extendability and created an API that allows seamless FSM implementation. -- --- The following derived classes are available in the MOOSE framework, that implement a specialised form of a FSM: +-- The following derived classes are available in the MOOSE framework, that implement a specialized form of a FSM: -- -- * @{#FSM_TASK}: Models Finite State Machines for @{Task}s. -- * @{#FSM_PROCESS}: Models Finite State Machines for @{Task} actions, which control @{Client}s. diff --git a/Moose Development/Moose/Core/Menu.lua b/Moose Development/Moose/Core/Menu.lua index bd64eb773..b3d6ab618 100644 --- a/Moose Development/Moose/Core/Menu.lua +++ b/Moose Development/Moose/Core/Menu.lua @@ -778,7 +778,7 @@ end do -- This local variable is used to cache the menus registered under groups. - -- Menus don't dissapear when groups for players are destroyed and restarted. + -- Menus don't disappear when groups for players are destroyed and restarted. -- So every menu for a client created must be tracked so that program logic accidentally does not create. -- the same menus twice during initialization logic. -- These menu classes are handling this logic with this variable. diff --git a/Moose Development/Moose/Core/Spawn.lua b/Moose Development/Moose/Core/Spawn.lua index a067cc680..fc0749415 100644 --- a/Moose Development/Moose/Core/Spawn.lua +++ b/Moose Development/Moose/Core/Spawn.lua @@ -1373,7 +1373,7 @@ function SPAWN:SpawnWithIndex( SpawnIndex, NoBirth ) SpawnTemplate.modulation = self.SpawnInitModu end - -- Set country, coaliton and categroy. + -- Set country, coalition and category. SpawnTemplate.CategoryID = self.SpawnInitCategory or SpawnTemplate.CategoryID SpawnTemplate.CountryID = self.SpawnInitCountry or SpawnTemplate.CountryID SpawnTemplate.CoalitionID = self.SpawnInitCoalition or SpawnTemplate.CoalitionID @@ -2360,7 +2360,7 @@ end -- The known AIRBASE objects are automatically imported at mission start by MOOSE. -- Therefore, there isn't any New() constructor defined for AIRBASE objects. -- --- Ships and Farps are added within the mission, and are therefore not known. +-- Ships and FARPs are added within the mission, and are therefore not known. -- For these AIRBASE objects, there isn't an @{Wrapper.Airbase#AIRBASE} enumeration defined. -- You need to provide the **exact name** of the airbase as the parameter to the @{Wrapper.Airbase#AIRBASE.FindByName}() method! -- diff --git a/Moose Development/Moose/Core/Zone.lua b/Moose Development/Moose/Core/Zone.lua index 332a73dda..a8759d97b 100644 --- a/Moose Development/Moose/Core/Zone.lua +++ b/Moose Development/Moose/Core/Zone.lua @@ -9,7 +9,7 @@ -- * Create polygon zones. -- * Create moving zones around a unit. -- * Create moving zones around a group. --- * Provide the zone behaviour. Some zones are static, while others are moveable. +-- * Provide the zone behavior. Some zones are static, while others are moveable. -- * Enquiry if a coordinate is within a zone. -- * Smoke zones. -- * Set a zone probability to control zone selection. @@ -20,10 +20,10 @@ -- * Draw zones (circular and polygon) on the F10 map. -- -- --- There are essentially two core functions that zones accomodate: +-- There are essentially two core functions that zones accommodate: -- -- * Test if an object is within the zone boundaries. --- * Provide the zone behaviour. Some zones are static, while others are moveable. +-- * Provide the zone behavior. Some zones are static, while others are moveable. -- -- The object classes are using the zone classes to test the zone boundaries, which can take various forms: -- @@ -53,7 +53,6 @@ -- @module Core.Zone -- @image Core_Zones.JPG - --- @type ZONE_BASE -- @field #string ZoneName Name of the zone. -- @field #number ZoneProbability A value between 0 and 1. 0 = 0% and 1 = 100% probability. @@ -61,7 +60,6 @@ -- @field #table Color Table with four entries, e.g. {1, 0, 0, 0.15}. First three are RGB color code. Fourth is the transparency Alpha value. -- @extends Core.Fsm#FSM - --- This class is an abstract BASE class for derived classes, and is not meant to be instantiated. -- -- ## Each zone has a name: @@ -107,11 +105,10 @@ ZONE_BASE = { ClassName = "ZONE_BASE", ZoneName = "", ZoneProbability = 1, - DrawID=nil, - Color={} + DrawID = nil, + Color = {}, } - --- The ZONE_BASE.BoundingSquare -- @type ZONE_BASE.BoundingSquare -- @field DCS#Distance x1 The lower x coordinate (left down) @@ -119,7 +116,6 @@ ZONE_BASE = { -- @field DCS#Distance x2 The higher x coordinate (right up) -- @field DCS#Distance y2 The higher y coordinate (right up) - --- ZONE_BASE constructor -- @param #ZONE_BASE self -- @param #string ZoneName Name of the zone. @@ -133,8 +129,6 @@ function ZONE_BASE:New( ZoneName ) return self end - - --- Returns the name of the zone. -- @param #ZONE_BASE self -- @return #string The name of the zone. @@ -144,7 +138,6 @@ function ZONE_BASE:GetName() return self.ZoneName end - --- Sets the name of the zone. -- @param #ZONE_BASE self -- @param #string ZoneName The name of the zone. @@ -201,7 +194,6 @@ function ZONE_BASE:IsPointVec3InZone( PointVec3 ) return InZone end - --- Returns the @{DCS#Vec2} coordinate of the zone. -- @param #ZONE_BASE self -- @return #nil. @@ -225,7 +217,6 @@ function ZONE_BASE:GetPointVec2() return PointVec2 end - --- Returns the @{DCS#Vec3} of the zone. -- @param #ZONE_BASE self -- @param DCS#Distance Height The height to add to the land height where the center of the zone is located. @@ -264,31 +255,30 @@ end -- @param #ZONE_BASE self -- @param DCS#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( Height ) --R2.1 - self:F2(self.ZoneName) +function ZONE_BASE:GetCoordinate( Height ) -- R2.1 + self:F2( self.ZoneName ) local Vec3 = self:GetVec3( Height ) if self.Coordinate then -- Update coordinates. - self.Coordinate.x=Vec3.x - self.Coordinate.y=Vec3.y - self.Coordinate.z=Vec3.z + self.Coordinate.x = Vec3.x + self.Coordinate.y = Vec3.y + self.Coordinate.z = Vec3.z - --env.info("FF GetCoordinate NEW for ZONE_BASE "..tostring(self.ZoneName)) + -- env.info("FF GetCoordinate NEW for ZONE_BASE "..tostring(self.ZoneName)) else -- Create a new coordinate object. - self.Coordinate=COORDINATE:NewFromVec3(Vec3) + self.Coordinate = COORDINATE:NewFromVec3( Vec3 ) - --env.info("FF GetCoordinate NEW for ZONE_BASE "..tostring(self.ZoneName)) + -- env.info("FF GetCoordinate NEW for ZONE_BASE "..tostring(self.ZoneName)) end return self.Coordinate end - --- Define a random @{DCS#Vec2} within the zone. -- @param #ZONE_BASE self -- @return DCS#Vec2 The Vec2 coordinates. @@ -314,7 +304,7 @@ end -- @param #ZONE_BASE self -- @return #nil The bounding square. function ZONE_BASE:GetBoundingSquare() - --return { x1 = 0, y1 = 0, x2 = 0, y2 = 0 } + -- return { x1 = 0, y1 = 0, x2 = 0, y2 = 0 } return nil end @@ -325,22 +315,21 @@ function ZONE_BASE:BoundZone() end - --- Set color of zone. -- @param #ZONE_BASE self -- @param #table RGBcolor RGB color table. Default `{1, 0, 0}`. -- @param #number Alpha Transparacy between 0 and 1. Default 0.15. -- @return #ZONE_BASE self -function ZONE_BASE:SetColor(RGBcolor, Alpha) +function ZONE_BASE:SetColor( RGBcolor, Alpha ) - RGBcolor=RGBcolor or {1, 0, 0} - Alpha=Alpha or 0.15 + RGBcolor = RGBcolor or { 1, 0, 0 } + Alpha = Alpha or 0.15 - self.Color={} - self.Color[1]=RGBcolor[1] - self.Color[2]=RGBcolor[2] - self.Color[3]=RGBcolor[3] - self.Color[4]=Alpha + self.Color = {} + self.Color[1] = RGBcolor[1] + self.Color[2] = RGBcolor[2] + self.Color[3] = RGBcolor[3] + self.Color[4] = Alpha return self end @@ -356,10 +345,10 @@ end -- @param #ZONE_BASE self -- @return #table Table with three entries, e.g. {1, 0, 0}, which is the RGB color code. function ZONE_BASE:GetColorRGB() - local rgb={} - rgb[1]=self.Color[1] - rgb[2]=self.Color[2] - rgb[3]=self.Color[3] + local rgb = {} + rgb[1] = self.Color[1] + rgb[2] = self.Color[2] + rgb[3] = self.Color[3] return rgb end @@ -367,7 +356,7 @@ end -- @param #ZONE_BASE self -- @return #number Alpha value. function ZONE_BASE:GetColorAlpha() - local alpha=self.Color[4] + local alpha = self.Color[4] return alpha end @@ -375,12 +364,12 @@ end -- @param #ZONE_BASE self -- @param #number Delay (Optional) Delay before the drawing is removed. -- @return #ZONE_BASE self -function ZONE_BASE:UndrawZone(Delay) - if Delay and Delay>0 then - self:ScheduleOnce(Delay, ZONE_BASE.UndrawZone, self) +function ZONE_BASE:UndrawZone( Delay ) + if Delay and Delay > 0 then + self:ScheduleOnce( Delay, ZONE_BASE.UndrawZone, self ) else if self.DrawID then - UTILS.RemoveMark(self.DrawID) + UTILS.RemoveMark( self.DrawID ) end end return self @@ -394,7 +383,6 @@ function ZONE_BASE:GetDrawID() return self.DrawID end - --- Smokes the zone boundaries in a color. -- @param #ZONE_BASE self -- @param Utilities.Utils#SMOKECOLOR SmokeColor The smoke color. @@ -459,7 +447,6 @@ function ZONE_BASE:GetZoneMaybe() end end - --- The ZONE_RADIUS class, defined by a zone name, a location and a radius. -- @type ZONE_RADIUS -- @field DCS#Vec2 Vec2 The current location of the zone. @@ -498,8 +485,8 @@ end -- -- @field #ZONE_RADIUS ZONE_RADIUS = { - ClassName="ZONE_RADIUS", - } + ClassName = "ZONE_RADIUS", +} --- Constructor of @{#ZONE_RADIUS}, taking the zone name, the zone location and a radius. -- @param #ZONE_RADIUS self @@ -516,7 +503,7 @@ function ZONE_RADIUS:New( ZoneName, Vec2, Radius ) self.Radius = Radius self.Vec2 = Vec2 - --self.Coordinate=COORDINATE:NewFromVec2(Vec2) + -- self.Coordinate=COORDINATE:NewFromVec2(Vec2) return self end @@ -526,13 +513,13 @@ end -- @param DCS#Vec2 Vec2 The location of the zone. -- @param DCS#Distance Radius The radius of the zone. -- @return #ZONE_RADIUS self -function ZONE_RADIUS:UpdateFromVec2(Vec2, Radius) +function ZONE_RADIUS:UpdateFromVec2( Vec2, Radius ) -- New center of the zone. - self.Vec2=Vec2 + self.Vec2 = Vec2 if Radius then - self.Radius=Radius + self.Radius = Radius end return self @@ -543,14 +530,14 @@ end -- @param DCS#Vec3 Vec3 The location of the zone. -- @param DCS#Distance Radius The radius of the zone. -- @return #ZONE_RADIUS self -function ZONE_RADIUS:UpdateFromVec3(Vec3, Radius) +function ZONE_RADIUS:UpdateFromVec3( Vec3, Radius ) -- New center of the zone. - self.Vec2.x=Vec3.x - self.Vec2.y=Vec3.z + self.Vec2.x = Vec3.x + self.Vec2.y = Vec3.z if Radius then - self.Radius=Radius + self.Radius = Radius end return self @@ -560,7 +547,7 @@ end -- @param #ZONE_RADIUS self -- @param #number Points (Optional) The amount of points in the circle. Default 360. -- @return #ZONE_RADIUS self -function ZONE_RADIUS:MarkZone(Points) +function ZONE_RADIUS:MarkZone( Points ) local Point = {} local Vec2 = self:GetVec2() @@ -568,16 +555,16 @@ function ZONE_RADIUS:MarkZone(Points) Points = Points and Points or 360 local Angle - local RadialBase = math.pi*2 + local RadialBase = math.pi * 2 - for Angle = 0, 360, (360 / Points ) do + for Angle = 0, 360, (360 / Points) do local Radial = Angle * RadialBase / 360 Point.x = Vec2.x + math.cos( Radial ) * self:GetRadius() Point.y = Vec2.y + math.sin( Radial ) * self:GetRadius() - COORDINATE:NewFromVec2(Point):MarkToAll(self:GetName()) + COORDINATE:NewFromVec2( Point ):MarkToAll( self:GetName() ) end @@ -593,18 +580,18 @@ end -- @param #number LineType Line type: 0=No line, 1=Solid, 2=Dashed, 3=Dotted, 4=Dot dash, 5=Long dash, 6=Two dash. Default 1=Solid. -- @param #boolean ReadOnly (Optional) Mark is readonly and cannot be removed by users. Default false. -- @return #ZONE_RADIUS self -function ZONE_RADIUS:DrawZone(Coalition, Color, Alpha, FillColor, FillAlpha, LineType, ReadOnly) +function ZONE_RADIUS:DrawZone( Coalition, Color, Alpha, FillColor, FillAlpha, LineType, ReadOnly ) - local coordinate=self:GetCoordinate() + local coordinate = self:GetCoordinate() - local Radius=self:GetRadius() + local Radius = self:GetRadius() - Color=Color or self:GetColorRGB() - Alpha=Alpha or 1 - FillColor=FillColor or Color - FillAlpha=FillAlpha or self:GetColorAlpha() + Color = Color or self:GetColorRGB() + Alpha = Alpha or 1 + FillColor = FillColor or Color + FillAlpha = FillAlpha or self:GetColorAlpha() - self.DrawID=coordinate:CircleToAll(Radius, Coalition, Color, Alpha, FillColor, FillAlpha, LineType, ReadOnly) + self.DrawID = coordinate:CircleToAll( Radius, Coalition, Color, Alpha, FillColor, FillAlpha, LineType, ReadOnly ) return self end @@ -623,10 +610,10 @@ function ZONE_RADIUS:BoundZone( Points, CountryID, UnBound ) Points = Points and Points or 360 local Angle - local RadialBase = math.pi*2 + local RadialBase = math.pi * 2 -- - for Angle = 0, 360, (360 / Points ) do + for Angle = 0, 360, (360 / Points) do local Radial = Angle * RadialBase / 360 Point.x = Vec2.x + math.cos( Radial ) * self:GetRadius() Point.y = Vec2.y + math.sin( Radial ) * self:GetRadius() @@ -634,16 +621,16 @@ function ZONE_RADIUS:BoundZone( Points, CountryID, UnBound ) local CountryName = _DATABASE.COUNTRY_NAME[CountryID] local Tire = { - ["country"] = CountryName, - ["category"] = "Fortifications", - ["canCargo"] = false, - ["shape_name"] = "H-tyre_B_WF", - ["type"] = "Black_Tyre_WF", - --["unitId"] = Angle + 10000, - ["y"] = Point.y, - ["x"] = Point.x, - ["name"] = string.format( "%s-Tire #%0d", self:GetName(), Angle ), - ["heading"] = 0, + ["country"] = CountryName, + ["category"] = "Fortifications", + ["canCargo"] = false, + ["shape_name"] = "H-tyre_B_WF", + ["type"] = "Black_Tyre_WF", + -- ["unitId"] = Angle + 10000, + ["y"] = Point.y, + ["x"] = Point.x, + ["name"] = string.format( "%s-Tire #%0d", self:GetName(), Angle ), + ["heading"] = 0, } -- end of ["group"] local Group = coalition.addStaticObject( CountryID, Tire ) @@ -655,7 +642,6 @@ function ZONE_RADIUS:BoundZone( Points, CountryID, UnBound ) return self end - --- Smokes the zone boundaries in a color. -- @param #ZONE_RADIUS self -- @param Utilities.Utils#SMOKECOLOR SmokeColor The smoke color. @@ -675,10 +661,10 @@ function ZONE_RADIUS:SmokeZone( SmokeColor, Points, AddHeight, AngleOffset ) Points = Points and Points or 360 local Angle - local RadialBase = math.pi*2 + local RadialBase = math.pi * 2 for Angle = 0, 360, 360 / Points do - local Radial = ( Angle + AngleOffset ) * RadialBase / 360 + local Radial = (Angle + AngleOffset) * RadialBase / 360 Point.x = Vec2.x + math.cos( Radial ) * self:GetRadius() Point.y = Vec2.y + math.sin( Radial ) * self:GetRadius() POINT_VEC2:New( Point.x, Point.y, AddHeight ):Smoke( SmokeColor ) @@ -687,7 +673,6 @@ function ZONE_RADIUS:SmokeZone( SmokeColor, Points, AddHeight, AngleOffset ) return self end - --- Flares the zone boundaries in a color. -- @param #ZONE_RADIUS self -- @param Utilities.Utils#FLARECOLOR FlareColor The flare color. @@ -706,7 +691,7 @@ function ZONE_RADIUS:FlareZone( FlareColor, Points, Azimuth, AddHeight ) Points = Points and Points or 360 local Angle - local RadialBase = math.pi*2 + local RadialBase = math.pi * 2 for Angle = 0, 360, 360 / Points do local Radial = Angle * RadialBase / 360 @@ -784,10 +769,6 @@ function ZONE_RADIUS:GetVec3( Height ) return Vec3 end - - - - --- Scan the zone for the presence of units of the given ObjectCategories. -- Note that after a zone has been scanned, the zone can be evaluated by: -- @@ -813,27 +794,27 @@ function ZONE_RADIUS:Scan( ObjectCategories, UnitCategories ) local ZoneCoord = self:GetCoordinate() local ZoneRadius = self:GetRadius() - self:F({ZoneCoord = ZoneCoord, ZoneRadius = ZoneRadius, ZoneCoordLL = ZoneCoord:ToStringLLDMS()}) + self:F( { ZoneCoord = ZoneCoord, ZoneRadius = ZoneRadius, ZoneCoordLL = ZoneCoord:ToStringLLDMS() } ) local SphereSearch = { id = world.VolumeType.SPHERE, - params = { + params = { point = ZoneCoord:GetVec3(), radius = ZoneRadius, - } - } + }, + } local function EvaluateZone( ZoneObject ) - --if ZoneObject:isExist() then --FF: isExist always returns false for SCENERY objects since DCS 2.2 and still in DCS 2.5 + -- if ZoneObject:isExist() then --FF: isExist always returns false for SCENERY objects since DCS 2.2 and still in DCS 2.5 if ZoneObject then local ObjectCategory = ZoneObject:getCategory() - --local name=ZoneObject:getName() - --env.info(string.format("Zone object %s", tostring(name))) - --self:E(ZoneObject) + -- local name=ZoneObject:getName() + -- env.info(string.format("Zone object %s", tostring(name))) + -- self:E(ZoneObject) - if ( ObjectCategory == Object.Category.UNIT and ZoneObject:isExist() and ZoneObject:isActive() ) or (ObjectCategory == Object.Category.STATIC and ZoneObject:isExist()) then + if (ObjectCategory == Object.Category.UNIT and ZoneObject:isExist() and ZoneObject:isActive()) or (ObjectCategory == Object.Category.STATIC and ZoneObject:isExist()) then local CoalitionDCSUnit = ZoneObject:getCoalition() @@ -872,7 +853,7 @@ function ZONE_RADIUS:Scan( ObjectCategories, UnitCategories ) local SceneryName = ZoneObject:getName() self.ScanData.Scenery[SceneryType] = self.ScanData.Scenery[SceneryType] or {} self.ScanData.Scenery[SceneryType][SceneryName] = SCENERY:Register( SceneryName, ZoneObject ) - self:F2( { SCENERY = self.ScanData.Scenery[SceneryType][SceneryName] } ) + self:F2( { SCENERY = self.ScanData.Scenery[SceneryType][SceneryName] } ) end end @@ -893,7 +874,6 @@ function ZONE_RADIUS:GetScannedUnits() return self.ScanData.Units end - --- Get a set of scanned units. -- @param #ZONE_RADIUS self -- @return Core.Set#SET_UNIT Set of units and statics inside the zone. @@ -926,19 +906,19 @@ end -- @return Core.Set#SET_GROUP Set of groups. function ZONE_RADIUS:GetScannedSetGroup() - self.ScanSetGroup=self.ScanSetGroup or SET_GROUP:New() --Core.Set#SET_GROUP + self.ScanSetGroup = self.ScanSetGroup or SET_GROUP:New() -- Core.Set#SET_GROUP - self.ScanSetGroup.Set={} + self.ScanSetGroup.Set = {} if self.ScanData then for ObjectID, UnitObject in pairs( self.ScanData.Units ) do local UnitObject = UnitObject -- DCS#Unit if UnitObject:isExist() then - local FoundUnit=UNIT:FindByName(UnitObject:getName()) + local FoundUnit = UNIT:FindByName( UnitObject:getName() ) if FoundUnit then - local group=FoundUnit:GetGroup() - self.ScanSetGroup:AddGroup(group) + local group = FoundUnit:GetGroup() + self.ScanSetGroup:AddGroup( group ) end end end @@ -947,7 +927,6 @@ function ZONE_RADIUS:GetScannedSetGroup() return self.ScanSetGroup end - --- Count the number of different coalitions inside the zone. -- @param #ZONE_RADIUS self -- @return #number Counted coalitions. @@ -1000,7 +979,6 @@ function ZONE_RADIUS:GetScannedCoalition( Coalition ) end end - --- Get scanned scenery type -- @param #ZONE_RADIUS self -- @return #table Table of DCS scenery type objects. @@ -1008,7 +986,6 @@ function ZONE_RADIUS:GetScannedSceneryType( SceneryType ) return self.ScanData.Scenery[SceneryType] end - --- Get scanned scenery table -- @param #ZONE_RADIUS self -- @return #table Table of DCS scenery objects. @@ -1016,9 +993,8 @@ function ZONE_RADIUS:GetScannedScenery() return self.ScanData.Scenery end - --- Is All in Zone of Coalition? --- Check if only the specifed coalition is inside the zone and noone else. +-- Check if only the specified coalition is inside the zone and noone else. -- @param #ZONE_RADIUS self -- @param #number Coalition Coalition ID of the coalition which is checked to be the only one in the zone. -- @return #boolean True, if **only** that coalition is inside the zone and no one else. @@ -1027,11 +1003,10 @@ end -- local IsGuarded = self.Zone:IsAllInZoneOfCoalition( self.Coalition ) function ZONE_RADIUS:IsAllInZoneOfCoalition( Coalition ) - --self:E( { Coalitions = self.Coalitions, Count = self:CountScannedCoalitions() } ) + -- self:E( { Coalitions = self.Coalitions, Count = self:CountScannedCoalitions() } ) return self:CountScannedCoalitions() == 1 and self:GetScannedCoalition( Coalition ) == true end - --- Is All in Zone of Other Coalition? -- Check if only one coalition is inside the zone and the specified coalition is not the one. -- You first need to use the @{#ZONE_RADIUS.Scan} method to scan the zone before it can be evaluated! @@ -1044,27 +1019,27 @@ end -- local IsCaptured = self.Zone:IsAllInZoneOfOtherCoalition( self.Coalition ) function ZONE_RADIUS:IsAllInZoneOfOtherCoalition( Coalition ) - --self:E( { Coalitions = self.Coalitions, Count = self:CountScannedCoalitions() } ) + -- self:E( { Coalitions = self.Coalitions, Count = self:CountScannedCoalitions() } ) return self:CountScannedCoalitions() == 1 and self:GetScannedCoalition( Coalition ) == nil end - --- Is Some in Zone of Coalition? --- Check if more than one coaltion is inside the zone and the specifed coalition is one of them. +-- Check if more than one coalition is inside the zone and the specified coalition is one of them. -- You first need to use the @{#ZONE_RADIUS.Scan} method to scan the zone before it can be evaluated! -- Note that once a zone has been scanned, multiple evaluations can be done on the scan result set. -- @param #ZONE_RADIUS self --- @param #number Coalition ID of the coaliton which is checked to be inside the zone. +-- @param #number Coalition ID of the coalition which is checked to be inside the zone. -- @return #boolean True if more than one coalition is inside the zone and the specified coalition is one of them. -- @usage +-- -- self.Zone:Scan() -- local IsAttacked = self.Zone:IsSomeInZoneOfCoalition( self.Coalition ) +-- function ZONE_RADIUS:IsSomeInZoneOfCoalition( Coalition ) return self:CountScannedCoalitions() > 1 and self:GetScannedCoalition( Coalition ) == true end - --- Is None in Zone of Coalition? -- You first need to use the @{#ZONE_RADIUS.Scan} method to scan the zone before it can be evaluated! -- Note that once a zone has been scanned, multiple evaluations can be done on the scan result set. @@ -1072,30 +1047,30 @@ end -- @param Coalition -- @return #boolean -- @usage +-- -- self.Zone:Scan() -- local IsOccupied = self.Zone:IsNoneInZoneOfCoalition( self.Coalition ) +-- function ZONE_RADIUS:IsNoneInZoneOfCoalition( Coalition ) return self:GetScannedCoalition( Coalition ) == nil end - --- Is None in Zone? -- You first need to use the @{#ZONE_RADIUS.Scan} method to scan the zone before it can be evaluated! -- Note that once a zone has been scanned, multiple evaluations can be done on the scan result set. -- @param #ZONE_RADIUS self -- @return #boolean -- @usage +-- -- self.Zone:Scan() -- local IsEmpty = self.Zone:IsNoneInZone() +-- function ZONE_RADIUS:IsNoneInZone() return self:CountScannedCoalitions() == 0 end - - - --- Searches the zone -- @param #ZONE_RADIUS self -- @param ObjectCategories A list of categories, which are members of Object.Category @@ -1107,19 +1082,18 @@ function ZONE_RADIUS:SearchZone( EvaluateFunction, ObjectCategories ) local ZoneCoord = self:GetCoordinate() local ZoneRadius = self:GetRadius() - self:F({ZoneCoord = ZoneCoord, ZoneRadius = ZoneRadius, ZoneCoordLL = ZoneCoord:ToStringLLDMS()}) + self:F( { ZoneCoord = ZoneCoord, ZoneRadius = ZoneRadius, ZoneCoordLL = ZoneCoord:ToStringLLDMS() } ) local SphereSearch = { id = world.VolumeType.SPHERE, params = { - point = ZoneCoord:GetVec3(), - radius = ZoneRadius / 2, - } + point = ZoneCoord:GetVec3(), + radius = ZoneRadius / 2, + }, } local function EvaluateZone( ZoneDCSUnit ) - local ZoneUnit = UNIT:Find( ZoneDCSUnit ) return EvaluateFunction( ZoneUnit ) @@ -1139,7 +1113,7 @@ function ZONE_RADIUS:IsVec2InZone( Vec2 ) local ZoneVec2 = self:GetVec2() if ZoneVec2 then - if (( Vec2.x - ZoneVec2.x )^2 + ( Vec2.y - ZoneVec2.y ) ^2 ) ^ 0.5 <= self:GetRadius() then + if ((Vec2.x - ZoneVec2.x) ^ 2 + (Vec2.y - ZoneVec2.y) ^ 2) ^ 0.5 <= self:GetRadius() then return true end end @@ -1173,8 +1147,8 @@ function ZONE_RADIUS:GetRandomVec2( inner, outer ) local _outer = outer or self:GetRadius() local angle = math.random() * math.pi * 2; - Point.x = Vec2.x + math.cos( angle ) * math.random(_inner, _outer); - Point.y = Vec2.y + math.sin( angle ) * math.random(_inner, _outer); + Point.x = Vec2.x + math.cos( angle ) * math.random( _inner, _outer ); + Point.y = Vec2.y + math.sin( angle ) * math.random( _inner, _outer ); self:T( { Point } ) @@ -1211,7 +1185,6 @@ function ZONE_RADIUS:GetRandomVec3( inner, outer ) return { x = Vec2.x, y = self.y, z = Vec2.y } end - --- Returns a @{Core.Point#POINT_VEC3} object reflecting a random 3D location within the zone. -- @param #ZONE_RADIUS self -- @param #number inner (optional) Minimal distance from the center of the zone. Default is 0. @@ -1227,7 +1200,6 @@ function ZONE_RADIUS:GetRandomPointVec3( inner, outer ) return PointVec3 end - --- Returns a @{Core.Point#COORDINATE} object reflecting a random 3D location within the zone. -- @param #ZONE_RADIUS self -- @param #number inner (optional) Minimal distance from the center of the zone. Default is 0. @@ -1236,19 +1208,16 @@ end function ZONE_RADIUS:GetRandomCoordinate( inner, outer ) self:F( self.ZoneName, inner, outer ) - local Coordinate = COORDINATE:NewFromVec2( self:GetRandomVec2(inner, outer) ) + local Coordinate = COORDINATE:NewFromVec2( self:GetRandomVec2( inner, outer ) ) self:T3( { Coordinate = Coordinate } ) return Coordinate end - - --- @type ZONE -- @extends #ZONE_RADIUS - --- The ZONE class, defined by the zone name as defined within the Mission Editor. -- This class implements the inherited functions from @{#ZONE_RADIUS} taking into account the own zone format and properties. -- @@ -1278,9 +1247,8 @@ end -- -- @field #ZONE ZONE = { - ClassName="ZONE", - } - + ClassName = "ZONE", +} --- Constructor of ZONE taking the zone name. -- @param #ZONE self @@ -1289,10 +1257,10 @@ ZONE = { function ZONE:New( ZoneName ) -- First try to find the zone in the DB. - local zone=_DATABASE:FindZone(ZoneName) + local zone = _DATABASE:FindZone( ZoneName ) if zone then - --env.info("FF found zone in DB") + -- env.info("FF found zone in DB") return zone end @@ -1306,11 +1274,11 @@ function ZONE:New( ZoneName ) end -- Create a new ZONE_RADIUS. - local self=BASE:Inherit( self, ZONE_RADIUS:New(ZoneName, {x=Zone.point.x, y=Zone.point.z}, Zone.radius)) - self:F(ZoneName) + local self = BASE:Inherit( self, ZONE_RADIUS:New( ZoneName, { x = Zone.point.x, y = Zone.point.z }, Zone.radius ) ) + self:F( ZoneName ) -- Color of zone. - self.Color={1, 0, 0, 0.15} + self.Color = { 1, 0, 0, 0.15 } -- DCS zone. self.Zone = Zone @@ -1328,13 +1296,10 @@ function ZONE:FindByName( ZoneName ) return ZoneFound end - - --- @type ZONE_UNIT -- @field Wrapper.Unit#UNIT ZoneUNIT -- @extends Core.Zone#ZONE_RADIUS - --- # ZONE_UNIT class, extends @{Zone#ZONE_RADIUS} -- -- The ZONE_UNIT class defined by a zone attached to a @{Wrapper.Unit#UNIT} with a radius and optional offsets. @@ -1342,8 +1307,8 @@ end -- -- @field #ZONE_UNIT ZONE_UNIT = { - ClassName="ZONE_UNIT", - } + ClassName = "ZONE_UNIT", +} --- Constructor to create a ZONE_UNIT instance, taking the zone name, a zone unit and a radius and optional offsets in X and Y directions. -- @param #ZONE_UNIT self @@ -1358,12 +1323,12 @@ ZONE_UNIT = { -- relative_to_unit If true, theta is measured clockwise from unit's direction else clockwise from north. If using dx, dy setting this to true makes +x parallel to unit heading. -- dx, dy OR rho, theta may be used, not both. -- @return #ZONE_UNIT self -function ZONE_UNIT:New( ZoneName, ZoneUNIT, Radius, Offset) +function ZONE_UNIT:New( ZoneName, ZoneUNIT, Radius, Offset ) if Offset then -- check if the inputs was reasonable, either (dx, dy) or (rho, theta) can be given, else raise an exception. if (Offset.dx or Offset.dy) and (Offset.rho or Offset.theta) then - error("Cannot use (dx, dy) with (rho, theta)") + error( "Cannot use (dx, dy) with (rho, theta)" ) end self.dy = Offset.dy or 0.0 @@ -1386,7 +1351,6 @@ function ZONE_UNIT:New( ZoneName, ZoneUNIT, Radius, Offset) return self end - --- Returns the current location of the @{Wrapper.Unit#UNIT}. -- @param #ZONE_UNIT self -- @return DCS#Vec2 The location of the zone based on the @{Wrapper.Unit#UNIT}location and the offset, if any. @@ -1398,9 +1362,9 @@ function ZONE_UNIT:GetVec2() local heading if self.relative_to_unit then - heading = ( self.ZoneUNIT:GetHeading() or 0.0 ) * math.pi / 180.0 - else - heading = 0.0 + heading = (self.ZoneUNIT:GetHeading() or 0.0) * math.pi / 180.0 + else + heading = 0.0 end -- update the zone position with the offsets. @@ -1414,8 +1378,8 @@ function ZONE_UNIT:GetVec2() -- if using the polar coordinates if (self.rho or self.theta) then - ZoneVec2.x = ZoneVec2.x + self.rho * math.cos( self.theta + heading ) - ZoneVec2.y = ZoneVec2.y + self.rho * math.sin( self.theta + heading ) + ZoneVec2.x = ZoneVec2.x + self.rho * math.cos( self.theta + heading ) + ZoneVec2.y = ZoneVec2.y + self.rho * math.sin( self.theta + heading ) end self.LastVec2 = ZoneVec2 @@ -1436,14 +1400,14 @@ function ZONE_UNIT:GetRandomVec2() self:F( self.ZoneName ) local RandomVec2 = {} - --local Vec2 = self.ZoneUNIT:GetVec2() -- FF: This does not take care of the new offset feature! + -- local Vec2 = self.ZoneUNIT:GetVec2() -- FF: This does not take care of the new offset feature! local Vec2 = self:GetVec2() if not Vec2 then Vec2 = self.LastVec2 end - local angle = math.random() * math.pi*2; + local angle = math.random() * math.pi * 2; RandomVec2.x = Vec2.x + math.cos( angle ) * math.random() * self:GetRadius(); RandomVec2.y = Vec2.y + math.sin( angle ) * math.random() * self:GetRadius(); @@ -1473,14 +1437,13 @@ end --- @type ZONE_GROUP -- @extends #ZONE_RADIUS - --- The ZONE_GROUP class defines by a zone around a @{Wrapper.Group#GROUP} with a radius. The current leader of the group defines the center of the zone. -- This class implements the inherited functions from @{Core.Zone#ZONE_RADIUS} taking into account the own zone format and properties. -- -- @field #ZONE_GROUP ZONE_GROUP = { - ClassName="ZONE_GROUP", - } + ClassName = "ZONE_GROUP", +} --- Constructor to create a ZONE_GROUP instance, taking the zone name, a zone @{Wrapper.Group#GROUP} and a radius. -- @param #ZONE_GROUP self @@ -1501,7 +1464,6 @@ function ZONE_GROUP:New( ZoneName, ZoneGROUP, Radius ) return self end - --- Returns the current location of the @{Wrapper.Group}. -- @param #ZONE_GROUP self -- @return DCS#Vec2 The location of the zone based on the @{Wrapper.Group} location. @@ -1531,7 +1493,7 @@ function ZONE_GROUP:GetRandomVec2() local Point = {} local Vec2 = self._.ZoneGROUP:GetVec2() - local angle = math.random() * math.pi*2; + local angle = math.random() * math.pi * 2; Point.x = Vec2.x + math.cos( angle ) * math.random() * self:GetRadius(); Point.y = Vec2.y + math.sin( angle ) * math.random() * self:GetRadius(); @@ -1555,12 +1517,10 @@ function ZONE_GROUP:GetRandomPointVec2( inner, outer ) return PointVec2 end - --- @type ZONE_POLYGON_BASE -- --@field #ZONE_POLYGON_BASE.ListVec2 Polygon The polygon defined by an array of @{DCS#Vec2}. -- @extends #ZONE_BASE - --- The ZONE_POLYGON_BASE class defined by a sequence of @{Wrapper.Group#GROUP} waypoints within the Mission Editor, forming a polygon. -- This class implements the inherited functions from @{Core.Zone#ZONE_RADIUS} taking into account the own zone format and properties. -- This class is an abstract BASE class for derived classes, and is not meant to be instantiated. @@ -1571,7 +1531,7 @@ end -- -- * @{#ZONE_POLYGON_BASE.GetRandomVec2}(): Gets a random 2D point in the zone. -- * @{#ZONE_POLYGON_BASE.GetRandomPointVec2}(): Return a @{Core.Point#POINT_VEC2} object representing a random 2D point within the zone. --- * @{#ZONE_POLYGON_BASE.GetRandomPointVec3}(): Return a @{Core.Point#POINT_VEC3} object representing a random 3D point at landheight within the zone. +-- * @{#ZONE_POLYGON_BASE.GetRandomPointVec3}(): Return a @{Core.Point#POINT_VEC3} object representing a random 3D point at land height within the zone. -- -- ## Draw zone -- @@ -1581,8 +1541,8 @@ end -- -- @field #ZONE_POLYGON_BASE ZONE_POLYGON_BASE = { - ClassName="ZONE_POLYGON_BASE", - } + ClassName = "ZONE_POLYGON_BASE", +} --- A 2D points array. -- @type ZONE_POLYGON_BASE.ListVec2 @@ -1623,14 +1583,14 @@ end -- @param #ZONE_POLYGON_BASE self -- @param #ZONE_POLYGON_BASE.ListVec2 Vec2Array An array of @{DCS#Vec2}, forming a polygon. -- @return #ZONE_POLYGON_BASE self -function ZONE_POLYGON_BASE:UpdateFromVec2(Vec2Array) +function ZONE_POLYGON_BASE:UpdateFromVec2( Vec2Array ) self._.Polygon = {} - for i=1,#Vec2Array do + for i = 1, #Vec2Array do self._.Polygon[i] = {} - self._.Polygon[i].x=Vec2Array[i].x - self._.Polygon[i].y=Vec2Array[i].y + self._.Polygon[i].x = Vec2Array[i].x + self._.Polygon[i].y = Vec2Array[i].y end return self @@ -1640,14 +1600,14 @@ end -- @param #ZONE_POLYGON_BASE self -- @param #ZONE_POLYGON_BASE.ListVec3 Vec2Array An array of @{DCS#Vec3}, forming a polygon. -- @return #ZONE_POLYGON_BASE self -function ZONE_POLYGON_BASE:UpdateFromVec3(Vec3Array) +function ZONE_POLYGON_BASE:UpdateFromVec3( Vec3Array ) self._.Polygon = {} - for i=1,#Vec3Array do + for i = 1, #Vec3Array do self._.Polygon[i] = {} - self._.Polygon[i].x=Vec3Array[i].x - self._.Polygon[i].y=Vec3Array[i].z + self._.Polygon[i].x = Vec3Array[i].x + self._.Polygon[i].y = Vec3Array[i].z end return self @@ -1661,14 +1621,14 @@ function ZONE_POLYGON_BASE:GetVec2() local Bounds = self:GetBoundingSquare() - return { x = ( Bounds.x2 + Bounds.x1 ) / 2, y = ( Bounds.y2 + Bounds.y1 ) / 2 } + return { x = (Bounds.x2 + Bounds.x1) / 2, y = (Bounds.y2 + Bounds.y1) / 2 } end --- Get a vertex of the polygon. -- @param #ZONE_POLYGON_BASE self -- @param #number Index Index of the vertex. Default 1. -- @return DCS#Vec2 Vertex of the polygon. -function ZONE_POLYGON_BASE:GetVertexVec2(Index) +function ZONE_POLYGON_BASE:GetVertexVec2( Index ) return self._.Polygon[Index or 1] end @@ -1676,10 +1636,10 @@ end -- @param #ZONE_POLYGON_BASE self -- @param #number Index Index of the vertex. Default 1. -- @return DCS#Vec3 Vertex of the polygon. -function ZONE_POLYGON_BASE:GetVertexVec3(Index) - local vec2=self:GetVertexVec2(Index) +function ZONE_POLYGON_BASE:GetVertexVec3( Index ) + local vec2 = self:GetVertexVec2( Index ) if vec2 then - local vec3={x=vec2.x, y=land.getHeight(vec2), z=vec2.y} + local vec3 = { x = vec2.x, y = land.getHeight( vec2 ), z = vec2.y } return vec3 end return nil @@ -1689,16 +1649,15 @@ end -- @param #ZONE_POLYGON_BASE self -- @param #number Index Index of the vertex. Default 1. -- @return Core.Point#COORDINATE Vertex of the polygon. -function ZONE_POLYGON_BASE:GetVertexCoordinate(Index) - local vec2=self:GetVertexVec2(Index) +function ZONE_POLYGON_BASE:GetVertexCoordinate( Index ) + local vec2 = self:GetVertexVec2( Index ) if vec2 then - local coord=COORDINATE:NewFromVec2(vec2) + local coord = COORDINATE:NewFromVec2( vec2 ) return coord end return nil end - --- Get a list of verticies of the polygon. -- @param #ZONE_POLYGON_BASE self -- @return List of DCS#Vec2 verticies defining the edges of the polygon. @@ -1711,11 +1670,11 @@ end -- @return #table List of DCS#Vec3 verticies defining the edges of the polygon. function ZONE_POLYGON_BASE:GetVerticiesVec3() - local coords={} + local coords = {} - for i,vec2 in ipairs(self._.Polygon) do - local vec3={x=vec2.x, y=land.getHeight(vec2), z=vec2.y} - table.insert(coords, vec3) + for i, vec2 in ipairs( self._.Polygon ) do + local vec3 = { x = vec2.x, y = land.getHeight( vec2 ), z = vec2.y } + table.insert( coords, vec3 ) end return coords @@ -1726,11 +1685,11 @@ end -- @return #table List of COORDINATES verticies defining the edges of the polygon. function ZONE_POLYGON_BASE:GetVerticiesCoordinates() - local coords={} + local coords = {} - for i,vec2 in ipairs(self._.Polygon) do - local coord=COORDINATE:NewFromVec2(vec2) - table.insert(coords, coord) + for i, vec2 in ipairs( self._.Polygon ) do + local coord = COORDINATE:NewFromVec2( vec2 ) + table.insert( coords, coord ) end return coords @@ -1794,7 +1753,6 @@ function ZONE_POLYGON_BASE:BoundZone( UnBound ) return self end - --- Draw the zone on the F10 map. **NOTE** Currently, only polygons with **exactly four points** are supported! -- @param #ZONE_POLYGON_BASE self -- @param #number Coalition Coalition: All=-1, Neutral=0, Red=1, Blue=2. Default -1=All. @@ -1805,34 +1763,32 @@ end -- @param #number LineType Line type: 0=No line, 1=Solid, 2=Dashed, 3=Dotted, 4=Dot dash, 5=Long dash, 6=Two dash. Default 1=Solid. -- @param #boolean ReadOnly (Optional) Mark is readonly and cannot be removed by users. Default false. -- @return #ZONE_POLYGON_BASE self -function ZONE_POLYGON_BASE:DrawZone(Coalition, Color, Alpha, FillColor, FillAlpha, LineType, ReadOnly) +function ZONE_POLYGON_BASE:DrawZone( Coalition, Color, Alpha, FillColor, FillAlpha, LineType, ReadOnly ) - local coordinate=COORDINATE:NewFromVec2(self._.Polygon[1]) + local coordinate = COORDINATE:NewFromVec2( self._.Polygon[1] ) - Color=Color or self:GetColorRGB() - Alpha=Alpha or 1 - FillColor=FillColor or Color - FillAlpha=FillAlpha or self:GetColorAlpha() + Color = Color or self:GetColorRGB() + Alpha = Alpha or 1 + FillColor = FillColor or Color + FillAlpha = FillAlpha or self:GetColorAlpha() + if #self._.Polygon == 4 then - if #self._.Polygon==4 then + local Coord2 = COORDINATE:NewFromVec2( self._.Polygon[2] ) + local Coord3 = COORDINATE:NewFromVec2( self._.Polygon[3] ) + local Coord4 = COORDINATE:NewFromVec2( self._.Polygon[4] ) - local Coord2=COORDINATE:NewFromVec2(self._.Polygon[2]) - local Coord3=COORDINATE:NewFromVec2(self._.Polygon[3]) - local Coord4=COORDINATE:NewFromVec2(self._.Polygon[4]) - - self.DrawID=coordinate:QuadToAll(Coord2, Coord3, Coord4, Coalition, Color, Alpha, FillColor, FillAlpha, LineType, ReadOnly) + self.DrawID = coordinate:QuadToAll( Coord2, Coord3, Coord4, Coalition, Color, Alpha, FillColor, FillAlpha, LineType, ReadOnly ) else - local Coordinates=self:GetVerticiesCoordinates() - table.remove(Coordinates, 1) + local Coordinates = self:GetVerticiesCoordinates() + table.remove( Coordinates, 1 ) - self.DrawID=coordinate:MarkupToAllFreeForm(Coordinates, Coalition, Color, Alpha, FillColor, FillAlpha, LineType, ReadOnly) + self.DrawID = coordinate:MarkupToAllFreeForm( Coordinates, Coalition, Color, Alpha, FillColor, FillAlpha, LineType, ReadOnly ) end - return self end @@ -1844,10 +1800,10 @@ end function ZONE_POLYGON_BASE:SmokeZone( SmokeColor, Segments ) self:F2( SmokeColor ) - Segments=Segments or 10 + Segments = Segments or 10 - local i=1 - local j=#self._.Polygon + local i = 1 + local j = #self._.Polygon while i <= #self._.Polygon do self:T( { i, j, self._.Polygon[i], self._.Polygon[j] } ) @@ -1856,8 +1812,8 @@ function ZONE_POLYGON_BASE:SmokeZone( SmokeColor, Segments ) local DeltaY = self._.Polygon[j].y - self._.Polygon[i].y for Segment = 0, Segments do -- We divide each line in 5 segments and smoke a point on the line. - local PointX = self._.Polygon[i].x + ( Segment * DeltaX / Segments ) - local PointY = self._.Polygon[i].y + ( Segment * DeltaY / Segments ) + local PointX = self._.Polygon[i].x + (Segment * DeltaX / Segments) + local PointY = self._.Polygon[i].y + (Segment * DeltaY / Segments) POINT_VEC2:New( PointX, PointY ):Smoke( SmokeColor ) end j = i @@ -1867,7 +1823,6 @@ function ZONE_POLYGON_BASE:SmokeZone( SmokeColor, Segments ) return self end - --- Flare the zone boundaries in a color. -- @param #ZONE_POLYGON_BASE self -- @param Utilities.Utils#FLARECOLOR FlareColor The flare color. @@ -1876,14 +1831,14 @@ end -- @param #number AddHeight (optional) The height to be added for the smoke. -- @return #ZONE_POLYGON_BASE self function ZONE_POLYGON_BASE:FlareZone( FlareColor, Segments, Azimuth, AddHeight ) - self:F2(FlareColor) + self:F2( FlareColor ) - Segments=Segments or 10 + Segments = Segments or 10 AddHeight = AddHeight or 0 - local i=1 - local j=#self._.Polygon + local i = 1 + local j = #self._.Polygon while i <= #self._.Polygon do self:T( { i, j, self._.Polygon[i], self._.Polygon[j] } ) @@ -1892,9 +1847,9 @@ function ZONE_POLYGON_BASE:FlareZone( FlareColor, Segments, Azimuth, AddHeight ) local DeltaY = self._.Polygon[j].y - self._.Polygon[i].y for Segment = 0, Segments do -- We divide each line in 5 segments and smoke a point on the line. - local PointX = self._.Polygon[i].x + ( Segment * DeltaX / Segments ) - local PointY = self._.Polygon[i].y + ( Segment * DeltaY / Segments ) - POINT_VEC2:New( PointX, PointY, AddHeight ):Flare(FlareColor, Azimuth) + local PointX = self._.Polygon[i].x + (Segment * DeltaX / Segments) + local PointY = self._.Polygon[i].y + (Segment * DeltaY / Segments) + POINT_VEC2:New( PointX, PointY, AddHeight ):Flare( FlareColor, Azimuth ) end j = i i = i + 1 @@ -1903,9 +1858,6 @@ function ZONE_POLYGON_BASE:FlareZone( FlareColor, Segments, Azimuth, AddHeight ) return self end - - - --- Returns if a location is within the zone. -- Source learned and taken from: https://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html -- @param #ZONE_POLYGON_BASE self @@ -1923,10 +1875,9 @@ function ZONE_POLYGON_BASE:IsVec2InZone( Vec2 ) while Next <= #self._.Polygon do self:T( { Next, Prev, self._.Polygon[Next], self._.Polygon[Prev] } ) - if ( ( ( self._.Polygon[Next].y > Vec2.y ) ~= ( self._.Polygon[Prev].y > Vec2.y ) ) and - ( Vec2.x < ( self._.Polygon[Prev].x - self._.Polygon[Next].x ) * ( Vec2.y - self._.Polygon[Next].y ) / ( self._.Polygon[Prev].y - self._.Polygon[Next].y ) + self._.Polygon[Next].x ) - ) then - InPolygon = not InPolygon + if (((self._.Polygon[Next].y > Vec2.y) ~= (self._.Polygon[Prev].y > Vec2.y)) and + (Vec2.x < (self._.Polygon[Prev].x - self._.Polygon[Next].x) * (Vec2.y - self._.Polygon[Next].y) / (self._.Polygon[Prev].y - self._.Polygon[Next].y) + self._.Polygon[Next].x)) then + InPolygon = not InPolygon end self:T2( { InPolygon = InPolygon } ) Prev = Next @@ -1989,7 +1940,6 @@ function ZONE_POLYGON_BASE:GetRandomPointVec3() return PointVec3 end - --- Return a @{Core.Point#COORDINATE} object representing a random 3D point at landheight within the zone. -- @param #ZONE_POLYGON_BASE self -- @return Core.Point#COORDINATE @@ -2003,7 +1953,6 @@ function ZONE_POLYGON_BASE:GetRandomCoordinate() return Coordinate end - --- Get the bounding square the zone. -- @param #ZONE_POLYGON_BASE self -- @return #ZONE_POLYGON_BASE.BoundingSquare The bounding square. @@ -2016,10 +1965,10 @@ function ZONE_POLYGON_BASE:GetBoundingSquare() for i = 2, #self._.Polygon do self:T2( { self._.Polygon[i], x1, y1, x2, y2 } ) - x1 = ( x1 > self._.Polygon[i].x ) and self._.Polygon[i].x or x1 - x2 = ( x2 < self._.Polygon[i].x ) and self._.Polygon[i].x or x2 - y1 = ( y1 > self._.Polygon[i].y ) and self._.Polygon[i].y or y1 - y2 = ( y2 < self._.Polygon[i].y ) and self._.Polygon[i].y or y2 + x1 = (x1 > self._.Polygon[i].x) and self._.Polygon[i].x or x1 + x2 = (x2 < self._.Polygon[i].x) and self._.Polygon[i].x or x2 + y1 = (y1 > self._.Polygon[i].y) and self._.Polygon[i].y or y1 + y2 = (y2 < self._.Polygon[i].y) and self._.Polygon[i].y or y2 end @@ -2035,41 +1984,40 @@ end -- @param #number Segments (Optional) Number of segments within boundary line. Default 10. -- @param #boolean Closed (Optional) Link the last point with the first one to obtain a closed boundary. Default false -- @return #ZONE_POLYGON_BASE self -function ZONE_POLYGON_BASE:Boundary(Coalition, Color, Radius, Alpha, Segments, Closed) - Coalition = Coalition or -1 - Color = Color or {1, 1, 1} - Radius = Radius or 1000 - Alpha = Alpha or 1 - Segments = Segments or 10 - Closed = Closed or false - local i = 1 - local j = #self._.Polygon - if (Closed) then - Limit = #self._.Polygon + 1 - else - Limit = #self._.Polygon +function ZONE_POLYGON_BASE:Boundary( Coalition, Color, Radius, Alpha, Segments, Closed ) + Coalition = Coalition or -1 + Color = Color or { 1, 1, 1 } + Radius = Radius or 1000 + Alpha = Alpha or 1 + Segments = Segments or 10 + Closed = Closed or false + local i = 1 + local j = #self._.Polygon + if (Closed) then + Limit = #self._.Polygon + 1 + else + Limit = #self._.Polygon + end + while i <= #self._.Polygon do + self:T( { i, j, self._.Polygon[i], self._.Polygon[j] } ) + if j ~= Limit then + local DeltaX = self._.Polygon[j].x - self._.Polygon[i].x + local DeltaY = self._.Polygon[j].y - self._.Polygon[i].y + for Segment = 0, Segments do + local PointX = self._.Polygon[i].x + (Segment * DeltaX / Segments) + local PointY = self._.Polygon[i].y + (Segment * DeltaY / Segments) + ZONE_RADIUS:New( "Zone", { x = PointX, y = PointY }, Radius ):DrawZone( Coalition, Color, 1, Color, Alpha, nil, true ) + end end - while i <= #self._.Polygon do - self:T( { i, j, self._.Polygon[i], self._.Polygon[j] } ) - if j ~= Limit then - local DeltaX = self._.Polygon[j].x - self._.Polygon[i].x - local DeltaY = self._.Polygon[j].y - self._.Polygon[i].y - for Segment = 0, Segments do - local PointX = self._.Polygon[i].x + ( Segment * DeltaX / Segments ) - local PointY = self._.Polygon[i].y + ( Segment * DeltaY / Segments ) - ZONE_RADIUS:New( "Zone", {x = PointX, y = PointY}, Radius ):DrawZone(Coalition, Color, 1, Color, Alpha, nil, true) - end - end - j = i - i = i + 1 - end - return self + j = i + i = i + 1 + end + return self end --- @type ZONE_POLYGON -- @extends #ZONE_POLYGON_BASE - --- The ZONE_POLYGON class defined by a sequence of @{Wrapper.Group#GROUP} waypoints within the Mission Editor, forming a polygon. -- This class implements the inherited functions from @{Core.Zone#ZONE_RADIUS} taking into account the own zone format and properties. -- @@ -2095,8 +2043,8 @@ end -- -- @field #ZONE_POLYGON ZONE_POLYGON = { - ClassName="ZONE_POLYGON", - } + ClassName = "ZONE_POLYGON", +} --- Constructor to create a ZONE_POLYGON instance, taking the zone name and the @{Wrapper.Group#GROUP} defined within the Mission Editor. -- The @{Wrapper.Group#GROUP} waypoints define the polygon corners. The first and the last point are automatically connected by ZONE_POLYGON. @@ -2117,7 +2065,6 @@ function ZONE_POLYGON:New( ZoneName, ZoneGroup ) return self end - --- Constructor to create a ZONE_POLYGON instance, taking the zone name and the **name** of the @{Wrapper.Group#GROUP} defined within the Mission Editor. -- The @{Wrapper.Group#GROUP} waypoints define the polygon corners. The first and the last point are automatically connected by ZONE_POLYGON. -- @param #ZONE_POLYGON self @@ -2138,7 +2085,6 @@ function ZONE_POLYGON:NewFromGroupName( GroupName ) return self end - --- Find a polygon zone in the _DATABASE using the name of the polygon zone. -- @param #ZONE_POLYGON self -- @param #string ZoneName The name of the polygon zone. @@ -2154,16 +2100,13 @@ do -- ZONE_AIRBASE --- @type ZONE_AIRBASE -- @extends #ZONE_RADIUS - --- The ZONE_AIRBASE class defines by a zone around a @{Wrapper.Airbase#AIRBASE} with a radius. -- This class implements the inherited functions from @{Core.Zone#ZONE_RADIUS} taking into account the own zone format and properties. -- -- @field #ZONE_AIRBASE ZONE_AIRBASE = { - ClassName="ZONE_AIRBASE", - } - - + ClassName = "ZONE_AIRBASE", + } --- Constructor to create a ZONE_AIRBASE instance, taking the zone name, a zone @{Wrapper.Airbase#AIRBASE} and a radius. -- @param #ZONE_AIRBASE self @@ -2172,7 +2115,7 @@ do -- ZONE_AIRBASE -- @return #ZONE_AIRBASE self function ZONE_AIRBASE:New( AirbaseName, Radius ) - Radius=Radius or 4000 + Radius = Radius or 4000 local Airbase = AIRBASE:FindByName( AirbaseName ) @@ -2223,7 +2166,7 @@ do -- ZONE_AIRBASE local Point = {} local Vec2 = self._.ZoneAirbase:GetVec2() - local angle = math.random() * math.pi*2; + local angle = math.random() * math.pi * 2; Point.x = Vec2.x + math.cos( angle ) * math.random() * self:GetRadius(); Point.y = Vec2.y + math.sin( angle ) * math.random() * self:GetRadius(); @@ -2247,5 +2190,4 @@ do -- ZONE_AIRBASE return PointVec2 end - end diff --git a/Moose Development/Moose/Functional/Artillery.lua b/Moose Development/Moose/Functional/Artillery.lua index 8f7192641..f611ff58d 100644 --- a/Moose Development/Moose/Functional/Artillery.lua +++ b/Moose Development/Moose/Functional/Artillery.lua @@ -73,7 +73,7 @@ -- @field Core.Point#COORDINATE RearmingPlaceCoord Coordinates of the rearming place. If the place is more than 100 m away from the ARTY group, the group will go there. -- @field #boolean RearmingArtyOnRoad If true, ARTY group will move to rearming place using mainly roads. Default false. -- @field Core.Point#COORDINATE InitialCoord Initial coordinates of the ARTY group. --- @field #boolean report Arty group sends messages about their current state or target to its coaliton. +-- @field #boolean report Arty group sends messages about their current state or target to its coalition. -- @field #table ammoshells Table holding names of the shell types which are included when counting the ammo. Default is {"weapons.shells"} which include most shells. -- @field #table ammorockets Table holding names of the rocket types which are included when counting the ammo. Default is {"weapons.nurs"} which includes most unguided rockets. -- @field #table ammomissiles Table holding names of the missile types which are included when counting the ammo. Default is {"weapons.missiles"} which includes some guided missiles. diff --git a/Moose Development/Moose/Functional/RAT.lua b/Moose Development/Moose/Functional/RAT.lua index bcc2a4fff..39ff5d97c 100644 --- a/Moose Development/Moose/Functional/RAT.lua +++ b/Moose Development/Moose/Functional/RAT.lua @@ -69,7 +69,7 @@ -- @field #string category Category of aircarft: "plane" or "heli". -- @field #number groupsize Number of aircraft in group. -- @field #string friendly Possible departure/destination airport: all=blue+red+neutral, same=spawn+neutral, spawnonly=spawn, blue=blue+neutral, blueonly=blue, red=red+neutral, redonly=red. --- @field #table ctable Table with the valid coalitons from choice self.friendly. +-- @field #table ctable Table with the valid coalitions from choice self.friendly. -- @field #table aircraft Table which holds the basic aircraft properties (speed, range, ...). -- @field #number Vcruisemax Max cruise speed in m/s (250 m/s = 900 km/h = 486 kt) set by user. -- @field #number Vclimb Default climb rate in ft/min. @@ -348,7 +348,7 @@ RAT={ category = nil, -- Category of aircarft: "plane" or "heli". groupsize=nil, -- Number of aircraft in the group. friendly = "same", -- Possible departure/destination airport: same=spawn+neutral, spawnonly=spawn, blue=blue+neutral, blueonly=blue, red=red+neutral, redonly=red, neutral. - ctable = {}, -- Table with the valid coalitons from choice self.friendly. + ctable = {}, -- Table with the valid coalitions from choice self.friendly. aircraft = {}, -- Table which holds the basic aircraft properties (speed, range, ...). Vcruisemax=nil, -- Max cruise speed in set by user. Vclimb=1500, -- Default climb rate in ft/min. @@ -657,7 +657,7 @@ end -- @param #RAT self -- @param #number naircraft (Optional) Number of aircraft to spawn. Default is one aircraft. -- @return #boolean True if spawning was successful or nil if nothing was spawned. --- @usage yak:Spawn(5) will spawn five aircraft. By default aircraft will spawn at neutral and red airports if the template group is part of the red coaliton. +-- @usage yak:Spawn(5) will spawn five aircraft. By default aircraft will spawn at neutral and red airports if the template group is part of the red coalition. function RAT:Spawn(naircraft) -- Make sure that this function is only been called once per RAT object. diff --git a/Moose Development/Moose/Functional/Warehouse.lua b/Moose Development/Moose/Functional/Warehouse.lua index e96feb3b5..2bd6d1e8d 100644 --- a/Moose Development/Moose/Functional/Warehouse.lua +++ b/Moose Development/Moose/Functional/Warehouse.lua @@ -50,7 +50,7 @@ -- @field #boolean Report If true, send status messages to coalition. -- @field Wrapper.Static#STATIC warehouse The phyical warehouse structure. -- @field #string alias Alias of the warehouse. Name its called when sending messages. --- @field Core.Zone#ZONE zone Zone around the warehouse. If this zone is captured, the warehouse and all its assets goes to the capturing coaliton. +-- @field Core.Zone#ZONE zone Zone around the warehouse. If this zone is captured, the warehouse and all its assets goes to the capturing coalition. -- @field Wrapper.Airbase#AIRBASE airbase Airbase the warehouse belongs to. -- @field #string airbasename Name of the airbase associated to the warehouse. -- @field Core.Point#COORDINATE road Closest point to warehouse on road. @@ -764,7 +764,7 @@ -- warehouseBatumi:Load("D:\\My Warehouse Data\\") -- warehouseBatumi:Start() -- --- This sequence loads all assets from file. If a warehouse was captured in the last mission, it also respawns the static warehouse structure with the right coaliton. +-- This sequence loads all assets from file. If a warehouse was captured in the last mission, it also respawns the static warehouse structure with the right coalition. -- However, it due to DCS limitations it is not possible to set the airbase coalition. This has to be done manually in the mission editor. Or alternatively, one could -- spawn some ground units via a self request and let them capture the airbase. -- @@ -1811,7 +1811,7 @@ WAREHOUSE.version="1.0.2" -- DONE: Add shipping lanes between warehouses. -- DONE: Handle cases with immobile units <== should be handled by dispatcher classes. -- DONE: Handle cases for aircraft carriers and other ships. Place warehouse on carrier possible? On others probably not - exclude them? --- DONE: Add general message function for sending to coaliton or debug. +-- DONE: Add general message function for sending to coalition or debug. -- DONE: Fine tune event handlers. -- DONE: Improve generalized attributes. -- DONE: If warehouse is destroyed, all asssets are gone. @@ -3155,7 +3155,7 @@ end -- @param MinAssets (Optional) Minimum number of assets the warehouse should have. Default 0. -- @param #string Descriptor (Optional) Descriptor describing the selected assets which should be in stock. See @{#WAREHOUSE.Descriptor} for possible values. -- @param DescriptorValue (Optional) Descriptor value selecting the type of assets which should be in stock. --- @param DCS#Coalition.side Coalition (Optional) Coalition side of the warehouse. Default is the same coaliton as the present warehouse. Set to false for any coalition. +-- @param DCS#Coalition.side Coalition (Optional) Coalition side of the warehouse. Default is the same coalition as the present warehouse. Set to false for any coalition. -- @param Core.Point#COORDINATE RefCoordinate (Optional) Coordinate to which the closest warehouse is searched. Default is the warehouse calling this function. -- @return #WAREHOUSE The the nearest warehouse object. Or nil if no warehouse is found. -- @return #number The distance to the nearest warehouse in meters. Or nil if no warehouse is found. @@ -3267,7 +3267,7 @@ function WAREHOUSE:onafterStart(From, Event, To) -- Short info. local text=string.format("Starting warehouse %s alias %s:\n",self.warehouse:GetName(), self.alias) - text=text..string.format("Coaliton = %s\n", self:GetCoalitionName()) + text=text..string.format("Coalition = %s\n", self:GetCoalitionName()) text=text..string.format("Country = %s\n", self:GetCountryName()) text=text..string.format("Airbase = %s (category=%d)\n", self:GetAirbaseName(), self:GetAirbaseCategory()) env.info(text) @@ -8460,7 +8460,7 @@ function WAREHOUSE:_GetStockAssetsText(messagetoall) end --- Create or update mark text at warehouse, which is displayed in F10 map showing how many assets of each type are in stock. --- Only the coaliton of the warehouse owner is able to see it. +-- Only the coalition of the warehouse owner is able to see it. -- @param #WAREHOUSE self -- @return #string Text about warehouse stock function WAREHOUSE:_UpdateWarehouseMarkText() diff --git a/Moose Development/Moose/Functional/ZoneCaptureCoalition.lua b/Moose Development/Moose/Functional/ZoneCaptureCoalition.lua index d90dfcca7..9be2c35bf 100644 --- a/Moose Development/Moose/Functional/ZoneCaptureCoalition.lua +++ b/Moose Development/Moose/Functional/ZoneCaptureCoalition.lua @@ -804,7 +804,7 @@ do -- ZONE_CAPTURE_COALITION return IsEmpty end - --- Check if zone is "Guarded", i.e. only one (the defending) coaliton is present inside the zone. + --- Check if zone is "Guarded", i.e. only one (the defending) coalition is present inside the zone. -- @param #ZONE_CAPTURE_COALITION self -- @return #boolean self:IsAllInZoneOfCoalition( self.Coalition ) function ZONE_CAPTURE_COALITION:IsGuarded() @@ -826,7 +826,7 @@ do -- ZONE_CAPTURE_COALITION return IsCaptured end - --- Check if zone is "Attacked", i.e. another coaliton entered the zone. + --- Check if zone is "Attacked", i.e. another coalition entered the zone. -- @param #ZONE_CAPTURE_COALITION self -- @return #boolean self:IsSomeInZoneOfCoalition( self.Coalition ) function ZONE_CAPTURE_COALITION:IsAttacked() @@ -899,24 +899,23 @@ do -- ZONE_CAPTURE_COALITION end self:I(text) end - + end ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -- Misc Functions ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - --- Update Mark on F10 map. -- @param #ZONE_CAPTURE_COALITION self function ZONE_CAPTURE_COALITION:Mark() - + if self.MarkOn then - + local Coord = self:GetCoordinate() local ZoneName = self:GetZoneName() local State = self:GetState() - + -- Remove marks. if self.MarkRed then Coord:RemoveMark(self.MarkRed) @@ -924,21 +923,21 @@ do -- ZONE_CAPTURE_COALITION if self.MarkBlue then Coord:RemoveMark(self.MarkBlue) end - - -- Create new marks for each coaliton. + + -- Create new marks for each coalition. if self.Coalition == coalition.side.BLUE then - self.MarkBlue = Coord:MarkToCoalitionBlue( "Coalition: Blue\nGuard Zone: " .. ZoneName .. "\nStatus: " .. State ) + self.MarkBlue = Coord:MarkToCoalitionBlue( "Coalition: Blue\nGuard Zone: " .. ZoneName .. "\nStatus: " .. State ) self.MarkRed = Coord:MarkToCoalitionRed( "Coalition: Blue\nCapture Zone: " .. ZoneName .. "\nStatus: " .. State ) elseif self.Coalition == coalition.side.RED then - self.MarkRed = Coord:MarkToCoalitionRed( "Coalition: Red\nGuard Zone: " .. ZoneName .. "\nStatus: " .. State ) + self.MarkRed = Coord:MarkToCoalitionRed( "Coalition: Red\nGuard Zone: " .. ZoneName .. "\nStatus: " .. State ) self.MarkBlue = Coord:MarkToCoalitionBlue( "Coalition: Red\nCapture Zone: " .. ZoneName .. "\nStatus: " .. State ) else - self.MarkRed = Coord:MarkToCoalitionRed( "Coalition: Neutral\nCapture Zone: " .. ZoneName .. "\nStatus: " .. State ) + self.MarkRed = Coord:MarkToCoalitionRed( "Coalition: Neutral\nCapture Zone: " .. ZoneName .. "\nStatus: " .. State ) self.MarkBlue = Coord:MarkToCoalitionBlue( "Coalition: Neutral\nCapture Zone: " .. ZoneName .. "\nStatus: " .. State ) end - + end - + end end diff --git a/Moose Development/Moose/Functional/ZoneGoalCoalition.lua b/Moose Development/Moose/Functional/ZoneGoalCoalition.lua index 6296b4835..d2086f1ad 100644 --- a/Moose Development/Moose/Functional/ZoneGoalCoalition.lua +++ b/Moose Development/Moose/Functional/ZoneGoalCoalition.lua @@ -1,16 +1,16 @@ --- **Functional (WIP)** -- Base class that models processes to achieve goals involving a Zone for a Coalition. -- -- === --- --- ZONE_GOAL_COALITION models processes that have a Goal with a defined achievement involving a Zone for a Coalition. +-- +-- ZONE_GOAL_COALITION models processes that have a Goal with a defined achievement involving a Zone for a Coalition. -- Derived classes implement the ways how the achievements can be realized. --- +-- -- === --- +-- -- ### Author: **FlightControl** --- +-- -- === --- +-- -- @module Functional.ZoneGoalCoalition -- @image MOOSE.JPG @@ -24,34 +24,33 @@ do -- ZoneGoal -- @field #table ObjectCategories Table of object categories that are able to hold a zone. Default is UNITS and STATICS. -- @extends Functional.ZoneGoal#ZONE_GOAL - - --- ZONE_GOAL_COALITION models processes that have a Goal with a defined achievement involving a Zone for a Coalition. + --- ZONE_GOAL_COALITION models processes that have a Goal with a defined achievement involving a Zone for a Coalition. -- Derived classes implement the ways how the achievements can be realized. - -- + -- -- ## 1. ZONE_GOAL_COALITION constructor - -- + -- -- * @{#ZONE_GOAL_COALITION.New}(): Creates a new ZONE_GOAL_COALITION object. - -- + -- -- ## 2. ZONE_GOAL_COALITION is a finite state machine (FSM). - -- + -- -- ### 2.1 ZONE_GOAL_COALITION States - -- + -- -- ### 2.2 ZONE_GOAL_COALITION Events - -- + -- -- ### 2.3 ZONE_GOAL_COALITION State Machine - -- + -- -- @field #ZONE_GOAL_COALITION ZONE_GOAL_COALITION = { - ClassName = "ZONE_GOAL_COALITION", - Coalition = nil, - PreviousCoaliton = nil, - UnitCategories = nil, + ClassName = "ZONE_GOAL_COALITION", + Coalition = nil, + PreviousCoalition = nil, + UnitCategories = nil, ObjectCategories = nil, } - + --- @field #table ZONE_GOAL_COALITION.States ZONE_GOAL_COALITION.States = {} - + --- ZONE_GOAL_COALITION Constructor. -- @param #ZONE_GOAL_COALITION self -- @param Core.Zone#ZONE Zone A @{Zone} object with the goal to be achieved. @@ -59,33 +58,32 @@ do -- ZoneGoal -- @param #table UnitCategories Table of unit categories. See [DCS Class Unit](https://wiki.hoggitworld.com/view/DCS_Class_Unit). Default {Unit.Category.GROUND_UNIT}. -- @return #ZONE_GOAL_COALITION function ZONE_GOAL_COALITION:New( Zone, Coalition, UnitCategories ) - + if not Zone then - BASE:E("ERROR: No Zone specified in ZONE_GOAL_COALITON!") + BASE:E( "ERROR: No Zone specified in ZONE_GOAL_COALITION!" ) return nil end - + -- Inherit ZONE_GOAL. local self = BASE:Inherit( self, ZONE_GOAL:New( Zone ) ) -- #ZONE_GOAL_COALITION - self:F( { Zone = Zone, Coalition = Coalition } ) + self:F( { Zone = Zone, Coalition = Coalition } ) -- Set initial owner. - self:SetCoalition( Coalition or coalition.side.NEUTRAL) - + self:SetCoalition( Coalition or coalition.side.NEUTRAL ) + -- Set default unit and object categories for the zone scan. - self:SetUnitCategories(UnitCategories) + self:SetUnitCategories( UnitCategories ) self:SetObjectCategories() - + return self end - --- Set the owning coalition of the zone. -- @param #ZONE_GOAL_COALITION self -- @param DCSCoalition.DCSCoalition#coalition Coalition The coalition ID, e.g. *coalition.side.RED*. -- @return #ZONE_GOAL_COALITION function ZONE_GOAL_COALITION:SetCoalition( Coalition ) - self.PreviousCoalition=self.Coalition or Coalition + self.PreviousCoalition = self.Coalition or Coalition self.Coalition = Coalition return self end @@ -95,31 +93,31 @@ do -- ZoneGoal -- @param #table UnitCategories Table of unit categories. See [DCS Class Unit](https://wiki.hoggitworld.com/view/DCS_Class_Unit). Default {Unit.Category.GROUND_UNIT}. -- @return #ZONE_GOAL_COALITION function ZONE_GOAL_COALITION:SetUnitCategories( UnitCategories ) - - if UnitCategories and type(UnitCategories)~="table" then - UnitCategories={UnitCategories} + + if UnitCategories and type( UnitCategories ) ~= "table" then + UnitCategories = { UnitCategories } end - - self.UnitCategories=UnitCategories or {Unit.Category.GROUND_UNIT} - + + self.UnitCategories = UnitCategories or { Unit.Category.GROUND_UNIT } + return self end - + --- Set the owning coalition of the zone. -- @param #ZONE_GOAL_COALITION self -- @param #table ObjectCategories Table of unit categories. See [DCS Class Object](https://wiki.hoggitworld.com/view/DCS_Class_Object). Default {Object.Category.UNIT, Object.Category.STATIC}, i.e. all UNITS and STATICS. -- @return #ZONE_GOAL_COALITION function ZONE_GOAL_COALITION:SetObjectCategories( ObjectCategories ) - - if ObjectCategories and type(ObjectCategories)~="table" then - ObjectCategories={ObjectCategories} + + if ObjectCategories and type( ObjectCategories ) ~= "table" then + ObjectCategories = { ObjectCategories } end - - self.ObjectCategories=ObjectCategories or {Object.Category.UNIT, Object.Category.STATIC} - + + self.ObjectCategories = ObjectCategories or { Object.Category.UNIT, Object.Category.STATIC } + return self - end - + end + --- Get the owning coalition of the zone. -- @param #ZONE_GOAL_COALITION self -- @return DCSCoalition.DCSCoalition#coalition Coalition. @@ -127,39 +125,37 @@ do -- ZoneGoal return self.Coalition end - --- Get the previous coaliton, i.e. the one owning the zone before the current one. + --- Get the previous coalition, i.e. the one owning the zone before the current one. -- @param #ZONE_GOAL_COALITION self -- @return DCSCoalition.DCSCoalition#coalition Coalition. function ZONE_GOAL_COALITION:GetPreviousCoalition() return self.PreviousCoalition end - --- Get the owning coalition name of the zone. -- @param #ZONE_GOAL_COALITION self -- @return #string Coalition name. function ZONE_GOAL_COALITION:GetCoalitionName() - return UTILS.GetCoalitionName(self.Coalition) + return UTILS.GetCoalitionName( self.Coalition ) end - --- Check status Coalition ownership. -- @param #ZONE_GOAL_COALITION self -- @return #ZONE_GOAL_COALITION function ZONE_GOAL_COALITION:StatusZone() - + -- Get current state. local State = self:GetState() - + -- Debug text. - local text=string.format("Zone state=%s, Owner=%s, Scanning...", State, self:GetCoalitionName()) - self:F(text) - + local text = string.format( "Zone state=%s, Owner=%s, Scanning...", State, self:GetCoalitionName() ) + self:F( text ) + -- Scan zone. self:Scan( self.ObjectCategories, self.UnitCategories ) - + return self end - + end diff --git a/Moose Development/Moose/Ops/Airboss.lua b/Moose Development/Moose/Ops/Airboss.lua index 853295f5a..d2d0f6657 100644 --- a/Moose Development/Moose/Ops/Airboss.lua +++ b/Moose Development/Moose/Ops/Airboss.lua @@ -6058,7 +6058,7 @@ function AIRBOSS:_RefuelAI( flight ) -- Guide AI to divert field -- ------------------------------ - -- Closest Airfield of the coaliton. + -- Closest Airfield of the coalition. local divertfield = self:GetCoordinate():GetClosestAirbase( Airbase.Category.AIRDROME, self:GetCoalition() ) -- Handle case where there is no divert field of the own coalition and try neutral instead. diff --git a/Moose Development/Moose/Tasking/Mission.lua b/Moose Development/Moose/Tasking/Mission.lua index f057c9648..e8da4f102 100644 --- a/Moose Development/Moose/Tasking/Mission.lua +++ b/Moose Development/Moose/Tasking/Mission.lua @@ -132,7 +132,7 @@ MISSION = { -- @param #string MissionName Name of the mission. This name will be used to reference the status of each mission by the players. -- @param #string MissionPriority String indicating the "priority" of the Mission. e.g. "Primary", "Secondary". It is free format and up to the Mission designer to choose. There are no rules behind this field. -- @param #string MissionBriefing String indicating the mission briefing to be shown when a player joins a @{CLIENT}. --- @param DCS#coaliton.side MissionCoalition Side of the coalition, i.e. and enumerator @{#DCS.coalition.side} corresponding to RED, BLUE or NEUTRAL. +-- @param DCS#coalition.side MissionCoalition Side of the coalition, i.e. and enumerator @{#DCS.coalition.side} corresponding to RED, BLUE or NEUTRAL. -- @return #MISSION self function MISSION:New( CommandCenter, MissionName, MissionPriority, MissionBriefing, MissionCoalition ) diff --git a/Moose Development/Moose/Tasking/Task.lua b/Moose Development/Moose/Tasking/Task.lua index 7cd79f453..f553cfc71 100644 --- a/Moose Development/Moose/Tasking/Task.lua +++ b/Moose Development/Moose/Tasking/Task.lua @@ -82,7 +82,7 @@ -- -- ![Mission](../Tasking/Report_Statistics_Progress.JPG) -- --- A statistic report on the progress of the mission. Each task achievement will increase the %-tage to 100% as a goal to complete the task. +-- A statistic report on the progress of the mission. Each task achievement will increase the % to 100% as a goal to complete the task. -- -- ## 1.3) Join a Task. -- diff --git a/Moose Development/Moose/Utilities/Utils.lua b/Moose Development/Moose/Utilities/Utils.lua index 671fbb347..6ef1b9f68 100644 --- a/Moose Development/Moose/Utilities/Utils.lua +++ b/Moose Development/Moose/Utilities/Utils.lua @@ -1353,7 +1353,7 @@ function UTILS.CheckMemory( output ) return mem end ---- Get the coalition name from its numerical ID, e.g. coaliton.side.RED. +--- Get the coalition name from its numerical ID, e.g. coalition.side.RED. -- @param #number Coalition The coalition ID. -- @return #string The coalition name, i.e. "Neutral", "Red" or "Blue" (or "Unknown"). function UTILS.GetCoalitionName( Coalition ) diff --git a/Moose Development/Moose/Wrapper/Controllable.lua b/Moose Development/Moose/Wrapper/Controllable.lua index 97a0e22d3..963558549 100644 --- a/Moose Development/Moose/Wrapper/Controllable.lua +++ b/Moose Development/Moose/Wrapper/Controllable.lua @@ -1,4 +1,4 @@ - --- **Wrapper** -- CONTROLLABLE is an intermediate class wrapping Group and Unit classes "controllers". +--- **Wrapper** -- CONTROLLABLE is an intermediate class wrapping Group and Unit classes "controllers". -- -- === -- @@ -11,14 +11,11 @@ -- @module Wrapper.Controllable -- @image Wrapper_Controllable.JPG - --- @type CONTROLLABLE -- @field DCS#Controllable DCSControllable The DCS controllable class. -- @field #string ControllableName The name of the controllable. -- @extends Wrapper.Positionable#POSITIONABLE - - --- Wrapper class to handle the "DCS Controllable objects", which are Groups and Units: -- -- * Support all DCS Controllable APIs. @@ -62,10 +59,10 @@ -- * @{#CONTROLLABLE.TaskHoldPosition}: (AIR) Hold position at the current position of the first unit of the controllable. -- * @{#CONTROLLABLE.TaskLand}: (AIR HELICOPTER) Landing at the ground. For helicopters only. -- * @{#CONTROLLABLE.TaskLandAtZone}: (AIR) Land the controllable at a @{Core.Zone#ZONE_RADIUS). --- * @{#CONTROLLABLE.TaskOrbitCircle}: (AIR) Orbit at the current position of the first unit of the controllable at a specified alititude. --- * @{#CONTROLLABLE.TaskOrbitCircleAtVec2}: (AIR) Orbit at a specified position at a specified alititude during a specified duration with a specified speed. +-- * @{#CONTROLLABLE.TaskOrbitCircle}: (AIR) Orbit at the current position of the first unit of the controllable at a specified altitude. +-- * @{#CONTROLLABLE.TaskOrbitCircleAtVec2}: (AIR) Orbit at a specified position at a specified altitude during a specified duration with a specified speed. -- * @{#CONTROLLABLE.TaskRefueling}: (AIR) Refueling from the nearest tanker. No parameters. --- * @{#CONTROLLABLE.TaskRoute}: (AIR + GROUND) Return a Misson task to follow a given route defined by Points. +-- * @{#CONTROLLABLE.TaskRoute}: (AIR + GROUND) Return a Mission task to follow a given route defined by Points. -- * @{#CONTROLLABLE.TaskRouteToVec2}: (AIR + GROUND) Make the Controllable move to a given point. -- * @{#CONTROLLABLE.TaskRouteToVec3}: (AIR + GROUND) Make the Controllable move to a given point. -- * @{#CONTROLLABLE.TaskRouteToZone}: (AIR + GROUND) Route the controllable to a given zone. @@ -86,7 +83,7 @@ -- -- ## 2.3) Task preparation -- --- There are certain task methods that allow to tailor the task behaviour: +-- There are certain task methods that allow to tailor the task behavior: -- -- * @{#CONTROLLABLE.TaskWrappedAction}: Return a WrappedAction Task taking a Command. -- * @{#CONTROLLABLE.TaskCombo}: Return a Combo Task taking an array of Tasks. @@ -133,7 +130,7 @@ -- -- # 5) Option methods -- --- Controllable **Option methods** change the behaviour of the Controllable while being alive. +-- Controllable **Option methods** change the behavior of the Controllable while being alive. -- -- ## 5.1) Rule of Engagement: -- @@ -190,7 +187,7 @@ CONTROLLABLE = { -- @return #CONTROLLABLE self function CONTROLLABLE:New( ControllableName ) local self = BASE:Inherit( self, POSITIONABLE:New( ControllableName ) ) -- #CONTROLLABLE - --self:F( ControllableName ) + -- self:F( ControllableName ) self.ControllableName = ControllableName self.TaskScheduler = SCHEDULER:New( self ) @@ -215,7 +212,6 @@ end -- Get methods - --- Returns the health. Dead controllables have health <= 1.0. -- @param #CONTROLLABLE self -- @return #number The controllable health value (unit or group average). @@ -274,7 +270,7 @@ function CONTROLLABLE:GetLife0() end --- Returns relative minimum amount of fuel (from 0.0 to 1.0) a unit or group has in its internal tanks. --- This method returns nil to ensure polymorphic behaviour! This method needs to be overridden by GROUP or UNIT. +-- This method returns nil to ensure polymorphic behavior! This method needs to be overridden by GROUP or UNIT. -- @param #CONTROLLABLE self -- @return #nil The CONTROLLABLE is not existing or alive. function CONTROLLABLE:GetFuelMin() @@ -284,7 +280,7 @@ function CONTROLLABLE:GetFuelMin() end --- Returns relative average amount of fuel (from 0.0 to 1.0) a unit or group has in its internal tanks. --- This method returns nil to ensure polymorphic behaviour! This method needs to be overridden by GROUP or UNIT. +-- This method returns nil to ensure polymorphic behavior! This method needs to be overridden by GROUP or UNIT. -- @param #CONTROLLABLE self -- @return #nil The CONTROLLABLE is not existing or alive. function CONTROLLABLE:GetFuelAve() @@ -294,7 +290,7 @@ function CONTROLLABLE:GetFuelAve() end --- Returns relative amount of fuel (from 0.0 to 1.0) the unit has in its internal tanks. --- This method returns nil to ensure polymorphic behaviour! This method needs to be overridden by GROUP or UNIT. +-- This method returns nil to ensure polymorphic behavior! This method needs to be overridden by GROUP or UNIT. -- @param #CONTROLLABLE self -- @return #nil The CONTROLLABLE is not existing or alive. function CONTROLLABLE:GetFuel() @@ -302,7 +298,6 @@ function CONTROLLABLE:GetFuel() return nil end - -- Tasks --- Clear all tasks from the controllable. @@ -321,7 +316,6 @@ function CONTROLLABLE:ClearTasks() return nil end - --- Popping current Task from the controllable. -- @param #CONTROLLABLE self -- @return Wrapper.Controllable#CONTROLLABLE self @@ -399,7 +393,7 @@ function CONTROLLABLE:SetTask( DCSTask, WaitTime ) local function SetTask( Controller, DCSTask ) if self and self:IsAlive() then local Controller = self:_GetController() - --self:I( "Before SetTask" ) + -- self:I( "Before SetTask" ) Controller:setTask( DCSTask ) -- AI_FORMATION class (used by RESCUEHELO) calls SetTask twice per second! hence spamming the DCS log file ==> setting this to trace. self:T( { ControllableName = self:GetName(), DCSTask = DCSTask } ) @@ -425,7 +419,7 @@ end --- Checking the Task Queue of the controllable. Returns false if no task is on the queue. true if there is a task. -- @param #CONTROLLABLE self -- @return Wrapper.Controllable#CONTROLLABLE self -function CONTROLLABLE:HasTask() --R2.2 +function CONTROLLABLE:HasTask() -- R2.2 local HasTaskResult = false @@ -440,7 +434,6 @@ function CONTROLLABLE:HasTask() --R2.2 return HasTaskResult end - --- Return a condition section for a controlled task. -- @param #CONTROLLABLE self -- @param DCS#Time time DCS mission time. @@ -452,7 +445,7 @@ end -- return DCS#Task function CONTROLLABLE:TaskCondition( time, userFlag, userFlagValue, condition, duration, lastWayPoint ) ---[[ + --[[ StopCondition = { time = Time, userFlag = string, @@ -485,8 +478,8 @@ function CONTROLLABLE:TaskControlled( DCSTask, DCSStopCondition ) id = 'ControlledTask', params = { task = DCSTask, - stopCondition = DCSStopCondition - } + stopCondition = DCSStopCondition, + }, } return DCSTaskControlled @@ -501,8 +494,8 @@ function CONTROLLABLE:TaskCombo( DCSTasks ) local DCSTaskCombo = { id = 'ComboTask', params = { - tasks = DCSTasks - } + tasks = DCSTasks, + }, } return DCSTaskCombo @@ -540,9 +533,6 @@ function CONTROLLABLE:SetTaskWaypoint( Waypoint, Task ) return Waypoint.task end - - - --- Executes a command action for the CONTROLLABLE. -- @param #CONTROLLABLE self -- @param DCS#Command DCSCommand The command to be executed. @@ -567,17 +557,18 @@ end -- @param #number ToWayPoint -- @return DCS#Task -- @usage --- --- This test demonstrates the use(s) of the SwitchWayPoint method of the GROUP class. --- HeliGroup = GROUP:FindByName( "Helicopter" ) -- --- --- Route the helicopter back to the FARP after 60 seconds. --- -- We use the SCHEDULER class to do this. --- SCHEDULER:New( nil, --- function( HeliGroup ) --- local CommandRTB = HeliGroup:CommandSwitchWayPoint( 2, 8 ) --- HeliGroup:SetCommand( CommandRTB ) --- end, { HeliGroup }, 90 --- ) +-- -- This test demonstrates the use(s) of the SwitchWayPoint method of the GROUP class. +-- HeliGroup = GROUP:FindByName( "Helicopter" ) +-- +-- -- Route the helicopter back to the FARP after 60 seconds. +-- -- We use the SCHEDULER class to do this. +-- SCHEDULER:New( nil, +-- function( HeliGroup ) +-- local CommandRTB = HeliGroup:CommandSwitchWayPoint( 2, 8 ) +-- HeliGroup:SetCommand( CommandRTB ) +-- end, { HeliGroup }, 90 +-- ) function CONTROLLABLE:CommandSwitchWayPoint( FromWayPoint, ToWayPoint ) self:F2( { FromWayPoint, ToWayPoint } ) @@ -619,16 +610,15 @@ function CONTROLLABLE:CommandStopRoute( StopRoute ) return CommandStopRoute end - --- Give an uncontrolled air controllable the start command. -- @param #CONTROLLABLE self -- @param #number delay (Optional) Delay before start command in seconds. -- @return #CONTROLLABLE self -function CONTROLLABLE:StartUncontrolled(delay) - if delay and delay>0 then - SCHEDULER:New(nil, CONTROLLABLE.StartUncontrolled, {self}, delay) +function CONTROLLABLE:StartUncontrolled( delay ) + if delay and delay > 0 then + SCHEDULER:New( nil, CONTROLLABLE.StartUncontrolled, { self }, delay ) else - self:SetCommand({id='Start', params={}}) + self:SetCommand( { id = 'Start', params = {} } ) end return self end @@ -640,7 +630,7 @@ end -- @param Core.Radio#BEACON.Type Type Beacon type (VOR, DME, TACAN, RSBN, ILS etc). -- @param Core.Radio#BEACON.System System Beacon system (VOR, DME, TACAN, RSBN, ILS etc). -- @param #number Frequency Frequency in Hz the beacon is running on. Use @{#UTILS.TACANToFrequency} to generate a frequency for TACAN beacons. --- @param #number UnitID The ID of the unit the beacon is attached to. Usefull if more units are in one group. +-- @param #number UnitID The ID of the unit the beacon is attached to. Useful if more units are in one group. -- @param #number Channel Channel the beacon is using. For, e.g. TACAN beacons. -- @param #string ModeChannel The TACAN mode of the beacon, i.e. "X" or "Y". -- @param #boolean AA If true, create and Air-Air beacon. IF nil, automatically set if CONTROLLABLE depending on whether unit is and aircraft or not. @@ -648,13 +638,13 @@ end -- @param #boolean Bearing If true, beacon provides bearing information - if supported by the unit the beacon is attached to. -- @param #number Delay (Optional) Delay in seconds before the beacon is activated. -- @return #CONTROLLABLE self -function CONTROLLABLE:CommandActivateBeacon(Type, System, Frequency, UnitID, Channel, ModeChannel, AA, Callsign, Bearing, Delay) +function CONTROLLABLE:CommandActivateBeacon( Type, System, Frequency, UnitID, Channel, ModeChannel, AA, Callsign, Bearing, Delay ) - AA=AA or self:IsAir() - UnitID=UnitID or self:GetID() + AA = AA or self:IsAir() + UnitID = UnitID or self:GetID() -- Command - local CommandActivateBeacon= { + local CommandActivateBeacon = { id = "ActivateBeacon", params = { ["type"] = Type, @@ -666,13 +656,13 @@ function CONTROLLABLE:CommandActivateBeacon(Type, System, Frequency, UnitID, Cha ["AA"] = AA, ["callsign"] = Callsign, ["bearing"] = Bearing, - } + }, } - if Delay and Delay>0 then - SCHEDULER:New(nil, self.CommandActivateBeacon, {self, Type, System, Frequency, UnitID, Channel, ModeChannel, AA, Callsign, Bearing}, Delay) + if Delay and Delay > 0 then + SCHEDULER:New( nil, self.CommandActivateBeacon, { self, Type, System, Frequency, UnitID, Channel, ModeChannel, AA, Callsign, Bearing }, Delay ) else - self:SetCommand(CommandActivateBeacon) + self:SetCommand( CommandActivateBeacon ) end return self @@ -685,42 +675,41 @@ end -- @param #string Callsign Morse code identification callsign. -- @param #number Delay (Optional) Delay in seconds before the ICLS is deactivated. -- @return #CONTROLLABLE self -function CONTROLLABLE:CommandActivateICLS(Channel, UnitID, Callsign, Delay) +function CONTROLLABLE:CommandActivateICLS( Channel, UnitID, Callsign, Delay ) -- Command to activate ICLS system. - local CommandActivateICLS= { + local CommandActivateICLS = { id = "ActivateICLS", - params= { + params = { ["type"] = BEACON.Type.ICLS, ["channel"] = Channel, ["unitId"] = UnitID, ["callsign"] = Callsign, - } + }, } - if Delay and Delay>0 then - SCHEDULER:New(nil, self.CommandActivateICLS, {self}, Delay) + if Delay and Delay > 0 then + SCHEDULER:New( nil, self.CommandActivateICLS, { self }, Delay ) else - self:SetCommand(CommandActivateICLS) + self:SetCommand( CommandActivateICLS ) end return self end - --- Deactivate the active beacon of the CONTROLLABLE. -- @param #CONTROLLABLE self -- @param #number Delay (Optional) Delay in seconds before the beacon is deactivated. -- @return #CONTROLLABLE self -function CONTROLLABLE:CommandDeactivateBeacon(Delay) +function CONTROLLABLE:CommandDeactivateBeacon( Delay ) -- Command to deactivate - local CommandDeactivateBeacon={id='DeactivateBeacon', params={}} + local CommandDeactivateBeacon = { id = 'DeactivateBeacon', params = {} } - if Delay and Delay>0 then - SCHEDULER:New(nil, self.CommandActivateBeacon, {self}, Delay) + if Delay and Delay > 0 then + SCHEDULER:New( nil, self.CommandActivateBeacon, { self }, Delay ) else - self:SetCommand(CommandDeactivateBeacon) + self:SetCommand( CommandDeactivateBeacon ) end return self @@ -730,15 +719,15 @@ end -- @param #CONTROLLABLE self -- @param #number Delay (Optional) Delay in seconds before the ICLS is deactivated. -- @return #CONTROLLABLE self -function CONTROLLABLE:CommandDeactivateICLS(Delay) +function CONTROLLABLE:CommandDeactivateICLS( Delay ) -- Command to deactivate - local CommandDeactivateICLS={id='DeactivateICLS', params={}} + local CommandDeactivateICLS = { id = 'DeactivateICLS', params = {} } - if Delay and Delay>0 then - SCHEDULER:New(nil, self.CommandDeactivateICLS, {self}, Delay) + if Delay and Delay > 0 then + SCHEDULER:New( nil, self.CommandDeactivateICLS, { self }, Delay ) else - self:SetCommand(CommandDeactivateICLS) + self:SetCommand( CommandDeactivateICLS ) end return self @@ -750,15 +739,15 @@ end -- @param #number CallNumber The number value the group will be referred to as. Only valid numbers are 1-9. For example Uzi **5**-1. Default 1. -- @param #number Delay (Optional) Delay in seconds before the callsign is set. Default is immediately. -- @return #CONTROLLABLE self -function CONTROLLABLE:CommandSetCallsign(CallName, CallNumber, Delay) +function CONTROLLABLE:CommandSetCallsign( CallName, CallNumber, Delay ) -- Command to set the callsign. - local CommandSetCallsign={id='SetCallsign', params={callname=CallName, number=CallNumber or 1}} + local CommandSetCallsign = { id = 'SetCallsign', params = { callname = CallName, number = CallNumber or 1 } } - if Delay and Delay>0 then - SCHEDULER:New(nil, self.CommandSetCallsign, {self, CallName, CallNumber}, Delay) + if Delay and Delay > 0 then + SCHEDULER:New( nil, self.CommandSetCallsign, { self, CallName, CallNumber }, Delay ) else - self:SetCommand(CommandSetCallsign) + self:SetCommand( CommandSetCallsign ) end return self @@ -769,26 +758,26 @@ end -- @param #boolean SwitchOnOff If true (or nil) switch EPLRS on. If false switch off. -- @param #number Delay (Optional) Delay in seconds before the callsign is set. Default is immediately. -- @return #CONTROLLABLE self -function CONTROLLABLE:CommandEPLRS(SwitchOnOff, Delay) +function CONTROLLABLE:CommandEPLRS( SwitchOnOff, Delay ) - if SwitchOnOff==nil then - SwitchOnOff=true + if SwitchOnOff == nil then + SwitchOnOff = true end -- Command to set the callsign. - local CommandEPLRS={ - id='EPLRS', - params={ - value=SwitchOnOff, - groupId=self:GetID() - } + local CommandEPLRS = { + id = 'EPLRS', + params = { + value = SwitchOnOff, + groupId = self:GetID(), + }, } - if Delay and Delay>0 then - SCHEDULER:New(nil, self.CommandEPLRS, {self, SwitchOnOff}, Delay) + if Delay and Delay > 0 then + SCHEDULER:New( nil, self.CommandEPLRS, { self, SwitchOnOff }, Delay ) else - self:T(string.format("EPLRS=%s for controllable %s (id=%s)", tostring(SwitchOnOff), tostring(self:GetName()), tostring(self:GetID()))) - self:SetCommand(CommandEPLRS) + self:T( string.format( "EPLRS=%s for controllable %s (id=%s)", tostring( SwitchOnOff ), tostring( self:GetName() ), tostring( self:GetID() ) ) ) + self:SetCommand( CommandEPLRS ) end return self @@ -798,52 +787,50 @@ end -- @param #CONTROLLABLE self -- @param #number Frequency Radio frequency in MHz. -- @param #number Modulation Radio modulation. Default `radio.modulation.AM`. --- @param #number Delay (Optional) Delay in seconds before the frequncy is set. Default is immediately. +-- @param #number Delay (Optional) Delay in seconds before the frequency is set. Default is immediately. -- @return #CONTROLLABLE self -function CONTROLLABLE:CommandSetFrequency(Frequency, Modulation, Delay) +function CONTROLLABLE:CommandSetFrequency( Frequency, Modulation, Delay ) local CommandSetFrequency = { id = 'SetFrequency', params = { - frequency = Frequency*1000000, + frequency = Frequency * 1000000, modulation = Modulation or radio.modulation.AM, - } + }, } - if Delay and Delay>0 then - SCHEDULER:New(nil, self.CommandSetFrequency, {self, Frequency, Modulation}, Delay) + if Delay and Delay > 0 then + SCHEDULER:New( nil, self.CommandSetFrequency, { self, Frequency, Modulation }, Delay ) else - self:SetCommand(CommandSetFrequency) + self:SetCommand( CommandSetFrequency ) end return self end - --- Set EPLRS data link on/off. -- @param #CONTROLLABLE self -- @param #boolean SwitchOnOff If true (or nil) switch EPLRS on. If false switch off. -- @param #number idx Task index. Default 1. -- @return #table Task wrapped action. -function CONTROLLABLE:TaskEPLRS(SwitchOnOff, idx) +function CONTROLLABLE:TaskEPLRS( SwitchOnOff, idx ) - if SwitchOnOff==nil then - SwitchOnOff=true + if SwitchOnOff == nil then + SwitchOnOff = true end -- Command to set the callsign. - local CommandEPLRS={ - id='EPLRS', - params={ - value=SwitchOnOff, - groupId=self:GetID() - } + local CommandEPLRS = { + id = 'EPLRS', + params = { + value = SwitchOnOff, + groupId = self:GetID(), + }, } - return self:TaskWrappedAction(CommandEPLRS, idx or 1) + return self:TaskWrappedAction( CommandEPLRS, idx or 1 ) end - -- TASKS FOR AIR CONTROLLABLES --- (AIR) Attack a Controllable. @@ -851,14 +838,14 @@ end -- @param Wrapper.Group#GROUP AttackGroup The Group to be attacked. -- @param #number WeaponType (optional) Bitmask of weapon types those allowed to use. If parameter is not defined that means no limits on weapon usage. -- @param DCS#AI.Task.WeaponExpend WeaponExpend (optional) Determines how much weapon will be released at each attack. If parameter is not defined the unit / controllable will choose expend on its own discretion. --- @param #number AttackQty (optional) This parameter limits maximal quantity of attack. The aicraft/controllable will not make more attack than allowed even if the target controllable not destroyed and the aicraft/controllable still have ammo. If not defined the aircraft/controllable will attack target until it will be destroyed or until the aircraft/controllable will run out of ammo. +-- @param #number AttackQty (optional) This parameter limits maximal quantity of attack. The aircraft/controllable will not make more attack than allowed even if the target controllable not destroyed and the aircraft/controllable still have ammo. If not defined the aircraft/controllable will attack target until it will be destroyed or until the aircraft/controllable will run out of ammo. -- @param DCS#Azimuth Direction (optional) Desired ingress direction from the target to the attacking aircraft. Controllable/aircraft will make its attacks from the direction. Of course if there is no way to attack from the direction due the terrain controllable/aircraft will choose another direction. -- @param DCS#Distance Altitude (optional) Desired attack start altitude. Controllable/aircraft will make its attacks from the altitude. If the altitude is too low or too high to use weapon aircraft/controllable will choose closest altitude to the desired attack start altitude. If the desired altitude is defined controllable/aircraft will not attack from safe altitude. -- @param #boolean AttackQtyLimit (optional) The flag determines how to interpret attackQty parameter. If the flag is true then attackQty is a limit on maximal attack quantity for "AttackGroup" and "AttackUnit" tasks. If the flag is false then attackQty is a desired attack quantity for "Bombing" and "BombingRunway" tasks. -- @param #boolean GroupAttack (Optional) If true, attack as group. -- @return DCS#Task The DCS task structure. function CONTROLLABLE:TaskAttackGroup( AttackGroup, WeaponType, WeaponExpend, AttackQty, Direction, Altitude, AttackQtyLimit, GroupAttack ) - --self:F2( { self.ControllableName, AttackGroup, WeaponType, WeaponExpend, AttackQty, Direction, Altitude, AttackQtyLimit } ) + -- self:F2( { self.ControllableName, AttackGroup, WeaponType, WeaponExpend, AttackQty, Direction, Altitude, AttackQtyLimit } ) -- AttackGroup = { -- id = 'AttackGroup', @@ -899,12 +886,12 @@ end -- @param Wrapper.Unit#UNIT AttackUnit The UNIT to be attacked -- @param #boolean GroupAttack (Optional) If true, all units in the group will attack the Unit when found. Default false. -- @param DCS#AI.Task.WeaponExpend WeaponExpend (Optional) Determines how many weapons will be released at each attack. If parameter is not defined the unit / controllable will choose expend on its own discretion. --- @param #number AttackQty (Optional) Limits maximal quantity of attack. The aicraft/controllable will not make more attacks than allowed even if the target controllable not destroyed and the aicraft/controllable still have ammo. If not defined the aircraft/controllable will attack target until it will be destroyed or until the aircraft/controllable will run out of ammo. +-- @param #number AttackQty (Optional) Limits maximal quantity of attack. The aircraft/controllable will not make more attacks than allowed even if the target controllable not destroyed and the aircraft/controllable still have ammo. If not defined the aircraft/controllable will attack target until it will be destroyed or until the aircraft/controllable will run out of ammo. -- @param DCS#Azimuth Direction (Optional) Desired ingress direction from the target to the attacking aircraft. Controllable/aircraft will make its attacks from the direction. -- @param #number Altitude (Optional) The (minimum) altitude in meters from where to attack. Default is altitude of unit to attack but at least 1000 m. -- @param #number WeaponType (optional) The WeaponType. See [DCS Enumerator Weapon Type](https://wiki.hoggitworld.com/view/DCS_enum_weapon_flag) on Hoggit. -- @return DCS#Task The DCS task structure. -function CONTROLLABLE:TaskAttackUnit(AttackUnit, GroupAttack, WeaponExpend, AttackQty, Direction, Altitude, WeaponType) +function CONTROLLABLE:TaskAttackUnit( AttackUnit, GroupAttack, WeaponExpend, AttackQty, Direction, Altitude, WeaponType ) local DCSTask = { id = 'AttackUnit', @@ -919,19 +906,18 @@ function CONTROLLABLE:TaskAttackUnit(AttackUnit, GroupAttack, WeaponExpend, Atta attackQtyLimit = AttackQty and true or false, attackQty = AttackQty, weaponType = WeaponType or 1073741822, - } + }, } return DCSTask end - --- (AIR) Delivering weapon at the point on the ground. -- @param #CONTROLLABLE self -- @param DCS#Vec2 Vec2 2D-coordinates of the point to deliver weapon at. -- @param #boolean GroupAttack (optional) If true, all units in the group will attack the Unit when found. -- @param DCS#AI.Task.WeaponExpend WeaponExpend (optional) Determines how much weapon will be released at each attack. If parameter is not defined the unit / controllable will choose expend on its own discretion. --- @param #number AttackQty (optional) This parameter limits maximal quantity of attack. The aicraft/controllable will not make more attack than allowed even if the target controllable not destroyed and the aicraft/controllable still have ammo. If not defined the aircraft/controllable will attack target until it will be destroyed or until the aircraft/controllable will run out of ammo. +-- @param #number AttackQty (optional) This parameter limits maximal quantity of attack. The aircraft/controllable will not make more attack than allowed even if the target controllable not destroyed and the aircraft/controllable still have ammo. If not defined the aircraft/controllable will attack target until it will be destroyed or until the aircraft/controllable will run out of ammo. -- @param DCS#Azimuth Direction (optional) Desired ingress direction from the target to the attacking aircraft. Controllable/aircraft will make its attacks from the direction. Of course if there is no way to attack from the direction due the terrain controllable/aircraft will choose another direction. -- @param #number Altitude (optional) The altitude from where to attack. -- @param #number WeaponType (optional) The WeaponType. @@ -966,7 +952,7 @@ end -- @param DCS#Vec2 Vec2 2D-coordinates of the point to deliver weapon at. -- @param #boolean GroupAttack (Optional) If true, all units in the group will attack the Unit when found. -- @param DCS#AI.Task.WeaponExpend WeaponExpend (Optional) Determines how much weapon will be released at each attack. If parameter is not defined the unit will choose expend on its own discretion. --- @param #number AttackQty (Optional) This parameter limits maximal quantity of attack. The aicraft/controllable will not make more attack than allowed even if the target controllable not destroyed and the aicraft/controllable still have ammo. If not defined the aircraft/controllable will attack target until it will be destroyed or until the aircraft/controllable will run out of ammo. +-- @param #number AttackQty (Optional) This parameter limits maximal quantity of attack. The aircraft/controllable will not make more attack than allowed even if the target controllable not destroyed and the aircraft/controllable still have ammo. If not defined the aircraft/controllable will attack target until it will be destroyed or until the aircraft/controllable will run out of ammo. -- @param DCS#Azimuth Direction (Optional) Desired ingress direction from the target to the attacking aircraft. Controllable/aircraft will make its attacks from the direction. Of course if there is no way to attack from the direction due the terrain controllable/aircraft will choose another direction. -- @param #number Altitude (Optional) The altitude [meters] from where to attack. Default 30 m. -- @param #number WeaponType (Optional) The WeaponType. Default Auto=1073741822. @@ -994,19 +980,18 @@ function CONTROLLABLE:TaskAttackMapObject( Vec2, GroupAttack, WeaponExpend, Atta return DCSTask end - --- (AIR) Delivering weapon via CarpetBombing (all bombers in formation release at same time) at the point on the ground. -- @param #CONTROLLABLE self -- @param DCS#Vec2 Vec2 2D-coordinates of the point to deliver weapon at. -- @param #boolean GroupAttack (optional) If true, all units in the group will attack the Unit when found. -- @param DCS#AI.Task.WeaponExpend WeaponExpend (optional) Determines how much weapon will be released at each attack. If parameter is not defined the unit will choose expend on its own discretion. --- @param #number AttackQty (optional) This parameter limits maximal quantity of attack. The aicraft/controllable will not make more attack than allowed even if the target controllable not destroyed and the aicraft/controllable still have ammo. If not defined the aircraft/controllable will attack target until it will be destroyed or until the aircraft/controllable will run out of ammo. +-- @param #number AttackQty (optional) This parameter limits maximal quantity of attack. The aircraft/controllable will not make more attack than allowed even if the target controllable not destroyed and the aircraft/controllable still have ammo. If not defined the aircraft/controllable will attack target until it will be destroyed or until the aircraft/controllable will run out of ammo. -- @param DCS#Azimuth Direction (optional) Desired ingress direction from the target to the attacking aircraft. Controllable/aircraft will make its attacks from the direction. Of course if there is no way to attack from the direction due the terrain controllable/aircraft will choose another direction. -- @param #number Altitude (optional) The altitude from where to attack. -- @param #number WeaponType (optional) The WeaponType. -- @param #number CarpetLength (optional) default to 500 m. -- @return DCS#Task The DCS task structure. -function CONTROLLABLE:TaskCarpetBombing(Vec2, GroupAttack, WeaponExpend, AttackQty, Direction, Altitude, WeaponType, CarpetLength) +function CONTROLLABLE:TaskCarpetBombing( Vec2, GroupAttack, WeaponExpend, AttackQty, Direction, Altitude, WeaponType, CarpetLength ) -- Build Task Structure local DCSTask = { @@ -1025,14 +1010,12 @@ function CONTROLLABLE:TaskCarpetBombing(Vec2, GroupAttack, WeaponExpend, AttackQ direction = Direction and math.rad(Direction) or 0, altitudeEnabled = Altitude and true or false, altitude = Altitude, - } + }, } return DCSTask end - - --- (AIR) Following another airborne controllable. -- The unit / controllable will follow lead unit of another controllable, wingmens of both controllables will continue following their leaders. -- Used to support CarpetBombing Task @@ -1041,7 +1024,7 @@ end -- @param DCS#Vec3 Vec3 Position of the unit / lead unit of the controllable relative lead unit of another controllable in frame reference oriented by course of lead unit of another controllable. If another controllable is on land the unit / controllable will orbit around. -- @param #number LastWaypointIndex Detach waypoint of another controllable. Once reached the unit / controllable Follow task is finished. -- @return DCS#Task The DCS task structure. -function CONTROLLABLE:TaskFollowBigFormation(FollowControllable, Vec3, LastWaypointIndex ) +function CONTROLLABLE:TaskFollowBigFormation( FollowControllable, Vec3, LastWaypointIndex ) local DCSTask = { id = 'FollowBigFormation', @@ -1049,14 +1032,13 @@ function CONTROLLABLE:TaskFollowBigFormation(FollowControllable, Vec3, LastWaypo groupId = FollowControllable:GetID(), pos = Vec3, lastWptIndexFlag = LastWaypointIndex and true or false, - lastWptIndex = LastWaypointIndex - } + lastWptIndex = LastWaypointIndex, + }, } return DCSTask end - --- (AIR HELICOPTER) Move the controllable to a Vec2 Point, wait for a defined duration and embark infantry groups. -- @param #CONTROLLABLE self -- @param Core.Point#COORDINATE Coordinate The point where to pickup the troops. @@ -1064,29 +1046,29 @@ end -- @param #number Duration (Optional) The maximum duration in seconds to wait until all groups have embarked. -- @param #table Distribution (Optional) Distribution used to put the infantry groups into specific carrier units. -- @return DCS#Task The DCS task structure. -function CONTROLLABLE:TaskEmbarking(Coordinate, GroupSetForEmbarking, Duration, Distribution) +function CONTROLLABLE:TaskEmbarking( Coordinate, GroupSetForEmbarking, Duration, Distribution ) -- Table of group IDs for embarking. - local g4e={} + local g4e = {} if GroupSetForEmbarking then - for _,_group in pairs(GroupSetForEmbarking:GetSet()) do - local group=_group --Wrapper.Group#GROUP - table.insert(g4e, group:GetID()) + for _, _group in pairs( GroupSetForEmbarking:GetSet() ) do + local group = _group -- Wrapper.Group#GROUP + table.insert( g4e, group:GetID() ) end else - self:E("ERROR: No groups for embarking specified!") + self:E( "ERROR: No groups for embarking specified!" ) return nil end -- Table of group IDs for embarking. - --local Distribution={} + -- local Distribution={} -- Distribution - --local distribution={} - --distribution[id]=gids + -- local distribution={} + -- distribution[id]=gids - local groupID=self and self:GetID() + local groupID = self and self:GetID() local DCSTask = { id = 'Embarking', @@ -1099,13 +1081,12 @@ function CONTROLLABLE:TaskEmbarking(Coordinate, GroupSetForEmbarking, Duration, duration = Duration, distributionFlag = Distribution and true or false, distribution = Distribution, - } + }, } return DCSTask end - --- Used in conjunction with the embarking task for a transport helicopter group. The Ground units will move to the specified location and wait to be picked up by a helicopter. -- The helicopter will then fly them to their dropoff point defined by another task for the ground forces; DisembarkFromTransport task. -- The controllable has to be an infantry group! @@ -1114,7 +1095,7 @@ end -- @param #number Radius Radius in meters. Default 200 m. -- @param #string UnitType The unit type name of the carrier, e.g. "UH-1H". Must not be specified. -- @return DCS#Task Embark to transport task. -function CONTROLLABLE:TaskEmbarkToTransport(Coordinate, Radius, UnitType) +function CONTROLLABLE:TaskEmbarkToTransport( Coordinate, Radius, UnitType ) local EmbarkToTransport = { id = "EmbarkToTransport", @@ -1123,46 +1104,44 @@ function CONTROLLABLE:TaskEmbarkToTransport(Coordinate, Radius, UnitType) y = Coordinate.z, zoneRadius = Radius or 200, selectedType = UnitType, - } + }, } return EmbarkToTransport end - --- Specifies the location infantry groups that is being transported by helicopters will be unloaded at. Used in conjunction with the EmbarkToTransport task. -- @param #CONTROLLABLE self -- @param Core.Point#COORDINATE Coordinate Coordinates where AI is expecting to be picked up. -- @return DCS#Task Embark to transport task. -function CONTROLLABLE:TaskDisembarking(Coordinate, GroupSetToDisembark) +function CONTROLLABLE:TaskDisembarking( Coordinate, GroupSetToDisembark ) -- Table of group IDs for disembarking. - local g4e={} + local g4e = {} if GroupSetToDisembark then - for _,_group in pairs(GroupSetToDisembark:GetSet()) do - local group=_group --Wrapper.Group#GROUP - table.insert(g4e, group:GetID()) + for _, _group in pairs( GroupSetToDisembark:GetSet() ) do + local group = _group -- Wrapper.Group#GROUP + table.insert( g4e, group:GetID() ) end else - self:E("ERROR: No groups for disembarking specified!") + self:E( "ERROR: No groups for disembarking specified!" ) return nil end - local Disembarking={ - id = "Disembarking", - params = { - x = Coordinate.x, - y = Coordinate.z, - groupsForEmbarking = g4e, -- This is no bug, the entry is really "groupsForEmbarking" even if we disembark the troops. - } - } + local Disembarking = { + id = "Disembarking", + params = { + x = Coordinate.x, + y = Coordinate.z, + groupsForEmbarking = g4e, -- This is no bug, the entry is really "groupsForEmbarking" even if we disembark the troops. + }, + } return Disembarking end - ---- (AIR) Orbit at a specified position at a specified alititude during a specified duration with a specified speed. +--- (AIR) Orbit at a specified position at a specified altitude during a specified duration with a specified speed. -- @param #CONTROLLABLE self -- @param DCS#Vec2 Point The point to hold the position. -- @param #number Altitude The altitude AGL in meters to hold the position. @@ -1177,8 +1156,8 @@ function CONTROLLABLE:TaskOrbitCircleAtVec2( Point, Altitude, Speed ) pattern = AI.Task.OrbitPattern.CIRCLE, point = Point, speed = Speed, - altitude = Altitude + land.getHeight( Point ) - } + altitude = Altitude + land.getHeight( Point ), + }, } return DCSTask @@ -1191,15 +1170,15 @@ end -- @param #number Speed Speed [m/s] flying the orbit pattern. Default 128 m/s = 250 knots. -- @param Core.Point#COORDINATE CoordRaceTrack (Optional) If this coordinate is specified, the CONTROLLABLE will fly a race-track pattern using this and the initial coordinate. -- @return #CONTROLLABLE self -function CONTROLLABLE:TaskOrbit(Coord, Altitude, Speed, CoordRaceTrack) +function CONTROLLABLE:TaskOrbit( Coord, Altitude, Speed, CoordRaceTrack ) - local Pattern=AI.Task.OrbitPattern.CIRCLE + local Pattern = AI.Task.OrbitPattern.CIRCLE - local P1=Coord:GetVec2() - local P2=nil + local P1 = Coord:GetVec2() + local P2 = nil if CoordRaceTrack then - Pattern=AI.Task.OrbitPattern.RACE_TRACK - P2=CoordRaceTrack:GetVec2() + Pattern = AI.Task.OrbitPattern.RACE_TRACK + P2 = CoordRaceTrack:GetVec2() end local Task = { @@ -1210,13 +1189,13 @@ function CONTROLLABLE:TaskOrbit(Coord, Altitude, Speed, CoordRaceTrack) point2 = P2, speed = Speed or UTILS.KnotsToMps(250), altitude = Altitude or Coord.y, - } + }, } return Task end ---- (AIR) Orbit at the current position of the first unit of the controllable at a specified alititude. +--- (AIR) Orbit at the current position of the first unit of the controllable at a specified altitude. -- @param #CONTROLLABLE self -- @param #number Altitude The altitude [m] to hold the position. -- @param #number Speed The speed [m/s] flying when holding the position. @@ -1235,8 +1214,6 @@ function CONTROLLABLE:TaskOrbitCircle( Altitude, Speed, Coordinate ) return nil end - - --- (AIR) Hold position at the current position of the first unit of the controllable. -- @param #CONTROLLABLE self -- @param #number Duration The maximum duration in seconds to hold the position. @@ -1247,7 +1224,6 @@ function CONTROLLABLE:TaskHoldPosition() return self:TaskOrbitCircle( 30, 10 ) end - --- (AIR) Delivering weapon on the runway. See [hoggit](https://wiki.hoggitworld.com/view/DCS_task_bombingRunway) -- -- Make sure the aircraft has the following role: @@ -1267,7 +1243,7 @@ end -- @param DCS#Azimuth Direction (optional) Desired ingress direction from the target to the attacking aircraft. Controllable/aircraft will make its attacks from the direction. Of course if there is no way to attack from the direction due the terrain controllable/aircraft will choose another direction. -- @param #boolean GroupAttack (optional) Flag indicates that the target must be engaged by all aircrafts of the controllable. Has effect only if the task is assigned to a group and not to a single aircraft. -- @return DCS#Task The DCS task structure. -function CONTROLLABLE:TaskBombingRunway(Airbase, WeaponType, WeaponExpend, AttackQty, Direction, GroupAttack) +function CONTROLLABLE:TaskBombingRunway( Airbase, WeaponType, WeaponExpend, AttackQty, Direction, GroupAttack ) local DCSTask = { id = 'BombingRunway', @@ -1284,27 +1260,25 @@ function CONTROLLABLE:TaskBombingRunway(Airbase, WeaponType, WeaponExpend, Attac return DCSTask end - --- (AIR) Refueling from the nearest tanker. No parameters. -- @param #CONTROLLABLE self -- @return DCS#Task The DCS task structure. function CONTROLLABLE:TaskRefueling() - local DCSTask={ - id='Refueling', - params={} + local DCSTask = { + id = 'Refueling', + params = {}, } return DCSTask end - --- (AIR HELICOPTER) Landing at the ground. For helicopters only. -- @param #CONTROLLABLE self -- @param DCS#Vec2 Vec2 The point where to land. -- @param #number Duration The duration in seconds to stay on the ground. -- @return #CONTROLLABLE self -function CONTROLLABLE:TaskLandAtVec2(Vec2, Duration) +function CONTROLLABLE:TaskLandAtVec2( Vec2, Duration ) local DCSTask = { id = 'Land', @@ -1326,15 +1300,13 @@ end function CONTROLLABLE:TaskLandAtZone( Zone, Duration, RandomPoint ) -- Get landing point - local Point=RandomPoint and Zone:GetRandomVec2() or Zone:GetVec2() + local Point = RandomPoint and Zone:GetRandomVec2() or Zone:GetVec2() local DCSTask = CONTROLLABLE.TaskLandAtVec2( self, Point, Duration ) return DCSTask end - - --- (AIR) Following another airborne controllable. -- The unit / controllable will follow lead unit of another controllable, wingmens of both controllables will continue following their leaders. -- If another controllable is on land the unit / controllable will orbit around. @@ -1346,15 +1318,15 @@ end function CONTROLLABLE:TaskFollow( FollowControllable, Vec3, LastWaypointIndex ) self:F2( { self.ControllableName, FollowControllable, Vec3, LastWaypointIndex } ) --- Follow = { --- id = 'Follow', --- params = { --- groupId = Group.ID, --- pos = Vec3, --- lastWptIndexFlag = boolean, --- lastWptIndex = number --- } --- } + -- Follow = { + -- id = 'Follow', + -- params = { + -- groupId = Group.ID, + -- pos = Vec3, + -- lastWptIndexFlag = boolean, + -- lastWptIndex = number + -- } + -- } local LastWaypointIndexFlag = false local lastWptIndexFlagChangedManually = false @@ -1371,14 +1343,13 @@ function CONTROLLABLE:TaskFollow( FollowControllable, Vec3, LastWaypointIndex ) lastWptIndexFlag = LastWaypointIndexFlag, lastWptIndex = LastWaypointIndex, lastWptIndexFlagChangedManually = lastWptIndexFlagChangedManually, - } + }, } self:T3( { DCSTask } ) return DCSTask end - --- (AIR) Escort another airborne controllable. -- The unit / controllable will follow lead unit of another controllable, wingmens of both controllables will continue following their leaders. -- The unit / controllable will also protect that controllable from threats of specified types. @@ -1391,17 +1362,17 @@ end -- @return DCS#Task The DCS task structure. function CONTROLLABLE:TaskEscort( FollowControllable, Vec3, LastWaypointIndex, EngagementDistance, TargetTypes ) --- Escort = { --- id = 'Escort', --- params = { --- groupId = Group.ID, --- pos = Vec3, --- lastWptIndexFlag = boolean, --- lastWptIndex = number, --- engagementDistMax = Distance, --- targetTypes = array of AttributeName, --- } --- } + -- Escort = { + -- id = 'Escort', + -- params = { + -- groupId = Group.ID, + -- pos = Vec3, + -- lastWptIndexFlag = boolean, + -- lastWptIndex = number, + -- engagementDistMax = Distance, + -- targetTypes = array of AttributeName, + -- } + -- } local DCSTask DCSTask = { @@ -1419,7 +1390,6 @@ function CONTROLLABLE:TaskEscort( FollowControllable, Vec3, LastWaypointIndex, E return DCSTask end - -- GROUND TASKS --- (GROUND) Fire at a VEC2 point until ammunition is finished. @@ -1443,8 +1413,8 @@ function CONTROLLABLE:TaskFireAtPoint( Vec2, Radius, AmmoCount, WeaponType, Alti radius = Radius, expendQty = 100, -- dummy value expendQtyEnabled = false, - alt_type = ASL and 0 or 1 - } + alt_type = ASL and 0 or 1, + }, } if AmmoCount then @@ -1453,14 +1423,14 @@ function CONTROLLABLE:TaskFireAtPoint( Vec2, Radius, AmmoCount, WeaponType, Alti end if Altitude then - DCSTask.params.altitude=Altitude + DCSTask.params.altitude = Altitude end if WeaponType then - DCSTask.params.weaponType=WeaponType + DCSTask.params.weaponType = WeaponType end - --self:I(DCSTask) + -- self:I(DCSTask) return DCSTask end @@ -1469,11 +1439,10 @@ end -- @param #CONTROLLABLE self -- @return DCS#Task The DCS task structure. function CONTROLLABLE:TaskHold() - local DCSTask = {id = 'Hold', params = {}} + local DCSTask = { id = 'Hold', params = {} } return DCSTask end - -- TASKS FOR AIRBORNE AND GROUND UNITS/CONTROLLABLES --- (AIR + GROUND) The task makes the controllable/unit a FAC and orders the FAC to control the target (enemy ground controllable) destruction. @@ -1503,7 +1472,7 @@ function CONTROLLABLE:TaskFAC_AttackGroup( AttackGroup, WeaponType, Designation, modulation = Modulation or radio.modulation.AM, callname = CallsignName, number = CallsignNumber, - } + }, } return DCSTask @@ -1526,14 +1495,12 @@ function CONTROLLABLE:EnRouteTaskEngageTargets( Distance, TargetTypes, Priority maxDist = Distance, targetTypes = TargetTypes or {"Air"}, priority = Priority or 0, - } + }, } return DCSTask end - - --- (AIR) Engaging a targets of defined types at circle-shaped zone. -- @param #CONTROLLABLE self -- @param DCS#Vec2 Vec2 2D-coordinates of the zone. @@ -1550,20 +1517,19 @@ function CONTROLLABLE:EnRouteTaskEngageTargetsInZone( Vec2, Radius, TargetTypes, zoneRadius = Radius, targetTypes = TargetTypes or {"Air"}, priority = Priority or 0 - } + }, } return DCSTask end - --- (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. -- @param #CONTROLLABLE self -- @param Wrapper.Controllable#CONTROLLABLE AttackGroup The Controllable to be attacked. -- @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. -- @param #number WeaponType (optional) Bitmask of weapon types those allowed to use. If parameter is not defined that means no limits on weapon usage. -- @param DCS#AI.Task.WeaponExpend WeaponExpend (optional) Determines how much weapon will be released at each attack. If parameter is not defined the unit / controllable will choose expend on its own discretion. --- @param #number AttackQty (optional) This parameter limits maximal quantity of attack. The aicraft/controllable will not make more attack than allowed even if the target controllable not destroyed and the aicraft/controllable still have ammo. If not defined the aircraft/controllable will attack target until it will be destroyed or until the aircraft/controllable will run out of ammo. +-- @param #number AttackQty (optional) This parameter limits maximal quantity of attack. The aircraft/controllable will not make more attack than allowed even if the target controllable not destroyed and the aircraft/controllable still have ammo. If not defined the aircraft/controllable will attack target until it will be destroyed or until the aircraft/controllable will run out of ammo. -- @param DCS#Azimuth Direction (optional) Desired ingress direction from the target to the attacking aircraft. Controllable/aircraft will make its attacks from the direction. Of course if there is no way to attack from the direction due the terrain controllable/aircraft will choose another direction. -- @param DCS#Distance Altitude (optional) Desired attack start altitude. Controllable/aircraft will make its attacks from the altitude. If the altitude is too low or too high to use weapon aircraft/controllable will choose closest altitude to the desired attack start altitude. If the desired altitude is defined controllable/aircraft will not attack from safe altitude. -- @param #boolean AttackQtyLimit (optional) The flag determines how to interpret attackQty parameter. If the flag is true then attackQty is a limit on maximal attack quantity for "AttackGroup" and "AttackUnit" tasks. If the flag is false then attackQty is a desired attack quantity for "Bombing" and "BombingRunway" tasks. @@ -1605,14 +1571,13 @@ function CONTROLLABLE:EnRouteTaskEngageGroup( AttackGroup, Priority, WeaponType, return DCSTask end - --- (AIR) Search and attack the Unit. -- @param #CONTROLLABLE self -- @param Wrapper.Unit#UNIT EngageUnit The UNIT. -- @param #number Priority (optional) 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. -- @param #boolean GroupAttack (optional) If true, all units in the group will attack the Unit when found. -- @param DCS#AI.Task.WeaponExpend WeaponExpend (optional) Determines how much weapon will be released at each attack. If parameter is not defined the unit / controllable will choose expend on its own discretion. --- @param #number AttackQty (optional) This parameter limits maximal quantity of attack. The aicraft/controllable will not make more attack than allowed even if the target controllable not destroyed and the aicraft/controllable still have ammo. If not defined the aircraft/controllable will attack target until it will be destroyed or until the aircraft/controllable will run out of ammo. +-- @param #number AttackQty (optional) This parameter limits maximal quantity of attack. The aircraft/controllable will not make more attack than allowed even if the target controllable not destroyed and the aircraft/controllable still have ammo. If not defined the aircraft/controllable will attack target until it will be destroyed or until the aircraft/controllable will run out of ammo. -- @param DCS#Azimuth Direction (optional) Desired ingress direction from the target to the attacking aircraft. Controllable/aircraft will make its attacks from the direction. Of course if there is no way to attack from the direction due the terrain controllable/aircraft will choose another direction. -- @param DCS#Distance Altitude (optional) Desired altitude to perform the unit engagement. -- @param #boolean Visible (optional) Unit must be visible. @@ -1641,12 +1606,10 @@ function CONTROLLABLE:EnRouteTaskEngageUnit( EngageUnit, Priority, GroupAttack, return DCSTask end - - --- (AIR) Aircraft will act as an AWACS for friendly units (will provide them with information about contacts). No parameters. -- @param #CONTROLLABLE self -- @return DCS#Task The DCS task structure. -function CONTROLLABLE:EnRouteTaskAWACS( ) +function CONTROLLABLE:EnRouteTaskAWACS() local DCSTask = { id = 'AWACS', @@ -1656,11 +1619,10 @@ function CONTROLLABLE:EnRouteTaskAWACS( ) return DCSTask end - --- (AIR) Aircraft will act as a tanker for friendly units. No parameters. -- @param #CONTROLLABLE self -- @return DCS#Task The DCS task structure. -function CONTROLLABLE:EnRouteTaskTanker( ) +function CONTROLLABLE:EnRouteTaskTanker() local DCSTask = { id = 'Tanker', @@ -1670,13 +1632,12 @@ function CONTROLLABLE:EnRouteTaskTanker( ) return DCSTask end - -- En-route tasks for ground units/controllables --- (GROUND) Ground unit (EW-radar) will act as an EWR for friendly units (will provide them with information about contacts). No parameters. -- @param #CONTROLLABLE self -- @return DCS#Task The DCS task structure. -function CONTROLLABLE:EnRouteTaskEWR( ) +function CONTROLLABLE:EnRouteTaskEWR() local DCSTask = { id = 'EWR', @@ -1686,7 +1647,6 @@ function CONTROLLABLE:EnRouteTaskEWR( ) return DCSTask end - -- En-route tasks for airborne and ground units/controllables --- (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. @@ -1709,13 +1669,12 @@ function CONTROLLABLE:EnRouteTaskFAC_EngageGroup( AttackGroup, Priority, WeaponT designation = Designation, datalink = Datalink and Datalink or false, priority = Priority or 0, - } + }, } return DCSTask end - --- (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. -- The killer is player-controlled allied CAS-aircraft that is in contact with the FAC. -- If the task is assigned to the controllable lead unit will be a FAC. @@ -1725,13 +1684,13 @@ end -- @return DCS#Task The DCS task structure. function CONTROLLABLE:EnRouteTaskFAC( Radius, Priority ) --- FAC = { --- id = 'FAC', --- params = { --- radius = Distance, --- priority = number --- } --- } + -- FAC = { + -- id = 'FAC', + -- params = { + -- radius = Distance, + -- priority = number + -- } + -- } local DCSTask = { id = 'FAC', @@ -1744,7 +1703,6 @@ function CONTROLLABLE:EnRouteTaskFAC( Radius, Priority ) return DCSTask end - --- This creates a Task element, with an action to call a function as part of a Wrapped Task. -- This Task can then be embedded at a Waypoint by calling the method @{#CONTROLLABLE.SetTaskWaypoint}. -- @param #CONTROLLABLE self @@ -1797,24 +1755,22 @@ function CONTROLLABLE:TaskFunction( FunctionString, ... ) -- Script local DCSScript = {} - DCSScript[#DCSScript+1] = "local MissionControllable = GROUP:Find( ... ) " + DCSScript[#DCSScript + 1] = "local MissionControllable = GROUP:Find( ... ) " if arg and arg.n > 0 then - local ArgumentKey = '_' .. tostring( arg ):match("table: (.*)") + local ArgumentKey = '_' .. tostring( arg ):match( "table: (.*)" ) self:SetState( self, ArgumentKey, arg ) - DCSScript[#DCSScript+1] = "local Arguments = MissionControllable:GetState( MissionControllable, '" .. ArgumentKey .. "' ) " - DCSScript[#DCSScript+1] = FunctionString .. "( MissionControllable, unpack( Arguments ) )" + DCSScript[#DCSScript + 1] = "local Arguments = MissionControllable:GetState( MissionControllable, '" .. ArgumentKey .. "' ) " + DCSScript[#DCSScript + 1] = FunctionString .. "( MissionControllable, unpack( Arguments ) )" else - DCSScript[#DCSScript+1] = FunctionString .. "( MissionControllable )" + DCSScript[#DCSScript + 1] = FunctionString .. "( MissionControllable )" end -- DCS task. - local DCSTask = self:TaskWrappedAction(self:CommandDoScript(table.concat( DCSScript ))) + local DCSTask = self:TaskWrappedAction( self:CommandDoScript( table.concat( DCSScript ) ) ) return DCSTask end - - --- (AIR + GROUND) Return a mission task from a mission template. -- @param #CONTROLLABLE self -- @param #table TaskMission A table containing the mission task. @@ -1823,13 +1779,14 @@ function CONTROLLABLE:TaskMission( TaskMission ) local DCSTask = { id = 'Mission', - params = { TaskMission, }, + params = { + TaskMission, + }, } return DCSTask end - do -- Patrol methods --- (GROUND) Patrol iteratively using the waypoints the for the (parent) group. @@ -1851,32 +1808,31 @@ do -- Patrol methods -- Calculate the new Route. local FromCoord = PatrolGroup:GetCoordinate() - + -- test for submarine local depth = 0 local IsSub = false if PatrolGroup:IsShip() then local navalvec3 = FromCoord:GetVec3() - if navalvec3.y < 0 then + if navalvec3.y < 0 then depth = navalvec3.y IsSub = true end end - - + local Waypoint = Waypoints[1] local Speed = Waypoint.speed or (20 / 3.6) - local From = FromCoord:WaypointGround( Speed ) - - if IsSub then - From = FromCoord:WaypointNaval( Speed, Waypoint.alt ) + local From = FromCoord:WaypointGround( Speed ) + + if IsSub then + From = FromCoord:WaypointNaval( Speed, Waypoint.alt ) end - + table.insert( Waypoints, 1, From ) local TaskRoute = PatrolGroup:TaskFunction( "CONTROLLABLE.PatrolRoute" ) - self:F({Waypoints = Waypoints}) + self:F( { Waypoints = Waypoints } ) local Waypoint = Waypoints[#Waypoints] PatrolGroup:SetTaskWaypoint( Waypoint, TaskRoute ) -- Set for the given Route at Waypoint 2 the TaskRouteToZone. @@ -1916,31 +1872,31 @@ do -- Patrol methods local IsSub = false if PatrolGroup:IsShip() then local navalvec3 = FromCoord:GetVec3() - if navalvec3.y < 0 then + if navalvec3.y < 0 then depth = navalvec3.y IsSub = true end end -- Loop until a waypoint has been found that is not the same as the current waypoint. - -- Otherwise the object zon't move or drive in circles and the algorithm would not do exactly + -- Otherwise the object won't move, or drive in circles, and the algorithm would not do exactly -- what it is supposed to do, which is making groups drive around. local ToWaypoint repeat -- Select a random waypoint and check if it is not the same waypoint as where the object is about. ToWaypoint = math.random( 1, #Waypoints ) - until( ToWaypoint ~= FromWaypoint ) + until (ToWaypoint ~= FromWaypoint) self:F( { FromWaypoint = FromWaypoint, ToWaypoint = ToWaypoint } ) - local Waypoint = Waypoints[ToWaypoint] -- Select random waypoint. + local Waypoint = Waypoints[ToWaypoint] -- Select random waypoint. local ToCoord = COORDINATE:NewFromVec2( { x = Waypoint.x, y = Waypoint.y } ) -- Create a "ground route point", which is a "point" structure that can be given as a parameter to a Task local Route = {} if IsSub then - Route[#Route+1] = FromCoord:WaypointNaval( Speed, depth ) - Route[#Route+1] = ToCoord:WaypointNaval( Speed, Waypoint.alt ) + Route[#Route + 1] = FromCoord:WaypointNaval( Speed, depth ) + Route[#Route + 1] = ToCoord:WaypointNaval( Speed, Waypoint.alt ) else - Route[#Route+1] = FromCoord:WaypointGround( Speed, Formation ) - Route[#Route+1] = ToCoord:WaypointGround( Speed, Formation ) + Route[#Route + 1] = FromCoord:WaypointGround( Speed, Formation ) + Route[#Route + 1] = ToCoord:WaypointGround( Speed, Formation ) end local TaskRouteToZone = PatrolGroup:TaskFunction( "CONTROLLABLE.PatrolRouteRandom", Speed, Formation, ToWaypoint ) @@ -1972,43 +1928,43 @@ do -- Patrol methods PatrolGroup = self:GetGroup() -- Wrapper.Group#GROUP end - DelayMin=DelayMin or 1 - if not DelayMax or DelayMax LengthDirect*10) or (LengthRoad/LengthOnRoad*100<5)) + LongRoad = LengthOnRoad and ((LengthOnRoad > LengthDirect * 10) or (LengthRoad / LengthOnRoad * 100 < 5)) -- Debug info. - self:T(string.format("Length on road = %.3f km", LengthOnRoad/1000)) - self:T(string.format("Length directly = %.3f km", LengthDirect/1000)) - self:T(string.format("Length fraction = %.3f km", LengthOnRoad/LengthDirect)) - self:T(string.format("Length only road = %.3f km", LengthRoad/1000)) - self:T(string.format("Length off road = %.3f km", LengthOffRoad/1000)) - self:T(string.format("Percent on road = %.1f", LengthRoad/LengthOnRoad*100)) + self:T( string.format( "Length on road = %.3f km", LengthOnRoad / 1000 ) ) + self:T( string.format( "Length directly = %.3f km", LengthDirect / 1000 ) ) + self:T( string.format( "Length fraction = %.3f km", LengthOnRoad / LengthDirect ) ) + self:T( string.format( "Length only road = %.3f km", LengthRoad / 1000 ) ) + self:T( string.format( "Length off road = %.3f km", LengthOffRoad / 1000 ) ) + self:T( string.format( "Percent on road = %.1f", LengthRoad / LengthOnRoad * 100 ) ) end -- Route, ground waypoints along road. - local route={} - local canroad=false + local route = {} + local canroad = false -- Check if a valid path on road could be found. if GotPath and LengthRoad and LengthDirect > 2000 then -- if the length of the movement is less than 1 km, drive directly. @@ -2357,43 +2303,43 @@ do -- Route methods -- Road is long ==> we take the short cut. - table.insert(route, FromCoordinate:WaypointGround(Speed, OffRoadFormation)) - table.insert(route, ToCoordinate:WaypointGround(Speed, OffRoadFormation)) + table.insert( route, FromCoordinate:WaypointGround( Speed, OffRoadFormation ) ) + table.insert( route, ToCoordinate:WaypointGround( Speed, OffRoadFormation ) ) else -- Create waypoints. - table.insert(route, FromCoordinate:WaypointGround(Speed, OffRoadFormation)) - table.insert(route, PathOnRoad[2]:WaypointGround(Speed, "On Road")) - table.insert(route, PathOnRoad[#PathOnRoad-1]:WaypointGround(Speed, "On Road")) + table.insert( route, FromCoordinate:WaypointGround( Speed, OffRoadFormation ) ) + table.insert( route, PathOnRoad[2]:WaypointGround( Speed, "On Road" ) ) + table.insert( route, PathOnRoad[#PathOnRoad - 1]:WaypointGround( Speed, "On Road" ) ) -- Add the final coordinate because the final might not be on the road. - local dist=ToCoordinate:Get2DDistance(PathOnRoad[#PathOnRoad-1]) - if dist>10 then - table.insert(route, ToCoordinate:WaypointGround(Speed, OffRoadFormation)) - table.insert(route, ToCoordinate:GetRandomCoordinateInRadius(10,5):WaypointGround(5, OffRoadFormation)) - table.insert(route, ToCoordinate:GetRandomCoordinateInRadius(10,5):WaypointGround(5, OffRoadFormation)) + local dist = ToCoordinate:Get2DDistance( PathOnRoad[#PathOnRoad - 1] ) + if dist > 10 then + table.insert( route, ToCoordinate:WaypointGround( Speed, OffRoadFormation ) ) + table.insert( route, ToCoordinate:GetRandomCoordinateInRadius( 10, 5 ):WaypointGround( 5, OffRoadFormation ) ) + table.insert( route, ToCoordinate:GetRandomCoordinateInRadius( 10, 5 ):WaypointGround( 5, OffRoadFormation ) ) end end - canroad=true + canroad = true else -- No path on road could be found (can happen!) ==> Route group directly from A to B. - table.insert(route, FromCoordinate:WaypointGround(Speed, OffRoadFormation)) - table.insert(route, ToCoordinate:WaypointGround(Speed, OffRoadFormation)) + table.insert( route, FromCoordinate:WaypointGround( Speed, OffRoadFormation ) ) + table.insert( route, ToCoordinate:WaypointGround( Speed, OffRoadFormation ) ) end -- Add passing waypoint function. if WaypointFunction then - local N=#route - for n,waypoint in pairs(route) do + local N = #route + for n, waypoint in pairs( route ) do waypoint.task = {} waypoint.task.id = "ComboTask" waypoint.task.params = {} - waypoint.task.params.tasks = {self:TaskFunction("CONTROLLABLE.___PassingWaypoint", n, N, WaypointFunction, unpack(WaypointFunctionArguments or {}))} + waypoint.task.params.tasks = { self:TaskFunction( "CONTROLLABLE.___PassingWaypoint", n, N, WaypointFunction, unpack( WaypointFunctionArguments or {} ) ) } end end @@ -2407,40 +2353,40 @@ do -- Route methods -- @param #function WaypointFunction (Optional) Function called when passing a waypoint. First parameters of the function are the @{CONTROLLABLE} object, the number of the waypoint and the total number of waypoints. -- @param #table WaypointFunctionArguments (Optional) List of parameters passed to the *WaypointFunction*. -- @return Task - function CONTROLLABLE:TaskGroundOnRailRoads(ToCoordinate, Speed, WaypointFunction, WaypointFunctionArguments ) - self:F2({ToCoordinate=ToCoordinate, Speed=Speed}) + function CONTROLLABLE:TaskGroundOnRailRoads( ToCoordinate, Speed, WaypointFunction, WaypointFunctionArguments ) + self:F2( { ToCoordinate = ToCoordinate, Speed = Speed } ) -- Defaults. - Speed=Speed or 20 + Speed = Speed or 20 -- Current coordinate. local FromCoordinate = self:GetCoordinate() -- Get path and path length on railroad. - local PathOnRail, LengthOnRail=FromCoordinate:GetPathOnRoad(ToCoordinate, false, true) + local PathOnRail, LengthOnRail = FromCoordinate:GetPathOnRoad( ToCoordinate, false, true ) -- Debug info. - self:T(string.format("Length on railroad = %.3f km", LengthOnRail/1000)) + self:T( string.format( "Length on railroad = %.3f km", LengthOnRail / 1000 ) ) -- Route, ground waypoints along road. - local route={} + local route = {} -- Check if a valid path on railroad could be found. if PathOnRail then - table.insert(route, PathOnRail[1]:WaypointGround(Speed, "On Railroad")) - table.insert(route, PathOnRail[2]:WaypointGround(Speed, "On Railroad")) + table.insert( route, PathOnRail[1]:WaypointGround( Speed, "On Railroad" ) ) + table.insert( route, PathOnRail[2]:WaypointGround( Speed, "On Railroad" ) ) end -- Add passing waypoint function. if WaypointFunction then - local N=#route - for n,waypoint in pairs(route) do + local N = #route + for n, waypoint in pairs( route ) do waypoint.task = {} waypoint.task.id = "ComboTask" waypoint.task.params = {} - waypoint.task.params.tasks = {self:TaskFunction("CONTROLLABLE.___PassingWaypoint", n, N, WaypointFunction, unpack(WaypointFunctionArguments or {}))} + waypoint.task.params.tasks = { self:TaskFunction( "CONTROLLABLE.___PassingWaypoint", n, N, WaypointFunction, unpack( WaypointFunctionArguments or {} ) ) } end end @@ -2452,11 +2398,10 @@ do -- Route methods -- @param #number n Current waypoint number passed. -- @param #number N Total number of waypoints. -- @param #function waypointfunction Function called when a waypoint is passed. - function CONTROLLABLE.___PassingWaypoint(controllable, n, N, waypointfunction, ...) - waypointfunction(controllable, n, N, ...) + function CONTROLLABLE.___PassingWaypoint( controllable, n, N, waypointfunction, ... ) + waypointfunction( controllable, n, N, ... ) end - --- Make the AIR Controllable fly towards a specific point. -- @param #CONTROLLABLE self -- @param Core.Point#COORDINATE ToCoordinate A Coordinate to drive to. @@ -2478,7 +2423,6 @@ do -- Route methods return self end - --- (AIR + GROUND) Route the controllable to a given zone. -- The controllable final destination point can be randomized. -- A speed can be given in km/h. @@ -2504,7 +2448,6 @@ do -- Route methods PointFrom.action = Formation or "Cone" PointFrom.speed = 20 / 3.6 - local PointTo = {} local ZonePoint @@ -2564,7 +2507,6 @@ do -- Route methods PointFrom.action = Formation or "Cone" PointFrom.speed = 20 / 3.6 - local PointTo = {} PointTo.x = Vec2.x @@ -2616,7 +2558,6 @@ function CONTROLLABLE:CommandDoScript( DoScript ) return DCSDoScript end - --- Return the mission template of the controllable. -- @param #CONTROLLABLE self -- @return #table The MissionTemplate @@ -2636,8 +2577,6 @@ function CONTROLLABLE:GetTaskRoute() return routines.utils.deepCopy( _DATABASE.Templates.Controllables[self.ControllableName].Template.route.points ) end - - --- Return the route of a controllable by using the @{Core.Database#DATABASE} class. -- @param #CONTROLLABLE self -- @param #number Begin The route point from where the copy will start. The base route point is 0. @@ -2671,7 +2610,7 @@ function CONTROLLABLE:CopyRoute( Begin, End, Randomize, Radius ) for TPointID = Begin + 1, #Template.route.points - End do if Template.route.points[TPointID] then - Points[#Points+1] = routines.utils.deepCopy( Template.route.points[TPointID] ) + Points[#Points + 1] = routines.utils.deepCopy( Template.route.points[TPointID] ) if Randomize then if not Radius then Radius = 500 @@ -2689,7 +2628,6 @@ function CONTROLLABLE:CopyRoute( Begin, End, Randomize, Radius ) return nil end - --- Return the detected targets of the controllable. -- The optional parametes specify the detection methods that can be applied. -- If no detection method is given, the detection will use all the available methods by default. @@ -2708,35 +2646,33 @@ function CONTROLLABLE:GetDetectedTargets( DetectVisual, DetectOptical, DetectRad if DCSControllable then - local DetectionVisual = ( DetectVisual and DetectVisual == true ) and Controller.Detection.VISUAL or nil - local DetectionOptical = ( DetectOptical and DetectOptical == true ) and Controller.Detection.OPTICAL or nil - local DetectionRadar = ( DetectRadar and DetectRadar == true ) and Controller.Detection.RADAR or nil - local DetectionIRST = ( DetectIRST and DetectIRST == true ) and Controller.Detection.IRST or nil - local DetectionRWR = ( DetectRWR and DetectRWR == true ) and Controller.Detection.RWR or nil - local DetectionDLINK = ( DetectDLINK and DetectDLINK == true ) and Controller.Detection.DLINK or nil - + local DetectionVisual = (DetectVisual and DetectVisual == true) and Controller.Detection.VISUAL or nil + local DetectionOptical = (DetectOptical and DetectOptical == true) and Controller.Detection.OPTICAL or nil + local DetectionRadar = (DetectRadar and DetectRadar == true) and Controller.Detection.RADAR or nil + local DetectionIRST = (DetectIRST and DetectIRST == true) and Controller.Detection.IRST or nil + local DetectionRWR = (DetectRWR and DetectRWR == true) and Controller.Detection.RWR or nil + local DetectionDLINK = (DetectDLINK and DetectDLINK == true) and Controller.Detection.DLINK or nil local Params = {} if DetectionVisual then - Params[#Params+1] = DetectionVisual + Params[#Params + 1] = DetectionVisual end if DetectionOptical then - Params[#Params+1] = DetectionOptical + Params[#Params + 1] = DetectionOptical end if DetectionRadar then - Params[#Params+1] = DetectionRadar + Params[#Params + 1] = DetectionRadar end if DetectionIRST then - Params[#Params+1] = DetectionIRST + Params[#Params + 1] = DetectionIRST end if DetectionRWR then - Params[#Params+1] = DetectionRWR + Params[#Params + 1] = DetectionRWR end if DetectionDLINK then - Params[#Params+1] = DetectionDLINK + Params[#Params + 1] = DetectionDLINK end - self:T2( { DetectionVisual, DetectionOptical, DetectionRadar, DetectionIRST, DetectionRWR, DetectionDLINK } ) return self:_GetController():getDetectedTargets( Params[1], Params[2], Params[3], Params[4], Params[5], Params[6] ) @@ -2772,12 +2708,12 @@ function CONTROLLABLE:IsTargetDetected( DCSObject, DetectVisual, DetectOptical, if DCSControllable then - local DetectionVisual = ( DetectVisual and DetectVisual == true ) and Controller.Detection.VISUAL or nil - local DetectionOptical = ( DetectOptical and DetectOptical == true ) and Controller.Detection.OPTICAL or nil - local DetectionRadar = ( DetectRadar and DetectRadar == true ) and Controller.Detection.RADAR or nil - local DetectionIRST = ( DetectIRST and DetectIRST == true ) and Controller.Detection.IRST or nil - local DetectionRWR = ( DetectRWR and DetectRWR == true ) and Controller.Detection.RWR or nil - local DetectionDLINK = ( DetectDLINK and DetectDLINK == true ) and Controller.Detection.DLINK or nil + local DetectionVisual = (DetectVisual and DetectVisual == true) and Controller.Detection.VISUAL or nil + local DetectionOptical = (DetectOptical and DetectOptical == true) and Controller.Detection.OPTICAL or nil + local DetectionRadar = (DetectRadar and DetectRadar == true) and Controller.Detection.RADAR or nil + local DetectionIRST = (DetectIRST and DetectIRST == true) and Controller.Detection.IRST or nil + local DetectionRWR = (DetectRWR and DetectRWR == true) and Controller.Detection.RWR or nil + local DetectionDLINK = (DetectDLINK and DetectDLINK == true) and Controller.Detection.DLINK or nil local Controller = self:_GetController() @@ -2813,7 +2749,7 @@ function CONTROLLABLE:IsUnitDetected( Unit, DetectVisual, DetectOptical, DetectR self:F2( self.ControllableName ) if Unit and Unit:IsAlive() then - return self:IsTargetDetected(Unit:GetDCSObject(), DetectVisual, DetectOptical, DetectRadar, DetectIRST, DetectRWR, DetectDLINK) + return self:IsTargetDetected( Unit:GetDCSObject(), DetectVisual, DetectOptical, DetectRadar, DetectIRST, DetectRWR, DetectDLINK ) end return nil @@ -2836,11 +2772,11 @@ function CONTROLLABLE:IsGroupDetected( Group, DetectVisual, DetectOptical, Detec self:F2( self.ControllableName ) if Group and Group:IsAlive() then - for _,_unit in pairs(Group:GetUnits()) do - local unit=_unit --Wrapper.Unit#UNIT + for _, _unit in pairs( Group:GetUnits() ) do + local unit = _unit -- Wrapper.Unit#UNIT if unit and unit:IsAlive() then - local isdetected=self:IsUnitDetected(unit, DetectVisual, DetectOptical, DetectRadar, DetectIRST, DetectRWR, DetectDLINK) + local isdetected = self:IsUnitDetected( unit, DetectVisual, DetectOptical, DetectRadar, DetectIRST, DetectRWR, DetectDLINK ) if isdetected then return true @@ -2853,7 +2789,6 @@ function CONTROLLABLE:IsGroupDetected( Group, DetectVisual, DetectOptical, Detec return nil end - --- Return the detected targets of the controllable. -- The optional parametes specify the detection methods that can be applied. -- If **no** detection method is given, the detection will use **all** the available methods by default. @@ -2866,23 +2801,23 @@ end -- @param #boolean DetectRWR (Optional) If *false*, do not include targets detected by RWR. -- @param #boolean DetectDLINK (Optional) If *false*, do not include targets detected by data link. -- @return Core.Set#SET_UNIT Set of detected units. -function CONTROLLABLE:GetDetectedUnitSet(DetectVisual, DetectOptical, DetectRadar, DetectIRST, DetectRWR, DetectDLINK) +function CONTROLLABLE:GetDetectedUnitSet( DetectVisual, DetectOptical, DetectRadar, DetectIRST, DetectRWR, DetectDLINK ) -- Get detected DCS units. - local detectedtargets=self:GetDetectedTargets(DetectVisual, DetectOptical, DetectRadar, DetectIRST, DetectRWR, DetectDLINK) + local detectedtargets = self:GetDetectedTargets( DetectVisual, DetectOptical, DetectRadar, DetectIRST, DetectRWR, DetectDLINK ) - local unitset=SET_UNIT:New() + local unitset = SET_UNIT:New() - for DetectionObjectID, Detection in pairs(detectedtargets or {}) do - local DetectedObject=Detection.object -- DCS#Object + for DetectionObjectID, Detection in pairs( detectedtargets or {} ) do + local DetectedObject = Detection.object -- DCS#Object - if DetectedObject and DetectedObject:isExist() and DetectedObject.id_<50000000 then - local unit=UNIT:Find(DetectedObject) + if DetectedObject and DetectedObject:isExist() and DetectedObject.id_ < 50000000 then + local unit = UNIT:Find( DetectedObject ) if unit and unit:IsAlive() then - if not unitset:FindUnit(unit:GetName()) then - unitset:AddUnit(unit) + if not unitset:FindUnit( unit:GetName() ) then + unitset:AddUnit( unit ) end end @@ -2903,24 +2838,24 @@ end -- @param #boolean DetectRWR (Optional) If *false*, do not include targets detected by RWR. -- @param #boolean DetectDLINK (Optional) If *false*, do not include targets detected by data link. -- @return Core.Set#SET_GROUP Set of detected groups. -function CONTROLLABLE:GetDetectedGroupSet(DetectVisual, DetectOptical, DetectRadar, DetectIRST, DetectRWR, DetectDLINK) +function CONTROLLABLE:GetDetectedGroupSet( DetectVisual, DetectOptical, DetectRadar, DetectIRST, DetectRWR, DetectDLINK ) -- Get detected DCS units. - local detectedtargets=self:GetDetectedTargets(DetectVisual, DetectOptical, DetectRadar, DetectIRST, DetectRWR, DetectDLINK) + local detectedtargets = self:GetDetectedTargets( DetectVisual, DetectOptical, DetectRadar, DetectIRST, DetectRWR, DetectDLINK ) - local groupset=SET_GROUP:New() + local groupset = SET_GROUP:New() - for DetectionObjectID, Detection in pairs(detectedtargets or {}) do - local DetectedObject=Detection.object -- DCS#Object + for DetectionObjectID, Detection in pairs( detectedtargets or {} ) do + local DetectedObject = Detection.object -- DCS#Object - if DetectedObject and DetectedObject:isExist() and DetectedObject.id_<50000000 then - local unit=UNIT:Find(DetectedObject) + if DetectedObject and DetectedObject:isExist() and DetectedObject.id_ < 50000000 then + local unit = UNIT:Find( DetectedObject ) if unit and unit:IsAlive() then - local group=unit:GetGroup() + local group = unit:GetGroup() - if group and not groupset:FindGroup(group:GetName()) then - groupset:AddGroup(group) + if group and not groupset:FindGroup( group:GetName() ) then + groupset:AddGroup( group ) end end @@ -2930,7 +2865,6 @@ function CONTROLLABLE:GetDetectedGroupSet(DetectVisual, DetectOptical, DetectRad return groupset end - -- Options --- Set option. @@ -2938,7 +2872,7 @@ end -- @param #number OptionID ID/Type of the option. -- @param #number OptionValue Value of the option -- @return #CONTROLLABLE self -function CONTROLLABLE:SetOption(OptionID, OptionValue) +function CONTROLLABLE:SetOption( OptionID, OptionValue ) local DCSControllable = self:GetDCSObject() if DCSControllable then @@ -2956,7 +2890,7 @@ end -- @param Wrapper.Controllable#CONTROLLABLE self -- @param #number ROEvalue ROE value. See ENUMS.ROE. -- @return #CONTROLLABLE self -function CONTROLLABLE:OptionROE(ROEvalue) +function CONTROLLABLE:OptionROE( ROEvalue ) local DCSControllable = self:GetDCSObject() @@ -2965,11 +2899,11 @@ function CONTROLLABLE:OptionROE(ROEvalue) local Controller = self:_GetController() if self:IsAir() then - Controller:setOption(AI.Option.Air.id.ROE, ROEvalue ) + Controller:setOption( AI.Option.Air.id.ROE, ROEvalue ) elseif self:IsGround() then - Controller:setOption(AI.Option.Ground.id.ROE, ROEvalue ) + Controller:setOption( AI.Option.Ground.id.ROE, ROEvalue ) elseif self:IsShip() then - Controller:setOption(AI.Option.Naval.id.ROE, ROEvalue ) + Controller:setOption( AI.Option.Naval.id.ROE, ROEvalue ) end return self @@ -3199,7 +3133,6 @@ function CONTROLLABLE:OptionROTNoReactionPossible() return nil end - --- No evasion on enemy threats. -- @param #CONTROLLABLE self -- @return #CONTROLLABLE self @@ -3224,7 +3157,7 @@ end -- @param #CONTROLLABLE self -- @param #number ROTvalue ROT value. See ENUMS.ROT. -- @return #CONTROLLABLE self -function CONTROLLABLE:OptionROT(ROTvalue) +function CONTROLLABLE:OptionROT( ROTvalue ) self:F2( { self.ControllableName } ) local DCSControllable = self:GetDCSObject() @@ -3297,7 +3230,6 @@ function CONTROLLABLE:OptionROTEvadeFirePossible() return nil end - --- Evade on fire. -- @param #CONTROLLABLE self -- @return #CONTROLLABLE self @@ -3336,7 +3268,6 @@ function CONTROLLABLE:OptionROTVerticalPossible() return nil end - --- Evade on fire using vertical manoeuvres. -- @param #CONTROLLABLE self -- @return #CONTROLLABLE self @@ -3368,10 +3299,10 @@ function CONTROLLABLE:OptionAlarmStateAuto() local Controller = self:_GetController() if self:IsGround() then - Controller:setOption(AI.Option.Ground.id.ALARM_STATE, AI.Option.Ground.val.ALARM_STATE.AUTO) + Controller:setOption( AI.Option.Ground.id.ALARM_STATE, AI.Option.Ground.val.ALARM_STATE.AUTO ) elseif self:IsShip() then - --Controller:setOption(AI.Option.Naval.id.ALARM_STATE, AI.Option.Naval.val.ALARM_STATE.AUTO) - Controller:setOption(9, 0) + -- Controller:setOption(AI.Option.Naval.id.ALARM_STATE, AI.Option.Naval.val.ALARM_STATE.AUTO) + Controller:setOption( 9, 0 ) end return self @@ -3394,8 +3325,8 @@ function CONTROLLABLE:OptionAlarmStateGreen() Controller:setOption( AI.Option.Ground.id.ALARM_STATE, AI.Option.Ground.val.ALARM_STATE.GREEN ) elseif self:IsShip() then -- AI.Option.Naval.id.ALARM_STATE does not seem to exist! - --Controller:setOption( AI.Option.Naval.id.ALARM_STATE, AI.Option.Naval.val.ALARM_STATE.GREEN ) - Controller:setOption(9, 1) + -- Controller:setOption( AI.Option.Naval.id.ALARM_STATE, AI.Option.Naval.val.ALARM_STATE.GREEN ) + Controller:setOption( 9, 1 ) end return self @@ -3415,10 +3346,10 @@ function CONTROLLABLE:OptionAlarmStateRed() local Controller = self:_GetController() if self:IsGround() then - Controller:setOption(AI.Option.Ground.id.ALARM_STATE, AI.Option.Ground.val.ALARM_STATE.RED) + Controller:setOption( AI.Option.Ground.id.ALARM_STATE, AI.Option.Ground.val.ALARM_STATE.RED ) elseif self:IsShip() then - --Controller:setOption(AI.Option.Naval.id.ALARM_STATE, AI.Option.Naval.val.ALARM_STATE.RED) - Controller:setOption(9, 2) + -- Controller:setOption(AI.Option.Naval.id.ALARM_STATE, AI.Option.Naval.val.ALARM_STATE.RED) + Controller:setOption( 9, 2 ) end return self @@ -3427,18 +3358,17 @@ function CONTROLLABLE:OptionAlarmStateRed() return nil end - --- Set RTB on bingo fuel. -- @param #CONTROLLABLE self -- @param #boolean RTB true if RTB on bingo fuel (default), false if no RTB on bingo fuel. -- Warning! When you switch this option off, the airborne group will continue to fly until all fuel has been consumed, and will crash. -- @return #CONTROLLABLE self -function CONTROLLABLE:OptionRTBBingoFuel( RTB ) --R2.2 +function CONTROLLABLE:OptionRTBBingoFuel( RTB ) -- R2.2 self:F2( { self.ControllableName } ) - --RTB = RTB or true - if RTB==nil then - RTB=true + -- RTB = RTB or true + if RTB == nil then + RTB = true end local DCSControllable = self:GetDCSObject() @@ -3455,7 +3385,6 @@ function CONTROLLABLE:OptionRTBBingoFuel( RTB ) --R2.2 return nil end - --- Set RTB on ammo. -- @param #CONTROLLABLE self -- @param #boolean WeaponsFlag Weapons.flag enumerator. @@ -3477,7 +3406,6 @@ function CONTROLLABLE:OptionRTBAmmo( WeaponsFlag ) return nil end - --- Allow to Jettison of weapons upon threat. -- @param #CONTROLLABLE self -- @return #CONTROLLABLE self @@ -3498,7 +3426,6 @@ function CONTROLLABLE:OptionAllowJettisonWeaponsOnThreat() return nil end - --- Keep weapons upon threat. -- @param #CONTROLLABLE self -- @return #CONTROLLABLE self @@ -3523,15 +3450,15 @@ end -- @param #CONTROLLABLE self -- @param #boolean Prohibit If true or nil, prohibit. If false, do not prohibit. -- @return #CONTROLLABLE self -function CONTROLLABLE:OptionProhibitAfterburner(Prohibit) +function CONTROLLABLE:OptionProhibitAfterburner( Prohibit ) self:F2( { self.ControllableName } ) - if Prohibit==nil then - Prohibit=true + if Prohibit == nil then + Prohibit = true end if self:IsAir() then - self:SetOption(AI.Option.Air.id.PROHIBIT_AB, Prohibit) + self:SetOption( AI.Option.Air.id.PROHIBIT_AB, Prohibit ) end return self @@ -3544,7 +3471,7 @@ function CONTROLLABLE:OptionECM_Never() self:F2( { self.ControllableName } ) if self:IsAir() then - self:SetOption(AI.Option.Air.id.ECM_USING, 0) + self:SetOption( AI.Option.Air.id.ECM_USING, 0 ) end return self @@ -3557,13 +3484,12 @@ function CONTROLLABLE:OptionECM_OnlyLockByRadar() self:F2( { self.ControllableName } ) if self:IsAir() then - self:SetOption(AI.Option.Air.id.ECM_USING, 1) + self:SetOption( AI.Option.Air.id.ECM_USING, 1 ) end return self end - --- Defines the usage of Electronic Counter Measures by airborne forces. If the AI is being detected by a radar they will enable their ECM. -- @param #CONTROLLABLE self -- @return #CONTROLLABLE self @@ -3571,7 +3497,7 @@ function CONTROLLABLE:OptionECM_DetectedLockByRadar() self:F2( { self.ControllableName } ) if self:IsAir() then - self:SetOption(AI.Option.Air.id.ECM_USING, 2) + self:SetOption( AI.Option.Air.id.ECM_USING, 2 ) end return self @@ -3584,7 +3510,7 @@ function CONTROLLABLE:OptionECM_AlwaysOn() self:F2( { self.ControllableName } ) if self:IsAir() then - self:SetOption(AI.Option.Air.id.ECM_USING, 3) + self:SetOption( AI.Option.Air.id.ECM_USING, 3 ) end return self @@ -3613,7 +3539,7 @@ end -- @param #CONTROLLABLE self -- @return #table WayPoints If WayPoints is given, then return the WayPoints structure. function CONTROLLABLE:GetWayPoints() - self:F( ) + self:F() if self.WayPoints then return self.WayPoints @@ -3636,7 +3562,6 @@ function CONTROLLABLE:WayPointFunction( WayPoint, WayPointIndex, WayPointFunctio return self end - --- Executes the WayPoint plan. -- The function gets a WayPoint parameter, that you can use to restart the mission at a specific WayPoint. -- Note that when the WayPoint parameter is used, the new start mission waypoint of the controllable will be 1! @@ -3698,8 +3623,8 @@ end --- Sets Controllable Option for Restriction of Afterburner. -- @param #CONTROLLABLE self -- @param #boolean RestrictBurner If true, restrict burner. If false or nil, allow (unrestrict) burner. -function CONTROLLABLE:OptionRestrictBurner(RestrictBurner) - self:F2({self.ControllableName}) +function CONTROLLABLE:OptionRestrictBurner( RestrictBurner ) + self:F2( { self.ControllableName } ) local DCSControllable = self:GetDCSObject() @@ -3711,11 +3636,11 @@ function CONTROLLABLE:OptionRestrictBurner(RestrictBurner) -- Issue https://github.com/FlightControl-Master/MOOSE/issues/1216 if RestrictBurner == true then if self:IsAir() then - Controller:setOption(16, true) + Controller:setOption( 16, true ) end else if self:IsAir() then - Controller:setOption(16, false) + Controller:setOption( 16, false ) end end @@ -3729,20 +3654,20 @@ end -- @param #number range Defines the range -- @return #CONTROLLABLE self -- @usage Range can be one of MAX_RANGE = 0, NEZ_RANGE = 1, HALF_WAY_RMAX_NEZ = 2, TARGET_THREAT_EST = 3, RANDOM_RANGE = 4. Defaults to 3. See: https://wiki.hoggitworld.com/view/DCS_option_missileAttack -function CONTROLLABLE:OptionAAAttackRange(range) +function CONTROLLABLE:OptionAAAttackRange( range ) self:F2( { self.ControllableName } ) -- defaults to 3 local range = range or 3 - if range < 0 or range > 4 then + if range < 0 or range > 4 then range = 3 end local DCSControllable = self:GetDCSObject() if DCSControllable then local Controller = self:_GetController() if Controller then - if self:IsAir() then - self:SetOption(AI.Option.Air.val.MISSILE_ATTACK, range) - end + if self:IsAir() then + self:SetOption( AI.Option.Air.val.MISSILE_ATTACK, range ) + end end return self end @@ -3753,22 +3678,22 @@ end -- @param #CONTROLLABLE self -- @param #number EngageRange Engage range limit in percent (a number between 0 and 100). Default 100. -- @return #CONTROLLABLE self -function CONTROLLABLE:OptionEngageRange(EngageRange) +function CONTROLLABLE:OptionEngageRange( EngageRange ) self:F2( { self.ControllableName } ) -- Set default if not specified. - EngageRange=EngageRange or 100 - if EngageRange < 0 or EngageRange > 100 then + EngageRange = EngageRange or 100 + if EngageRange < 0 or EngageRange > 100 then EngageRange = 100 end local DCSControllable = self:GetDCSObject() if DCSControllable then local Controller = self:_GetController() if Controller then - if self:IsGround() then - self:SetOption(AI.Option.Ground.id.AC_ENGAGEMENT_RANGE_RESTRICTION, EngageRange) - end + if self:IsGround() then + self:SetOption( AI.Option.Ground.id.AC_ENGAGEMENT_RANGE_RESTRICTION, EngageRange ) + end end - return self + return self end return nil end @@ -3781,26 +3706,26 @@ end -- @param #boolean shortcut If true and onroad is set, take a shorter route - if available - off road, default false -- @param #string formation Formation string as in the mission editor, e.g. "Vee", "Diamond", "Line abreast", etc. Defaults to "Off Road" -- @return #CONTROLLABLE self -function CONTROLLABLE:RelocateGroundRandomInRadius(speed, radius, onroad, shortcut, formation) +function CONTROLLABLE:RelocateGroundRandomInRadius( speed, radius, onroad, shortcut, formation ) self:F2( { self.ControllableName } ) - local _coord = self:GetCoordinate() - local _radius = radius or 500 - local _speed = speed or 20 - local _tocoord = _coord:GetRandomCoordinateInRadius(_radius,100) - local _onroad = onroad or true - local _grptsk = {} - local _candoroad = false - local _shortcut = shortcut or false - local _formation = formation or "Off Road" + local _coord = self:GetCoordinate() + local _radius = radius or 500 + local _speed = speed or 20 + local _tocoord = _coord:GetRandomCoordinateInRadius( _radius, 100 ) + local _onroad = onroad or true + local _grptsk = {} + local _candoroad = false + local _shortcut = shortcut or false + local _formation = formation or "Off Road" - -- create a DCS Task an push it on the group - if onroad then - _grptsk, _candoroad = self:TaskGroundOnRoad(_tocoord,_speed,_formation,_shortcut) - self:Route(_grptsk,5) - else - self:TaskRouteToVec2(_tocoord:GetVec2(),_speed,_formation) - end + -- create a DCS Task an push it on the group + if onroad then + _grptsk, _candoroad = self:TaskGroundOnRoad( _tocoord, _speed, _formation, _shortcut ) + self:Route( _grptsk, 5 ) + else + self:TaskRouteToVec2( _tocoord:GetVec2(), _speed, _formation ) + end return self end @@ -3809,7 +3734,7 @@ end -- @param #CONTROLLABLE self -- @param #number Seconds Any positive number: AI will disperse, but only for the specified time before continuing their route. 0: AI will not disperse. -- @return #CONTROLLABLE self -function CONTROLLABLE:OptionDisperseOnAttack(Seconds) +function CONTROLLABLE:OptionDisperseOnAttack( Seconds ) self:F2( { self.ControllableName } ) -- Set default if not specified. local seconds = Seconds or 0 @@ -3817,11 +3742,11 @@ function CONTROLLABLE:OptionDisperseOnAttack(Seconds) if DCSControllable then local Controller = self:_GetController() if Controller then - if self:IsGround() then - self:SetOption(AI.Option.Ground.id.DISPERSE_ON_ATTACK, seconds) - end + if self:IsGround() then + self:SetOption( AI.Option.Ground.id.DISPERSE_ON_ATTACK, seconds ) + end end - return self + return self end return nil end @@ -3836,11 +3761,11 @@ function POSITIONABLE:IsSubmarine() if DCSUnit then local UnitDescriptor = DCSUnit:getDesc() - if UnitDescriptor.attributes["Submarines"] == true then - return true - else - return false - end + if UnitDescriptor.attributes["Submarines"] == true then + return true + else + return false + end end return nil diff --git a/Moose Development/Moose/Wrapper/Identifiable.lua b/Moose Development/Moose/Wrapper/Identifiable.lua index 5b340aec8..a450c4ef3 100644 --- a/Moose Development/Moose/Wrapper/Identifiable.lua +++ b/Moose Development/Moose/Wrapper/Identifiable.lua @@ -176,7 +176,7 @@ function IDENTIFIABLE:GetCoalitionName() if DCSIdentifiable then - -- Get coaliton ID. + -- Get coalition ID. local IdentifiableCoalition = DCSIdentifiable:getCoalition() self:T3( IdentifiableCoalition ) diff --git a/Moose Development/Moose/Wrapper/Marker.lua b/Moose Development/Moose/Wrapper/Marker.lua index 88a868501..b5dcfc5df 100644 --- a/Moose Development/Moose/Wrapper/Marker.lua +++ b/Moose Development/Moose/Wrapper/Marker.lua @@ -15,7 +15,6 @@ -- @module Wrapper.Marker -- @image Wrapper_Marker.png - --- Marker class. -- @type MARKER -- @field #string ClassName Name of the class. @@ -24,7 +23,7 @@ -- @field #number mid Marker ID. -- @field Core.Point#COORDINATE coordinate Coordinate of the mark. -- @field #string text Text displayed in the mark panel. --- @field #string message Message dispayed when the mark is added. +-- @field #string message Message displayed when the mark is added. -- @field #boolean readonly Marker is read-only. -- @field #number coalition Coalition to which the marker is displayed. -- @extends Core.Fsm#FSM @@ -42,29 +41,29 @@ -- # Create a Marker -- -- -- Create a MARKER object at Batumi with a trivial text. --- local Coordinate=AIRBASE:FindByName("Batumi"):GetCoordinate() --- mymarker=MARKER:New(Coordinate, "I am Batumi Airfield") +-- local Coordinate = AIRBASE:FindByName( "Batumi" ):GetCoordinate() +-- mymarker = MARKER:New( Coordinate, "I am Batumi Airfield" ) -- --- Now this does **not** show the marker yet. We still need to specifiy to whom it is shown. There are several options, i.e. --- show the marker to everyone, to a speficic coaliton only, or only to a specific group. +-- Now this does **not** show the marker yet. We still need to specify to whom it is shown. There are several options, i.e. +-- show the marker to everyone, to a specific coalition only, or only to a specific group. -- -- ## For Everyone -- -- If the marker should be visible to everyone, you can use the :ToAll() function. -- --- mymarker=MARKER:New(Coordinate, "I am Batumi Airfield"):ToAll() +-- mymarker = MARKER:New( Coordinate, "I am Batumi Airfield" ):ToAll() -- --- ## For a Coaliton +-- ## For a Coalition -- -- If the maker should be visible to a specific coalition, you can use the :ToCoalition() function. -- --- mymarker=MARKER:New(Coordinate, "I am Batumi Airfield"):ToCoaliton(coaliton.side.BLUE) +-- mymarker = MARKER:New( Coordinate , "I am Batumi Airfield" ):ToCoalition( coalition.side.BLUE ) -- --- ### To Blue Coaliton +-- ### To Blue Coalition -- -- ### To Red Coalition -- --- This would show the marker only to the Blue coaliton. +-- This would show the marker only to the Blue coalition. -- -- ## For a Group -- @@ -76,28 +75,28 @@ -- -- The marker text and coordinate can be updated easily as shown below. -- --- However, note that **updateing involves to remove and recreate the marker if either text or its coordinate is changed**. +-- However, note that **updating involves to remove and recreate the marker if either text or its coordinate is changed**. -- *This is a DCS scripting engine limitation.* -- -- ## Update Text -- --- If you created a marker "mymarker" as shown above, you can update the dispayed test by +-- If you created a marker "mymarker" as shown above, you can update the displayed test by -- --- mymarker:UpdateText("I am the new text at Batumi") +-- mymarker:UpdateText( "I am the new text at Batumi" ) -- -- The update can also be delayed by, e.g. 90 seconds, using -- --- mymarker:UpdateText("I am the new text at Batumi", 90) +-- mymarker:UpdateText( "I am the new text at Batumi", 90 ) -- -- ## Update Coordinate -- -- If you created a marker "mymarker" as shown above, you can update its coordinate on the F10 map by -- --- mymarker:UpdateCoordinate(NewCoordinate) +-- mymarker:UpdateCoordinate( NewCoordinate ) -- -- The update can also be delayed by, e.g. 60 seconds, using -- --- mymarker:UpdateCoordinate(NewCoordinate, 60) +-- mymarker:UpdateCoordinate( NewCoordinate , 60 ) -- -- # Retrieve Data -- @@ -105,18 +104,18 @@ -- -- ## Text -- --- local text=mymarker:GetText() --- env.info("Marker Text = " .. text) +-- local text =mymarker:GetText() +-- env.info( "Marker Text = " .. text ) -- -- ## Coordinate -- --- local Coordinate=mymarker:GetCoordinate() --- env.info("Marker Coordinate LL DSM = " .. Coordinate:ToStringLLDMS()) +-- local Coordinate = mymarker:GetCoordinate() +-- env.info( "Marker Coordinate LL DSM = " .. Coordinate:ToStringLLDMS() ) -- -- -- # FSM Events -- --- Moose creates addditonal events, so called FSM event, when markers are added, changed, removed, and text or the coordianteis updated. +-- Moose creates additional events, so called FSM event, when markers are added, changed, removed, and text or the coordinate is updated. -- -- These events can be captured and used for processing via OnAfter functions as shown below. -- @@ -133,26 +132,25 @@ -- -- # Examples -- --- -- @field #MARKER MARKER = { - ClassName = "MARKER", - Debug = false, - lid = nil, - mid = nil, - coordinate = nil, - text = nil, - message = nil, - readonly = nil, - coalition = nil, + ClassName = "MARKER", + Debug = false, + lid = nil, + mid = nil, + coordinate = nil, + text = nil, + message = nil, + readonly = nil, + coalition = nil, } --- Marker ID. Running number. -_MARKERID=0 +_MARKERID = 0 --- Marker class version. -- @field #string version -MARKER.version="0.1.0" +MARKER.version = "0.1.0" ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -- TODO list @@ -172,38 +170,38 @@ MARKER.version="0.1.0" -- @param Core.Point#COORDINATE Coordinate Coordinate where to place the marker. -- @param #string Text Text displayed on the mark panel. -- @return #MARKER self -function MARKER:New(Coordinate, Text) +function MARKER:New( Coordinate, Text ) -- Inherit everything from FSM class. - local self=BASE:Inherit(self, FSM:New()) -- #MARKER + local self = BASE:Inherit( self, FSM:New() ) -- #MARKER - self.coordinate=Coordinate + self.coordinate = Coordinate - self.text=Text + self.text = Text -- Defaults - self.readonly=false - self.message="" + self.readonly = false + self.message = "" -- New marker ID. This is not the one of the actual marker. - _MARKERID=_MARKERID+1 + _MARKERID = _MARKERID + 1 - self.myid=_MARKERID + self.myid = _MARKERID -- Log ID. - self.lid=string.format("Marker #%d | ", self.myid) + self.lid = string.format( "Marker #%d | ", self.myid ) -- Start State. - self:SetStartState("Invisible") + self:SetStartState( "Invisible" ) -- Add FSM transitions. -- From State --> Event --> To State - self:AddTransition("Invisible", "Added", "Visible") -- Marker was added. - self:AddTransition("Visible", "Removed", "Invisible") -- Marker was removed. - self:AddTransition("*", "Changed", "*") -- Marker was changed. + self:AddTransition( "Invisible", "Added", "Visible" ) -- Marker was added. + self:AddTransition( "Visible", "Removed", "Invisible" ) -- Marker was removed. + self:AddTransition( "*", "Changed", "*" ) -- Marker was changed. - self:AddTransition("*", "TextUpdate", "*") -- Text updated. - self:AddTransition("*", "CoordUpdate", "*") -- Coordinates updated. + self:AddTransition( "*", "TextUpdate", "*" ) -- Text updated. + self:AddTransition( "*", "CoordUpdate", "*" ) -- Coordinates updated. --- Triggers the FSM event "Added". -- @function [parent=#MARKER] Added @@ -223,7 +221,6 @@ function MARKER:New(Coordinate, Text) -- @param #string To To state. -- @param Core.Event#EVENTDATA EventData Event data table. - --- Triggers the FSM event "Removed". -- @function [parent=#MARKER] Removed -- @param #MARKER self @@ -242,7 +239,6 @@ function MARKER:New(Coordinate, Text) -- @param #string To To state. -- @param Core.Event#EVENTDATA EventData Event data table. - --- Triggers the FSM event "Changed". -- @function [parent=#MARKER] Changed -- @param #MARKER self @@ -261,7 +257,6 @@ function MARKER:New(Coordinate, Text) -- @param #string To To state. -- @param Core.Event#EVENTDATA EventData Event data table. - --- Triggers the FSM event "TextUpdate". -- @function [parent=#MARKER] TextUpdate -- @param #MARKER self @@ -280,7 +275,6 @@ function MARKER:New(Coordinate, Text) -- @param #string To To state. -- @param #string Text The new text. - --- Triggers the FSM event "CoordUpdate". -- @function [parent=#MARKER] CoordUpdate -- @param #MARKER self @@ -299,11 +293,10 @@ function MARKER:New(Coordinate, Text) -- @param #string To To state. -- @param Core.Point#COORDINATE Coordinate The updated Coordinate. - -- Handle events. - self:HandleEvent(EVENTS.MarkAdded) - self:HandleEvent(EVENTS.MarkRemoved) - self:HandleEvent(EVENTS.MarkChange) + self:HandleEvent( EVENTS.MarkAdded ) + self:HandleEvent( EVENTS.MarkRemoved ) + self:HandleEvent( EVENTS.MarkChange ) return self end @@ -317,7 +310,7 @@ end -- @return #MARKER self function MARKER:ReadOnly() - self.readonly=true + self.readonly = true return self end @@ -326,9 +319,9 @@ end -- @param #MARKER self -- @param #string Text Message displayed when the marker is added. -- @return #MARKER self -function MARKER:Message(Text) +function MARKER:Message( Text ) - self.message=Text or "" + self.message = Text or "" return self end @@ -337,28 +330,28 @@ end -- @param #MARKER self -- @param #number Delay (Optional) Delay in seconds, before the marker is created. -- @return #MARKER self -function MARKER:ToAll(Delay) +function MARKER:ToAll( Delay ) - if Delay and Delay>0 then - self:ScheduleOnce(Delay, MARKER.ToAll, self) + if Delay and Delay > 0 then + self:ScheduleOnce( Delay, MARKER.ToAll, self ) else - self.toall=true - self.tocoaliton=nil - self.coalition=nil - self.togroup=nil - self.groupname=nil - self.groupid=nil + self.toall = true + self.tocoalition = nil + self.coalition = nil + self.togroup = nil + self.groupname = nil + self.groupid = nil -- First remove an existing mark. if self.shown then self:Remove() end - self.mid=UTILS.GetMarkID() + self.mid = UTILS.GetMarkID() -- Call DCS function. - trigger.action.markToAll(self.mid, self.text, self.coordinate:GetVec3(), self.readonly, self.message) + trigger.action.markToAll( self.mid, self.text, self.coordinate:GetVec3(), self.readonly, self.message ) end @@ -367,32 +360,32 @@ end --- Place marker visible for a specific coalition only. -- @param #MARKER self --- @param #number Coalition Coalition 1=Red, 2=Blue, 0=Neutral. See `coaliton.side.RED`. +-- @param #number Coalition Coalition 1=Red, 2=Blue, 0=Neutral. See `coalition.side.RED`. -- @param #number Delay (Optional) Delay in seconds, before the marker is created. -- @return #MARKER self -function MARKER:ToCoalition(Coalition, Delay) +function MARKER:ToCoalition( Coalition, Delay ) - if Delay and Delay>0 then - self:ScheduleOnce(Delay, MARKER.ToCoalition, self, Coalition) + if Delay and Delay > 0 then + self:ScheduleOnce( Delay, MARKER.ToCoalition, self, Coalition ) else - self.coalition=Coalition + self.coalition = Coalition - self.tocoaliton=true - self.toall=false - self.togroup=false - self.groupname=nil - self.groupid=nil + self.tocoalition = true + self.toall = false + self.togroup = false + self.groupname = nil + self.groupid = nil -- First remove an existing mark. if self.shown then self:Remove() end - self.mid=UTILS.GetMarkID() + self.mid = UTILS.GetMarkID() -- Call DCS function. - trigger.action.markToCoalition(self.mid, self.text, self.coordinate:GetVec3(), self.coalition, self.readonly, self.message) + trigger.action.markToCoalition( self.mid, self.text, self.coordinate:GetVec3(), self.coalition, self.readonly, self.message ) end @@ -403,8 +396,8 @@ end -- @param #MARKER self -- @param #number Delay (Optional) Delay in seconds, before the marker is created. -- @return #MARKER self -function MARKER:ToBlue(Delay) - self:ToCoalition(coalition.side.BLUE, Delay) +function MARKER:ToBlue( Delay ) + self:ToCoalition( coalition.side.BLUE, Delay ) return self end @@ -412,8 +405,8 @@ end -- @param #MARKER self -- @param #number Delay (Optional) Delay in seconds, before the marker is created. -- @return #MARKER self -function MARKER:ToRed(Delay) - self:ToCoalition(coalition.side.RED, Delay) +function MARKER:ToRed( Delay ) + self:ToCoalition( coalition.side.RED, Delay ) return self end @@ -421,51 +414,50 @@ end -- @param #MARKER self -- @param #number Delay (Optional) Delay in seconds, before the marker is created. -- @return #MARKER self -function MARKER:ToNeutral(Delay) - self:ToCoalition(coalition.side.NEUTRAL, Delay) +function MARKER:ToNeutral( Delay ) + self:ToCoalition( coalition.side.NEUTRAL, Delay ) return self end - --- Place marker visible for a specific group only. -- @param #MARKER self -- @param Wrapper.Group#GROUP Group The group to which the marker is displayed. -- @param #number Delay (Optional) Delay in seconds, before the marker is created. -- @return #MARKER self -function MARKER:ToGroup(Group, Delay) +function MARKER:ToGroup( Group, Delay ) - if Delay and Delay>0 then - self:ScheduleOnce(Delay, MARKER.ToGroup, self, Group) + if Delay and Delay > 0 then + self:ScheduleOnce( Delay, MARKER.ToGroup, self, Group ) else -- Check if group exists. - if Group and Group:IsAlive()~=nil then + if Group and Group:IsAlive() ~= nil then - self.groupid=Group:GetID() + self.groupid = Group:GetID() if self.groupid then - self.groupname=Group:GetName() + self.groupname = Group:GetName() - self.togroup=true - self.tocoaliton=nil - self.coalition=nil - self.toall=nil + self.togroup = true + self.tocoalition = nil + self.coalition = nil + self.toall = nil -- First remove an existing mark. if self.shown then self:Remove() end - self.mid=UTILS.GetMarkID() + self.mid = UTILS.GetMarkID() -- Call DCS function. - trigger.action.markToGroup(self.mid, self.text, self.coordinate:GetVec3(), self.groupid, self.readonly, self.message) + trigger.action.markToGroup( self.mid, self.text, self.coordinate:GetVec3(), self.groupid, self.readonly, self.message ) end else - --TODO: Warning! + -- TODO: Warning! end end @@ -478,17 +470,17 @@ end -- @param #string Text Updated text. -- @param #number Delay (Optional) Delay in seconds, before the marker is created. -- @return #MARKER self -function MARKER:UpdateText(Text, Delay) +function MARKER:UpdateText( Text, Delay ) - if Delay and Delay>0 then - self:ScheduleOnce(Delay, MARKER.UpdateText, self, Text) + if Delay and Delay > 0 then + self:ScheduleOnce( Delay, MARKER.UpdateText, self, Text ) else - self.text=tostring(Text) + self.text = tostring( Text ) self:Refresh() - self:TextUpdate(tostring(Text)) + self:TextUpdate( tostring( Text ) ) end @@ -500,17 +492,17 @@ end -- @param Core.Point#COORDINATE Coordinate The new coordinate. -- @param #number Delay (Optional) Delay in seconds, before the marker is created. -- @return #MARKER self -function MARKER:UpdateCoordinate(Coordinate, Delay) +function MARKER:UpdateCoordinate( Coordinate, Delay ) - if Delay and Delay>0 then - self:ScheduleOnce(Delay, MARKER.UpdateCoordinate, self, Coordinate) + if Delay and Delay > 0 then + self:ScheduleOnce( Delay, MARKER.UpdateCoordinate, self, Coordinate ) else - self.coordinate=Coordinate + self.coordinate = Coordinate self:Refresh() - self:CoordUpdate(Coordinate) + self:CoordUpdate( Coordinate ) end @@ -521,28 +513,28 @@ end -- @param #MARKER self -- @param #number Delay (Optional) Delay in seconds, before the marker is created. -- @return #MARKER self -function MARKER:Refresh(Delay) +function MARKER:Refresh( Delay ) - if Delay and Delay>0 then - self:ScheduleOnce(Delay, MARKER.Refresh, self) + if Delay and Delay > 0 then + self:ScheduleOnce( Delay, MARKER.Refresh, self ) else if self.toall then self:ToAll() - elseif self.tocoaliton then + elseif self.tocoalition then - self:ToCoalition(self.coalition) + self:ToCoalition( self.coalition ) elseif self.togroup then - local group=GROUP:FindByName(self.groupname) + local group = GROUP:FindByName( self.groupname ) - self:ToGroup(group) + self:ToGroup( group ) else - self:E(self.lid.."ERROR: unknown To in :Refresh()!") + self:E( self.lid .. "ERROR: unknown To in :Refresh()!" ) end end @@ -554,16 +546,16 @@ end -- @param #MARKER self -- @param #number Delay (Optional) Delay in seconds, before the marker is removed. -- @return #MARKER self -function MARKER:Remove(Delay) +function MARKER:Remove( Delay ) - if Delay and Delay>0 then - self:ScheduleOnce(Delay, MARKER.Remove, self) + if Delay and Delay > 0 then + self:ScheduleOnce( Delay, MARKER.Remove, self ) else if self.shown then -- Call DCS function. - trigger.action.removeMark(self.mid) + trigger.action.removeMark( self.mid ) end @@ -590,24 +582,23 @@ end -- @param #MARKER self -- @param #string Text Marker text. Default is an empty sting "". -- @return #MARKER self -function MARKER:SetText(Text) - self.text=Text and tostring(Text) or "" +function MARKER:SetText( Text ) + self.text = Text and tostring( Text ) or "" return self end - --- Check if marker is currently visible on the F10 map. -- @param #MARKER self -- @return #boolean True if the marker is currently visible. function MARKER:IsVisible() - return self:Is("Visible") + return self:Is( "Visible" ) end --- Check if marker is currently invisible on the F10 map. -- @param #MARKER self -- @return function MARKER:IsInvisible() - return self:Is("Invisible") + return self:Is( "Invisible" ) end ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- @@ -617,19 +608,19 @@ end --- Event function when a MARKER is added. -- @param #MARKER self -- @param Core.Event#EVENTDATA EventData -function MARKER:OnEventMarkAdded(EventData) +function MARKER:OnEventMarkAdded( EventData ) if EventData and EventData.MarkID then - local MarkID=EventData.MarkID + local MarkID = EventData.MarkID - self:T3(self.lid..string.format("Captured event MarkAdded for Mark ID=%s", tostring(MarkID))) + self:T3( self.lid .. string.format( "Captured event MarkAdded for Mark ID=%s", tostring( MarkID ) ) ) - if MarkID==self.mid then + if MarkID == self.mid then - self.shown=true + self.shown = true - self:Added(EventData) + self:Added( EventData ) end @@ -640,19 +631,19 @@ end --- Event function when a MARKER is removed. -- @param #MARKER self -- @param Core.Event#EVENTDATA EventData -function MARKER:OnEventMarkRemoved(EventData) +function MARKER:OnEventMarkRemoved( EventData ) if EventData and EventData.MarkID then - local MarkID=EventData.MarkID + local MarkID = EventData.MarkID - self:T3(self.lid..string.format("Captured event MarkAdded for Mark ID=%s", tostring(MarkID))) + self:T3( self.lid .. string.format( "Captured event MarkAdded for Mark ID=%s", tostring( MarkID ) ) ) - if MarkID==self.mid then + if MarkID == self.mid then - self.shown=false + self.shown = false - self:Removed(EventData) + self:Removed( EventData ) end @@ -663,19 +654,19 @@ end --- Event function when a MARKER changed. -- @param #MARKER self -- @param Core.Event#EVENTDATA EventData -function MARKER:OnEventMarkChange(EventData) +function MARKER:OnEventMarkChange( EventData ) if EventData and EventData.MarkID then - local MarkID=EventData.MarkID + local MarkID = EventData.MarkID - self:T3(self.lid..string.format("Captured event MarkChange for Mark ID=%s", tostring(MarkID))) + self:T3( self.lid .. string.format( "Captured event MarkChange for Mark ID=%s", tostring( MarkID ) ) ) - if MarkID==self.mid then + if MarkID == self.mid then - self:Changed(EventData) + self:Changed( EventData ) - self:TextChanged(tostring(EventData.MarkText)) + self:TextChanged( tostring( EventData.MarkText ) ) end @@ -693,17 +684,17 @@ end -- @param #string Event Event. -- @param #string To To state. -- @param Core.Event#EVENTDATA EventData Event data table. -function MARKER:onafterAdded(From, Event, To, EventData) +function MARKER:onafterAdded( From, Event, To, EventData ) -- Debug info. - local text=string.format("Captured event MarkAdded for myself:\n") - text=text..string.format("Marker ID = %s\n", tostring(EventData.MarkID)) - text=text..string.format("Coalition = %s\n", tostring(EventData.MarkCoalition)) - text=text..string.format("Group ID = %s\n", tostring(EventData.MarkGroupID)) - text=text..string.format("Initiator = %s\n", EventData.IniUnit and EventData.IniUnit:GetName() or "Nobody") - text=text..string.format("Coordinate = %s\n", EventData.MarkCoordinate and EventData.MarkCoordinate:ToStringLLDMS() or "Nowhere") - text=text..string.format("Text: \n%s", tostring(EventData.MarkText)) - self:T2(self.lid..text) + local text = string.format( "Captured event MarkAdded for myself:\n" ) + text = text .. string.format( "Marker ID = %s\n", tostring( EventData.MarkID ) ) + text = text .. string.format( "Coalition = %s\n", tostring( EventData.MarkCoalition ) ) + text = text .. string.format( "Group ID = %s\n", tostring( EventData.MarkGroupID ) ) + text = text .. string.format( "Initiator = %s\n", EventData.IniUnit and EventData.IniUnit:GetName() or "Nobody" ) + text = text .. string.format( "Coordinate = %s\n", EventData.MarkCoordinate and EventData.MarkCoordinate:ToStringLLDMS() or "Nowhere" ) + text = text .. string.format( "Text: \n%s", tostring( EventData.MarkText ) ) + self:T2( self.lid .. text ) end @@ -713,17 +704,17 @@ end -- @param #string Event Event. -- @param #string To To state. -- @param Core.Event#EVENTDATA EventData Event data table. -function MARKER:onafterRemoved(From, Event, To, EventData) +function MARKER:onafterRemoved( From, Event, To, EventData ) -- Debug info. - local text=string.format("Captured event MarkRemoved for myself:\n") - text=text..string.format("Marker ID = %s\n", tostring(EventData.MarkID)) - text=text..string.format("Coalition = %s\n", tostring(EventData.MarkCoalition)) - text=text..string.format("Group ID = %s\n", tostring(EventData.MarkGroupID)) - text=text..string.format("Initiator = %s\n", EventData.IniUnit and EventData.IniUnit:GetName() or "Nobody") - text=text..string.format("Coordinate = %s\n", EventData.MarkCoordinate and EventData.MarkCoordinate:ToStringLLDMS() or "Nowhere") - text=text..string.format("Text: \n%s", tostring(EventData.MarkText)) - self:T2(self.lid..text) + local text = string.format( "Captured event MarkRemoved for myself:\n" ) + text = text .. string.format( "Marker ID = %s\n", tostring( EventData.MarkID ) ) + text = text .. string.format( "Coalition = %s\n", tostring( EventData.MarkCoalition ) ) + text = text .. string.format( "Group ID = %s\n", tostring( EventData.MarkGroupID ) ) + text = text .. string.format( "Initiator = %s\n", EventData.IniUnit and EventData.IniUnit:GetName() or "Nobody" ) + text = text .. string.format( "Coordinate = %s\n", EventData.MarkCoordinate and EventData.MarkCoordinate:ToStringLLDMS() or "Nowhere" ) + text = text .. string.format( "Text: \n%s", tostring( EventData.MarkText ) ) + self:T2( self.lid .. text ) end @@ -733,17 +724,17 @@ end -- @param #string Event Event. -- @param #string To To state. -- @param Core.Event#EVENTDATA EventData Event data table. -function MARKER:onafterChanged(From, Event, To, EventData) +function MARKER:onafterChanged( From, Event, To, EventData ) -- Debug info. - local text=string.format("Captured event MarkChange for myself:\n") - text=text..string.format("Marker ID = %s\n", tostring(EventData.MarkID)) - text=text..string.format("Coalition = %s\n", tostring(EventData.MarkCoalition)) - text=text..string.format("Group ID = %s\n", tostring(EventData.MarkGroupID)) - text=text..string.format("Initiator = %s\n", EventData.IniUnit and EventData.IniUnit:GetName() or "Nobody") - text=text..string.format("Coordinate = %s\n", EventData.MarkCoordinate and EventData.MarkCoordinate:ToStringLLDMS() or "Nowhere") - text=text..string.format("Text: \n%s", tostring(EventData.MarkText)) - self:T2(self.lid..text) + local text = string.format( "Captured event MarkChange for myself:\n" ) + text = text .. string.format( "Marker ID = %s\n", tostring( EventData.MarkID ) ) + text = text .. string.format( "Coalition = %s\n", tostring( EventData.MarkCoalition ) ) + text = text .. string.format( "Group ID = %s\n", tostring( EventData.MarkGroupID ) ) + text = text .. string.format( "Initiator = %s\n", EventData.IniUnit and EventData.IniUnit:GetName() or "Nobody" ) + text = text .. string.format( "Coordinate = %s\n", EventData.MarkCoordinate and EventData.MarkCoordinate:ToStringLLDMS() or "Nowhere" ) + text = text .. string.format( "Text: \n%s", tostring( EventData.MarkText ) ) + self:T2( self.lid .. text ) end @@ -753,9 +744,9 @@ end -- @param #string Event Event. -- @param #string To To state. -- @param #string Text The updated text, displayed in the mark panel. -function MARKER:onafterTextUpdate(From, Event, To, Text) +function MARKER:onafterTextUpdate( From, Event, To, Text ) - self:T(self.lid..string.format("New Marker Text:\n%s", Text)) + self:T( self.lid .. string.format( "New Marker Text:\n%s", Text ) ) end @@ -765,12 +756,8 @@ end -- @param #string Event Event. -- @param #string To To state. -- @param Core.Point#COORDINATE Coordinate The updated coordinates. -function MARKER:onafterCoordUpdate(From, Event, To, Coordinate) +function MARKER:onafterCoordUpdate( From, Event, To, Coordinate ) - self:T(self.lid..string.format("New Marker Coordinate in LL DMS: %s", Coordinate:ToStringLLDMS())) + self:T( self.lid .. string.format( "New Marker Coordinate in LL DMS: %s", Coordinate:ToStringLLDMS() ) ) end - -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------